UNPKG

redis-smq

Version:

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

26 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._validateExchange = _validateExchange; const index_js_1 = require("../types/index.js"); const redis_keys_js_1 = require("../../common/redis/redis-keys/redis-keys.js"); const index_js_2 = require("../../errors/index.js"); function _validateExchange(client, exchange, required, cb) { const { keyExchange } = redis_keys_js_1.redisKeys.getExchangeKeys(exchange.ns, exchange.name); client.hget(keyExchange, String(index_js_1.EExchangeProperty.TYPE), (err, reply) => { if (err) return cb(err); if (reply == null) { if (required) return cb(new index_js_2.ExchangeNotFoundError()); return cb(); } const existingType = Number(reply); if (existingType !== exchange.type) { return cb(new index_js_2.ExchangeTypeMismatchError({ metadata: { expected: exchange.type, actual: existingType }, })); } cb(); }); } //# sourceMappingURL=_validate-exchange.js.map