Class: AllMyCircuits::Strategies::AbstractStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/all_my_circuits/strategies/abstract_strategy.rb

Overview

Public: determines whether the circuit breaker should be tripped open upon another error within the supplied block.

See AllMyCircuits::Strategies::NumberOverWindowStrategy, AllMyCircuits::Strategies::PercentageOverWindowStrategy for examples.

Direct Known Subclasses

AbstractWindowStrategy

Instance Method Summary collapse

Instance Method Details

#closedObject

Public: called whenever circuit is closed.



28
29
# File 'lib/all_my_circuits/strategies/abstract_strategy.rb', line 28

def closed
end

#errorObject

Public: called whenever a request has failed within circuit breaker.



18
19
# File 'lib/all_my_circuits/strategies/abstract_strategy.rb', line 18

def error
end

#openedObject

Public: called whenever circuit is tripped open.



23
24
# File 'lib/all_my_circuits/strategies/abstract_strategy.rb', line 23

def opened
end

#should_open?Boolean

Public: called after each error within circuit breaker to determine whether it should be tripped open.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/all_my_circuits/strategies/abstract_strategy.rb', line 34

def should_open?
  raise NotImplementedError
end

#successObject

Public: called whenever a request has ran successfully through circuit breaker.



13
14
# File 'lib/all_my_circuits/strategies/abstract_strategy.rb', line 13

def success
end