Class: Autoscaler::Sidekiq::SleepWaitServer
- Inherits:
-
Object
- Object
- Autoscaler::Sidekiq::SleepWaitServer
- Defined in:
- lib/autoscaler/sidekiq/sleep_wait_server.rb
Overview
Sidekiq server middleware Performs scale-down when the queue is empty
Instance Method Summary collapse
-
#call(worker, msg, queue, redis = ::Sidekiq.method(:redis)) ⇒ Object
Sidekiq middleware api entry point.
-
#initialize(scaler, timeout, specified_queues = nil) ⇒ SleepWaitServer
constructor
A new instance of SleepWaitServer.
Constructor Details
#initialize(scaler, timeout, specified_queues = nil) ⇒ SleepWaitServer
Returns a new instance of SleepWaitServer.
12 13 14 15 16 |
# File 'lib/autoscaler/sidekiq/sleep_wait_server.rb', line 12 def initialize(scaler, timeout, specified_queues = nil) @scaler = scaler @timeout = timeout @system = QueueSystem.new(specified_queues) end |
Instance Method Details
#call(worker, msg, queue, redis = ::Sidekiq.method(:redis)) ⇒ Object
Sidekiq middleware api entry point
19 20 21 22 23 24 25 |
# File 'lib/autoscaler/sidekiq/sleep_wait_server.rb', line 19 def call(worker, msg, queue, redis = ::Sidekiq.method(:redis)) working!(queue, redis) yield ensure working!(queue, redis) wait_for_task_or_scale(redis) end |