Class: OkComputer::SolidQueueCheck

Inherits:
Check
  • Object
show all
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.

See https://github.com/rails/solid_queue

Constant Summary

Constants inherited from Check

Check::CheckNotDefined

Instance Attribute Summary

Attributes inherited from Check

#failure_occurred, #message, #registrant_name, #skip_all, #time

Instance Method Summary collapse

Methods inherited from Check

#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking

Instance Method Details

#checkObject

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
    mark_message "SolidQueue is DOWN. No workers are alive. (#{stats})"
  elsif live_dispatchers.zero?
    mark_failure
    mark_message "SolidQueue dispatcher is DOWN. Scheduled jobs will not run. (#{stats})"
  else
    mark_message "SolidQueue is up (#{live_workers} worker(s), #{live_dispatchers} dispatcher(s) alive). Job Counts: #{stats}"
  end
rescue => e
  mark_failure
  mark_message "Error: '#{e}'"
end

#live_dispatchersObject

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_workersObject

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

#statsObject

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