feat(jobs): echo worker + CLI bootstrap

Job queue starts only in the CLI gate (not inside createApp), so tests
manage their own queue lifecycle. waitForJob() takes a (name, id) pair
to match pg-boss v10's getJobById signature.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-01 03:28:06 +10:00
parent 17a13dddb8
commit 53ffd705c4
5 changed files with 56 additions and 9 deletions

10
lib/jobs/index.js Normal file
View File

@@ -0,0 +1,10 @@
import * as queue from './queue.js';
import * as echo from './workers/echo.js';
const WORKERS = [echo];
export async function registerWorkers() {
for (const w of WORKERS) {
await queue.subscribe(w.NAME, w.handler, w.opts || {});
}
}

5
lib/jobs/workers/echo.js Normal file
View File

@@ -0,0 +1,5 @@
export const NAME = 'echo';
export async function handler(job) {
return { pong: job.data?.ping ?? 0 };
}