pub struct FlowEngine { /* private fields */ }Expand description
The primary harness for running and validating workflows.
Produced by FlowEngineBuilder::build().
Implementations§
Source§impl FlowEngine
impl FlowEngine
Sourcepub fn validate(&self, def: &WorkflowDef) -> Result<(), Vec<ValidationError>>
pub fn validate(&self, def: &WorkflowDef) -> Result<(), Vec<ValidationError>>
Validate a workflow definition against the registered executors, providers, and gate resolvers.
Collects all errors before returning. Returns Ok(()) when valid, or
Err(errors) with one entry per problem found. Public so CI lint tools
can call it without actually running the workflow.
§Registry asymmetry with run()
This method validates against the FlowEngine’s own registries (those
supplied to FlowEngineBuilder). run(), however, validates against the
ExecutionState’s registries at call time. Because the two registry
sets are independent, a workflow that passes validate() may still be
rejected by run() if the ExecutionState was built with a different
set of action executors or item providers. Use validate() for static
analysis (CI lint, pre-flight checks) when you control both the engine
and execution state; rely on run()’s own validation when working with
externally-supplied ExecutionState values.
Sourcepub fn run(
&self,
def: &WorkflowDef,
state: &mut ExecutionState,
) -> Result<WorkflowResult>
pub fn run( &self, def: &WorkflowDef, state: &mut ExecutionState, ) -> Result<WorkflowResult>
Run a workflow definition with a pre-built execution state.
Validates against the execution state’s own registries (action,
item-provider) so the validation check uses the same source of truth
as dispatch-time lookup. Gate resolvers are validated against the
FlowEngine’s registry because ExecutionState carries none — gates
are resolved via persistence callbacks, not the executor pipeline.
Event sinks registered on the engine are injected into the state for
this run; any sinks already set on state.event_sinks are replaced.
Sourcepub fn run_workflow(
&self,
def: &WorkflowDef,
input: RunInput,
) -> Result<WorkflowResult>
pub fn run_workflow( &self, def: &WorkflowDef, input: RunInput, ) -> Result<WorkflowResult>
Run a top-level workflow, constructing ExecutionState internally from input.
Acquires the lease inside this call so callers never observe an uninitialized
lease_generation. Engine-wide event sinks are merged with input.event_sinks
(engine sinks first).
Sourcepub fn run_child(
&self,
def: &WorkflowDef,
input: ChildRunInput,
parent_ctx: &ChildWorkflowContext,
) -> Result<WorkflowResult>
pub fn run_child( &self, def: &WorkflowDef, input: ChildRunInput, parent_ctx: &ChildWorkflowContext, ) -> Result<WorkflowResult>
Run a child workflow as part of a ChildWorkflowRunner implementation.
Inherits run_ctx, extra_plugin_dirs, model, exec_config, and event sinks
from parent_ctx. Remaining harness-side fields come from input. The child’s
parent_run_id is set to parent_ctx.workflow_run_id.
inputs is sourced from input.inputs_override when Some, otherwise from
parent_ctx.inputs.
Engine-wide event sinks are merged with parent_ctx.event_sinks (engine first).
Sourcepub fn resume(
&self,
def: &WorkflowDef,
state: &mut ExecutionState,
) -> Result<WorkflowResult>
pub fn resume( &self, def: &WorkflowDef, state: &mut ExecutionState, ) -> Result<WorkflowResult>
Resume a workflow from the post-reset DB state.
Reads completed steps from persistence, builds the skip set internally, and
delegates to run(). The state.resume_ctx must be None on entry — this
method owns skip-set construction so that it reads the post-reset DB state.
Sourcepub fn cancel_run(&self, run_id: &str, reason: CancellationReason) -> Result<()>
pub fn cancel_run(&self, run_id: &str, reason: CancellationReason) -> Result<()>
Cancel a running workflow by run ID.
Marks the DB run as Cancelling, signals the in-memory token so the engine
halts at the next step boundary, and fire-and-forgets executor.cancel()
for the step currently in flight.
Returns Err if the run is not currently active in this engine instance.