Workflow

Struct Workflow 

Source
pub struct Workflow<Input, Current, FlowSink, Encode, Compact, Context, IdType> { /* private fields */ }

Implementations§

Source§

impl<Input, Current, FlowSink, Encode, Compact> Workflow<Input, Current, FlowSink, Encode, Compact, FlowSink::Context, FlowSink::IdType>
where Current: Send + 'static, FlowSink: Send + Clone + Sync + 'static + Unpin + WeakTaskSink<Current, Codec = Encode>,

Source

pub fn delay_for<CodecError, DbError>( self, duration: Duration, ) -> Workflow<Input, Current, FlowSink, Encode, Compact, FlowSink::Context, FlowSink::IdType>
where Current: Send + 'static + Sync, FlowSink::Context: Send + Sync + Default + 'static + MetadataExt<WorkflowRequest>, FlowSink: Sink<Task<Compact, FlowSink::Context, FlowSink::IdType>, Error = DbError> + Backend<Error = DbError>, DbError: Error + Send + Sync + 'static, FlowSink::IdType: Send + GenerateId, Compact: Sync + Send + 'static, Encode: Codec<Current, Compact = Compact, Error = CodecError> + Send + Sync + 'static + Codec<GoTo<Current>, Compact = Compact, Error = CodecError>, CodecError: Send + Sync + Error + 'static, <FlowSink::Context as MetadataExt<WorkflowRequest>>::Error: Error + Sync + Send + 'static,

Source§

impl<Input, Current, FlowSink, Encode, Compact> Workflow<Input, Vec<Current>, FlowSink, Encode, Compact, FlowSink::Context, FlowSink::IdType>
where Current: Send + 'static, FlowSink: Backend, FlowSink::Context: MetadataExt<FilterContext<FlowSink::IdType>> + Send + 'static,

Source

pub fn filter_map<F, Output, FnArgs, SvcError, MetadataError, CodecError, DbError>( self, predicate: F, ) -> Workflow<Input, Vec<Output>, FlowSink, Encode, Compact, FlowSink::Context, FlowSink::IdType>
where F: Send + 'static + Sync + Clone, TaskFn<F, Current, FlowSink::Context, FnArgs>: Service<Task<Current, FlowSink::Context, FlowSink::IdType>, Response = Option<Output>, Error = SvcError>, FnArgs: Send + 'static + Sync, Current: Send + 'static + Serialize + Sync + Debug, FlowSink::Context: Send + 'static + Sync + Default + MetadataExt<FilterContext<FlowSink::IdType>, Error = MetadataError> + MetadataExt<WorkflowRequest, Error = MetadataError> + MetadataExt<FilterState, Error = MetadataError>, <TaskFn<F, Current, FlowSink::Context, FnArgs> as Service<Task<Current, FlowSink::Context, FlowSink::IdType>>>::Future: Send + 'static, Output: Send + 'static + Sync, FlowSink: WeakTaskSink<Option<Output>, Codec = Encode, Error = DbError> + WeakTaskSink<Vec<Output>, Codec = Encode, Error = DbError> + Sink<Task<Compact, FlowSink::Context, FlowSink::IdType>, Error = DbError> + Sync + Clone + Send + 'static + WaitForCompletion<GoTo<Option<Output>>> + Unpin, DbError: Debug + Into<BoxDynError> + Send + Sync + Error + 'static, SvcError: Send + Sync + 'static + Into<BoxDynError>, FlowSink::IdType: Send + GenerateId + Sync + Display, Encode: Codec<Current, Compact = Compact, Error = CodecError> + Codec<GoTo<Option<Output>>, Compact = Compact, Error = CodecError> + Codec<Option<Output>, Compact = Compact, Error = CodecError> + Codec<Vec<Current>, Compact = Compact, Error = CodecError> + Codec<Vec<Output>, Compact = Compact, Error = CodecError> + Codec<GoTo<Vec<Output>>, Compact = Compact, Error = CodecError> + Send + Sync + 'static, Compact: Send + Sync + 'static, CodecError: Error + Sync + Send + 'static, MetadataError: Error + Sync + Send + 'static,

Adds a filter_map step to the workflow, allowing you to filter and map items in the workflow using a predicate function.

§Example
use apalis_workflow::WorkFlow;
// Suppose you have a workflow of integers and want to filter even numbers and double them.
let workflow = WorkFlow::new("the-even-doubler")
    .filter_map(|x: i32| async move { if x % 2 == 0 { Some(x * 2) } else { None } });
// The resulting workflow will only contain doubled even numbers.
§Returns

Returns a new WorkFlow with the filter_map step added, producing a vector of outputs.

§Errors

Errors from the predicate function or encoding/decoding are propagated as boxed dynamic errors.

§Notes
  • The predicate function must be Send, Sync, and 'static.
  • The workflow step is inserted at the end of the current steps.
  • This method is intended for advanced workflow composition scenarios.
Source§

impl<Input, Current, FlowSink, Encode, Compact> Workflow<Input, Current, FlowSink, Encode, Compact, FlowSink::Context, FlowSink::IdType>
where Current: Send + 'static, FlowSink: Send + Clone + Sync + 'static + Unpin + Backend,

Source

