feat: implement background job system with queue, worker, scheduler, and handlers

- Add job queue abstraction (InMemoryQueue and Redis/BullMQ adapter)
- Add polling worker with retry logic and exponential backoff
- Add 6 job handlers: darkwatch.scan, voiceprint.batch, hometitle.scan,
  removebrokers.process, reports.generate, notifications.send
- Add cron-based scheduler with tier-appropriate frequencies
  (Basic/Plus/Premium)
- Add tRPC scheduler router for admin (runJobNow, getJobStatus, etc.)
- Add entry point with graceful shutdown support
- Achieve 100% test pass rate for new job system
This commit is contained in:
2026-05-25 17:16:21 -04:00
parent 659ab9b71a
commit eb8e57c674
19 changed files with 1429 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import { object, string, optional, enumType } from "valibot";
export const RunJobNowSchema = object({
type: string(),
payload: object({
userId: optional(string()),
subscriptionId: optional(string()),
requestId: optional(string()),
reportType: optional(string()),
reportScheduleId: optional(string()),
channel: optional(string()),
alertId: optional(string()),
jobId: optional(string()),
}),
});
export const JobStatusSchema = object({
jobId: string(),
});