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 ⇒ Object
Iterates each strategy in collection.
-
#finalize! ⇒ 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.
-
#retry_in(*args) ⇒ Float
How long, in seconds, before we’ll next be able to take on jobs.
-
#throttled? ⇒ 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 ⇒ Object
Iterates each strategy in collection
29 30 31 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 29 def each(...) @strategies.each(...) end |
#finalize! ⇒ void
This method returns an undefined value.
Marks job as being processed.
51 52 53 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 51 def finalize!(...) each { |c| c.finalize!(...) } end |
#reset! ⇒ void
This method returns an undefined value.
Resets count of jobs of all avaliable strategies
57 58 59 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 57 def reset! each(&:reset!) end |
#retry_in(*args) ⇒ Float
Returns How long, in seconds, before we’ll next be able to take on jobs.
45 46 47 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 45 def retry_in(*args) max { |s| s.retry_in(*args) } end |
#throttled? ⇒ Boolean
by any strategy in collection.
40 41 42 |
# File 'lib/sidekiq/throttled/strategy_collection.rb', line 40 def throttled?(...) any? { |s| s.throttled?(...) } end |