redis-smq
Version:
A simple high-performance Redis message queue for Node.js.
39 lines • 1.59 kB
JavaScript
import { withRedisClient } from 'redis-smq-common';
import { ExchangeAbstract } from '../exchange-abstract.js';
import { _getTopicExchangeParams } from './_/_get-topic-exchange-params.js';
import { _getTopicExchangeQueues } from './_/_get-topic-exchange-queues.js';
export class ExchangeTopic extends ExchangeAbstract {
constructor() {
super();
this.logger.info('ExchangeTopic initialized');
}
getQueues(exchangeParams, cb) {
this.logger.debug(`Getting queues for topic exchange`, { exchangeParams });
const topic = _getTopicExchangeParams(exchangeParams);
if (topic instanceof Error) {
this.logger.error(`Invalid topic exchange parameters`, {
error: topic.message,
});
return cb(topic);
}
withRedisClient(this.redisClient, (client, cb) => {
this.logger.debug(`Getting topic exchange queues`, { topic });
_getTopicExchangeQueues(client, topic, (err, queues) => {
if (err) {
this.logger.error(`Failed to get topic exchange queues`, {
error: err.message,
});
cb(err);
}
else {
this.logger.debug(`Successfully retrieved topic exchange queues`, {
topic,
queueCount: queues?.length || 0,
});
cb(null, queues);
}
});
}, cb);
}
}
//# sourceMappingURL=exchange-topic.js.map