Worker binary and job queue #4
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What to build
Implements ADR 0004. Background work moves out of
tokio::spawncalls inside the server and into a dedicated worker binary, driven by a job queue with visible state.The rule that makes this safe: no job may be enqueued unless a query over domain state can independently rediscover the same work. Losing a job then costs latency, never data, so the queue needs no transactional guarantees and saving a
MoodEntrystays one small transaction that must simply succeed.Everything downstream of that save is best-effort but traceable — status, attempt count, last error — so a failure can be retried deliberately rather than disappearing.
Three concrete prerequisites:
mpscevent channel cannot cross a process boundary. It is not the transport.busy_timeout. Two processes writing one file without it produces intermittentSQLITE_BUSYfailures.SQLite is the store of record. NATS, where available, is a relay for fan-out, never the source of truth.
Migrate the existing reminder scheduler and session cleanup into the worker as proof the split works end to end.
Acceptance criteria
busy_timeoutis configured on the pool; concurrent writes from both processes succeedBlocked by
None - can start immediately.