Class: OkComputer::SolidQueueScheduledBackedUpCheck
- Inherits:
-
SizeThresholdCheck
- Object
- Check
- SizeThresholdCheck
- OkComputer::SolidQueueScheduledBackedUpCheck
- Defined in:
- lib/ok_computer/built_in_checks/solid_queue_scheduled_backed_up_check.rb
Overview
Detects a stalled SolidQueue dispatcher by counting scheduled jobs that are
overdue — i.e. their scheduled_at is more than grace in the past, so a
healthy dispatcher should already have promoted them to ready_executions.
This is distinct from SolidQueueBackedUpCheck, which measures ready (already promoted) depth. A dead/behind dispatcher leaves jobs stuck in scheduled and invisible to that check; this check surfaces them.
Constant Summary
Constants inherited from Check
Instance Attribute Summary collapse
-
#grace ⇒ Object
Returns the value of attribute grace.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
Attributes inherited from SizeThresholdCheck
Attributes inherited from Check
#failure_occurred, #message, #registrant_name, #skip_all, #time
Instance Method Summary collapse
-
#initialize(threshold, grace: 1.minute) ⇒ SolidQueueScheduledBackedUpCheck
constructor
Public: Initialize a check for overdue scheduled SolidQueue jobs.
-
#size ⇒ Object
Public: Count of scheduled jobs overdue by more than
grace.
Methods inherited from SizeThresholdCheck
Methods inherited from Check
#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking
Constructor Details
#initialize(threshold, grace: 1.minute) ⇒ SolidQueueScheduledBackedUpCheck
Public: Initialize a check for overdue scheduled SolidQueue jobs
threshold - An Integer; the number of overdue scheduled jobs to tolerate before considering the dispatcher backed up. grace - An ActiveSupport::Duration; how far past scheduled_at a job must be before it counts as overdue. The dispatcher polls roughly every second (config/queue.yml polling_interval), so sub-poll lateness is normal and a grace window prevents flapping. Defaults to 1 minute.
21 22 23 24 25 |
# File 'lib/ok_computer/built_in_checks/solid_queue_scheduled_backed_up_check.rb', line 21 def initialize(threshold, grace: 1.minute) self.threshold = Integer(threshold) self.grace = grace self.name = "SolidQueue overdue scheduled jobs" end |
Instance Attribute Details
#grace ⇒ Object
Returns the value of attribute grace.
11 12 13 |
# File 'lib/ok_computer/built_in_checks/solid_queue_scheduled_backed_up_check.rb', line 11 def grace @grace end |
#threshold ⇒ Object
Returns the value of attribute threshold.
10 11 12 |
# File 'lib/ok_computer/built_in_checks/solid_queue_scheduled_backed_up_check.rb', line 10 def threshold @threshold end |
Instance Method Details
#size ⇒ Object
Public: Count of scheduled jobs overdue by more than grace. A healthy
dispatcher keeps this at 0.
29 30 31 |
# File 'lib/ok_computer/built_in_checks/solid_queue_scheduled_backed_up_check.rb', line 29 def size SolidQueue::ScheduledExecution.where("scheduled_at <= ?", grace.ago).count end |