Class: SolidQueue::Dispatcher::ConcurrencyMaintenance
- Inherits:
-
Object
- Object
- SolidQueue::Dispatcher::ConcurrencyMaintenance
- Includes:
- AppExecutor
- Defined in:
- lib/solid_queue/dispatcher/concurrency_maintenance.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
readonly
Returns the value of attribute batch_size.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
Instance Method Summary collapse
-
#initialize(interval, batch_size) ⇒ ConcurrencyMaintenance
constructor
A new instance of ConcurrencyMaintenance.
- #start ⇒ Object
- #stop ⇒ Object
Methods included from AppExecutor
#handle_thread_error, #wrap_in_app_executor
Constructor Details
#initialize(interval, batch_size) ⇒ ConcurrencyMaintenance
Returns a new instance of ConcurrencyMaintenance.
9 10 11 12 |
# File 'lib/solid_queue/dispatcher/concurrency_maintenance.rb', line 9 def initialize(interval, batch_size) @interval = interval @batch_size = batch_size end |
Instance Attribute Details
#batch_size ⇒ Object (readonly)
Returns the value of attribute batch_size.
7 8 9 |
# File 'lib/solid_queue/dispatcher/concurrency_maintenance.rb', line 7 def batch_size @batch_size end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
7 8 9 |
# File 'lib/solid_queue/dispatcher/concurrency_maintenance.rb', line 7 def interval @interval end |
Instance Method Details
#start ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/solid_queue/dispatcher/concurrency_maintenance.rb', line 14 def start @concurrency_maintenance_task = Concurrent::TimerTask.new(run_now: true, execution_interval: interval) do expire_semaphores unblock_blocked_executions end @concurrency_maintenance_task.add_observer do |_, _, error| handle_thread_error(error) if error end @concurrency_maintenance_task.execute end |
#stop ⇒ Object
27 28 29 |
# File 'lib/solid_queue/dispatcher/concurrency_maintenance.rb', line 27 def stop @concurrency_maintenance_task&.shutdown end |