Class: SidekiqAutoscale::SidekiqInterface
- Inherits:
-
Object
- Object
- SidekiqAutoscale::SidekiqInterface
- Defined in:
- lib/sidekiq_autoscale/sidekiq_interface.rb
Instance Method Summary collapse
- #available_threads ⇒ Object
- #busy_threads ⇒ Object
- #latency ⇒ Object
- #queue_names ⇒ Object
- #total_queue_size ⇒ Object
- #total_threads ⇒ Object
- #total_workers ⇒ Object
- #youngest_worker ⇒ Object
Instance Method Details
#available_threads ⇒ Object
36 37 38 |
# File 'lib/sidekiq_autoscale/sidekiq_interface.rb', line 36 def available_threads total_threads - busy_threads end |
#busy_threads ⇒ Object
20 21 22 |
# File 'lib/sidekiq_autoscale/sidekiq_interface.rb', line 20 def busy_threads ::Sidekiq::Workers.new.map {|_, thread, _| thread }.uniq.size end |
#latency ⇒ Object
24 25 26 |
# File 'lib/sidekiq_autoscale/sidekiq_interface.rb', line 24 def latency queue_names.map {|q| ::Sidekiq::Queue.new(q).latency }.max end |
#queue_names ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/sidekiq_autoscale/sidekiq_interface.rb', line 11 def queue_names from_env = ENV["SIDEKIQ_QUEUES"] if from_env JSON.parse(from_env) else ::Sidekiq::Queue.all.map(&:name) end end |
#total_queue_size ⇒ Object
7 8 9 |
# File 'lib/sidekiq_autoscale/sidekiq_interface.rb', line 7 def total_queue_size queue_names.map {|q| ::Sidekiq::Queue.new(q).size }.reduce(0, &:+) end |
#total_threads ⇒ Object
32 33 34 |
# File 'lib/sidekiq_autoscale/sidekiq_interface.rb', line 32 def total_threads process_set.map {|w| w["concurrency"] }.reduce(0, &:+) end |
#total_workers ⇒ Object
28 29 30 |
# File 'lib/sidekiq_autoscale/sidekiq_interface.rb', line 28 def total_workers process_set.size end |
#youngest_worker ⇒ Object
40 41 42 |
# File 'lib/sidekiq_autoscale/sidekiq_interface.rb', line 40 def youngest_worker process_set.map {|w| w["started_at"] }.max end |