Class: SwitchGear::CircuitBreaker::Memory
- Inherits:
-
Object
- Object
- SwitchGear::CircuitBreaker::Memory
- Includes:
- SwitchGear::CircuitBreaker
- Defined in:
- lib/switch_gear/circuit_breaker/memory.rb
Instance Attribute Summary collapse
-
#circuit ⇒ Proc/Lambda
The main runner, must respond to #call.
-
#failure_limit ⇒ Integer
The count of failures.
-
#failures ⇒ Array<CircuitBreaker::Failure>
The current failures.
-
#logger ⇒ Object
The current logger.
-
#reset_timeout ⇒ Integer
The amount of time in seconds before a breaker should reset if currently open.
-
#state ⇒ Symbol
The current state.
Instance Method Summary collapse
-
#add_failure(failure) ⇒ Object
(look to add_failure).
-
#initialize {|circuit, failure_limit, reset_timeout, logger| ... } ⇒ SwitchGear::CircuitBreaker::Memory
constructor
The object.
Methods included from SwitchGear::CircuitBreaker
#call, #closed?, #failure_count, #half_open?, #open?
Constructor Details
#initialize {|circuit, failure_limit, reset_timeout, logger| ... } ⇒ SwitchGear::CircuitBreaker::Memory
Returns the object.
38 39 40 41 42 43 44 45 46 |
# File 'lib/switch_gear/circuit_breaker/memory.rb', line 38 def initialize(&block) yield self @failure_limit ||= 5 @reset_timeout ||= 10 @logger ||= Logger.new(STDOUT) @state = :closed @failures = [] run_validations end |
Instance Attribute Details
#circuit ⇒ Proc/Lambda
The main runner, must respond to #call
8 9 10 |
# File 'lib/switch_gear/circuit_breaker/memory.rb', line 8 def circuit @circuit end |
#failure_limit ⇒ Integer
The count of failures
11 12 13 |
# File 'lib/switch_gear/circuit_breaker/memory.rb', line 11 def failure_limit @failure_limit end |
#failures ⇒ Array<CircuitBreaker::Failure>
The current failures
24 25 26 |
# File 'lib/switch_gear/circuit_breaker/memory.rb', line 24 def failures @failures end |
#logger ⇒ Object
The current logger
17 18 19 |
# File 'lib/switch_gear/circuit_breaker/memory.rb', line 17 def logger @logger end |
#reset_timeout ⇒ Integer
The amount of time in seconds before a breaker should reset if currently open. Defaults to 5.
14 15 16 |
# File 'lib/switch_gear/circuit_breaker/memory.rb', line 14 def reset_timeout @reset_timeout end |
#state ⇒ Symbol
The current state
21 22 23 |
# File 'lib/switch_gear/circuit_breaker/memory.rb', line 21 def state @state end |
Instance Method Details
#add_failure(failure) ⇒ Object
(look to add_failure)
49 50 51 |
# File 'lib/switch_gear/circuit_breaker/memory.rb', line 49 def add_failure(failure) failures << failure end |