saga

fun <T> saga(clock: Clock = Clock.System, configure: SagaBuilder<T>.() -> Unit): Saga<T>(source)

DSL function for creating a saga.

Example:

val saga = saga<OrderResult> {
step(
name = "Reserve inventory",
action = { inventoryService.reserve(items) },
compensation = { result -> inventoryService.release(result) }
)

step(
name = "Process payment",
action = { paymentService.charge(amount) },
compensation = { result -> paymentService.refund(result) }
)
}