Skip to main content

StepBuilder

Struct StepBuilder 

Source
pub struct StepBuilder<D: WorkflowData> { /* private fields */ }
Expand description

Builder for configuring a single step in the workflow.

Owns the WorkflowBuilder, consuming self on each method call. This avoids all lifetime/borrow issues.

Implementations§

Source§

impl<D: WorkflowData> StepBuilder<D>

Source

pub fn name(self, name: &str) -> Self

Set the display name of the current step.

Source

pub fn id(self, external_id: &str) -> Self

Set an external ID for forward references.

Source

pub fn on_error(self, behavior: ErrorBehavior) -> Self

Set the error handling behavior for this step.

Source

pub fn config(self, config: Value) -> Self

Attach arbitrary JSON configuration to this step.

The step can read it at runtime via context.step.step_config.

Source

pub fn compensate_with<C: StepBody + Default + 'static>(self) -> Self

Add a compensation step for saga rollback.

Source

pub fn then<S: StepBody + Default + 'static>(self) -> StepBuilder<D>

Chain the next step. Wires an outcome from the current step to the new one.

Source

pub fn then_fn( self, f: impl Fn() -> ExecutionResult + Send + Sync + 'static, ) -> StepBuilder<D>

Chain an inline function step.

Source

pub fn wait_for(self, event_name: &str, event_key: &str) -> StepBuilder<D>

Insert a WaitFor step.

Source

pub fn delay(self, duration: Duration) -> StepBuilder<D>

Insert a Delay step.

Source

pub fn if_do<S: StepBody + Default + 'static>( self, build_children: impl FnOnce(&mut WorkflowBuilder<D>), ) -> StepBuilder<D>

Insert an If container step with child steps built by the closure. The type parameter S is the step type used for the If condition evaluation.

Source

pub fn while_do<S: StepBody + Default + 'static>( self, build_children: impl FnOnce(&mut WorkflowBuilder<D>), ) -> StepBuilder<D>

Insert a While container step.

Source

pub fn for_each<S: StepBody + Default + 'static>( self, build_children: impl FnOnce(&mut WorkflowBuilder<D>), ) -> StepBuilder<D>

Insert a ForEach container step.

Source

pub fn saga( self, build_children: impl FnOnce(&mut WorkflowBuilder<D>), ) -> StepBuilder<D>

Insert a Saga container step with child steps.

Source

pub fn parallel( self, build_branches: impl FnOnce(ParallelBuilder<D>) -> ParallelBuilder<D>, ) -> StepBuilder<D>

Start a parallel block.

Source

pub fn end_workflow(self) -> WorkflowBuilder<D>

Mark this step as the terminal step (no further outcomes).

Source

pub fn build(self, id: impl Into<String>, version: u32) -> WorkflowDefinition

Access the compiled definition directly (shortcut for end_workflow().build()).

Auto Trait Implementations§

§

impl<D> Freeze for StepBuilder<D>

§

impl<D> !RefUnwindSafe for StepBuilder<D>

§

impl<D> Send for StepBuilder<D>

§

impl<D> Sync for StepBuilder<D>

§

impl<D> Unpin for StepBuilder<D>
where D: Unpin,

§

impl<D> UnsafeUnpin for StepBuilder<D>

§

impl<D> !UnwindSafe for StepBuilder<D>

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