Class: Wurk::Limiter::Config
- Inherits:
-
Object
- Object
- Wurk::Limiter::Config
- Defined in:
- lib/wurk/limiter.rb
Overview
Global config. Sidekiq Enterprise documents three knobs (ยง1.6):
backoff (Proc), redis (a Hash that builds a dedicated pool), and
errors (Array of exception classes the middleware also treats as
OverLimit). All three are mutable and re-read on every push/perform.
Instance Attribute Summary collapse
-
#backoff ⇒ Object
Returns the value of attribute backoff.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #pool ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
76 77 78 79 80 81 |
# File 'lib/wurk/limiter.rb', line 76 def initialize @backoff = DEFAULT_BACKOFF @errors = [OverLimit] @redis = nil @redis_pool = nil end |
Instance Attribute Details
#backoff ⇒ Object
Returns the value of attribute backoff.
73 74 75 |
# File 'lib/wurk/limiter.rb', line 73 def backoff @backoff end |
#errors ⇒ Object
Returns the value of attribute errors.
73 74 75 |
# File 'lib/wurk/limiter.rb', line 73 def errors @errors end |
#redis ⇒ Object
Returns the value of attribute redis.
74 75 76 |
# File 'lib/wurk/limiter.rb', line 74 def redis @redis end |
Instance Method Details
#pool ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/wurk/limiter.rb', line 92 def pool return nil if @redis.nil? @pool ||= case @redis when Wurk::RedisPool then @redis when Hash Wurk::RedisPool.new( size: @redis[:size] || 10, url: @redis[:url] || Wurk::RedisPool::DEFAULT_URL, timeout: @redis[:timeout] || Wurk::RedisPool::DEFAULT_TIMEOUT, name: 'limiter' ) else raise ArgumentError, "Limiter.config.redis must be Hash or RedisPool, got #{@redis.class}" end end |