Class: StandardCircuit::NotifierBridge Private
- Inherits:
-
Object
- Object
- StandardCircuit::NotifierBridge
- Defined in:
- lib/standard_circuit/notifier_bridge.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Stoplight-shaped notifier whose only job is to translate the upstream ‘notifier.notify(light, from_color, to_color, error)` callback into a StandardCircuit Rails event.
Stoplight calls notifiers on every color transition (GREEN<->RED, RED->YELLOW for half-open recovery). We map each transition to a stable event name and forward a uniform payload to whichever event bus is live.
This is the single Stoplight notifier StandardCircuit registers — Logger, Sentry, and Metrics are now subscribers, not direct notifiers.
Constant Summary collapse
- EVENT_FOR_COLOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ Stoplight::Color::RED => "standard_circuit.circuit.opened", Stoplight::Color::GREEN => "standard_circuit.circuit.closed", Stoplight::Color::YELLOW => "standard_circuit.circuit.degraded" }.freeze
Instance Method Summary collapse
-
#initialize(config) ⇒ NotifierBridge
constructor
private
A new instance of NotifierBridge.
- #notify(light, from_color, to_color, error) ⇒ Object private
Constructor Details
#initialize(config) ⇒ NotifierBridge
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of NotifierBridge.
21 22 23 |
# File 'lib/standard_circuit/notifier_bridge.rb', line 21 def initialize(config) @config = config end |
Instance Method Details
#notify(light, from_color, to_color, error) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 |
# File 'lib/standard_circuit/notifier_bridge.rb', line 25 def notify(light, from_color, to_color, error) event_name = EVENT_FOR_COLOR[to_color] return unless event_name EventEmitter.emit(event_name, payload_for(light, from_color, to_color, error)) end |