JoobQ::Configure
Inherits Reference / Object
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}
Constructors
YAML configuration loading methods
Load from multiple YAML sources with merging
Class methods
Instance methods
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
Macros
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)