compensateWith

infix fun <C, R> SagaBuilder<C, R>.compensateWith(compensation: suspend (R) -> Unit): SagaBuilder<C, R>

Adds compensation to the last defined step using simple syntax (suspend function).

Example:

compensateWith { result -> cleanup(result) }

infix fun <C, R, S : Any> StatefulSagaBuilder<C, R, S>.compensateWith(compensation: suspend CompensationScope<R, S>.() -> Unit): StatefulSagaBuilder<C, R, S>

Adds compensation to the last defined step using simple syntax.

Example:

compensateWith {
if (state.escrowCaptured) refund(result.id) else cancel()
}