pub struct ParallelTasks { /* private fields */ }Expand description
Task that executes multiple tasks in parallel using JoinSet.
Tasks are spawned concurrently and all must succeed for the parallel task to succeed. Uses fail-fast behavior on first error.
Implementations§
Source§impl ParallelTasks
impl ParallelTasks
Sourcepub fn new(tasks: Vec<Box<dyn WorkflowTask>>) -> Self
pub fn new(tasks: Vec<Box<dyn WorkflowTask>>) -> Self
Creates a new parallel tasks wrapper.
§Arguments
tasks- Vector of tasks to execute
§Example
ⓘ
let task1 = Box::new(FunctionTask::new(
TaskId::new("task1"),
"Task 1".to_string(),
|_ctx| async { Ok(TaskResult::Success) }
));
let task2 = Box::new(FunctionTask::new(
TaskId::new("task2"),
"Task 2".to_string(),
|_ctx| async { Ok(TaskResult::Success) }
));
let parallel = ParallelTasks::new(vec![task1, task2]);Trait Implementations§
Source§impl WorkflowTask for ParallelTasks
impl WorkflowTask for ParallelTasks
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
context: &'life1 TaskContext,
) -> Pin<Box<dyn Future<Output = Result<TaskResult, TaskError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
context: &'life1 TaskContext,
) -> Pin<Box<dyn Future<Output = Result<TaskResult, TaskError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes the task with the provided context. Read more
Source§fn compensation(&self) -> Option<CompensationAction>
fn compensation(&self) -> Option<CompensationAction>
Returns the compensation action for this task (if any). Read more
Auto Trait Implementations§
impl Freeze for ParallelTasks
impl !RefUnwindSafe for ParallelTasks
impl Send for ParallelTasks
impl Sync for ParallelTasks
impl Unpin for ParallelTasks
impl UnsafeUnpin for ParallelTasks
impl !UnwindSafe for ParallelTasks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more