lib/sidekiq/throttled/fetch.rb in sidekiq-throttled-0.11.0 vs lib/sidekiq/throttled/fetch.rb in sidekiq-throttled-0.12.0

- old
+ new

@@ -15,14 +15,22 @@ # Timeout to sleep between fetch retries in case of no job received, # as well as timeout to wait for redis to give us something to work. TIMEOUT = 2 # Initializes fetcher instance. + # @param options [Hash] + # @option options [Integer] :throttled_queue_cooldown (TIMEOUT) + # Min delay in seconds before queue will be polled again after + # throttled job. + # @option options [Boolean] :strict (false) + # @option options [Array<#to_s>] :queue def initialize(options) - @paused = ExpirableList.new(TIMEOUT) + @paused = ExpirableList.new(options.fetch(:throttled_queue_cooldown, TIMEOUT)) - @strict = options[:strict] - @queues = options[:queues].map { |q| QueueName.expand q } + @strict = options.fetch(:strict, false) + @queues = options.fetch(:queues).map { |q| QueueName.expand q } + + raise ArgumentError, "empty :queues" if @queues.empty? @queues.uniq! if @strict end # Retrieves job from redis.