tobogganSe connecter

packages

The Louise packages, each released on its own

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

Packages: the postgres driver's pool and transactions (issue #145, part)

`postgres.start_pool(config, size)` starts a pool actor holding `size`
connections. `pg.with_connection(pool)` checks one out for a statement,
`pg.transaction(pool)` for a transaction's length: exclusive checkout,
`BEGIN`/`COMMIT`, `ROLLBACK` on an `Error`.

- **The pool watches everyone it talks to.** A borrower that stops while
  holding a connection frees it — closed, not reused, since its
  transaction state is then unknown — and a connection actor that stops
  frees its slot, replaced lazily at the next acquire. Waiting callers
  queue in order; the acquire timeout is the caller's, with a
  `CancelAcquire` best-effort drop of a request whose waiter gave up and
  a raced grant returned at once. The pool actor's mailbox is a
  `process.select`or over its messages and every monitor report.

- **The `sql` effect** (`postgres.sql`: `query`, `execute`,
  `query_statement`, `execute_statement`) is the ambient API:
  `pg.with_connection` and `pg.transaction` handle it against the
  checked-out connection, so domain code tested with an in-memory handler
  never touches a database. The explicit-connection forms are
  `pg.query_on`/`pg.execute_on`/`pg.query_statement_on`.

- **No `defer` for cleanups:** a cleanup may not perform `proc`
  (E0506 — a send could suspend mid-unwind), so rollback/release are on
  the normal and `Error` paths in code, and an unwind crashes the
  borrower, which the pool's monitor sees. A `final ctl` past the block
  is the documented hole (reclaimed when the borrower stops).

Live-tested against postgres:18 (`LOUISE_PG_URL`): a size-1 pool serving
statements twice, a 23505 aborting a transaction with the write rolled
back, and a committing one; the `sql` template through both.

olivier · il y a 1 mois · 2b1f9408e20f2fd3b3bc7f377969fb4d63633300

Parents 405fb02

4 fichiers modifiés, 615 ajouts, 21 suppressions