Trait golem_rust::Operation

source ·
pub trait Operation: Clone {
    type In: Clone;
    type Out: Clone;
    type Err: Clone;

    // Required methods
    fn execute(&self, input: Self::In) -> Result<Self::Out, Self::Err>;
    fn compensate(
        &self,
        input: Self::In,
        result: Self::Out,
    ) -> Result<(), Self::Err>;
}
Expand description

Represents an atomic operation of the transaction which has a rollback action.

Implement this trait and use it within a transaction block. Operations can also be constructed from closures using operation.

Required Associated Types§

Required Methods§

source

fn execute(&self, input: Self::In) -> Result<Self::Out, Self::Err>

Executes the operation which may fail with a domain error

source

fn compensate( &self, input: Self::In, result: Self::Out, ) -> Result<(), Self::Err>

Executes a compensation action for the operation.

Object Safety§

This trait is not object safe.

Implementors§