pub struct RollbackEngine { /* private fields */ }Expand description
Rollback engine for workflow failure recovery.
The rollback engine implements the Saga compensation pattern using DAG backward traversal to selectively roll back dependent tasks.
Implementations§
Source§impl RollbackEngine
impl RollbackEngine
Sourcepub fn find_rollback_set(
&self,
workflow: &Workflow,
failed_task: &TaskId,
strategy: RollbackStrategy,
) -> Result<Vec<TaskId>, RollbackError>
pub fn find_rollback_set( &self, workflow: &Workflow, failed_task: &TaskId, strategy: RollbackStrategy, ) -> Result<Vec<TaskId>, RollbackError>
Finds the set of tasks to roll back based on failure and strategy.
Uses reverse graph traversal starting from the failed task to find all dependent tasks. The rollback order is reverse execution order.
§Arguments
workflow- The workflow to analyzefailed_task- The task that failed (rollback origin)strategy- Rollback strategy to apply
§Returns
Ok(Vec<TaskId>)- Tasks in rollback order (reverse execution)Err(RollbackError)- If traversal fails
§Example
ⓘ
let engine = RollbackEngine::new();
let rollback_set = engine.find_rollback_set(
&workflow,
&TaskId::new("task_d"),
RollbackStrategy::AllDependent
)?;Sourcepub async fn execute_rollback(
&self,
workflow: &Workflow,
tasks: Vec<TaskId>,
workflow_id: &str,
audit_log: &mut AuditLog,
compensation_registry: &CompensationRegistry,
) -> Result<RollbackReport, RollbackError>
pub async fn execute_rollback( &self, workflow: &Workflow, tasks: Vec<TaskId>, workflow_id: &str, audit_log: &mut AuditLog, compensation_registry: &CompensationRegistry, ) -> Result<RollbackReport, RollbackError>
Executes rollback for a set of tasks.
Executes compensation actions for each task in rollback order. Tasks without compensation are skipped. Failed compensations are logged.
§Arguments
workflow- The workflow being rolled backtasks- Tasks to roll back (in rollback order)workflow_id- Workflow ID for audit loggingaudit_log- Audit log for recording rollback eventscompensation_registry- Registry containing compensation actions
§Returns
Ok(RollbackReport)- Report of rollback executionErr(RollbackError)- If critical failure occurs
Sourcepub fn validate_compensation_coverage(
&self,
workflow: &Workflow,
) -> CompensationReport
pub fn validate_compensation_coverage( &self, workflow: &Workflow, ) -> CompensationReport
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RollbackEngine
impl RefUnwindSafe for RollbackEngine
impl Send for RollbackEngine
impl Sync for RollbackEngine
impl Unpin for RollbackEngine
impl UnsafeUnpin for RollbackEngine
impl UnwindSafe for RollbackEngine
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