Class: Autoscaler::Sidekiq::EntireQueueSystem
- Inherits:
-
Object
- Object
- Autoscaler::Sidekiq::EntireQueueSystem
- Defined in:
- lib/autoscaler/sidekiq/entire_queue_system.rb
Overview
Interface to to interrogate the queuing system Includes every queue
Instance Method Summary collapse
-
#any_work? ⇒ Boolean
If any kind of work still needs to be done.
- #queue_names ⇒ Array[String]
-
#queued ⇒ Integer
Amount work ready to go.
-
#retrying ⇒ Integer
Amount of work still being retried.
-
#scheduled ⇒ Integer
Amount of work scheduled for some time in the future.
-
#total_work ⇒ Integer
Total amount of work.
-
#workers ⇒ Integer
Number of workers actively engaged.
Instance Method Details
#any_work? ⇒ Boolean
Returns if any kind of work still needs to be done.
30 31 32 |
# File 'lib/autoscaler/sidekiq/entire_queue_system.rb', line 30 def any_work? queued > 0 || scheduled > 0 || > 0 || workers > 0 end |
#queue_names ⇒ Array[String]
40 41 42 |
# File 'lib/autoscaler/sidekiq/entire_queue_system.rb', line 40 def queue_names sidekiq_queues.keys end |
#queued ⇒ Integer
Returns amount work ready to go.
15 16 17 |
# File 'lib/autoscaler/sidekiq/entire_queue_system.rb', line 15 def queued sidekiq_queues.values.map(&:to_i).reduce(&:+) || 0 end |
#retrying ⇒ Integer
Returns amount of work still being retried.
25 26 27 |
# File 'lib/autoscaler/sidekiq/entire_queue_system.rb', line 25 def ::Sidekiq::RetrySet.new.size end |
#scheduled ⇒ Integer
Returns amount of work scheduled for some time in the future.
20 21 22 |
# File 'lib/autoscaler/sidekiq/entire_queue_system.rb', line 20 def scheduled ::Sidekiq::ScheduledSet.new.size end |
#total_work ⇒ Integer
Returns total amount of work.
35 36 37 |
# File 'lib/autoscaler/sidekiq/entire_queue_system.rb', line 35 def total_work queued + scheduled + + workers end |
#workers ⇒ Integer
Returns number of workers actively engaged.
9 10 11 12 |
# File 'lib/autoscaler/sidekiq/entire_queue_system.rb', line 9 def workers ::Sidekiq::Workers.new.map {|pid, _, _| pid}.uniq.size # #size may be out-of-date. end |