saga

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

The Saga builder which exposes the SagaEffect.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>

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

Sources

Link copied to clipboard
Link copied to clipboard