Options
Every entry point takes the same database options. postgresStorage adds owner; openPostgresStore adds outbox.
Database options
Section titled “Database options”| Option | Default | What it does |
|---|---|---|
connection |
— | A postgres://… connection string. Exactly one of connection and pool is required. |
pool |
— | An existing node-postgres Pool. It must be dedicated to this adapter (see Session settings). |
schema |
"chord" |
The Postgres schema the store lives in. Created when missing. A plain identifier ([A-Za-z_][A-Za-z0-9_$]*). |
poolSize |
4 |
The pool’s max, when this adapter creates the pool. |
statementTimeoutMs |
30000 |
Postgres’ statement_timeout for this adapter’s statements; 0 disables it. A hung commit should fail the store, not hang it. |
Validation happens once, at the door, before a connection is taken:
- neither
connectionnorpool→TypeError - both →
TypeError - a
schemathat is not a plain identifier →TypeError, naming the value poolSizebelow 1, orstatementTimeoutMsbelow 0, or either not an integer →RangeError
Store options
Section titled “Store options”PostgresStoreOptions is the database’s options plus:
| Option | What it does |
|---|---|
outbox |
true turns chord’s outbox on, false turns it off; omitted, the store’s persisted setting stays as it was. Passed straight to openStore’s third argument. |
postgresBackend and postgresDatabase do not take it: outbox belongs to openStore, so postgresBackend followed
by your own openStore(backend, context, { outbox: true }) is the way to set it there.
pi-durable’s owner
Section titled “pi-durable’s owner”postgresStorage takes the store options plus one:
| Option | What it does |
|---|---|
owner |
The name pi-durable’s tables live under, as "<owner>:<table>". pi-durable’s rule for it is [a-z0-9@/._~-]+. The longest name it declares is <owner>:entries:conversation, so an owner longer than 38 characters exceeds Postgres’ 63-byte identifier limit and is refused when the tables are declared. |
owner is not a schema. Several owners can share one store: open the store with openPostgresStore and call
pi-durable’s StoreStorage.open(store, owner, context) once per owner.
Session settings
Section titled “Session settings”For every connection it uses, the adapter runs:
SET search_path TO "<schema>"SET statement_timeout = <statementTimeoutMs> -- only when the timeout is not 0Both are SET on the session, in one round trip, and they are remembered per connection so they are not re-issued for
every statement.
search_path is what makes chord’s unqualified table names land in the adapter’s schema, so it is not optional — and it
is why a pool you pass in must be this adapter’s alone. With a connection string the adapter creates (and closes) its
own pool, so this is only a concern for a borrowed one.
Scaling
Section titled “Scaling”- One store per schema. Several
openPostgresStorecalls on one schema serialise through the advisory lock and do not corrupt rows, but each store keeps its own in-memorylastSeqand id allocator, so their metadata row is last-writer-wins. Open several storages on one store instead. - One process, one pool: the pool size is the concurrency this adapter will use, and the queue serialises above it. A larger pool does not make a single store faster, because a transaction holds the queue for its whole callback.
- The default schema is
chord, notpublic, so a store never shares a namespace with an application’s tables.