ResumeOutcome

sealed interface ResumeOutcome<out R, out S>

Outcome of a ca.acendas.kstate.saga.StatefulSagaExecutor.resume call.

Case summary

CaseMeaning
ResumedRun was found in the journal and its terminal state was decoded.
IndeterminateJournal is intact but the last Intent has no effect-key; cannot determine whether the side effect fired.
NotFoundNo entries exist for this RunId.
CorruptJournalJournal integrity is broken (seq gap, codec failure, reducer threw, etc.).

Usage

when (val outcome = executor.resume(runId, ctx, journal)) {
is ResumeOutcome.Resumed -> process(outcome.result, outcome.state)
is ResumeOutcome.Indeterminate -> alert("ambiguous state at ${outcome.lastPhase}")
is ResumeOutcome.NotFound -> startFresh()
is ResumeOutcome.CorruptJournal -> quarantine(outcome.runId, outcome.reason)
}

Parameters

R

The result type produced by the saga.

S

The saga state type.

Inheritors

Types

Link copied to clipboard
data class CorruptJournal(val runId: RunId, val atSeq: Long, val reason: String) : ResumeOutcome<Nothing, Nothing>

Journal integrity is broken and the run cannot be safely resumed.

Link copied to clipboard
data class Indeterminate<S>(val lastPhase: EntryPhase, val atStep: TypedValue?, val state: S, val reason: String) : ResumeOutcome<Nothing, S>

The journal is intact up to this point but continuation is ambiguous.

Link copied to clipboard
data class NotFound(val runId: RunId) : ResumeOutcome<Nothing, Nothing>

No entries exist for this RunId in the journal.

Link copied to clipboard
data class Resumed<R, S>(val result: R, val state: S, val terminal: TerminalOutcome) : ResumeOutcome<R, S>

The run was found and its outcome decoded.