UNPKG

redis-smq

Version:

A simple high-performance Redis message queue for Node.js.

26 lines 1.05 kB
import { async, CallbackEmptyReplyError, } from 'redis-smq-common'; import { _getQueues } from '../../../queue/_/_get-queues.js'; import { _getTopicExchangeParams } from './_get-topic-exchange-params.js'; export function _getTopicExchangeQueues(redisClient, topic, cb) { const topicParams = _getTopicExchangeParams(topic); if (topicParams instanceof Error) cb(topicParams); else { _getQueues(redisClient, (err, queues) => { if (err) cb(err); else if (!queues) cb(new CallbackEmptyReplyError()); else { const matched = []; const regExp = new RegExp(topicParams.topic); async.eachOf(queues, (queue, index, done) => { if (queue.ns === topicParams.ns && regExp.test(queue.name)) matched.push(queue); done(); }, (err) => cb(err, matched)); } }); } } //# sourceMappingURL=_get-topic-exchange-queues.js.map