import { Queue } from 'bullmq'; import { connection } from './redis.server'; import type { FlyerJobData, EmailJobData, AnalyticsJobData, WeeklyAnalyticsJobData, CleanupJobData, TokenCleanupJobData, } from '../types/job-data'; // --- Queues --- export const flyerQueue = new Queue('flyer-processing', { connection, defaultJobOptions: { attempts: 3, backoff: { type: 'exponential', delay: 5000, }, }, }); export const emailQueue = new Queue('email-sending', { connection, defaultJobOptions: { attempts: 5, backoff: { type: 'exponential', delay: 10000, }, }, }); export const analyticsQueue = new Queue('analytics-reporting', { connection, defaultJobOptions: { attempts: 2, backoff: { type: 'exponential', delay: 60000, }, removeOnComplete: true, removeOnFail: 50, }, }); export const weeklyAnalyticsQueue = new Queue('weekly-analytics-reporting', { connection, defaultJobOptions: { attempts: 2, backoff: { type: 'exponential', delay: 3600000 }, removeOnComplete: true, removeOnFail: 50, }, }); export const cleanupQueue = new Queue('file-cleanup', { connection, defaultJobOptions: { attempts: 3, backoff: { type: 'exponential', delay: 30000 }, removeOnComplete: true, }, }); export const tokenCleanupQueue = new Queue('token-cleanup', { connection, defaultJobOptions: { attempts: 2, backoff: { type: 'exponential', delay: 3600000 }, removeOnComplete: true, removeOnFail: 10, }, });