Terminal Encoder
User-supplied encoder that produces a journal Terminal entry payload P for a given TerminalOutcome.
Called by ca.acendas.kstate.saga.StatefulSagaExecutor.resume when it needs to append a synthetic Terminal entry to the journal — specifically, when it detects an ca.acendas.kstate.saga.journal.EntryPhase.Intent entry without an effect-key and must record TerminalOutcome.Indeterminate before returning ResumeOutcome.Indeterminate.
Contract
Pure — must not perform I/O or mutate external state.
Deterministic — the same outcome must always produce the same payload P.
Inverse of TerminalDecoder —
decoder.decode(encoder.encode(outcome))must return a pair whose second element equals outcome.
Example
// P = MyPayload, R = String
val encoder = TerminalEncoder<MyPayload> { outcome ->
MyPayload.Terminal(result = "", terminalOutcome = outcome)
}Parameters
The journal payload type.
Functions
Encodes outcome into a journal payload P suitable for a Terminal ca.acendas.kstate.saga.journal.JournalEntry.