Skip to main content

FlowEngine

Struct FlowEngine 

Source
pub struct FlowEngine { /* private fields */ }
Expand description

The primary harness for running and validating workflows.

Produced by FlowEngineBuilder::build().

Implementations§

Source§

impl FlowEngine

Source

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.

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Trait Implementations§

Source§

impl Drop for FlowEngine

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more