96 lines
2.0 KiB
TypeScript
96 lines
2.0 KiB
TypeScript
import { Queue } from 'bullmq';
|
|
import { connection } from './redis.server';
|
|
import type { FlyerJobData } from './flyerProcessingService.server';
|
|
|
|
// --- Job Data Interfaces ---
|
|
|
|
export interface EmailJobData {
|
|
to: string;
|
|
subject: string;
|
|
text: string;
|
|
html: string;
|
|
}
|
|
|
|
export interface AnalyticsJobData {
|
|
reportDate: string; // e.g., '2024-10-26'
|
|
}
|
|
|
|
export interface WeeklyAnalyticsJobData {
|
|
reportYear: number;
|
|
reportWeek: number; // ISO week number (1-53)
|
|
}
|
|
|
|
export interface CleanupJobData {
|
|
flyerId: number;
|
|
paths?: string[];
|
|
}
|
|
|
|
export interface TokenCleanupJobData {
|
|
timestamp: string;
|
|
}
|
|
|
|
// --- 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,
|
|
},
|
|
}); |