UNPKG

redis-smq

Version:

A high-performance, reliable, and scalable message queue for Node.js.

40 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._getQueueConsumers = _getQueueConsumers; const redis_smq_common_1 = require("redis-smq-common"); const redis_keys_js_1 = require("../../common/redis/redis-keys/redis-keys.js"); const _queue_exists_js_1 = require("./_queue-exists.js"); const index_js_1 = require("../../errors/index.js"); function _getQueueConsumers(client, queue, cb) { const data = {}; redis_smq_common_1.async.series([ (cb) => (0, _queue_exists_js_1._queueExists)(client, queue, (err, reply) => { if (err) return cb(err); if (!reply) return cb(new index_js_1.QueueNotFoundError({ metadata: { queue, }, })); cb(); }), (cb) => { const { keyQueueConsumers } = redis_keys_js_1.redisKeys.getQueueKeys(queue.ns, queue.name, null); client.hgetall(keyQueueConsumers, (err, reply) => { if (err) return cb(err); const consumers = reply !== null && reply !== void 0 ? reply : {}; redis_smq_common_1.async.eachIn(consumers, (item, key, done) => { data[key] = JSON.parse(item); done(); }, cb); }); }, ], (err) => { if (err) return cb(err); cb(null, data); }); } //# sourceMappingURL=_get-queue-consumers.js.map