class Sidekiq::Throttled::StrategyCollection
Collection which transparently group several meta-strategies of one kind
@private
Attributes
Public Class Methods
Source
# File lib/sidekiq/throttled/strategy_collection.rb, line 21 def initialize(strategies, strategy:, name:, key_suffix:) @strategies = (strategies.is_a?(Hash) ? [strategies] : Array(strategies)).map do |options| make_strategy(strategy, name, key_suffix, options) end end
@param [Hash, Array, nil] strategies Concurrency or Threshold options
or array of options. See keyword args of {Strategy::Concurrency#initialize} for details. See keyword args of {Strategy::Threshold#initialize} for details.
@param [Class] strategy class of strategy: Concurrency or Threshold @param [#to_s] name @param [#call] key_suffix Dynamic key suffix generator.
Public Instance Methods
Source
# File lib/sidekiq/throttled/strategy_collection.rb, line 34 def dynamic? any?(&:dynamic?) end
@return [Boolean] whenever any strategy in collection has dynamic config
Source
# File lib/sidekiq/throttled/strategy_collection.rb, line 29 def each(...) @strategies.each(...) end
@param [#call] block Iterates each strategy in collection
Source
# File lib/sidekiq/throttled/strategy_collection.rb, line 51 def finalize!(...) each { |c| c.finalize!(...) } end
Marks job as being processed. @return [void]
Source
# File lib/sidekiq/throttled/strategy_collection.rb, line 57 def reset! each(&:reset!) end
Resets count of jobs of all avaliable strategies @return [void]
Source
# File lib/sidekiq/throttled/strategy_collection.rb, line 45 def retry_in(*args) map { |s| s.retry_in(*args) }.max end
@return [Float] How long, in seconds, before we’ll next be able to take on jobs
Source
# File lib/sidekiq/throttled/strategy_collection.rb, line 40 def throttled?(...) any? { |s| s.throttled?(...) } end
@return [Boolean] whenever job is throttled or not by any strategy in collection.
Private Instance Methods
Source
# File lib/sidekiq/throttled/strategy_collection.rb, line 64 def make_strategy(strategy, name, key_suffix, options) return unless options strategy.new("throttled:#{name}", key_suffix: key_suffix, **options) end
@return [Base, nil]