mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 11:39:26 +01:00
23 lines
493 B
TypeScript
23 lines
493 B
TypeScript
import { Queue } from 'bullmq'
|
|
import queueConfig from '#config/queue'
|
|
|
|
export class QueueService {
|
|
private queues: Map<string, Queue> = new Map()
|
|
|
|
getQueue(name: string): Queue {
|
|
if (!this.queues.has(name)) {
|
|
const queue = new Queue(name, {
|
|
connection: queueConfig.connection,
|
|
})
|
|
this.queues.set(name, queue)
|
|
}
|
|
return this.queues.get(name)!
|
|
}
|
|
|
|
async close() {
|
|
for (const queue of this.queues.values()) {
|
|
await queue.close()
|
|
}
|
|
}
|
|
}
|