Full

class Full<A>(action: suspend SagaEffect.() -> A, compensation: suspend (A) -> Unit) : Saga<A>

Full for a Saga that defines both action and Full.compensation.

Constructors

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

Functions

compensate
Link copied to clipboard
open infix fun compensate(compensate: suspend (A) -> Unit): Saga<A>

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.

parZip
Link copied to clipboard
open fun <B, C> parZip(other: Saga<B>, transform: suspend CoroutineScope.(A, B) -> C): Saga<C>
open fun <B, C, D> parZip(ctx: CoroutineContext, b: Saga<B>, c: Saga<C>, f: suspend CoroutineScope.(A, B, C) -> D): Saga<D>
open fun <B, C, D, E> parZip(ctx: CoroutineContext, b: Saga<B>, c: Saga<C>, d: Saga<D>, f: suspend CoroutineScope.(A, B, C, D) -> E): Saga<E>
open fun <B, C, D, E, F> parZip(ctx: CoroutineContext, b: Saga<B>, c: Saga<C>, d: Saga<D>, e: Saga<E>, f: suspend CoroutineScope.(A, B, C, D, E) -> F): Saga<F>
open fun <B, C, D, E, F, G> parZip(ctx: CoroutineContext, b: Saga<B>, c: Saga<C>, d: Saga<D>, e: Saga<E>, ff: Saga<F>, f: suspend CoroutineScope.(A, B, C, D, E, F) -> G): Saga<G>
open fun <B, C, D, E, F, G, H> parZip(ctx: CoroutineContext, b: Saga<B>, c: Saga<C>, d: Saga<D>, e: Saga<E>, ff: Saga<F>, g: Saga<G>, f: suspend CoroutineScope.(A, B, C, D, E, F, G) -> H): Saga<H>
open fun <B, C, D, E, F, G, H, I> parZip(ctx: CoroutineContext, b: Saga<B>, c: Saga<C>, d: Saga<D>, e: Saga<E>, ff: Saga<F>, g: Saga<G>, h: Saga<H>, f: suspend CoroutineScope.(A, B, C, D, E, F, G, H) -> I): Saga<I>

open fun <B, C> parZip(ctx: CoroutineContext, other: Saga<B>, transform: suspend CoroutineScope.(A, B) -> C): Saga<C>

Runs multiple Sagas in parallel and combines the result with the transform function. When one of the two Saga fails then it will cancel the other, if the other Saga already finished then its compensating action will be run.

transact
Link copied to clipboard
open suspend fun transact(): A

Transact runs the Saga turning it into a suspend effect that results in A. If the saga fails then all compensating actions are guaranteed to run. When a compensating action failed it will be ignored, and the other compensating actions will continue to be run.

Properties

action
Link copied to clipboard
val action: suspend SagaEffect.() -> A
compensation
Link copied to clipboard
val compensation: suspend (A) -> Unit

Sources

common source
Link copied to clipboard