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.
66 67 68 69 70 71 |
# File 'lib/wurk/limiter.rb', line 66 def initialize @backoff = DEFAULT_BACKOFF @errors = [OverLimit] @redis = nil @redis_pool = nil end |
Instance Attribute Details
#backoff ⇒ Object
Returns the value of attribute backoff.
63 64 65 |
# File 'lib/wurk/limiter.rb', line 63 def backoff @backoff end |
#errors ⇒ Object
Returns the value of attribute errors.
63 64 65 |
# File 'lib/wurk/limiter.rb', line 63 def errors @errors end |
#redis ⇒ Object
Returns the value of attribute redis.
64 65 66 |
# File 'lib/wurk/limiter.rb', line 64 def redis @redis end |
Instance Method Details
#pool ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/wurk/limiter.rb', line 82 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 |