tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

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

Examples: the event store on PostgreSQL (issue #145's example)

`examples/event_store`: the DDD discussion end to end.

- **Aggregates are pure**: `counter.lse`'s `decide`/`evolve`; the command
  handler's flow (load, evolve, decide, append) performs the
  `event_store` effect — memory in tests, PostgreSQL in production, and
  domain code sees only its port.
- **The port and its two handlers** (`lib.lse`): `event_store` with
  `load`/`append`; `with_memory` (a region and a dict) and
  `with_postgres` (each operation its own transaction on the pool).
- **Optimistic concurrency**: appends insert at their version with the
  head checked in the same statement (`insert ... select ... where`);
  a moved head inserts nothing and a race's loser meets the
  `(stream, version)` primary key — both become `Error(Conflict)`.
- **The outbox**: events and outbox rows are written in one transaction,
  with `pg_notify('event_store_events', stream)`; `projection.lse`'s
  delivery actor listens (the driver's `pg.listen`) and applies
  unpublished rows to the `stream_counts` projection in one transaction,
  marking them published — a failed drain leaves rows for the next
  notification.

Tests: the in-memory handler and the aggregate everywhere; on PostgreSQL
(`LOUISE_PG_URL`): migrate, append, load, a stale-writer conflict, and
the projection catching up through LISTEN/NOTIFY. The example is in CI
(scripts/ci.sh), skipping the live parts without a database.

olivier · il y a 1 mois · 7c035ce9d7a71472d2e3fa6ae7c1ea2c3854a37c

Parents 784e5c4

6 fichiers modifiés, 441 ajouts, 0 suppressions