Saga Result
Result of saga execution.
This sealed interface provides type-safe handling of saga execution outcomes, ensuring that all possible results are explicitly handled by the caller.
Result Types
Completed - Saga completed successfully with a result value
Aborted - Saga aborted due to step failure, all compensations succeeded
CompensationFailure - Saga aborted and compensation failed (critical failure)
Usage Example
val result = saga.execute(context)
when (result) {
is SagaResult.Completed -> {
// All steps succeeded
processResult(result.value)
}
is SagaResult.Aborted -> {
// A step failed but all compensations succeeded
logError(result.error)
notifyUser("Transaction cancelled")
}
is SagaResult.CompensationFailure -> {
// Critical failure - manual intervention may be required
alertOps(result.originalError, result.compensationErrors)
}
}Content copied to clipboard
Parameters
R
The result type on successful completion
Inheritors
Types
Link copied to clipboard
Saga aborted due to step failure.
Link copied to clipboard
data class CompensationFailure(val originalError: SagaExecutionError, val compensationErrors: List<SagaExecutionError>) : SagaResult<Nothing>
Saga aborted and compensation failed.