step
fun step(step: TypedValue, timeout: Duration? = null, forward: suspend StatefulStepScope<R, S>.(C) -> StepOutcome<R>): StatefulSagaBuilder<C, R, S>
Define a saga step with forward logic using explicit outcome control.
This method finalizes the previous step (if any) and starts configuring a new step. The forward action receives the saga context and has access to the shared state via StatefulStepScope.
The forward action must return a StepOutcome:
completes with result- Step completed successfullyfails with reason- Step failed, trigger compensationskip with reason- Skip remaining steps without compensation
Return
This builder for method chaining
Parameters
step
Step identifier wrapped in TypedValue (can be enum or string)
timeout
Maximum execution time for this step (null = no timeout)
forward
Suspend function that executes the step's forward logic
fun step(name: String, timeout: Duration? = null, forward: suspend StatefulStepScope<R, S>.(C) -> StepOutcome<R>): StatefulSagaBuilder<C, R, S>
Define a saga step with string name (convenience overload).