compensate
Add a compensating action to a Saga. A single Saga can have many compensating actions, they will be composed in a FILO order. This makes sure they're executed in reverse order as the actions.
saga {
saga { println("A") }.compensate { println("A - 1") }
.compensate { println("A - 2") }
.bind
throw RuntimeException("Boom!")
}.transact()
// A - 2
// A - 1
// RuntimeException("Boom!")
Content copied to clipboard