docs: adr 0015 transactional outbox

This commit is contained in:
2026-10-26 01:39:01 +01:00
parent 2fb577af65
commit 6ae3f54a36
3 changed files with 89 additions and 0 deletions

View File

@@ -188,6 +188,8 @@ cargo run -p worker # event worker (poster sync, in a separate terminal)
The worker polls the event queue and must run alongside the server to process background tasks like poster fetching. Both processes share the same database.
**Event flow.** The server never publishes events directly: every write that raises an event stores it in the `event_queue` table in the same transaction (a transactional outbox, see [ADR-0015](docs/adr/0015-transactional-outbox.md)). With `EVENT_BUS_BACKEND=db` the worker consumes those rows; with `nats` the worker relays them to JetStream (with `Nats-Msg-Id` set to the event id) and consumes them from there. Duplicates are filtered in three layers: the broker's duplicate window, a claim lease on queue rows, and a per-(event, handler) processed-event ledger. Handlers must stay idempotent.
## API
All REST endpoints are under `/api/v1/`. Authentication uses `Authorization: Bearer <token>` obtained from `POST /api/v1/auth/login`.