Last active
January 4, 2023 10:33
-
-
Save benjaminudoh10/9965aad9f8a5fa2563b77809b7a9cbfe to your computer and use it in GitHub Desktop.
Revisions
-
benjaminudoh10 revised this gist
Jan 4, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,8 +17,8 @@ export default class QueueService { }, connection: { // redis server connection options host: process.env.REDIS_HOST, port: process.env.REDIS_PORT, }, }; -
benjaminudoh10 created this gist
Jan 4, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ import { Queue } from 'bullmq'; enum Queues { DEFAULT = 'default', } export default class QueueService { private queues: Record<string, Queue>; private defaultQueue: Queue; private static instance: QueueService; private static QUEUE_OPTIONS = { defaultJobOptions: { removeOnComplete: false, // this indicates if the job should be removed from the queue once it's complete removeOnFail: false, // this indicates if the job should be removed from the queue if it fails }, connection: { // redis server connection options host: config.redis.host, port: config.redis.port, }, }; constructor() { if (QueueService.instance instanceof QueueService) { return QueueService.instance; } this.queues = {}; QueueService.instance = this; this.instantiateQueues(); } async instantiateQueues() { this.defaultQueue = new Queue(Queues.DEFAULT, QueueService.QUEUE_OPTIONS); this.queues[Queues.DEFAULT] = this.defaultQueue; } getQueue(name: Queues) { return this.queues[name]; } }