Package io.github.nomisrev

Types

Saga
Link copied to clipboard
class Saga<A>(action: suspend SagaEffect.() -> A, compensation: suspend (A) -> Unit)

The saga design pattern is a way to manage data consistency across microservices in distributed transaction scenarios. A Saga is useful when you need to manage data in a consistent manner across services in distributed transaction scenarios. Or when you need to compose multiple actions with a compensation that needs to run in a transaction like style.

SagaEffect
Link copied to clipboard
interface SagaEffect

Receiver DSL of the saga { } builder.

Functions

mapSaga
Link copied to clipboard
fun <A, B> Iterable<A>.mapSaga(transform: (A) -> Saga<B>): Saga<List<B>>

Traverses the Iterable and composes all Saga returned by the applies transform function.

saga
Link copied to clipboard
fun <A> saga(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.

sequence
Link copied to clipboard
fun <A> Iterable<Saga<A>>.sequence(): Saga<List<A>>

Alias for traverseSage { it }. Handy when you need to process List<Saga<A>> that might be coming from another layer.

traverse
Link copied to clipboard
fun <A, B> Iterable<A>.traverse(transform: (A) -> Saga<B>): Saga<List<B>>