RequestSeal.Replay.Postgres (RequestSeal v0.2.0)

Copy Markdown View Source

Optional Postgrex atomic replay adapter. The caller owns connections and DDL.

Prefer RequestSeal.Replay.AshOnetime for durable replay with ash_onetime's retention guards and externally managed cleanup. This Postgrex-only adapter remains available for callers selecting its explicit table contract.

The optional dependency has runtime: false; callers explicitly start the Postgrex application and their connection/pool. store/2 takes that existing connection/pool and an explicit table name. ddl/1 returns SQL for a bytea namespace/key primary key and bigint retention end; the caller executes it. Names contain only lowercase ASCII letters, digits, and underscores, begin with a letter, and occupy 1..63 bytes. Queries propagate the remaining operation deadline. Errors expose no SQL, connection, namespace, key, or backend exception. Conflicts never update retention and claims never evict. Required claims fail closed on outages.

sweep/3 accepts explicit Unix seconds. For production, the caller obtains this value from its trusted store clock and reconciles it with verification clocks; injected historical verification clocks require matching sweep times. Sweep deletes only entries whose exclusive retention end is at or before now. Multi-node operators sweep at now - max_internode_skew to preserve claims while any verifier still accepts the authenticated input. One namespace should use one freshness bound because duplicates never extend retention. PostgreSQL persistence follows the caller's database/storage configuration; this adapter does not start a database, pool, timer, or supervisor.

Summary

Functions

SQL the caller executes to create the replay table.

Reference an existing caller connection and explicit replay table.

Functions

ddl(name)

@spec ddl(binary()) :: binary() | {:error, RequestSeal.Replay.Error.t()}

SQL the caller executes to create the replay table.

store(conn, arg2)

@spec store(term(), keyword()) ::
  RequestSeal.Replay.Store.t() | {:error, RequestSeal.Replay.Error.t()}

Reference an existing caller connection and explicit replay table.