Module: Cachext::Features::CircuitBreaker
- Included in:
- Client
- Defined in:
- lib/cachext/features/circuit_breaker.rb
Instance Attribute Summary collapse
-
#breaker ⇒ Object
readonly
Returns the value of attribute breaker.
Instance Method Summary collapse
- #handle_error(key, options, error) ⇒ Object
- #initialize(config) ⇒ Object
- #read(key, options) ⇒ Object
Instance Attribute Details
#breaker ⇒ Object (readonly)
Returns the value of attribute breaker.
4 5 6 |
# File 'lib/cachext/features/circuit_breaker.rb', line 4 def breaker @breaker end |
Instance Method Details
#handle_error(key, options, error) ⇒ Object
21 22 23 24 |
# File 'lib/cachext/features/circuit_breaker.rb', line 21 def handle_error key, , error breaker.for(key).increment_failure super end |
#initialize(config) ⇒ Object
6 7 8 9 |
# File 'lib/cachext/features/circuit_breaker.rb', line 6 def initialize config super @breaker = Breaker.new(config) end |
#read(key, options) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/cachext/features/circuit_breaker.rb', line 11 def read key, circuit = breaker.for(key) if circuit.open? key.read_backup else circuit.check_health super end end |