Interface DedupeLedger

All Known Implementing Classes:
SessionDedupeLedger

interface DedupeLedger
Shared command-id and player-link receipt ledger; internal, not for module use.

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 Type
    Method
    Description
    boolean
    Records a previously unseen id in memory, subject to retention bounds.
    void
    Synchronously persists the current ids and receipts while the caller holds the ledger monitor.
    com.google.gson.JsonObject
    Looks up a completion result for replay, without invoking its handler again.
    void
    recordReceipt(String id, com.google.gson.JsonObject receipt)
    Records a completion result in memory; call persistNow in the same synchronized block.
  • Method Details

    • firstSeen

      boolean firstSeen(String id)
      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

      void persistNow() throws IOException
      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

      com.google.gson.JsonObject receiptFor(String id)
      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

      void recordReceipt(String id, com.google.gson.JsonObject receipt)
      Records a completion result in memory; call persistNow in the same synchronized block.
      Parameters:
      id - the completed-message envelope ULID
      receipt - the result payload; callers must not mutate it after recording