pub fn then<F, O, E, FnArgs, CodecError, DbError>( self, then: F, ) -> Workflow<Input, O, FlowSink, Encode, Compact, FlowSink::Context, FlowSink::IdType>
where O: Sync + Send + 'static, E: Into<BoxDynError> + Send + Sync + 'static, F: Send + 'static + Sync + Clone, TaskFn<F, Current, FlowSink::Context, FnArgs>: Service<Task<Current, FlowSink::Context, FlowSink::IdType>, Response = O, Error = E>, FnArgs: Send + 'static + Sync, Current: Send + 'static + Sync, FlowSink::Context: Send + Sync + Default + 'static + MetadataExt<WorkflowRequest>, DbError: Error + Send + Sync + 'static, <TaskFn<F, Current, FlowSink::Context, FnArgs> as Service<Task<Current, FlowSink::Context, FlowSink::IdType>>>::Future: Send + 'static, <TaskFn<F, Current, FlowSink::Context, FnArgs> as Service<Task<Current, FlowSink::Context, FlowSink::IdType>>>::Error: Into<BoxDynError>, FlowSink::IdType: Send + GenerateId, Compact: Sync + Send + 'static, Encode: Codec<Current, Compact = Compact, Error = CodecError> + Send + Sync + Codec<O, Compact = Compact, Error = CodecError> + 'static + Codec<GoTo<O>, Compact = Compact, Error = CodecError>, CodecError: Send + Sync + Error + 'static, <FlowSink::Context as MetadataExt<WorkflowRequest>>::Error: Error + Sync + Send + 'static, FlowSink: WeakTaskSink<O, Codec = Encode, Error = DbError> + Sink<Task<Compact, FlowSink::Context, FlowSink::IdType>, Error = DbError>,

Source§

impl<Input, FlowSink, Encode, Compact, Context, IdType> Workflow<Input, Input, FlowSink, Encode, Compact, Context, IdType>

Source

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

Source§

impl<Input, Current, FlowSink, Encode, Compact> Workflow<Input, Current, FlowSink, Encode, Compact, FlowSink::Context, FlowSink::IdType>
where Current: Send + 'static, FlowSink: Send + Clone + Sync + 'static + Unpin + Backend,

Source

pub fn add_step<S, Res, E, CodecError, BackendError>( self, step: S, ) -> Workflow<Input, Res, FlowSink, Encode, Compact, FlowSink::Context, FlowSink::IdType>
where FlowSink: WeakTaskSink<Res, Codec = Encode, Error = BackendError> + Sink<Task<Compact, FlowSink::Context, FlowSink::IdType>, Error = BackendError>, Current: Send + 'static + Sync, FlowSink::Context: Send + 'static + Sync + MetadataExt<WorkflowRequest>, S: Step<Current, FlowSink, Encode, Response = Res, Error = E> + Sync + Send + 'static + Clone, S::Response: Send, S::Error: Send, Res: 'static + Sync, FlowSink::IdType: Send, Encode: Codec<Current, Compact = Compact, Error = CodecError> + Codec<GoTo<Res>, Compact = Compact, Error = CodecError> + Codec<Res, Compact = Compact, Error = CodecError> + Send + Sync + 'static, Compact: Send + Sync + 'static, E: Into<BoxDynError> + Send + Sync + 'static, CodecError: Error + Send + 'static + Sync, BackendError: Error + Send + Sync + 'static,

Auto Trait Implementations§

§

impl<Input, Current, FlowSink, Encode, Compact, Context, IdType> Freeze for Workflow<Input, Current, FlowSink, Encode, Compact, Context, IdType>

§

impl<Input, Current, FlowSink, Encode, Compact, Context, IdType> !RefUnwindSafe for Workflow<Input, Current, FlowSink, Encode, Compact, Context, IdType>

§

impl<Input, Current, FlowSink, Encode, Compact, Context, IdType> Send for Workflow<Input, Current, FlowSink, Encode, Compact, Context, IdType>
where Input: Send, Current: Send, FlowSink: Send, Encode: Send,

§

impl<Input, Current, FlowSink, Encode, Compact, Context, IdType> Sync for Workflow<Input, Current, FlowSink, Encode, Compact, Context, IdType>
where Input: Sync, Current: Sync, FlowSink: Sync, Encode: Sync,

§

impl<Input, Current, FlowSink, Encode, Compact, Context, IdType> Unpin for Workflow<Input, Current, FlowSink, Encode, Compact, Context, IdType>
where Input: Unpin, Current: Unpin, FlowSink: Unpin, Encode: Unpin,

§

impl<Input, Current, FlowSink, Encode, Compact, Context, IdType> !UnwindSafe for Workflow<Input, Current, FlowSink, Encode, Compact, Context, IdType>

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, Args, Ctx, Svc, B, M> IntoWorkerServiceExt<Args, Ctx, Svc, B, M> for T
where T: IntoWorkerService<B, Svc, Args, Ctx>, B: Backend<Args = Args, Context = Ctx>, Svc: Service<Task<Args, Ctx, <B as Backend>::IdType>>,

Source§

fn build_with( self, builder: WorkerBuilder<Args, Ctx, B, M>, ) -> Worker<Args, Ctx, B, Svc, M>

Consumes the builder and returns a worker
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