Skip to main content

SteppedFlow

Struct SteppedFlow 

Source
pub struct SteppedFlow<Start, Current, Backend, T = Identity> { /* private fields */ }
Expand description

A workflow represents a sequence of steps to be executed in order.

Implementations§

Source§

impl<Start, Cur, B, L> SteppedFlow<Start, Cur, B, L>
where B: Backend,

Source

pub fn and_then<F, O, FnArgs>( self, and_then: F, ) -> SteppedFlow<Start, O, B, Stack<AndThen<TaskFn<F, Cur, FnArgs>>, L>>
where TaskFn<F, Cur, FnArgs>: Service<Task<Cur>, Response = O>,

Adds a transformation step to the workflow that processes the output of the previous step.

The and_then method allows you to chain operations by providing a function that takes the result of the current workflow step and transforms it into the input for the next step. This enables building complex processing pipelines with type-safe transformations between steps.

§Example
workflow
    .and_then(extract)
    .and_then(transform)
    .and_then(load);
Source§

impl<Start, Cur, B, L> SteppedFlow<Start, Cur, B, L>

Source

pub fn delay_for( self, delay: Duration, ) -> SteppedFlow<Start, Cur, B, Stack<DelayFor, L>>

Delay the workflow by a fixed duration

Source§

impl<Start, Cur, B, L> SteppedFlow<Start, Cur, B, L>

Source

pub fn delay_with<F>( self, f: F, ) -> SteppedFlow<Start, Cur, B, Stack<DelayWith<F, B, Cur>, L>>
where F: FnMut(Task<Cur>) -> Duration + Send + 'static,

Delay the workflow by a duration determined by a function

Source§

impl<Start, C, L, I: IntoIterator<Item = C>, B: Backend> SteppedFlow<Start, I, B, L>

Source

pub fn filter_map<F, Output, FnArgs>( self, filter_map: F, ) -> SteppedFlow<Start, Vec<Output>, B, Stack<FilterMap<TaskFn<F, C, FnArgs>, I>, L>>
where TaskFn<F, C, FnArgs>: Service<Task<C>, Response = Option<Output>>,

Adds a filter and map step to the workflow.

Source§

impl<Start, C, L, I: IntoIterator<Item = C>, B: Backend> SteppedFlow<Start, I, B, L>

Source

pub fn fold<F, Output, FnArgs, Init>( self, fold: F, ) -> SteppedFlow<Start, Output, B, Stack<Fold<TaskFn<F, (Init, C), FnArgs>, Init>, L>>
where TaskFn<F, (Init, C), FnArgs>: Service<Task<(Init, C)>, Response = Output>,

Folds over a collection of items in the workflow.

Source§

impl<Start, L, Input, B: Backend> SteppedFlow<Start, Input, B, L>

Source

pub fn repeat_until<F, Output, FnArgs>( self, repeater: F, ) -> SteppedFlow<Start, Output, B, Stack<RepeatUntil<TaskFn<F, Input, FnArgs>, Input, Output>, L>>
where TaskFn<F, Input, FnArgs>: Service<Task<Input>, Response = Option<Output>>,

Folds over a collection of items in the workflow.

Source§

impl<Start, Backend> SteppedFlow<Start, Start, Backend>

Source

pub fn new(name: &str) -> Self

Source§

impl<Start, Cur, B, L> SteppedFlow<Start, Cur, B, L>

Source

pub fn add_step<S, Output>( self, step: S, ) -> SteppedFlow<Start, Output, B, Stack<S, L>>

Adds a new step to the workflow pipeline.

This method should be used with caution, as it allows adding arbitrary steps and manipulating types. It is recommended to use higher-level abstractions for common workflow patterns.

Source

pub fn finalize<S>(self, root: S) -> SteppedFlow<Start, Cur, B, L::Step>
where S: Step<Cur, B>, L: Layer<S>, B: Backend + WireFormatBackend,

Finalizes the workflow by attaching a root step.

Source§

impl<Start, Cur, B, L> SteppedFlow<Start, Cur, B, L>
where B: Backend,

Source

pub fn build<N>(self) -> L::Step
where L: Layer<RootStep<N>>,

Builds the workflow by layering the root step.

Trait Implementations§

Source§

impl<Start: Debug, Current: Debug, Backend: Debug, T: Debug> Debug for SteppedFlow<Start, Current, Backend, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Input, Output, Current, B, Compact, L, Err> IntoWorkerService<B, WorkflowService<B, Input, Output>> for SteppedFlow<Input, Current, B, L>
where B: Backend<Task = Task<Compact>, Error = Err> + WireFormatBackend<Compact = Compact> + BackendConfig<Args = Input> + Send + Sync + 'static + Sink<Task<Compact>, Error = Err> + Clone + Unpin, B::Id: Send + 'static + Default + GenerateId, L: Layer<RootStep<Current>>, L::Step: Step<Output, B>, B::Codec: Clone, Err: Error + Send + Sync + 'static, Compact: Send + 'static,

Source§

type Task = Task<Compact>

The task type processed by the worker.
Source§

type Backend = WorkflowBackend<B>

The backend type used by the worker service.
Source§

fn into_service( self, backend: B, ) -> WorkerService<Self::Backend, WorkflowService<B, Input, Output>>

Builds a worker service from the provided backend.

Auto Trait Implementations§

§

impl<Start, Current, Backend, T> Freeze for SteppedFlow<Start, Current, Backend, T>

§

impl<Start, Current, Backend, T> RefUnwindSafe for SteppedFlow<Start, Current, Backend, T>

§

impl<Start, Current, Backend, T> Send for SteppedFlow<Start, Current, Backend, T>

§

impl<Start, Current, Backend, T> Sync for SteppedFlow<Start, Current, Backend, T>

§

impl<Start, Current, Backend, T> Unpin for SteppedFlow<Start, Current, Backend, T>

§

impl<Start, Current, Backend, T> UnsafeUnpin for SteppedFlow<Start, Current, Backend, T>

§

impl<Start, Current, Backend, T> UnwindSafe for SteppedFlow<Start, Current, Backend, T>

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