Skip to main content

compensatable_task

Attribute Macro compensatable_task 

Source
#[compensatable_task]
Expand description

Apply to the CompensatableTask trait definition, an impl CompensatableTask<S [, K]> for T block, or — for less boilerplate — an inherent impl T { ... } block.

Use as #[cano::saga::task].

Two surface forms on impl blocks:

  1. Trait-impl form: #[saga::task] impl CompensatableTask<S> for T { type Output = O; async fn run(..); async fn compensate(..); } — user writes the trait header.
  2. Inherent-impl form: #[saga::task(state = S [, key = K])] impl T { type Output = O; async fn run(..); async fn compensate(..); } — the macro builds the impl CompensatableTask<S [, K]> for T header from the attribute args and enforces that type Output, run, and compensate are present (config / name may be overridden).

Either way, every async fn is rewritten to return Pin<Box<dyn Future<Output = ...> + Send + 'async_trait>>. On the trait definition the macro just performs that rewrite.