Files
flyer-crawler.projectium.com/src/services/queues.server.ts
Torben Sorensen 2d2cd52011
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Failing after 3m58s
Massive Dependency Modernization Project
2026-02-13 00:34:22 -08:00

122 lines
2.7 KiB
TypeScript

import { Queue } from 'bullmq';
import { bullmqConnection as connection } from './redis.server';
import type {
FlyerJobData,
EmailJobData,
AnalyticsJobData,
WeeklyAnalyticsJobData,
CleanupJobData,
TokenCleanupJobData,
ReceiptJobData,
ExpiryAlertJobData,
BarcodeDetectionJobData,
} from '../types/job-data';
// --- Queues ---
export const flyerQueue = new Queue<FlyerJobData>('flyer-processing', {
connection,
defaultJobOptions: {
attempts: 3,
backoff: {
type: 'exponential',
delay: 5000,
},
},
});
export const emailQueue = new Queue<EmailJobData>('email-sending', {
connection,
defaultJobOptions: {
attempts: 5,
backoff: {
type: 'exponential',
delay: 10000,
},
},
});
export const analyticsQueue = new Queue<AnalyticsJobData>('analytics-reporting', {
connection,
defaultJobOptions: {
attempts: 2,
backoff: {
type: 'exponential',
delay: 60000,
},
removeOnComplete: true,
removeOnFail: 50,
},
});
export const weeklyAnalyticsQueue = new Queue<WeeklyAnalyticsJobData>(
'weekly-analytics-reporting',
{
connection,
defaultJobOptions: {
attempts: 2,
backoff: { type: 'exponential', delay: 3600000 },
removeOnComplete: true,
removeOnFail: 50,
},
},
);
export const cleanupQueue = new Queue<CleanupJobData>('file-cleanup', {
connection,
defaultJobOptions: {
attempts: 3,
backoff: { type: 'exponential', delay: 30000 },
removeOnComplete: true,
},
});
export const tokenCleanupQueue = new Queue<TokenCleanupJobData>('token-cleanup', {
connection,
defaultJobOptions: {
attempts: 2,
backoff: { type: 'exponential', delay: 3600000 },
removeOnComplete: true,
removeOnFail: 10,
},
});
// --- Receipt Processing Queue ---
export const receiptQueue = new Queue<ReceiptJobData>('receipt-processing', {
connection,
defaultJobOptions: {
attempts: 3,
backoff: {
type: 'exponential',
delay: 10000, // 10 seconds initial delay
},
removeOnComplete: 100, // Keep last 100 completed jobs
removeOnFail: 50,
},
});
// --- Expiry Alert Queue ---
export const expiryAlertQueue = new Queue<ExpiryAlertJobData>('expiry-alerts', {
connection,
defaultJobOptions: {
attempts: 2,
backoff: { type: 'exponential', delay: 300000 }, // 5 minutes
removeOnComplete: true,
removeOnFail: 20,
},
});
// --- Barcode Detection Queue ---
export const barcodeQueue = new Queue<BarcodeDetectionJobData>('barcode-detection', {
connection,
defaultJobOptions: {
attempts: 2,
backoff: {
type: 'exponential',
delay: 5000,
},
removeOnComplete: 50,
removeOnFail: 20,
},
});