Class: Stoplight::Domain::TrafficRecovery::ConsecutiveSuccesses Private
- Inherits:
-
Object
- Object
- Stoplight::Domain::TrafficRecovery::ConsecutiveSuccesses
- Defined in:
- lib/stoplight/domain/traffic_recovery/consecutive_successes.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 conservative strategy that requires multiple consecutive successful probes before resuming traffic flow.
The strategy immediately returns to RED state if any failure occurs during the recovery process, ensuring that only truly stable services resume full traffic flow.
Recovery behavior:
-
After cool-off period, Stoplight enters YELLOW (recovery) state
-
Requires 3 consecutive successful probes to transition to GREEN
-
Any failure during recovery immediately returns to RED state
-
Process repeats after another cool-off period
Configuration requirements:
-
‘recovery_threshold`: Integer > 0, specifies required consecutive successes
Failure behavior: Unlike some circuit breaker implementations that tolerate occasional failures during recovery, this strategy takes a zero-tolerance approach: any failure during the recovery phase immediately transitions back to RED state. This conservative approach prioritizes stability over recovery speed.
Instance Method Summary collapse
- #==(other) ⇒ Object private
- #check_compatibility(config) ⇒ Object private
-
#determine_color(config, recovery_metrics) ⇒ Object
private
Determines if traffic should be resumed based on successes counts.
Instance Method Details
#==(other) ⇒ 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.
58 |
# File 'lib/stoplight/domain/traffic_recovery/consecutive_successes.rb', line 58 def ==(other) = other.is_a?(self.class) |
#check_compatibility(config) ⇒ 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.
37 38 39 40 41 42 43 44 45 |
# File 'lib/stoplight/domain/traffic_recovery/consecutive_successes.rb', line 37 def check_compatibility(config) if config.recovery_threshold <= 0 CompatibilityResult.incompatible("`recovery_threshold` should be bigger than 0") elsif !config.recovery_threshold.is_a?(Integer) CompatibilityResult.incompatible("`recovery_threshold` should be an integer") else CompatibilityResult.compatible end end |
#determine_color(config, recovery_metrics) ⇒ 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.
Determines if traffic should be resumed based on successes counts.
48 49 50 51 52 53 54 55 56 |
# File 'lib/stoplight/domain/traffic_recovery/consecutive_successes.rb', line 48 def determine_color(config, recovery_metrics) if recovery_metrics.consecutive_errors > 0 TrafficRecovery::RED elsif recovery_metrics.consecutive_successes >= config.recovery_threshold TrafficRecovery::GREEN else TrafficRecovery::YELLOW end end |