use crate::context::SagaContext;
use crate::outcome::{CancelResult, CompensationResult, SagaResult};
pub trait SagaStep: Send + Sync {
type Command: Send;
type Success: Send;
type Compensation: Send;
fn execute(
&self,
context: &SagaContext,
command: Self::Command,
) -> impl std::future::Future<Output = SagaResult<Self::Success>> + Send;
fn compensate(
&self,
context: &SagaContext,
command: Self::Compensation,
) -> impl std::future::Future<Output = CompensationResult> + Send;
}
pub trait SagaCancelStep: Send + Sync {
type Command: Send;
fn cancel(
&self,
context: &SagaContext,
command: Self::Command,
) -> impl std::future::Future<Output = CancelResult> + Send;
}
pub trait SagaResolveStep: Send + Sync {
type Command: Send;
type Success: Send;
fn resolve(
&self,
context: &SagaContext,
command: Self::Command,
) -> impl std::future::Future<Output = SagaResult<Self::Success>> + Send;
}