Class: RubyReactor::Halt

Inherits:
Success show all
Defined in:
lib/ruby_reactor.rb

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

Attributes inherited from Success

#value

Instance Method Summary collapse

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_keyObject (readonly)

Returns the value of attribute period_key.



89
90
91
# File 'lib/ruby_reactor.rb', line 89

def period_key
  @period_key
end

#reasonObject (readonly)

Returns the value of attribute reason.



89
90
91
# File 'lib/ruby_reactor.rb', line 89

def reason
  @reason
end

#step_nameObject (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

Returns:



98
99
100
# File 'lib/ruby_reactor.rb', line 98

def halted?
  true
end