Skip to main content

Module db

Module db 

Source
Expand description

Postgres: the connection pool, this server’s schema, and the LISTEN connection that fans changes out to every replica.

SQL is written with chess. table prefixes; Db::sql swaps in the configured schema name. The server keeps its own players, API tokens and sessions there; a host site’s (site., CHESS_SITE_SCHEMA) are read once, to import the players who already used chess there. Explicit names rather than a search_path because Neon’s pooler (transaction pooling) doesn’t keep session settings.

Structs§

Db
Manager

Enums§

Note
A change other replicas (and local streams) need to hear about.

Functions§

direct_host
Neon’s pooled hostname (ep-x-123-pooler.region…) → the direct one, which LISTEN needs (transaction poolers don’t deliver notifications).
listen_url
The URL for LISTEN: a Neon -pooler host swapped for the direct one (the host is replaced, not added: tokio-postgres would try a second host only if the first failed, and the pooler doesn’t fail, it just never delivers notifications). Anything else is used as given.
notify
Send note from inside a transaction (delivered to every replica on commit). Payloads over Postgres’s 8000-byte limit are trimmed to a reload instruction.
quote_ident

Type Aliases§

Conn
Pool