Class: Phronomy::FSMSession
- Inherits:
-
Object
- Object
- Phronomy::FSMSession
- Defined in:
- lib/phronomy/engine/fsm_session.rb
Overview
Event-driven execution wrapper for a single FSM session.
All public methods are called from the Runtime-owned EventLoop thread. FSMSession owns FSM execution only; it does not own external Task handles, activity tokens, callback correlation, or domain-specific stale-event policy.
Constant Summary collapse
- FINISH =
WorkflowRunner::FINISH
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
- #handle(event) ⇒ Object
-
#initialize(id:, context:, entry_point:, entry_actions:, auto_state_set:, declared_states:, wait_state_names:, external_events:, phase_machine_class:, recursion_limit:, event_loop:, resume_event: nil, resume_phase: nil, stable_observer: nil) ⇒ FSMSession
constructor
A new instance of FSMSession.
- #start ⇒ Object
Constructor Details
#initialize(id:, context:, entry_point:, entry_actions:, auto_state_set:, declared_states:, wait_state_names:, external_events:, phase_machine_class:, recursion_limit:, event_loop:, resume_event: nil, resume_phase: nil, stable_observer: nil) ⇒ FSMSession
Returns a new instance of FSMSession.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/phronomy/engine/fsm_session.rb', line 14 def initialize( id:, context:, entry_point:, entry_actions:, auto_state_set:, declared_states:, wait_state_names:, external_events:, phase_machine_class:, recursion_limit:, event_loop:, resume_event: nil, resume_phase: nil, stable_observer: nil ) @id = id @ctx = context @context = context @entry_point = entry_point @entry_actions = entry_actions @auto_state_set = auto_state_set @declared_states = declared_states @wait_state_names = wait_state_names @external_events = external_events @phase_machine_class = phase_machine_class @recursion_limit = recursion_limit @event_loop = event_loop @resume_event = resume_event @resume_phase = resume_phase @stable_observer = stable_observer @step = 0 @done = false @current_state = nil @tracker = nil end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
12 13 14 |
# File 'lib/phronomy/engine/fsm_session.rb', line 12 def context @context end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/phronomy/engine/fsm_session.rb', line 12 def id @id end |
Instance Method Details
#handle(event) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/phronomy/engine/fsm_session.rb', line 75 def handle(event) return if @done context_disposition = apply_context_event(event) return if context_disposition == :consume if context_disposition && !has_external_event_from?(@current_state, event.type) return end fire_and_advance!(event) rescue => error finish_with_error(error) end |
#start ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/phronomy/engine/fsm_session.rb', line 51 def start if @resume_event @current_state = @resume_phase @tracker = build_tracker(@current_state) @tracker.context = @ctx fire_and_advance!( Phronomy::Event.new( type: @resume_event, target_id: @id, payload: nil ) ) else @current_state = @entry_point @tracker = build_tracker(@current_state) @tracker.context = @ctx run_initial_entry_actions! @tracker.context = @ctx advance_or_halt end rescue => error finish_with_error(error) end |