Module: HireFire::Macro::QC
- Extended by:
- Deprecated::QC, QC, Utility
- Included in:
- QC
- Defined in:
- lib/hirefire/macro/queue_classic.rb
Instance Method Summary collapse
-
#job_queue_latency(*queues) ⇒ Float
Calculates the maximum job queue latency using Queue Classic.
-
#job_queue_size(*queues) ⇒ Integer
Calculates the total job queue size using Queue Classic.
Methods included from Deprecated::QC
Instance Method Details
#job_queue_latency(*queues) ⇒ Float
Calculates the maximum job queue latency using Queue Classic. If no queues are specified, it measures latency across all available queues.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/hirefire/macro/queue_classic.rb', line 24 def job_queue_latency(*queues) queues = normalize_queues(queues, allow_empty: true) query = <<~SQL SELECT EXTRACT(EPOCH FROM (now() - scheduled_at)) AS latency FROM #{::QC.table_name} WHERE scheduled_at <= now() #{filter_by_queues_if_any(queues)} ORDER BY scheduled_at ASC LIMIT 1 SQL connection = ::QC.default_conn_adapter result = if queues.any? connection.execute(query, "{#{queues.to_a.join(",")}}") else connection.execute(query) end (result && result["latency"]) ? result["latency"].to_f : 0.0 end |
#job_queue_size(*queues) ⇒ Integer
Calculates the total job queue size using Queue Classic. If no queues are specified, it measures size across all available queues.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/hirefire/macro/queue_classic.rb', line 59 def job_queue_size(*queues) queues = normalize_queues(queues, allow_empty: true) query = <<~SQL SELECT COUNT(*) FROM #{::QC.table_name} WHERE scheduled_at <= now() #{filter_by_queues_if_any(queues)} SQL connection = ::QC.default_conn_adapter result = if queues.any? connection.execute(query, "{#{queues.to_a.join(",")}}") else connection.execute(query) end result["count"].to_i end |