Pass a connection pool (or any PgQueryable) and optionally a custom
table name. Run getIdempotencyMigration() once per deployment to
create the table.
Multi-agent namespace. The official serve() path automatically adds
its canonical host to the idempotency principal before this backend sees a
key. Low-level integrations that bypass serve() and can receive the same
principal/key on multiple logical agents MUST use distinct tableName
values (or separate schemas/databases). Construct one store per logical
agent and pass the matching store to that agent's server factory:
Reusing one table without an equivalent trusted host discriminator can
replay one agent's cached response on another when their server-controlled
principal and buyer key collide.
Startup probe. Call store.probe() (or probeIdempotencyStore(store))
before your server starts accepting traffic to catch a bad DATABASE_URL
at boot rather than on the first mutating request. Wire it via:
Idle-client errors.pg.Pool re-emits network drop / PG restart
errors on the pool itself. Without a listener, Node's EventEmitter
default-throws and crashes the process. Add one in your bootstrap:
pool.on('error', (err) =>console.error('pg pool error', err));
Create a Postgres-backed idempotency cache.
Pass a connection pool (or any
PgQueryable) and optionally a custom table name. RungetIdempotencyMigration()once per deployment to create the table.Multi-agent namespace. The official
serve()path automatically adds its canonical host to the idempotency principal before this backend sees a key. Low-level integrations that bypassserve()and can receive the same principal/key on multiple logical agents MUST use distincttableNamevalues (or separate schemas/databases). Construct one store per logical agent and pass the matching store to that agent's server factory:Reusing one table without an equivalent trusted host discriminator can replay one agent's cached response on another when their server-controlled principal and buyer key collide.
Startup probe. Call
store.probe()(orprobeIdempotencyStore(store)) before your server starts accepting traffic to catch a badDATABASE_URLat boot rather than on the first mutating request. Wire it via:Idle-client errors.
pg.Poolre-emits network drop / PG restart errors on the pool itself. Without a listener, Node'sEventEmitterdefault-throws and crashes the process. Add one in your bootstrap: