Module: HireFire::Macro::Delayed::Job
- Extended by:
- Job, HireFire::Macro::Deprecated::Delayed::Job, Utility
- Included in:
- Job
- Defined in:
- lib/hirefire/macro/delayed_job.rb
Defined Under Namespace
Classes: MapperNotDetectedError
Instance Method Summary collapse
-
#job_queue_latency(*queues) ⇒ Float
Calculates the maximum job queue latency using Delayed::Job.
-
#job_queue_size(*queues) ⇒ Integer
Calculates the total job queue size using Delayed::Job.
Methods included from HireFire::Macro::Deprecated::Delayed::Job
Instance Method Details
#job_queue_latency(*queues) ⇒ Float
Calculates the maximum job queue latency using Delayed::Job. If no queues are specified, it measures latency across all available queues. This method supports both ActiveRecord and Mongoid mappers.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hirefire/macro/delayed_job.rb', line 28 def job_queue_latency(*queues) queues = normalize_queues(queues, allow_empty: true) query = ::Delayed::Job.where(failed_at: nil).order(run_at: :asc) case mapper when :active_record query = query.where("run_at <= ?", Time.now) query = query.where(queue: queues) if queues.any? when :mongoid query = query.where(run_at: {"$lte" => Time.now}) query = query.in(queue: queues.to_a) if queues.any? end if (job = query.first) Time.now - job.run_at else 0.0 end end |
#job_queue_size(*queues) ⇒ Integer
Calculates the total job queue size using Delayed::Job. If no queues are specified, it measures size across all available queues. This method supports both ActiveRecord and Mongoid mappers.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/hirefire/macro/delayed_job.rb', line 61 def job_queue_size(*queues) queues = normalize_queues(queues, allow_empty: true) query = ::Delayed::Job.where(failed_at: nil) case mapper when :active_record query = query.where("run_at <= ?", Time.now) query = query.where(queue: queues) if queues.any? when :mongoid query = query.where(run_at: {"$lte" => Time.now}) query = query.in(queue: queues.to_a) if queues.any? end query.count end |