In Memory Saga Journal
Reference implementation of SagaJournal backed by a ConcurrentHashMap with per-RunId locking.
Thread-safety model
Different RunIds may append concurrently without contention — each run has its own Mutex. Within a single RunId, appends are serialized by the per-run lock. Lock creation uses ConcurrentHashMap.computeIfAbsent, which is itself thread-safe.
Codec placement (D3)
This implementation stores payload P directly. PayloadCodec is never called here. Persistent adapters (Room, JDBC, file) accept a PayloadCodec in their own constructor and convert at persistence boundaries. This keeps in-memory usage fast and free of serialization concerns.
Usage
val journal = InMemorySagaJournal<OrderEvent>()
// Plug into a saga executor (T006 wires this):
val saga = sagaExecutor(journal = journal, runId = RunId("order-42")) { ... }Parameters
Payload type stored verbatim without encoding.
Functions
Appends entry to this run's in-memory list.
Returns all entries for runId as an immutable snapshot.
Returns up to limit entries whose JournalEntry.seq>= seq, in ascending seq order.
Verifies the tamper-evident hash chain for runId over entries with seq in [fromSeq, toSeq].