UNPKG

redis-smq

Version:

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

23 lines 958 B
import { EExchangeProperty } from '../types/index.js'; import { redisKeys } from '../../common/redis/redis-keys/redis-keys.js'; import { ExchangeNotFoundError, ExchangeTypeMismatchError, } from '../../errors/index.js'; export function _validateExchange(client, exchange, required, cb) { const { keyExchange } = redisKeys.getExchangeKeys(exchange.ns, exchange.name); client.hget(keyExchange, String(EExchangeProperty.TYPE), (err, reply) => { if (err) return cb(err); if (reply == null) { if (required) return cb(new ExchangeNotFoundError()); return cb(); } const existingType = Number(reply); if (existingType !== exchange.type) { return cb(new ExchangeTypeMismatchError({ metadata: { expected: exchange.type, actual: existingType }, })); } cb(); }); } //# sourceMappingURL=_validate-exchange.js.map