BaseSagaStep

@MappedSuperclass
abstract class BaseSagaStep<T : BaseSagaStep<T>>(var id: Long? = null, var sagaId: String, var stepName: String, status: SagaStepStatus, var payload: String? = null, errorMessage: String? = null, var createdAt: Instant, completedAt: Instant? = null, compensationStepId: Long? = null, var version: Long? = null) : SagaStep<T> (source)

JPA-backed base implementation of the SagaStep port. See BaseSaga for the rationale behind the contract/adapter split — the engine sees an immutable port; this class mutates var fields internally and returns this so Hibernate can dirty-track the update.

Constructors

Link copied to clipboard
constructor(id: Long? = null, sagaId: String, stepName: String, status: SagaStepStatus, payload: String? = null, errorMessage: String? = null, createdAt: Instant, completedAt: Instant? = null, compensationStepId: Long? = null, version: Long? = null)

Properties

Link copied to clipboard
open override var compensationStepId: Long?

When this step compensates another, the id of the originally-completed step it reverts.

Link copied to clipboard
open override var completedAt: Instant?

Instant the step reached a terminal status; null while it is still in progress.

Link copied to clipboard
open override var createdAt: Instant

Instant the step row was created.

Link copied to clipboard
open override var errorMessage: String?

Latest failure reason if the step failed or its compensation failed; null otherwise.

Link copied to clipboard
open override var id: Long?

Storage-assigned surrogate id; null until the row is first persisted.

Link copied to clipboard
open override var payload: String?

Step-local payload as a JSON string; null when the step carries no data.

Link copied to clipboard
open override var sagaId: String

Owning saga's id (Saga.id).

Link copied to clipboard
open override var status: SagaStepStatus

Current lifecycle SagaStepStatus; see the enum's KDoc for terminal/transient semantics.

Link copied to clipboard
open override var stepName: String

Step name; conventionally a SagaTypeValue.value. Compensation rows are prefixed with Compensate.

Link copied to clipboard
open override var version: Long?

JPA optimistic-locking version, or null for storage backends that do not provide one.

Functions

Link copied to clipboard
open override fun linkToCompensationStep(compensationStepId: Long): T

Records the id of the compensating step that reverted this one.

Link copied to clipboard
open override fun markCompensated(): T
Link copied to clipboard
open override fun markCompensationFailed(error: String?): T

Transitions to SagaStepStatus.COMPENSATION_FAILED and stores error as errorMessage.

Link copied to clipboard
open override fun markCompleted(): T

Transitions to SagaStepStatus.COMPLETED and stamps completedAt.

Link copied to clipboard
open override fun markFailed(error: String): T

Transitions to SagaStepStatus.FAILED and stores error as errorMessage.