Class: Stoplight::Infrastructure::Notifier::FailSafe Private
- Inherits:
-
Object
- Object
- Stoplight::Infrastructure::Notifier::FailSafe
- Defined in:
- lib/stoplight/infrastructure/notifier/fail_safe.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.
A wrapper around a notifier that provides fail-safe mechanisms using a circuit breaker. It ensures that a notification can gracefully handle failures.
Instance Attribute Summary collapse
-
#error_notifier ⇒ Object
readonly
private
The underlying notifier being wrapped.
-
#notifier ⇒ Object
readonly
private
The underlying notifier being wrapped.
Instance Method Summary collapse
- #==(other) ⇒ Boolean private
-
#initialize(notifier:, error_notifier:) ⇒ FailSafe
constructor
private
A new instance of FailSafe.
-
#notify(info, from_color, to_color, error = nil) ⇒ Object
private
Sends a notification using the wrapped notifier with fail-safe mechanisms.
Constructor Details
#initialize(notifier:, error_notifier:) ⇒ FailSafe
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 FailSafe.
19 20 21 22 |
# File 'lib/stoplight/infrastructure/notifier/fail_safe.rb', line 19 def initialize(notifier:, error_notifier:) @notifier = notifier @error_notifier = error_notifier end |
Instance Attribute Details
#error_notifier ⇒ Object (readonly)
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.
The underlying notifier being wrapped.
15 16 17 |
# File 'lib/stoplight/infrastructure/notifier/fail_safe.rb', line 15 def error_notifier @error_notifier end |
#notifier ⇒ Object (readonly)
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.
The underlying notifier being wrapped.
13 14 15 |
# File 'lib/stoplight/infrastructure/notifier/fail_safe.rb', line 13 def notifier @notifier end |
Instance Method Details
#==(other) ⇒ Boolean
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.
37 38 39 |
# File 'lib/stoplight/infrastructure/notifier/fail_safe.rb', line 37 def ==(other) other.is_a?(self.class) && notifier == other.notifier end |
#notify(info, from_color, to_color, error = nil) ⇒ 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.
Sends a notification using the wrapped notifier with fail-safe mechanisms.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/stoplight/infrastructure/notifier/fail_safe.rb', line 25 def notify(info, from_color, to_color, error = nil) fallback = proc do |exception| error_notifier.call(exception) if exception nil end #: ^(StandardError?) -> void circuit_breaker.run(fallback) do notifier.notify(info, from_color, to_color, error) end #: void end |