Interface DedupeLedger
- All Known Implementing Classes:
SessionDedupeLedger
The ledger instance is the synchronization monitor for all callers sharing its
state. Hold synchronized (ledger) around reads and mutations and across
each mutation-and-persist sequence: firstSeen/persistNow for ack-first commands,
or recordReceipt/persistNow for completed-link results. Implementations must support
calls while this monitor is held and must not acquire it in reverse order from
their storage locks. Individual thread-safe methods alone do not make a sequence atomic.
Release the monitor before sending frames or invoking handlers. AckFirstGate persists ids only; player-link handlers own result receipts and must persist them before sending a completion result. Storage failure handling belongs to the caller: AckFirstGate explicitly continues with in-memory deduplication after IOException.
- Since:
- 6.3.1
-
Method Summary
Modifier and TypeMethodDescriptionbooleanRecords a previously unseen id in memory, subject to retention bounds.voidSynchronously persists the current ids and receipts while the caller holds the ledger monitor.com.google.gson.JsonObjectreceiptFor(String id) Looks up a completion result for replay, without invoking its handler again.voidrecordReceipt(String id, com.google.gson.JsonObject receipt) Records a completion result in memory; call persistNow in the same synchronized block.
-
Method Details
-
firstSeen
Records a previously unseen id in memory, subject to retention bounds.- Parameters:
id- the request envelope ULID- Returns:
- true for a newly recorded id, false for an unexpired duplicate
-
persistNow
Synchronously persists the current ids and receipts while the caller holds the ledger monitor.- Throws:
IOException- if the updated state could not be persisted
-
receiptFor
Looks up a completion result for replay, without invoking its handler again.- Parameters:
id- the completed-message envelope ULID- Returns:
- the recorded result payload, or null when absent; callers must not mutate it
-
recordReceipt
Records a completion result in memory; call persistNow in the same synchronized block.- Parameters:
id- the completed-message envelope ULIDreceipt- the result payload; callers must not mutate it after recording
-