compensate With
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) }Content copied to clipboard
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()
}Content copied to clipboard