refactor: update ioredis connection

This commit is contained in:
Mauricio Siu
2024-10-06 02:44:35 -06:00
parent ed8d32d050
commit 9e4bac1386
4 changed files with 16 additions and 14 deletions

View File

@@ -1,11 +1,15 @@
import { Queue, type RepeatableJob } from "bullmq";
import { logger } from "./logger";
import type { QueueJob } from "./schema";
import IORedis from "ioredis";
export const connection = new IORedis({
maxRetriesPerRequest: null,
path: process.env.REDIS_URL,
});
export const jobQueue = new Queue("backupQueue", {
connection: {
host: process.env.REDIS_URL,
},
connection,
defaultJobOptions: {
removeOnComplete: true,
removeOnFail: true,

View File

@@ -1,6 +1,8 @@
import { type Job, Worker } from "bullmq";
import type { QueueJob } from "./schema";
import { runJobs } from "./utils";
import Redis from "ioredis";
import { connection } from "./queue";
export const firstWorker = new Worker(
"backupQueue",
@@ -10,9 +12,7 @@ export const firstWorker = new Worker(
},
{
concurrency: 50,
connection: {
host: process.env.REDIS_URL,
},
connection,
},
);
export const secondWorker = new Worker(
@@ -23,8 +23,6 @@ export const secondWorker = new Worker(
},
{
concurrency: 50,
connection: {
host: process.env.REDIS_URL,
},
connection,
},
);