Class: Sidekiq::Throttled::StrategyCollection
- Inherits:
-
Object
- Object
- Sidekiq::Throttled::StrategyCollection
- Includes:
- Enumerable
- Defined in:
- lib/sidekiq/throttled/strategy_collection.rb
Overview
Collection which transparently group several meta-strategies of one kind
Instance Attribute Summary collapse
-
#strategies ⇒ Object
readonly
Returns the value of attribute strategies.
Instance Method Summary collapse
-
#dynamic? ⇒ Boolean
Whenever any strategy in collection has dynamic config.
-
#each(&block) ⇒ Object
Iterates each strategy in collection.
-
#finalize!(*args) ⇒ void
Marks job as being processed.
-
#initialize(strategies, strategy:, name:, key_suffix:) ⇒ StrategyCollection
constructor
A new instance of StrategyCollection.
-
#reset! ⇒ void
Resets count of jobs of all avaliable strategies.
-
#throttled?(*args) ⇒ Boolean
by any strategy in collection.
Constructor Details
#initialize(strategies, strategy:, name:, key_suffix:) ⇒ StrategyCollection
Returns a new instance of StrategyCollection.
21 22 23 24 25 |
# 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 || make_strategy(strategy, name, key_suffix, ) end end |
Instance Attribute Details
#strategies ⇒ Object (readonly)
Returns the value of attribute strategies.
12 13 14 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 12 def strategies @strategies end |
Instance Method Details
#dynamic? ⇒ Boolean
Returns whenever any strategy in collection has dynamic config.
34 35 36 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 34 def dynamic? any?(&:dynamic?) end |
#each(&block) ⇒ Object
Iterates each strategy in collection
29 30 31 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 29 def each(&block) @strategies.each(&block) end |
#finalize!(*args) ⇒ void
This method returns an undefined value.
Marks job as being processed.
46 47 48 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 46 def finalize!(*args) each { |c| c.finalize!(*args) } end |
#reset! ⇒ void
This method returns an undefined value.
Resets count of jobs of all avaliable strategies
52 53 54 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 52 def reset! each(&:reset!) end |
#throttled?(*args) ⇒ Boolean
by any strategy in collection.
40 41 42 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 40 def throttled?(*args) any? { |s| s.throttled?(*args) } end |