Class: Stoplight::Domain::Tracker::RecoveryProbe
- Defined in:
- lib/stoplight/domain/tracker/recovery_probe.rb,
sig/_private/stoplight/domain/tracker/recovery_probe.rbs
Instance Attribute Summary collapse
-
#config ⇒ Config
readonly
Returns the value of attribute config.
-
#metrics_store ⇒ _MetricsStore
readonly
Returns the value of attribute metrics_store.
-
#notifiers ⇒ Array[state_transition_notifier]
readonly
Returns the value of attribute notifiers.
-
#state_store ⇒ _StateStore
readonly
Returns the value of attribute state_store.
-
#traffic_recovery ⇒ _TrafficRecovery
readonly
Returns the value of attribute traffic_recovery.
Instance Method Summary collapse
-
#initialize(traffic_recovery:, notifiers:, config:, metrics_store:, state_store:) ⇒ RecoveryProbe
constructor
A new instance of RecoveryProbe.
- #record_failure(exception) ⇒ void
- #record_success ⇒ void
- #recover ⇒ void
Constructor Details
#initialize(traffic_recovery:, notifiers:, config:, metrics_store:, state_store:) ⇒ RecoveryProbe
Returns a new instance of RecoveryProbe.
7 8 9 10 11 12 13 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 7 def initialize(traffic_recovery:, notifiers:, config:, metrics_store:, state_store:) @traffic_recovery = traffic_recovery @notifiers = notifiers @config = config @metrics_store = metrics_store @state_store = state_store end |
Instance Attribute Details
#config ⇒ Config (readonly)
Returns the value of attribute config.
32 33 34 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 32 def config @config end |
#metrics_store ⇒ _MetricsStore (readonly)
Returns the value of attribute metrics_store.
33 34 35 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 33 def metrics_store @metrics_store end |
#notifiers ⇒ Array[state_transition_notifier] (readonly)
Returns the value of attribute notifiers.
31 32 33 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 31 def notifiers @notifiers end |
#state_store ⇒ _StateStore (readonly)
Returns the value of attribute state_store.
34 35 36 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 34 def state_store @state_store end |
#traffic_recovery ⇒ _TrafficRecovery (readonly)
Returns the value of attribute traffic_recovery.
30 31 32 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 30 def traffic_recovery @traffic_recovery end |
Instance Method Details
#record_failure(exception) ⇒ void
This method returns an undefined value.
16 17 18 19 20 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 16 def record_failure(exception) metrics_store.record_failure(exception) recover end |
#record_success ⇒ void
This method returns an undefined value.
22 23 24 25 26 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 22 def record_success metrics_store.record_success recover end |
#recover ⇒ void
This method returns an undefined value.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/stoplight/domain/tracker/recovery_probe.rb', line 36 def recover recovery_metrics = metrics_store.metrics_snapshot recovery_result = traffic_recovery.determine_color(config, recovery_metrics) return if recovery_result == TrafficRecovery::YELLOW from_color, to_color = case recovery_result when TrafficRecovery::GREEN then [Color::YELLOW, Color::GREEN] when TrafficRecovery::RED then [Color::YELLOW, Color::RED] else raise "recovery strategy returned unexpected color: #{recovery_result}" end state_store.transition_to_color(to_color) metrics_store.clear info = LightInfo.new(name: config.name) notifiers.each do |notifier| notifier.notify(info, from_color, to_color, nil) end end |