Saga Step
Persistence-agnostic contract for a single step of a saga.
Implementations can be backed by any storage technology (JPA, MongoDB, DynamoDB, in-memory, …). The engine and adapters only depend on this interface, never on a concrete entity class.
All fields are exposed as read-only (val). State transitions are performed exclusively through behavior methods that encapsulate the aggregate's invariants. See Saga for the rationale behind this design.
Inheritors
Properties
When this step compensates another, the id of the originally-completed step it reverts.
Instant the step reached a terminal status; null while it is still in progress.
Latest failure reason if the step failed or its compensation failed; null otherwise.
Current lifecycle SagaStepStatus; see the enum's KDoc for terminal/transient semantics.
Step name; conventionally a SagaTypeValue.value. Compensation rows are prefixed with Compensate.
Functions
Records the id of the compensating step that reverted this one.
Transitions to SagaStepStatus.COMPENSATED.
Transitions to SagaStepStatus.COMPENSATION_FAILED and stores error as errorMessage.
Transitions to SagaStepStatus.COMPLETED and stamps completedAt.
Transitions to SagaStepStatus.FAILED and stores error as errorMessage.