mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-13 14:32:03 +00:00
The five hand-written registrars (about 5,500 lines, one 997-line function) are replaced by `jobs/registry/`: one `defineJob` entry per queue with its cron, schedule send options, policy, work options, lock, lane and a handler loader. `registerJobGroup` creates, schedules, retires and binds each group in the order the registrars used; the worker boot walks the groups and runs their boot discovery. Handlers load on their queue's first job. The facts a declaration needs at boot (names, crons, concurrency, send options) moved out of the heavy job modules into light `*-queue.ts` siblings, and their importers point there, so loading the registry evaluates 288 modules instead of the 1,164 the registrars pulled in. The formerly inline handlers moved verbatim into handler modules under `jobs/reminder/`. Fitbit's queues live in `fitbit/jobs/definitions.ts` and enter the registry through one spread, so removing the integration later is that folder and that line. `tests/integration/queue-registration-parity.test.ts` proves pg-boss holds exactly what the registrars left (queues, schedules, bindings, byte for byte) and loads every handler once. The queue tests and the runtime guard assert on the registry objects instead of reading registrar source.
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
/**
|
|
* The queue facts of `offhost-backup.ts`: its name and, where it has them, its
|
|
* schedule, concurrency and send options. They live apart from the job so the
|
|
* worker registry and every sender can read them without loading it.
|
|
*/
|
|
import { BACKUP_HEARTBEAT_SECONDS } from "@/lib/jobs/data-backup-policy";
|
|
|
|
/**
|
|
* The off-host pass's expiry: four hours. It uploads every account and
|
|
* already stopped between accounts at three quarters of the default fifteen
|
|
* minutes, which on an instance of any size meant a retry per night; one
|
|
* large account past the default was retried beside itself. Four hours with
|
|
* the same budget and a lock (`lockedPass`) leaves room for the night's pass.
|
|
*/
|
|
export const OFFHOST_BACKUP_EXPIRE_SECONDS = 4 * 60 * 60;
|
|
|
|
export const OFFHOST_BACKUP_QUEUE = "data-backup-offhost";
|
|
|
|
/**
|
|
* What the nightly schedule sends with: the four hours above, and the
|
|
* heartbeat that notices a process that died under the pass within minutes
|
|
* rather than at the end of them (`BACKUP_HEARTBEAT_SECONDS`).
|
|
*/
|
|
export const OFFHOST_BACKUP_SEND_OPTIONS = {
|
|
expireInSeconds: OFFHOST_BACKUP_EXPIRE_SECONDS,
|
|
heartbeatSeconds: BACKUP_HEARTBEAT_SECONDS,
|
|
} as const;
|