Skip to main content

run_event_loop

Function run_event_loop 

Source
pub fn run_event_loop(
    ctx: &mut PhaseContext<'_>,
    initial_state: Option<PipelineState>,
    config: EventLoopConfig,
) -> Result<EventLoopResult>
Expand description

Run the main event loop for the reducer-based pipeline.

This function orchestrates pipeline execution by repeatedly:

  1. Determining the next effect based on the current state
  2. Executing the effect through the effect handler (which performs side effects)
  3. Applying the resulting event to state through the reducer (pure function)
  4. Repeating until a terminal state is reached or max iterations exceeded

The entire event loop is wrapped in panic recovery to ensure the pipeline never crashes due to agent failures (including segmentation faults).

§Arguments

  • ctx - Phase context for effect handlers
  • initial_state - Optional initial state (if None, creates a new state)
  • config - Event loop configuration

§Returns

Returns the event loop result containing the completion status and final state.