Skip to main content

CompensableEffect

Trait CompensableEffect 

Source
pub trait CompensableEffect: EffectHandler {
    // Required method
    fn compensate(
        &self,
        ctx: &CompensationContext,
        input: &Self::Input,
        output: Option<&Self::Output>,
    ) -> impl Future<Output = Result<(), Self::Error>> + Send;
}
Expand description

A handler whose effect can be undone.

Register it with Handler::compensable; undo an effect with Runtime::compensate. The compensation must be idempotent: a crashed or ambiguous attempt is run again. Send CompensationContext::idempotency_key to the remote system.

Required Methods§

Source

fn compensate( &self, ctx: &CompensationContext, input: &Self::Input, output: Option<&Self::Output>, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Undoes the effect. output is what execute returned, if it was stored.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§