Module: Sidekiq::Throttled::Registry
- Defined in:
- lib/sidekiq/throttled/registry.rb
Overview
Registred strategies.
Class Method Summary collapse
-
.add(name, **kwargs) ⇒ Strategy
Adds strategy to the registry.
-
.add_alias(new_name, old_name) ⇒ Strategy
Adds alias for existing strategy.
- .each ⇒ Object
- .each_with_static_keys ⇒ Object
- .get(name) ⇒ Object
Class Method Details
.add(name, **kwargs) ⇒ Strategy
Adds strategy to the registry.
20 21 22 23 24 |
# File 'lib/sidekiq/throttled/registry.rb', line 20 def add(name, **kwargs) name = name.to_s @strategies[name] = Strategy.new(name, **kwargs) end |
.add_alias(new_name, old_name) ⇒ Strategy
Adds alias for existing strategy.
32 33 34 35 36 37 38 39 |
# File 'lib/sidekiq/throttled/registry.rb', line 32 def add_alias(new_name, old_name) new_name = new_name.to_s old_name = old_name.to_s raise "Strategy not found: #{old_name}" unless @strategies[old_name] @aliases[new_name] = @strategies[old_name] end |
.each ⇒ Enumerator .each {|strategy| ... } ⇒ Registry
67 68 69 70 71 72 |
# File 'lib/sidekiq/throttled/registry.rb', line 67 def each return to_enum(__method__) unless block_given? @strategies.each { |*args| yield(*args) } self end |
.each_with_static_keys ⇒ Enumerator .each_with_static_keys {|strategy| ... } ⇒ Registry
82 83 84 85 86 87 88 |
# File 'lib/sidekiq/throttled/registry.rb', line 82 def each_with_static_keys return to_enum(__method__) unless block_given? @strategies.each do |name, strategy| yield(name, strategy) unless strategy.dynamic? end end |
.get(name) ⇒ Strategy? .get(name) {|strategy| ... } ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/sidekiq/throttled/registry.rb', line 51 def get(name) strategy = find(name.to_s) || find_by_class(name) return yield strategy if strategy && block_given? strategy end |