Class: EventMachine::CircuitBreaker::Strategy::Basic
- Inherits:
-
Object
- Object
- EventMachine::CircuitBreaker::Strategy::Basic
- Defined in:
- lib/eventmachine/circuit_breaker/strategy/basic.rb
Instance Method Summary collapse
- #handle_response(client) ⇒ Object
-
#initialize(failure_count: 5, recovery_time: 30) ⇒ Basic
constructor
A new instance of Basic.
- #open? ⇒ Boolean
Constructor Details
#initialize(failure_count: 5, recovery_time: 30) ⇒ Basic
Returns a new instance of Basic.
5 6 7 8 9 10 |
# File 'lib/eventmachine/circuit_breaker/strategy/basic.rb', line 5 def initialize(failure_count: 5, recovery_time: 30) @mutex = EventMachine::CircuitBreaker::RWMutex.new close! @failure_limit = failure_count @recovery_time = recovery_time end |
Instance Method Details
#handle_response(client) ⇒ Object
16 17 18 19 |
# File 'lib/eventmachine/circuit_breaker/strategy/basic.rb', line 16 def handle_response(client) increment_failures if client.response_header.server_error? close! if half_open? && client.response_header.successful? end |
#open? ⇒ Boolean
12 13 14 |
# File 'lib/eventmachine/circuit_breaker/strategy/basic.rb', line 12 def open? mutex.read_lock { @state == :open } end |