saga

inline fun <A> saga(noinline block: suspend SagaScope.() -> A): Saga<A>(source)

The Saga builder which exposes the SagaScope.bind. The saga builder uses the suspension system to run actions, and automatically register their compensating actions.

When the resulting Saga fails it will run all the required compensating actions, also when the Saga gets cancelled it will respect its compensating actions before returning.

By doing so we can guarantee that any transactional like operations made by the Saga will guarantee that it results in the correct state.


fun <A> saga(action: suspend SagaActionStep.() -> A, compensation: suspend (A) -> Unit): Saga<A>(source)

Create a lazy Saga that will only run when the Saga is invoked.