execute

abstract suspend fun execute(context: C): StatefulSagaResult<R, S>

Execute the saga with the given context.

Creates a fresh copy of the initial state for this execution. Executes all saga steps sequentially with shared state access. If any step fails, previously completed steps are compensated in reverse order (LIFO), with access to the current state.

Return

StatefulSagaResult indicating success, abort, or compensation failure

Parameters

context

The context to pass to saga steps


abstract suspend fun execute(context: C, coroutineContext: CoroutineContext = EmptyCoroutineContext, timeout: Duration? = null): StatefulSagaResult<R, S>

Execute the saga with the given context, coroutine context, and optional timeout.

Creates a fresh copy of the initial state for this execution. Executes all saga steps sequentially with the provided coroutine context.

Return

StatefulSagaResult indicating success, abort, or compensation failure

Parameters

context

The context to pass to saga steps

coroutineContext

Additional context to use for execution

timeout

Overall saga timeout (null = no timeout)