UNPKG

redis-smq

Version:

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

43 lines 1.9 kB
import { async } from 'redis-smq-common'; import { ELuaScriptName } from '../../../common/redis-client/scripts/scripts.js'; import { redisKeys } from '../../../common/redis-keys/redis-keys.js'; import { EQueueProperty, EQueueType } from '../../queue/index.js'; import { ConsumerGroupsConsumerGroupNotEmptyError, ConsumerGroupsError, ConsumerGroupsQueueNotFoundError, } from '../errors/index.js'; export function _deleteConsumerGroup(redisClient, eventBus, queue, groupId, cb) { async.waterfall([ (cb) => { const { keyQueueConsumerGroups, keyQueuePending, keyQueuePriorityPending, keyQueueProperties, } = redisKeys.getQueueKeys(queue, groupId); redisClient.runScript(ELuaScriptName.DELETE_CONSUMER_GROUP, [ keyQueueConsumerGroups, keyQueuePending, keyQueuePriorityPending, keyQueueProperties, ], [ EQueueProperty.QUEUE_TYPE, EQueueType.PRIORITY_QUEUE, EQueueType.LIFO_QUEUE, EQueueType.FIFO_QUEUE, groupId, ], (err, reply) => { if (err) cb(err); else if (reply !== 'OK') { if (reply === 'QUEUE_NOT_FOUND') { cb(new ConsumerGroupsQueueNotFoundError()); } else if (reply === 'CONSUMER_GROUP_NOT_EMPTY') { cb(new ConsumerGroupsConsumerGroupNotEmptyError()); } else { cb(new ConsumerGroupsError()); } } else { eventBus.emit('queue.consumerGroupDeleted', queue, groupId); cb(); } }); }, ], cb); } //# sourceMappingURL=_delete-consumer-group.js.map