class AllMyCircuits::Strategies::NumberOverWindowStrategy
Public: opens the circuit whenever failures threshold is reached within the window. Threshold is represented by absolute number of failures within the window.
Public Class Methods
new(failures_threshold:, **kwargs)
click to toggle source
Public: initializes a new instance.
Options
requests_window - number of consecutive requests tracked by the window. failures_threshold - number of failures within the window after which the circuit is tripped open.
Calls superclass method
AllMyCircuits::Strategies::AbstractWindowStrategy::new
# File lib/all_my_circuits/strategies/number_over_window_strategy.rb, line 18 def initialize(failures_threshold:, **kwargs) @failures_threshold = failures_threshold super(**kwargs) end
Public Instance Methods
should_open?()
click to toggle source
# File lib/all_my_circuits/strategies/number_over_window_strategy.rb, line 23 def should_open? return unless @window.full? failures = @window.count(:failed) failures >= @failures_threshold end