redis-smq
Version:
A high-performance, reliable, and scalable message queue for Node.js.
37 lines • 1.27 kB
JavaScript
import { async } from 'redis-smq-common';
import { redisKeys } from '../../common/redis/redis-keys/redis-keys.js';
import { _queueExists } from './_queue-exists.js';
import { QueueNotFoundError } from '../../errors/index.js';
export function _getQueueConsumers(client, queue, cb) {
const data = {};
async.series([
(cb) => _queueExists(client, queue, (err, reply) => {
if (err)
return cb(err);
if (!reply)
return cb(new QueueNotFoundError({
metadata: {
queue,
},
}));
cb();
}),
(cb) => {
const { keyQueueConsumers } = redisKeys.getQueueKeys(queue.ns, queue.name, null);
client.hgetall(keyQueueConsumers, (err, reply) => {
if (err)
return cb(err);
const consumers = reply ?? {};
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