Flow Based Saga Executor
Flow-based saga executor that emits events as a reactive stream.
This executor wraps a standard SagaExecutor and provides Flow-based event streaming for reactive consumption of saga lifecycle events.
Usage Example
val executor = sagaExecutor<OrderContext, OrderResult> {
step("reserve") { context -> /* ... */}
step("charge") { context -> /* ... */}
}.asFlow()
// Collect events reactively
launch {
executor.events.collect { event ->
println("Event: $event")
}
}
// Execute saga
val result = executor.execute(context)Content copied to clipboard
Parameters
C
The type of context passed to saga steps
R
The type of result produced by saga steps
Properties
Functions
Link copied to clipboard
Add a monitor to observe saga events.
Link copied to clipboard
Extension function to convert a SagaExecutor to a FlowBasedSagaExecutor.
Link copied to clipboard
Execute the saga with the given context.
open suspend override fun execute(context: C, coroutineContext: CoroutineContext, timeout: Duration?): SagaResult<R>
Execute the saga with the given context, coroutine context, and optional timeout.
Link copied to clipboard
fun <C, R> SagaExecutor<C, R>.executeToFlow(context: C, coroutineContext: CoroutineContext = EmptyCoroutineContext, timeout: Duration? = null): Flow<SagaEvent>
Execute saga and return a Flow that emits all events followed by a terminal result event.
Link copied to clipboard
Remove a monitor.