UNPKG

redis-smq

Version:

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

44 lines 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports._validateOperation = _validateOperation; const redis_smq_common_1 = require("redis-smq-common"); const index_js_1 = require("../../queue-manager/index.js"); const index_js_2 = require("../../errors/index.js"); const _check_operation_js_1 = require("./_check-operation.js"); function _validateOperation(client, queueParams, operation, cb) { (0, _check_operation_js_1._checkOperation)(client, queueParams, operation, (err, reply) => { if (err) return cb(err); if (!reply) return cb(new redis_smq_common_1.CallbackEmptyReplyError()); const { allowed, currentQueueState } = reply; if (!allowed) { if (currentQueueState === index_js_1.EQueueOperationalState.PAUSED) { return cb(new index_js_2.QueuePausedError({ metadata: { queue: queueParams, }, })); } if (currentQueueState === index_js_1.EQueueOperationalState.STOPPED) { return cb(new index_js_2.QueueStoppedError({ metadata: { queue: queueParams, }, })); } if (currentQueueState === index_js_1.EQueueOperationalState.LOCKED) { return cb(new index_js_2.QueueLockedError({ metadata: { queue: queueParams, }, })); } return cb(new index_js_2.QueueOperationForbiddenError({ metadata: { operation, queue: queueParams }, })); } cb(); }); } //# sourceMappingURL=_validate-operation.js.map