UNPKG

redis-smq

Version:

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

34 lines 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DirectExchange = void 0; const exchange_1 = require("./exchange"); const types_1 = require("../../../types"); const redis_keys_1 = require("../../common/redis-keys/redis-keys"); const queue_1 = require("../queue-manager/queue"); const invalid_exchange_data_error_1 = require("./errors/invalid-exchange-data.error"); class DirectExchange extends exchange_1.Exchange { constructor(queue) { super(queue, types_1.EExchangeType.DIRECT); } validateBindingParams(queue) { return typeof queue === 'string' ? redis_keys_1.redisKeys.validateRedisKey(queue) : { name: redis_keys_1.redisKeys.validateRedisKey(queue.name), ns: redis_keys_1.redisKeys.validateNamespace(queue.ns), }; } getQueues(redisClient, config, cb) { const queue = queue_1.Queue.getParams(config, this.bindingParams); cb(null, [queue]); } static fromJSON(json) { if (!json.bindingParams || json.type !== types_1.EExchangeType.DIRECT) throw new invalid_exchange_data_error_1.InvalidExchangeDataError(); const e = new DirectExchange(json.bindingParams); e.fromJSON(json); return e; } } exports.DirectExchange = DirectExchange; //# sourceMappingURL=direct-exchange.js.map