7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/solid_queue_guard/checks/runtime/dispatcher_check.rb', line 7
def call
with_queue_database do
dispatchers = SolidQueue::Process.where(kind: 'Dispatcher')
due_count = SolidQueue::ScheduledExecution.due.count
threshold = config.check_setting(:scheduled_backlog, :threshold, config.scheduled_backlog_threshold)
if dispatchers.none? && due_count.positive?
failure(
check_id,
"#{due_count} scheduled job(s) are due but no dispatcher is running",
suggestion: 'Start a dispatcher process or verify bin/jobs is running'
)
elsif due_count > threshold
warn(
check_id,
"#{due_count} scheduled executions are due (threshold: #{threshold})",
suggestion: 'Verify the dispatcher is keeping up with scheduled work'
)
else
pass(check_id, "Dispatcher healthy (#{due_count} due scheduled executions)")
end
end
end
|