Class: CircuitBreakage::RedisBackedBreaker
- Defined in:
- lib/circuit_breakage/redis_backed_breaker.rb
Overview
Similar to Breaker, but accepts a Redis connection and an arbitrary key, and will share state among an arbitrary number of RedisBackedBreakers via Redis. Relies on the SETNX redis command.
Constant Summary collapse
- DEFAULT_LOCK_TIMEOUT =
How long before we decide a lock-holder has crashed, in seconds.
DEFAULT_TIMEOUT + 10
Constants inherited from Breaker
Breaker::DEFAULT_DURATION, Breaker::DEFAULT_FAILURE_THRESHOLD, Breaker::DEFAULT_TIMEOUT
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#lock_timeout ⇒ Object
readonly
Returns the value of attribute lock_timeout.
Attributes inherited from Breaker
#block, #duration, #failure_count, #failure_threshold, #last_failed, #state, #timeout
Instance Method Summary collapse
-
#initialize(connection, key, block) ⇒ RedisBackedBreaker
constructor
A new instance of RedisBackedBreaker.
Methods inherited from Breaker
Constructor Details
#initialize(connection, key, block) ⇒ RedisBackedBreaker
Returns a new instance of RedisBackedBreaker.
13 14 15 16 17 18 |
# File 'lib/circuit_breakage/redis_backed_breaker.rb', line 13 def initialize(connection, key, block) @connection = connection @key = key @lock_timeout = DEFAULT_LOCK_TIMEOUT super(block) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
11 12 13 |
# File 'lib/circuit_breakage/redis_backed_breaker.rb', line 11 def connection @connection end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
11 12 13 |
# File 'lib/circuit_breakage/redis_backed_breaker.rb', line 11 def key @key end |
#lock_timeout ⇒ Object (readonly)
Returns the value of attribute lock_timeout.
11 12 13 |
# File 'lib/circuit_breakage/redis_backed_breaker.rb', line 11 def lock_timeout @lock_timeout end |