import { Worker } from "bullmq"; import { Redis } from "ioredis"; // BullMQ needs its own connection (can't share one used for pub/sub or with // maxRetriesPerRequest set to a finite value in some modes) — kept separate // from app/lib/redis.server.ts for that reason. const connection = new Redis(process.env.REDIS_URL || "redis://127.0.0.1:6379", { maxRetriesPerRequest: null, }); // TODO (Phase 4): hold-expiry — release a SlotHold whose TTL has passed. // TODO (Phase 9): notifications — send queued reminder/ETA messages. // TODO (Phase 5+): capacity-recompute — recalculate denormalized capacity // snapshots after config changes. The checkout snapshot // (app/services/checkout-snapshot.server.ts) is refreshed inline on every // order webhook and slot/blackout/enforcement edit, which covers all the // cases that matter. A periodic sweep here would only keep the 30-day // rolling horizon advancing on a store that takes zero orders and makes // zero edits for a month — worth adding once offline-session storage is // wired so this process can get an Admin client per shop. const holdExpiryWorker = new Worker( "hold-expiry", async (job) => { console.log("Processing hold-expiry job", job.id, job.data); }, { connection }, ); holdExpiryWorker.on("failed", (job, err) => { console.error(`hold-expiry job ${job?.id} failed:`, err); }); console.log("Worker started, listening for jobs...");