Class: RailsHealthChecks::Checks::GoodJobCheck
- Inherits:
-
RailsHealthChecks::Check
- Object
- RailsHealthChecks::Check
- RailsHealthChecks::Checks::GoodJobCheck
- Defined in:
- lib/rails_health_checks/checks/good_job_check.rb
Instance Attribute Summary
Attributes inherited from RailsHealthChecks::Check
#latency_ms, #message, #status
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(latency: nil) ⇒ GoodJobCheck
constructor
A new instance of GoodJobCheck.
Constructor Details
#initialize(latency: nil) ⇒ GoodJobCheck
Returns a new instance of GoodJobCheck.
6 7 8 9 10 11 12 |
# File 'lib/rails_health_checks/checks/good_job_check.rb', line 6 def initialize(latency: nil) unless defined?(::GoodJob) raise LoadError, "GoodJob is not installed. Add `gem 'good_job'` to your Gemfile to use the :good_job check." end @latency = latency end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rails_health_checks/checks/good_job_check.rb', line 14 def call measure do oldest = ::GoodJob::Job .where(finished_at: nil, performed_at: nil) .minimum(:created_at) if @latency && oldest age = (Time.current - oldest).to_i return warn_with("queue latency #{age}s exceeds threshold #{@latency}s") if age > @latency end end pass rescue StandardError => e fail_with(e.) end |