Class: OkComputer::SolidQueueCheck
- Defined in:
- lib/ok_computer/built_in_checks/solid_queue_check.rb
Overview
Verifies that SolidQueue is up and processing jobs by confirming that at least one worker process has a recent heartbeat, and reports a summary of the current job counts.
Constant Summary
Constants inherited from Check
Instance Attribute Summary
Attributes inherited from Check
#failure_occurred, #message, #registrant_name, #skip_all, #time
Instance Method Summary collapse
-
#check ⇒ Object
Public: Check whether SolidQueue has live workers and a live dispatcher, and report job stats.
-
#live_dispatchers ⇒ Object
Public: The number of dispatcher processes whose heartbeat is recent enough to be considered alive.
-
#live_workers ⇒ Object
Public: The number of worker processes whose heartbeat is within SolidQueue's configured alive threshold (default: 5 minutes).
-
#stats ⇒ Object
Public: A summary of the current job counts across SolidQueue.
Methods inherited from Check
#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking
Instance Method Details
#check ⇒ Object
Public: Check whether SolidQueue has live workers and a live dispatcher, and report job stats
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ok_computer/built_in_checks/solid_queue_check.rb', line 10 def check if live_workers.zero? mark_failure "SolidQueue is DOWN. No workers are alive. (#{stats})" elsif live_dispatchers.zero? mark_failure "SolidQueue dispatcher is DOWN. Scheduled jobs will not run. (#{stats})" else "SolidQueue is up (#{live_workers} worker(s), #{live_dispatchers} dispatcher(s) alive). Job Counts: #{stats}" end rescue => e mark_failure "Error: '#{e}'" end |
#live_dispatchers ⇒ Object
Public: The number of dispatcher processes whose heartbeat is recent enough to be considered alive
33 34 35 |
# File 'lib/ok_computer/built_in_checks/solid_queue_check.rb', line 33 def live_dispatchers alive_processes.where(kind: "Dispatcher").count end |
#live_workers ⇒ Object
Public: The number of worker processes whose heartbeat is within SolidQueue's configured alive threshold (default: 5 minutes)
27 28 29 |
# File 'lib/ok_computer/built_in_checks/solid_queue_check.rb', line 27 def live_workers alive_processes.where(kind: "Worker").count end |
#stats ⇒ Object
Public: A summary of the current job counts across SolidQueue
38 39 40 |
# File 'lib/ok_computer/built_in_checks/solid_queue_check.rb', line 38 def stats "ready: #{ready}, scheduled: #{scheduled}, in progress: #{in_progress}, failed: #{failed}" end |