class
JoobQ::Configure
- JoobQ::Configure
- Reference
- Object
Overview
Configure is responsible for managing the settings for the JoobQ job queue system.
Features
- Centralizes job queue configurations, Redis connection setup, and queue properties.
- Provides default settings and allows easy customization through environment variables.
- Supports defining queues, middlewares, throttling, and scheduling jobs.
Usage Example
JoobQ::Configure.instance.queue "my_queue", 5, MyJob, {limit: 10, period: 1.minute}
Defined in:
joobq/configure.crConstructors
-
.load_from_cli_args(args : Array(String)) : Configure
Load from CLI arguments
-
.load_from_yaml(path : String | Nil = nil, env : String | Nil = nil) : Configure
YAML configuration loading methods
-
.load_from_yaml_sources(sources : Array(String)) : Configure
Load from multiple YAML sources with merging
Class Method Summary
-
.load_hybrid(yaml_path : String | Nil = nil, &)
Hybrid configuration - YAML + programmatic
Macro Summary
-
queue(name, workers, job, throttle = nil)
Macro: Define a queue
-
register_job(job_class)
Helper macro to register a job type and add it to the factory
Instance Method Summary
-
#create_queues_from_yaml_config
Create queues from stored queue_configs using the QueueFactory
- #dead_letter_ttl : Time::Span
- #dead_letter_ttl=(dead_letter_ttl : Time::Span)
- #default_queue : String
- #default_queue=(default_queue : String)
-
#delayed_job_scheduler : DelayedJobScheduler
Delayed job scheduler (processes retrying jobs)
-
#delayed_job_scheduler=(delayed_job_scheduler : DelayedJobScheduler)
Delayed job scheduler (processes retrying jobs)
- #error_monitor : ErrorMonitor
-
#error_monitoring(&)
Configure error monitoring
-
#error_monitoring(alert_thresholds : Hash(String, Int32) | Nil = nil, time_window : Time::Span | Nil = nil, max_recent_errors : Int32 | Nil = nil, notify_alert : Proc(Hash(String, String), Nil) | Nil = nil)
Configure error monitoring with parameters
- #expires : Time::Span
- #expires=(expires : Time::Span)
- #failed_ttl : Time::Span
- #failed_ttl=(failed_ttl : Time::Span)
- #job_registry : JobSchemaRegistry
- #job_registry=(job_registry : JobSchemaRegistry)
- #middleware_pipeline : MiddlewarePipeline
-
#middlewares : Array(Middleware)
Middlewares and Pipeline
-
#middlewares=(middlewares : Array(Middleware))
Middlewares and Pipeline
-
#pipeline_batch_size : Int32
Pipeline optimization settings (always enabled)
-
#pipeline_batch_size=(pipeline_batch_size : Int32)
Pipeline optimization settings (always enabled)
- #pipeline_max_commands : Int32
- #pipeline_max_commands=(pipeline_max_commands : Int32)
- #pipeline_timeout : Float64
- #pipeline_timeout=(pipeline_timeout : Float64)
- #queue_configs : Hash(String, {job_class_name: String, workers: Int32, throttle: {limit: Int32, period: Time::Span}?})
-
#queues : Hash(String, JoobQ::BaseQueue)
Properties and Getters
- #rest_api_enabled=(rest_api_enabled : Bool)
- #rest_api_enabled? : Bool
- #retries : Int32
- #retries=(retries : Int32)
-
#scheduler(tz : Time::Location = self.time_location, &)
Add a scheduler and execute within its context
- #scheduler_configs : Array(NamedTuple(timezone: String, cron_jobs: Array(NamedTuple(pattern: String, job: String, args: Hash(String, YAML::Any))), recurring_jobs: Array(NamedTuple(interval: Time::Span, job: String, args: Hash(String, YAML::Any)))))
- #scheduler_configs=(scheduler_configs : Array(NamedTuple(timezone: String, cron_jobs: Array(NamedTuple(pattern: String, job: String, args: Hash(String, YAML::Any))), recurring_jobs: Array(NamedTuple(interval: Time::Span, job: String, args: Hash(String, YAML::Any))))))
-
#schedulers : Array(Scheduler)
Schedulers
-
#schedulers=(schedulers : Array(Scheduler))
Schedulers
-
#setup_schedulers_from_config
Helper method to setup schedulers from YAML configuration
- #stats_enabled=(stats_enabled : Bool)
- #stats_enabled? : Bool
- #store : Store
- #store=(store : Store)
- #time_location : Time::Location
-
#time_location=(tz : String = "America/New_York") : Time::Location
Set the time location globally
- #timeout : Time::Span
- #timeout=(timeout : Time::Span)
-
#use(&)
DSL: Add custom middlewares
-
#validate_configuration : Nil
Validation methods
- #worker_batch_size : Int32
- #worker_batch_size=(worker_batch_size : Int32)
Constructor Detail
Load from CLI arguments
YAML configuration loading methods
Load from multiple YAML sources with merging
Class Method Detail
Hybrid configuration - YAML + programmatic
Macro Detail
Macro: Define a queue
Adds a queue configuration and optionally applies throttling limits.
Helper macro to register a job type and add it to the factory
This combines job registry and queue factory registration in one call.
Example:
config = JoobQ.config
config.register_job(EmailJob)
config.register_job(ImageProcessingJob)
Instance Method Detail
Create queues from stored queue_configs using the QueueFactory
This method bridges YAML configuration with actual queue instantiation. It should be called after:
- YAML configuration is loaded
- Job classes are defined and available
- Job types are registered with QueueFactory
Example:
# Load YAML config
config = Configure.load_from_yaml("config/joobq.yml")
# Register job types (must be done after job classes are defined)
QueueFactory.register_job_type(EmailJob)
QueueFactory.register_job_type(ImageProcessingJob)
# Create queues from YAML configuration
config.create_queues_from_yaml_config
# Now queues are available
JoobQ.start
Delayed job scheduler (processes retrying jobs)
Configure error monitoring with parameters
Pipeline optimization settings (always enabled)
Add a scheduler and execute within its context
Helper method to setup schedulers from YAML configuration
This method should be called after job classes are available and loaded. It processes the scheduler configurations stored during YAML loading and sets up cron jobs and recurring jobs with proper job class resolution.
Example usage:
config = JoobQ::Configure.load_from_yaml("config/joobq.yml")
# ... load job classes ...
config.setup_schedulers_from_config
Set the time location globally