class Sidekiq::Throttled::Cooldown
@api internal
Queues cooldown manager. Tracks list of queues that should be temporarily (for the duration of {Config#cooldown_period}) excluded from polling.
Public Class Methods
Source
# File lib/sidekiq/throttled/cooldown.rb, line 19 def [](config) new(config) if config.cooldown_period end
Returns new {Cooldown} instance if {Config#cooldown_period} is not ‘nil`.
@param config [Config] @return [Cooldown, nil]
Source
# File lib/sidekiq/throttled/cooldown.rb, line 25 def initialize(config) @queues = ExpirableSet.new(config.cooldown_period) @threshold = config.cooldown_threshold @tracker = Concurrent::Map.new end
@param config [Config]
Public Instance Methods
Source
# File lib/sidekiq/throttled/cooldown.rb, line 43 def notify_admitted(queue) @tracker.delete(queue) end
Notify that given queue returned job that was not throttled.
@param queue [String] @return [void]
Source
# File lib/sidekiq/throttled/cooldown.rb, line 35 def notify_throttled(queue) @queues.add(queue) if @threshold <= @tracker.merge_pair(queue, 1, &:succ) end
Notify that given queue returned job that was throttled.
@param queue [String] @return [void]
Source
# File lib/sidekiq/throttled/cooldown.rb, line 50 def queues @queues.to_a end
List of queues that should not be polled
@return [Array<String>]