Module: Philiprehberger::Circuit::Callbacks

Included in:
Breaker
Defined in:
lib/philiprehberger/circuit/callbacks.rb

Overview

Callback registration and firing for state transitions

Instance Method Summary collapse

Instance Method Details

#on_closeObject



8
# File 'lib/philiprehberger/circuit/callbacks.rb', line 8

def on_close(&) = register_callback(:close, &)

#on_half_openObject



9
# File 'lib/philiprehberger/circuit/callbacks.rb', line 9

def on_half_open(&) = register_callback(:half_open, &)

#on_openObject



7
# File 'lib/philiprehberger/circuit/callbacks.rb', line 7

def on_open(&) = register_callback(:open, &)

#on_reset {|from_state, to_state| ... } ⇒ Object

Register a callback for any state transition

Yields:

  • (from_state, to_state)

    called on every transition



13
14
15
16
# File 'lib/philiprehberger/circuit/callbacks.rb', line 13

def on_reset(&block)
  @mutex.synchronize { @reset_callbacks << block }
  self
end