pub trait WorkflowTask: Send + Sync {
// Required methods
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 id(&self) -> TaskId;
fn name(&self) -> &str;
// Provided methods
fn dependencies(&self) -> Vec<TaskId> { ... }
fn compensation(&self) -> Option<CompensationAction> { ... }
}Expand description
Trait for workflow task execution.
All workflow tasks must implement this trait to enable execution by the WorkflowExecutor. Tasks are executed asynchronously in topological order based on their dependencies.
Required Methods§
Sourcefn 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,
Provided Methods§
Sourcefn dependencies(&self) -> Vec<TaskId>
fn dependencies(&self) -> Vec<TaskId>
Returns the list of task dependencies.
Default implementation returns an empty vector (no dependencies).
Sourcefn compensation(&self) -> Option<CompensationAction>
fn compensation(&self) -> Option<CompensationAction>
Returns the compensation action for this task (if any).
Compensation actions are used during workflow rollback to undo task side effects using the Saga pattern. Tasks that don’t have side effects (e.g., read-only queries) should return None.
Default implementation returns None (no compensation).
§Returns
Some(CompensationAction)- Task can be compensatedNone- Task has no compensation (will be skipped during rollback)