Skip to main content

WorkflowEngine

Struct WorkflowEngine 

Source
pub struct WorkflowEngine<S: DurableStore> { /* private fields */ }
Expand description

Drives workflow steps through the V1 Queue and records V2 Events.

Implementations§

Source§

impl<S: DurableStore> WorkflowEngine<S>

Source

pub fn new( queue: Queue, store: S, worker_id: String, lease_ttl: Duration, priority: Priority, ) -> Self

Source

pub fn register_workflow( &self, workflow: Workflow, bodies: Vec<StepFunc>, ) -> Result<(), EngineError>

Registers a workflow’s step bodies without running anything, so a later recover call (after a process restart) has something to re-admit an interrupted step into.

Source

pub async fn run( &self, workflow: Workflow, bodies: Vec<StepFunc>, ) -> Result<(), EngineError>

Runs all steps in order, recording events and honoring per-step retry policy.

Stops (without error) at the first step that enters StepStatus::Waiting — the workflow stays registered so a later Self::resume can continue it from that point.

Source

pub async fn cancel( &self, workflow_id: &str, reason: String, ) -> Result<(), EngineError>

Unblocks a step in StepStatus::Waiting, supplying opaque input for its next run, then continues driving the remaining steps in order — stopping again if a later step also enters Waiting. Records Event::WorkflowCancelled and un-registers the workflow so the engine will not claim or schedule further steps.

Idempotent: if the workflow already has a terminal event (Event::WorkflowCompleted, Event::WorkflowFailed, or Event::WorkflowCancelled), returns Ok(()) without appending anything.

Cancellation does not abort a step attempt already pushed to the V1 Queue and executing in a worker — V1 has no in-flight abort. Side effects from that run may still occur. While driving steps, cancellation is observed at the next step boundary (and between retry attempts for the current step); a body already running on the queue is not stopped.

Source

pub async fn resume( &self, workflow_id: &str, step_index: usize, input: String, ) -> Result<(), EngineError>

Source

pub fn resume_input( &self, workflow_id: &str, step_index: usize, ) -> Option<String>

Opaque input from the most recent Event::StepResumed for this step in durable storage, if any.

Auto Trait Implementations§

§

impl<S> !Freeze for WorkflowEngine<S>

§

impl<S> RefUnwindSafe for WorkflowEngine<S>
where S: RefUnwindSafe,

§

impl<S> Send for WorkflowEngine<S>

§

impl<S> Sync for WorkflowEngine<S>

§

impl<S> Unpin for WorkflowEngine<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for WorkflowEngine<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for WorkflowEngine<S>
where S: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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