Class: Stoplight::Domain::TrafficControl::ConsecutiveErrors Private
- Inherits:
-
Object
- Object
- Stoplight::Domain::TrafficControl::ConsecutiveErrors
- Defined in:
- lib/stoplight/domain/traffic_control/consecutive_errors.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 strategy that stops the traffic based on consecutive failures number.
This strategy implements two distinct behaviors based on whether a window size is configured:
-
When window_size is set: The Stoplight turns red when the total number of failures within the window reaches the threshold.
-
When window_size is not set: The Stoplight turns red when consecutive failures reach the threshold.
Will switch to red if 5 consecutive failures occur within the 60-second window
Will switch to red only if 5 consecutive failures occur regardless of the time window
Instance Method Summary collapse
- #==(other) ⇒ Object private
- #check_compatibility(config) ⇒ Object private
- #stop_traffic?(config, metrics) ⇒ Boolean private
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.
44 45 46 |
# File 'lib/stoplight/domain/traffic_control/consecutive_errors.rb', line 44 def ==(other) other.is_a?(self.class) end |
#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.
30 31 32 33 34 35 36 37 38 |
# File 'lib/stoplight/domain/traffic_control/consecutive_errors.rb', line 30 def check_compatibility(config) if config.threshold <= 0 CompatibilityResult.incompatible("`threshold` should be bigger than 0") elsif !config.threshold.is_a?(Integer) CompatibilityResult.incompatible("`threshold` should be an integer") else CompatibilityResult.compatible end end |
#stop_traffic?(config, metrics) ⇒ 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.
40 41 42 |
# File 'lib/stoplight/domain/traffic_control/consecutive_errors.rb', line 40 def stop_traffic?(config, metrics) metrics.consecutive_errors >= config.threshold end |