Step Outcome
Represents the outcome of a saga step execution.
This sealed interface provides type-safe, explicit control flow for saga steps, replacing exception-based cancellation with clean architecture principles.
Outcome Types
Completed - Step completed successfully with a result value
Failed - Step failed, triggering compensation for completed steps
Skipped - Step skipped, returning last successful result without compensation
Usage Example
enum class OrderSteps { VALIDATE, PAYMENT, SHIP }
enum class FailureReason { INVALID_ORDER, PAYMENT_DECLINED }
enum class SkipReason { ALREADY_PROCESSED }
first call OrderSteps.VALIDATE with { ctx ->
if (!ctx.valid) fails with FailureReason.INVALID_ORDER
if (ctx.alreadyProcessed) skip with SkipReason.ALREADY_PROCESSED
val order = validateOrder(ctx)
completes with order
}Content copied to clipboard
Parameters
R
The result type on successful completion