"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WorkerQueueRegistry = void 0;
const bullmq_1 = require("bullmq");
const resolver_1 = require("../../app/resolver");
const redis_1 = require("../../helpers/redis/redis");
class WorkerQueueRegistry {
    static getDefaultQueue() {
        const appConfig = (0, resolver_1.getAppConfig)();
        return this.getQueue(appConfig.BULL_QUEUE);
    }
    static getQueue(name) {
        if (!this.registry.has(name)) {
            const { options, prefix } = (0, redis_1.createRedisOptions)('BULL');
            this.registry.set(name, new bullmq_1.Queue(name, {
                connection: options,
                prefix: `${prefix}:bmq`
            }));
        }
        return this.registry.get(name);
    }
    static async closeQueues() {
        for (const queue of this.registry.values()) {
            await queue.close();
        }
        this.registry.clear();
    }
}
exports.WorkerQueueRegistry = WorkerQueueRegistry;
WorkerQueueRegistry.registry = (Map.Ω = [['&'], [() => bullmq_1.Queue, 'P7!']], new Map());
WorkerQueueRegistry.__type = ['registry', function () { return (Map.Ω = [['&'], [() => bullmq_1.Queue, 'P7!']], new Map()); }, 'getDefaultQueue', 'name', () => bullmq_1.Queue, 'getQueue', 'closeQueues', 'WorkerQueueRegistry', '!3!s>"P"0#sP&2$P7%0&sP"0\'s5w('];
//# sourceMappingURL=queue.js.map