redis-smq
Version:
A high-performance, reliable, and scalable message queue for Node.js.
71 lines • 3.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports._deleteConsumerGroup = _deleteConsumerGroup;
const scripts_js_1 = require("../../common/redis/scripts.js");
const redis_keys_js_1 = require("../../common/redis/redis-keys/redis-keys.js");
const index_js_1 = require("../../queue-manager/index.js");
const index_js_2 = require("../../errors/index.js");
const event_multiplexer_js_1 = require("../../event-bus/event-multiplexer.js");
function _deleteConsumerGroup(redisClient, queueParams, groupId, cb) {
const { keyQueueConsumerGroups, keyQueuePending, keyQueuePriority, keyQueueProperties, } = redis_keys_js_1.redisKeys.getQueueKeys(queueParams.ns, queueParams.name, groupId);
const { keyQueueConsumerGroupConsumers } = redis_keys_js_1.redisKeys.getQueueConsumerGroupKeys(queueParams, groupId);
const argv = [
index_js_1.EQueueProperty.QUEUE_TYPE,
index_js_1.EQueueType.PRIORITY_QUEUE,
index_js_1.EQueueProperty.DELIVERY_MODEL,
index_js_1.EQueueDeliveryModel.PUB_SUB,
groupId,
index_js_1.EQueueProperty.OPERATIONAL_STATE,
index_js_1.EQueueOperationalState.LOCKED,
index_js_1.EQueueProperty.LOCK_ID,
'',
];
redisClient.runScript(scripts_js_1.ERedisScriptName.DELETE_CONSUMER_GROUP, [
keyQueueConsumerGroups,
keyQueuePending,
keyQueuePriority,
keyQueueProperties,
keyQueueConsumerGroupConsumers,
], argv, (err, reply) => {
if (err)
return cb(err);
const replyStr = String(reply);
if (replyStr === 'QUEUE_LOCKED') {
return cb(new index_js_2.QueueLockedError({
metadata: {
queue: queueParams,
},
}));
}
if (replyStr === 'QUEUE_NOT_FOUND') {
return cb(new index_js_2.QueueNotFoundError({
metadata: {
queue: queueParams,
},
}));
}
if (replyStr === 'CONSUMER_GROUPS_NOT_SUPPORTED') {
return cb(new index_js_2.ConsumerGroupsNotSupportedError());
}
if (replyStr === 'CONSUMER_GROUP_NOT_EMPTY') {
return cb(new index_js_2.ConsumerGroupNotEmptyError());
}
if (replyStr === 'CONSUMER_GROUP_HAS_ACTIVE_CONSUMERS') {
return cb(new index_js_2.ConsumerGroupHasActiveConsumersError({
metadata: {
queue: queueParams,
consumerGroupId: groupId,
},
}));
}
if (replyStr !== 'OK') {
return cb(new index_js_2.UnexpectedScriptReplyError({
message: `Unexpected reply from DELETE_CONSUMER_GROUP script: ${replyStr}`,
metadata: { reply },
}));
}
event_multiplexer_js_1.EventMultiplexer.publish('queue.consumerGroupDeleted', queueParams, groupId);
cb();
});
}
//# sourceMappingURL=_delete-consumer-group.js.map