Module: HireFire::Macro::GoodJob
- Extended by:
- Deprecated::GoodJob, GoodJob, Helpers::GoodJob, Utility
- Included in:
- GoodJob
- Defined in:
- lib/hirefire/macro/good_job.rb
Instance Method Summary collapse
-
#job_queue_latency(*queues) ⇒ Float
Calculates the maximum job queue latency using GoodJob.
-
#job_queue_size(*queues) ⇒ Integer
Calculates the total job queue size using GoodJob.
Methods included from Helpers::GoodJob
error_event_supported?, good_job_class, included
Methods included from Deprecated::GoodJob
Instance Method Details
#job_queue_latency(*queues) ⇒ Float
Calculates the maximum job queue latency using GoodJob. If no queues are specified, it measures latency across all available queues.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hirefire/macro/good_job.rb', line 26 def job_queue_latency(*queues) queues = normalize_queues(queues, allow_empty: true) query = good_job_class query = query.where(queue_name: queues) if queues.any? query = query.where(performed_at: nil) query = query.where.not(error_event: discarded_enum).or(query.where(error_event: nil)) if error_event_supported? query = query.where(scheduled_at: ..Time.now).or(query.where(scheduled_at: nil)) query = query.order(scheduled_at: :asc, created_at: :asc) if (job = query.first) Time.now - (job.scheduled_at || job.created_at) else 0.0 end end |
#job_queue_size(*queues) ⇒ Integer
Calculates the total job queue size using GoodJob. If no queues are specified, it measures size across all available queues.
54 55 56 57 58 59 60 61 62 |
# File 'lib/hirefire/macro/good_job.rb', line 54 def job_queue_size(*queues) queues = normalize_queues(queues, allow_empty: true) query = good_job_class query = query.where(queue_name: queues) if queues.any? query = query.where(performed_at: nil) query = query.where.not(error_event: discarded_enum).or(query.where(error_event: nil)) if error_event_supported? query = query.where(scheduled_at: ..Time.now).or(query.where(scheduled_at: nil)) query.count end |