Liking cljdoc? Tell your friends :D

game.gm.store.postgres

Postgres GameStore: one schema per game, one row per protocol.

Opt-in. next.jdbc, the PostgreSQL driver and HikariCP are :provided dependencies of gm-lib, so a GM that wants this adds them to its own project.clj; the GMs that do not never load this namespace.

CONCURRENCY. An event row-locks the protocol rows it names (in name order, so two events cannot deadlock on them), then reads every row. f runs inside that transaction. A protocol it patches that it did NOT lock is written with a version check; if another event got there first the transaction rolls back and the event is re-run on fresh state. A deadlock or serialization failure is retried the same way, so f must be safe to run again. Events on different protocols never wait on each other, which is the point of one row per protocol.

f holding a row lock while it runs means a slow handler (an LLM call, say) holds its protocol's row for that long; other protocols are unaffected.

Postgres GameStore: one schema per game, one row per protocol.

Opt-in. next.jdbc, the PostgreSQL driver and HikariCP are :provided dependencies
of gm-lib, so a GM that wants this adds them to its own project.clj; the GMs that
do not never load this namespace.

CONCURRENCY. An event row-locks the protocol rows it names (in name order, so two
events cannot deadlock on them), then reads every row. `f` runs inside that
transaction. A protocol it patches that it did NOT lock is written with a version
check; if another event got there first the transaction rolls back and the event is
re-run on fresh state. A deadlock or serialization failure is retried the same way,
so `f` must be safe to run again. Events on different protocols never wait on each
other, which is the point of one row per protocol.

`f` holding a row lock while it runs means a slow handler (an LLM call, say) holds
its protocol's row for that long; other protocols are unaffected.
raw docstring

close!clj

(close! store)

create-storeclj

(create-store {:keys [jdbc-url user password schema max-pool-size min-idle]})

Connects, creates the schema and its tables if missing, and returns a store.

{:jdbc-url :user :password :schema [:max-pool-size 4] [:min-idle 1]}. schema must be a plain lower-case identifier (it is interpolated into DDL, so anything else is refused). The pool grows to max-pool-size under load but idles at min-idle: HikariCP's own default is to hold the whole pool open, which across many stores (or many tests) exhausts the database's connection limit.

Connects, creates the schema and its tables if missing, and returns a store.

{:jdbc-url :user :password :schema [:max-pool-size 4] [:min-idle 1]}. `schema` must
be a plain lower-case identifier (it is interpolated into DDL, so anything else is
refused). The pool grows to `max-pool-size` under load but idles at `min-idle`:
HikariCP's own default is to hold the whole pool open, which across many stores
(or many tests) exhausts the database's connection limit.
raw docstring

drop-schema!clj

(drop-schema! store)

Removes the schema and everything in it. For tests; a GM has no reason to.

Removes the schema and everything in it. For tests; a GM has no reason to.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close