Class: RubyReactor::Halt
Overview
A "clean halt" signal. Two ways to produce one:
1. Implicitly, when a reactor's `with_period` gate finds the bucket has
already been claimed. The executor short-circuits before any step
runs.
2. Explicitly, by returning `RubyReactor.Halt(reason: "...")` from a
step's `run` block. The reactor halts immediately — no further steps,
and crucially **no compensation** of already-completed steps. Use this
when a step discovers that the rest of the workflow is not needed
(e.g. "user already opted out", "nothing to do this round") and the
partial progress is still correct to keep.
Subclass of Success so callers that only check success? continue to work;
halted? distinguishes it. Deliberately does NOT define skipped? — a
migration site that still asks a halt whether it was skipped should raise
NoMethodError, not silently read false.
Instance Attribute Summary collapse
-
#period_key ⇒ Object
readonly
Returns the value of attribute period_key.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#step_name ⇒ Object
readonly
Returns the value of attribute step_name.
Attributes inherited from Success
Instance Method Summary collapse
- #halted? ⇒ Boolean
-
#initialize(reason: nil, period_key: nil, step_name: nil) ⇒ Halt
constructor
A new instance of Halt.
Methods inherited from Success
#failure?, #skipped?, #success?, #to_h
Constructor Details
#initialize(reason: nil, period_key: nil, step_name: nil) ⇒ Halt
Returns a new instance of Halt.
91 92 93 94 95 96 |
# File 'lib/ruby_reactor.rb', line 91 def initialize(reason: nil, period_key: nil, step_name: nil) super(nil) @reason = reason @period_key = period_key @step_name = step_name end |
Instance Attribute Details
#period_key ⇒ Object (readonly)
Returns the value of attribute period_key.
89 90 91 |
# File 'lib/ruby_reactor.rb', line 89 def period_key @period_key end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
89 90 91 |
# File 'lib/ruby_reactor.rb', line 89 def reason @reason end |
#step_name ⇒ Object (readonly)
Returns the value of attribute step_name.
89 90 91 |
# File 'lib/ruby_reactor.rb', line 89 def step_name @step_name end |
Instance Method Details
#halted? ⇒ Boolean
98 99 100 |
# File 'lib/ruby_reactor.rb', line 98 def halted? true end |