class

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

load_from_cli_args(args : Array(String)) : Configure

Load from CLI arguments

Source
load_from_yaml(path : String | Nil = nil, env : String | Nil = nil) : Configure

YAML configuration loading methods

Source
load_from_yaml_sources(sources : Array(String)) : Configure

Load from multiple YAML sources with merging

Source

Class methods

load_hybrid(yaml_path : String | Nil = nil, &)

Hybrid configuration - YAML + programmatic

Source

Instance methods

create_queues_from_yaml_config

Create queues from stored queue_configs using the QueueFactory

This method bridges YAML configuration with actual queue instantiation. It should be called after:

  1. YAML configuration is loaded
  2. Job classes are defined and available
  3. 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
Source
dead_letter_ttl
Source
dead_letter_ttl=(dead_letter_ttl : Time::Span)
Source
default_queue
Source
default_queue=(default_queue : String)
Source
delayed_job_scheduler

Delayed job scheduler (processes retrying jobs)

Source
delayed_job_scheduler=(delayed_job_scheduler : DelayedJobScheduler)

Delayed job scheduler (processes retrying jobs)

Source
error_monitor
Source
error_monitoring

Configure error monitoring

Source
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

Source
expires
Source
expires=(expires : Time::Span)
Source
failed_ttl
Source
failed_ttl=(failed_ttl : Time::Span)
Source
job_registry
Source
job_registry=(job_registry : JobSchemaRegistry)
Source
middleware_pipeline
Source
middlewares

Middlewares and Pipeline

Source
middlewares=(middlewares : Array(Middleware))

Middlewares and Pipeline

Source
pipeline_batch_size

Pipeline optimization settings (always enabled)

Source
pipeline_batch_size=(pipeline_batch_size : Int32)

Pipeline optimization settings (always enabled)

Source
pipeline_max_commands
Source
pipeline_max_commands=(pipeline_max_commands : Int32)
Source
pipeline_timeout
Source
pipeline_timeout=(pipeline_timeout : Float64)
Source
queue_configs
Source
queues

Properties and Getters

Source
rest_api_enabled=(rest_api_enabled : Bool)
Source
rest_api_enabled?
Source
retries
Source
retries=(retries : Int32)
Source
scheduler(tz : Time::Location = self.time_location, &)

Add a scheduler and execute within its context

Source
scheduler_configs
Source
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))))))
Source
schedulers

Schedulers

Source
schedulers=(schedulers : Array(Scheduler))

Schedulers

Source
setup_schedulers_from_config

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
Source
stats_enabled=(stats_enabled : Bool)
Source
stats_enabled?
Source
store
Source
store=(store : Store)
Source
time_location
Source
time_location=(tz : String = "America/New_York") : Time::Location

Set the time location globally

Source
timeout
Source
timeout=(timeout : Time::Span)
Source
use

DSL: Add custom middlewares

Source
validate_configuration

Validation methods

Source
worker_batch_size
Source
worker_batch_size=(worker_batch_size : Int32)
Source

Macros

queue(name, workers, job, throttle = nil)

Macro: Define a queue

Adds a queue configuration and optionally applies throttling limits.

Source
register_job(job_class)

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)
Source