SagaBuilder

class SagaBuilder<T>(clock: Clock = Clock.System)(source)

Builder for constructing a saga with multiple steps.

Constructors

Link copied to clipboard
constructor(clock: Clock = Clock.System)

Functions

Link copied to clipboard
fun build(): Saga<T>

Builds the saga.

Link copied to clipboard
fun configure(configure: SagaConfig.() -> SagaConfig): SagaBuilder<T>

Configures saga behavior.

Link copied to clipboard
fun <R> step(name: String, action: suspend () -> R, compensation: suspend (R) -> Unit? = null): SagaBuilder<T>

Adds a step to the saga.

Link copied to clipboard
fun <R> stepWithRetry(name: String, retries: Long = 3, action: suspend () -> R, compensation: suspend (R) -> Unit? = null): SagaBuilder<T>

Adds a step with retry capability.

Link copied to clipboard
fun <R> stepWithTimeout(name: String, timeout: Duration, action: suspend () -> R, compensation: suspend (R) -> Unit? = null): SagaBuilder<T>

Adds a step with timeout.