UNPKG

redis-smq

Version:

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

46 lines 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const configuration_error_1 = require("../configuration.error"); function getMessageStorageConfig(config, key) { var _a; const { store } = (_a = config.messages) !== null && _a !== void 0 ? _a : {}; if (typeof store === 'undefined' || typeof store === 'boolean') { return Boolean(store); } const params = store[key]; if (params) return params; return false; } function getMessageStorageParams(config, key) { var _a, _b; const params = getMessageStorageConfig(config, key); if (typeof params === 'boolean') { return { store: params, queueSize: 0, expire: 0, }; } const queueSize = Number((_a = params.queueSize) !== null && _a !== void 0 ? _a : 0); if (isNaN(queueSize) || queueSize < 0) { throw new configuration_error_1.ConfigurationError(`Parameter [queueSize] should be >= 0`); } const expire = Number((_b = params.expire) !== null && _b !== void 0 ? _b : 0); if (isNaN(expire) || expire < 0) { throw new configuration_error_1.ConfigurationError(`Parameter [expire] should be >= 0`); } return { store: true, queueSize, expire, }; } function Store(config) { return { acknowledged: getMessageStorageParams(config, 'acknowledged'), deadLettered: getMessageStorageParams(config, 'deadLettered'), }; } exports.default = Store; //# sourceMappingURL=store.js.map