Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM, PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source files covering clients, berths, interests/pipeline, documents/EOI, expenses/invoices, email, notifications, dashboard, admin, and client portal. CI/CD via Gitea Actions with Docker builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
40
src/lib/queue/index.ts
Normal file
40
src/lib/queue/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Queue, type ConnectionOptions } from 'bullmq';
|
||||
|
||||
const redisUrl = process.env.REDIS_URL!;
|
||||
|
||||
// 10 queues matching 11-REALTIME-AND-BACKGROUND-JOBS.md Section 3.1
|
||||
const QUEUE_CONFIGS = {
|
||||
email: { concurrency: 5, maxAttempts: 5 },
|
||||
documents: { concurrency: 3, maxAttempts: 5 },
|
||||
notifications: { concurrency: 10, maxAttempts: 3 },
|
||||
import: { concurrency: 1, maxAttempts: 1 },
|
||||
export: { concurrency: 2, maxAttempts: 3 },
|
||||
reports: { concurrency: 1, maxAttempts: 3 },
|
||||
webhooks: { concurrency: 5, maxAttempts: 3 },
|
||||
maintenance: { concurrency: 1, maxAttempts: 3 },
|
||||
ai: { concurrency: 2, maxAttempts: 3 },
|
||||
bulk: { concurrency: 2, maxAttempts: 3 },
|
||||
} as const;
|
||||
|
||||
export type QueueName = keyof typeof QUEUE_CONFIGS;
|
||||
|
||||
const queues = new Map<QueueName, Queue>();
|
||||
|
||||
export function getQueue(name: QueueName): Queue {
|
||||
let queue = queues.get(name);
|
||||
if (!queue) {
|
||||
queue = new Queue(name, {
|
||||
connection: { url: redisUrl } as ConnectionOptions,
|
||||
defaultJobOptions: {
|
||||
attempts: QUEUE_CONFIGS[name].maxAttempts,
|
||||
backoff: { type: 'exponential', delay: 1000 },
|
||||
removeOnComplete: { age: 24 * 3600 }, // keep completed jobs 24 hours
|
||||
removeOnFail: { age: 7 * 24 * 3600 }, // keep failed jobs 7 days
|
||||
},
|
||||
});
|
||||
queues.set(name, queue);
|
||||
}
|
||||
return queue;
|
||||
}
|
||||
|
||||
export { QUEUE_CONFIGS };
|
||||
Reference in New Issue
Block a user