Saga Compensation
Saga Compensation
A saga executes steps in order. If a step fails, the system runs compensating actions for all previous successful steps in reverse order.
Given the ordered steps with their success status, return the names of steps that must be compensated, in the order they should run.
If all steps succeed, return nil.
Types
type Step struct {
Name string
Success bool
}
Function signature
func SagaCompensations(steps []Step) []string
Example
steps = [A:true, B:true, C:false, D:false]
output = ["B", "A"]
Notes
- Only the first failure triggers compensation.
Run tests to see results
No issues detected