pub struct Saga<Input, Output, Ctx, Err> { /* private fields */ }Expand description
A compiled saga ready for execution.
Sagas execute a sequence of steps, where each step’s output becomes the next step’s input. If any step fails, previously completed steps are compensated in reverse order (LIFO).
Implementations§
Source§impl<Input, Output, Ctx, Err> Saga<Input, Output, Ctx, Err>
impl<Input, Output, Ctx, Err> Saga<Input, Output, Ctx, Err>
Sourcepub fn execute(&self, ctx: &Ctx, input: Input) -> Result<Output, SagaError<Err>>
pub fn execute(&self, ctx: &Ctx, input: Input) -> Result<Output, SagaError<Err>>
Execute the saga, returning the final output on success.
On failure, compensates all previously completed steps in reverse order.
§Errors
Returns SagaError::StepFailed if a step fails and all compensations succeed.
Returns SagaError::CompensationFailed if a step fails and some compensations also fail.
Sourcepub fn execute_with_audit(
&self,
ctx: &Ctx,
input: Input,
) -> (Result<Output, SagaError<Err>>, SagaAuditLog)
pub fn execute_with_audit( &self, ctx: &Ctx, input: Input, ) -> (Result<Output, SagaError<Err>>, SagaAuditLog)
Execute the saga and return both the result and an audit log.
The audit log tracks all step executions and compensations.
Auto Trait Implementations§
impl<Input, Output, Ctx, Err> Freeze for Saga<Input, Output, Ctx, Err>
impl<Input, Output, Ctx, Err> !RefUnwindSafe for Saga<Input, Output, Ctx, Err>
impl<Input, Output, Ctx, Err> !Send for Saga<Input, Output, Ctx, Err>
impl<Input, Output, Ctx, Err> !Sync for Saga<Input, Output, Ctx, Err>
impl<Input, Output, Ctx, Err> Unpin for Saga<Input, Output, Ctx, Err>
impl<Input, Output, Ctx, Err> UnsafeUnpin for Saga<Input, Output, Ctx, Err>
impl<Input, Output, Ctx, Err> !UnwindSafe for Saga<Input, Output, Ctx, Err>
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