Class: Stoplight::Domain::Strategies::RedRunStrategy Private
- Inherits:
-
Object
- Object
- Stoplight::Domain::Strategies::RedRunStrategy
- Defined in:
- lib/stoplight/domain/strategies/red_run_strategy.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.
Defines how the light executes when it is red.
This strategy prevents execution of the code block and either raises an error or invokes a fallback if provided.
Instance Method Summary collapse
-
#execute(fallback, state_snapshot:) ⇒ Object
private
Executes the fallback proc when the light is in the red state.
-
#initialize(name:, cool_off_time:) ⇒ RedRunStrategy
constructor
private
A new instance of RedRunStrategy.
Constructor Details
#initialize(name:, cool_off_time:) ⇒ RedRunStrategy
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 RedRunStrategy.
13 14 15 16 |
# File 'lib/stoplight/domain/strategies/red_run_strategy.rb', line 13 def initialize(name:, cool_off_time:) @name = name @cool_off_time = cool_off_time end |
Instance Method Details
#execute(fallback, state_snapshot:) ⇒ 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.
Executes the fallback proc when the light is in the red state.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/stoplight/domain/strategies/red_run_strategy.rb', line 24 def execute(fallback, state_snapshot:) if fallback fallback.call(nil) else raise Error::RedLight.new( @name, cool_off_time: @cool_off_time, retry_after: state_snapshot.recovery_scheduled_after ) end end |