Sha256: 41761db3b60b4556a248cbe421a46f64cadbb94ab251b90fc4a200c6102caf16
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module SidekiqHerokuScaler module Strategy class Latency attr_reader :inc_count, :dec_count def initialize(min_dynos_count:, max_dynos_count:, max_latency:, min_latency:, inc_count: nil, dec_count: nil) @min_dynos_count = min_dynos_count @max_dynos_count = max_dynos_count @max_latency = max_latency @min_latency = min_latency @inc_count = (inc_count || 1).to_i @dec_count = (dec_count || 1).to_i end def increase?(sidekiq_worker) sidekiq_worker.quantity < max_dynos_count && sidekiq_worker.latency > max_latency && sidekiq_worker.queues_size > sidekiq_worker.quantity * sidekiq_worker.concurrency end def decrease?(sidekiq_worker) sidekiq_worker.latency < min_latency && sidekiq_worker.quantity > min_dynos_count end def safe_quantity(quantity) return 1 if quantity <= 0 quantity > max_dynos_count ? max_dynos_count : quantity end private attr_reader :min_dynos_count, :max_dynos_count, :max_latency, :min_latency end end end
Version data entries
3 entries across 3 versions & 1 rubygems