Class: SolidQueue::Dispatcher::Maintenance
- Inherits:
-
Object
- Object
- SolidQueue::Dispatcher::Maintenance
show all
- Includes:
- AppExecutor
- Defined in:
- lib/solid_queue/dispatcher/maintenance.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#create_thread, #handle_thread_error, #wrap_in_app_executor
Constructor Details
#initialize(interval, batch_size, concurrency:, batches:) ⇒ Maintenance
9
10
11
12
13
14
|
# File 'lib/solid_queue/dispatcher/maintenance.rb', line 9
def initialize(interval, batch_size, concurrency:, batches:)
@interval = interval
@batch_size = batch_size
@concurrency = concurrency
@batches = batches
end
|
Instance Attribute Details
#batch_size ⇒ Object
Returns the value of attribute batch_size.
7
8
9
|
# File 'lib/solid_queue/dispatcher/maintenance.rb', line 7
def batch_size
@batch_size
end
|
#interval ⇒ Object
Returns the value of attribute interval.
7
8
9
|
# File 'lib/solid_queue/dispatcher/maintenance.rb', line 7
def interval
@interval
end
|
Instance Method Details
#batches? ⇒ Boolean
20
21
22
|
# File 'lib/solid_queue/dispatcher/maintenance.rb', line 20
def batches?
@batches
end
|
#concurrency? ⇒ Boolean
16
17
18
|
# File 'lib/solid_queue/dispatcher/maintenance.rb', line 16
def concurrency?
@concurrency
end
|
24
25
26
|
# File 'lib/solid_queue/dispatcher/maintenance.rb', line 24
def metadata
{ concurrency_maintenance_interval: (interval if concurrency?), batch_maintenance: batches? }
end
|
#start ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/solid_queue/dispatcher/maintenance.rb', line 28
def start
@maintenance_task = Concurrent::TimerTask.new(run_now: true, execution_interval: interval) do
if concurrency?
expire_semaphores
unblock_blocked_executions
end
sweep_stalled_batches if batches?
end
@maintenance_task.add_observer do |_, _, error|
handle_thread_error(error) if error
end
@maintenance_task.execute
end
|
#stop ⇒ Object
45
46
47
|
# File 'lib/solid_queue/dispatcher/maintenance.rb', line 45
def stop
@maintenance_task&.shutdown
end
|