lib/sidekiq-heroku-scaler/strategy/latency.rb in sidekiq-heroku-scaler-0.3.4 vs lib/sidekiq-heroku-scaler/strategy/latency.rb in sidekiq-heroku-scaler-0.3.5
- old
+ new
@@ -24,10 +24,11 @@
end
def decrease?(sidekiq_worker)
sidekiq_worker.quantity > min_dynos_count &&
sidekiq_worker.latency < min_latency &&
- (sidekiq_worker.quantity > 1 || !sidekiq_worker.jobs_running?)
+ (sidekiq_worker.quantity > 1 || !sidekiq_worker.jobs_running?) &&
+ (!sidekiq_worker.jobs_running? || safe_quantity(sidekiq_worker.quantity - dec_count).positive?)
end
def safe_quantity(quantity)
return min_dynos_count if quantity < min_dynos_count