Files
EvoBGP/docs/adr/001-durable-job-queue.md
DenozordecandCursor 26f5172f88 test(web): add Vitest CI, ADRs, and PR Definition of Done
FE unit-тесты селекторов/api-client в CI; ADR по durable jobs, OpenAPI codegen и legacy Svelte; PR template WEB-19; процесс KPI cross-app sync.

Co-authored-by: Cursor <[email protected]>
2026-07-31 12:27:13 +07:00

25 lines
920 B
Markdown

# ADR-001: Durable job queue via PostgreSQL job_audit
## Status
Accepted (2026-07)
## Context
`jobs.Registry` is in-process. ARCH-04 notes workers do not share memory across API replicas. Jobs were already audited to `job_audit`, but orphans after restart were not reclaimed.
## Decision
Keep in-process execution for latency; add durable reclaim:
1. Persist lifecycle via existing `SetPersistHooks``job_audit`.
2. Periodically `ReclaimStaleRunning` + `ClaimQueued` with `FOR UPDATE SKIP LOCKED`.
3. `Registry.Adopt` injects claimed rows into the local worker pool.
4. Claim grace (`EVOBGP_JOB_CLAIM_GRACE`, default 30s) avoids double-run of fresh local enqueues.
NATS JetStream remains optional (`EVOBGP_BROKER_URL` logged only).
## Consequences
Two `evobgp-api` processes can reclaim orphaned work. Fresh jobs still run on the enqueueing process. Full broker-based fan-out is out of scope for this ADR.