lib/sidekiq/throttled/strategy.rb in sidekiq-throttled-0.2.0 vs lib/sidekiq/throttled/strategy.rb in sidekiq-throttled-0.3.0.pre

- old
+ new

@@ -23,19 +23,20 @@ # See {Strategy::Threshold#initialize} for details. # @param [Hash] key_suffix Proc for dynamic keys. def initialize(name, concurrency: nil, threshold: nil, key_suffix: nil) key = "throttled:#{name}" - if concurrency - @concurrency = Concurrency.new( - key, concurrency.merge(:key_suffix => key_suffix) - ) - end - if threshold - @threshold = Threshold.new( - key, threshold.merge(:key_suffix => key_suffix) - ) - end + @concurrency = + if concurrency + concurrency[:key_suffix] = key_suffix + Concurrency.new(key, concurrency) + end + + @threshold = + if threshold + threshold[:key_suffix] = key_suffix + Threshold.new(key, threshold) + end return if @concurrency || @threshold raise ArgumentError, "Neither :concurrency nor :threshold given" end