pub async fn run_saga<Fut>(
name: &'static str,
fut: Fut,
) -> Result<Value, String>Expand description
Run a saga’s inner future under a 5 s timeout. The inner future
is responsible for emitting SagaStarted (the saga itself, since
it owns the saga_id allocation) and any compensation it needs;
run_saga only enforces the timeout and emits the terminal
SagaCompleted / SagaFailed.
Concrete usage (per saga):
ⓘ
pub async fn run(state: &AppState, ...) -> Result<Value, String> {
let saga_id = alloc_saga_id(state);
emit_saga_started(state, saga_id, "tear_off_tab", serde_json::json!({})).await;
let ctx = SagaCtx::new(state, saga_id);
let result = run_saga(run_inner(ctx, ...)).await;
emit_terminal(state, saga_id, classify_run_saga_result(&result)).await;
result
}