feat: add BullMQ queue infrastructure and frontend job status hook
- apps/Backend/src/queue/: connection, queues, workers, processors - apps/Frontend/src/hooks/use-job-status.ts: WebSocket job progress hook - apps/Frontend/src/lib/socket.ts: shared Socket.IO singleton Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
48
apps/Backend/src/queue/queues.ts
Normal file
48
apps/Backend/src/queue/queues.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Queue } from "bullmq";
|
||||
import { redisConnection } from "./connection";
|
||||
|
||||
/** Job types dispatched to the selenium Python worker. */
|
||||
export type SeleniumJobType =
|
||||
| "eligibility-check"
|
||||
| "claim-status-check"
|
||||
| "claim-submit"
|
||||
| "claim-pre-auth";
|
||||
|
||||
export interface SeleniumJobData {
|
||||
jobType: SeleniumJobType;
|
||||
userId: number;
|
||||
socketId?: string;
|
||||
/** Fully-enriched payload sent to the Python service. */
|
||||
enrichedPayload: any;
|
||||
/** Extra fields used for DB post-processing */
|
||||
insuranceId?: string;
|
||||
formFirstName?: string;
|
||||
formLastName?: string;
|
||||
formDob?: string;
|
||||
claimId?: number;
|
||||
/** Base64-encoded files for claim submit */
|
||||
files?: { originalname: string; bufferBase64: string; mimetype: string }[];
|
||||
}
|
||||
|
||||
export interface OcrJobData {
|
||||
userId: number;
|
||||
socketId?: string;
|
||||
files: { originalname: string; bufferBase64: string; mimetype: string }[];
|
||||
}
|
||||
|
||||
const defaultOpts = {
|
||||
removeOnComplete: { count: 100 },
|
||||
removeOnFail: { count: 50 },
|
||||
attempts: 2,
|
||||
backoff: { type: "exponential" as const, delay: 5000 },
|
||||
};
|
||||
|
||||
export const seleniumQueue = new Queue<SeleniumJobData>("selenium-jobs", {
|
||||
connection: redisConnection,
|
||||
defaultJobOptions: defaultOpts,
|
||||
});
|
||||
|
||||
export const ocrQueue = new Queue<OcrJobData>("ocr-jobs", {
|
||||
connection: redisConnection,
|
||||
defaultJobOptions: { ...defaultOpts, attempts: 2 },
|
||||
});
|
||||
Reference in New Issue
Block a user