UNPKG

rascal

Version:

A config driven wrapper for amqplib supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption, channel pooling and publication timeouts

16 lines (13 loc) 383 B
const _ = require('lodash'); const LRUCache = require('lru-cache'); module.exports = function init(options) { const size = _.get(options, 'size') || 1000; const cache = new LRUCache({ max: size }); return { incrementAndGet(key, next) { const redeliveries = cache.get(key) + 1 || 1; cache.set(key, redeliveries); next(null, redeliveries); }, }; };