Class: SolidQueue::Configuration
- Inherits:
-
Object
- Object
- SolidQueue::Configuration
- Defined in:
- lib/solid_queue/configuration.rb
Constant Summary collapse
- WORKER_DEFAULTS =
{ queues: "*", threads: 3, processes: 1, polling_interval: 0.1 }
- DISPATCHER_DEFAULTS =
{ batch_size: 500, polling_interval: 1, concurrency_maintenance: true, concurrency_maintenance_interval: 600, recurring_tasks: [] }
Instance Method Summary collapse
- #dispatchers ⇒ Object
-
#initialize(mode: :work, load_from: nil) ⇒ Configuration
constructor
A new instance of Configuration.
- #max_number_of_threads ⇒ Object
- #processes ⇒ Object
- #workers ⇒ Object
Constructor Details
#initialize(mode: :work, load_from: nil) ⇒ Configuration
Returns a new instance of Configuration.
20 21 22 23 |
# File 'lib/solid_queue/configuration.rb', line 20 def initialize(mode: :work, load_from: nil) @mode = mode @raw_config = config_from(load_from) end |
Instance Method Details
#dispatchers ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/solid_queue/configuration.rb', line 45 def dispatchers if mode.in? %i[ dispatch all] .map do || recurring_tasks = parse_recurring_tasks [:recurring_tasks] Dispatcher.new **.merge(recurring_tasks: recurring_tasks).with_defaults(DISPATCHER_DEFAULTS) end end end |
#max_number_of_threads ⇒ Object
55 56 57 58 |
# File 'lib/solid_queue/configuration.rb', line 55 def max_number_of_threads # At most "threads" in each worker + 1 thread for the worker + 1 thread for the heartbeat task .map { || [:threads] }.max + 2 end |
#processes ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/solid_queue/configuration.rb', line 25 def processes case mode when :dispatch then dispatchers when :work then workers when :all then dispatchers + workers else raise "Invalid mode #{mode}" end end |
#workers ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/solid_queue/configuration.rb', line 34 def workers if mode.in? %i[ work all] .flat_map do || processes = .fetch(:processes, WORKER_DEFAULTS[:processes]) processes.times.map { Worker.new(**.with_defaults(WORKER_DEFAULTS)) } end else [] end end |