Comparing version 14.4.5 to 15.0.0
# Change Log | ||
## 15.0.0 | ||
- Drop support for Node 10 | ||
- Introduce eslint-config-airbnb-base | ||
## 14.4.5 | ||
@@ -4,0 +9,0 @@ |
@@ -6,2 +6,3 @@ const _ = require('lodash'); | ||
const BrokerAsPromised = require('./lib/amqp/BrokerAsPromised'); | ||
const counters = require('./lib/counters'); | ||
@@ -22,4 +23,4 @@ module.exports = (function () { | ||
}, | ||
counters: require('./lib/counters'), | ||
counters, | ||
}; | ||
})(); |
@@ -11,2 +11,3 @@ const debug = require('debug')('rascal:Broker'); | ||
const fqn = require('../config/fqn'); | ||
const preflight = async.compose(validate, configure); | ||
@@ -16,3 +17,3 @@ const stub = require('../counters/stub'); | ||
const inMemoryCluster = require('../counters/inMemoryCluster').worker; | ||
const setTimeoutUnref = require('../utils/setTimeoutUnref'); | ||
const maxInterval = 2147483647; | ||
@@ -30,5 +31,5 @@ | ||
preflight(_.cloneDeep(config), (err, config) => { | ||
preflight(_.cloneDeep(config), (err, augmentedConfig) => { | ||
if (err) return next(err); | ||
new Broker(config, _.assign({}, components, { counters }))._init(next); | ||
new Broker(augmentedConfig, _.assign({}, components, { counters }))._init(next); | ||
}); | ||
@@ -147,3 +148,5 @@ }, | ||
if (err) return next(err); | ||
vhosts = publications = subscriptions = {}; | ||
vhosts = {}; | ||
publications = {}; | ||
subscriptions = {}; | ||
clearInterval(self.keepActive); | ||
@@ -216,2 +219,3 @@ debug('Finished nuking broker'); | ||
/* eslint-disable-next-line no-multi-assign */ | ||
this.getFullyQualifiedName = this.qualify = function (vhost, name) { | ||
@@ -218,0 +222,0 @@ return fqn.qualify(name, config.vhosts[vhost].namespace); |
@@ -18,3 +18,3 @@ const inherits = require('util').inherits; | ||
if (!err) return resolve(brokerAsPromised); | ||
err.broker = Symbol(); | ||
err.broker = Symbol('broker-as-promised'); | ||
Object.defineProperty(err, err.broker, { | ||
@@ -84,2 +84,3 @@ enumerable: false, | ||
/* eslint-disable-next-line no-multi-assign */ | ||
this.getFullyQualifiedName = this.qualify = function (vhost, name) { | ||
@@ -86,0 +87,0 @@ return broker.qualify(vhost, name); |
@@ -90,3 +90,3 @@ const debug = require('debug')('rascal:SubscriberError'); | ||
const nackMessage = (err) => { | ||
session._nack(message, (nackErr) => { | ||
session._nack(message, (_nackErr) => { | ||
// nackError just means the channel was already closed meaning the original message would have been rolled back | ||
@@ -144,3 +144,3 @@ once(err); | ||
const nackMessage = (err) => { | ||
session._nack(message, (nackErr) => { | ||
session._nack(message, (_nackErr) => { | ||
// nackError just means the channel was already closed meaning the original message would have been rolled back | ||
@@ -147,0 +147,0 @@ once(err); |
@@ -136,3 +136,3 @@ const debug = require('debug')('rascal:SubscriberSession'); | ||
.values() | ||
.filter((entry) => !entry.doomed) | ||
.filter((e) => !e.doomed) | ||
.sortBy('index') | ||
@@ -139,0 +139,0 @@ .last() |
const debug = require('debug')('rascal:Subscription'); | ||
const _ = require('lodash'); | ||
const format = require('util').format; | ||
const crypto = require('crypto'); | ||
const async = require('async'); | ||
const safeParse = require('safe-json-parse/callback'); | ||
const SubscriberSession = require('./SubscriberSession'); | ||
const SubscriberError = require('./SubscriberError'); | ||
const format = require('util').format; | ||
const backoff = require('../backoff'); | ||
const crypto = require('crypto'); | ||
const async = require('async'); | ||
const setTimeoutUnref = require('../utils/setTimeoutUnref'); | ||
@@ -18,4 +18,4 @@ | ||
function Subscription(broker, vhost, config, counter) { | ||
const timer = backoff(config.retry); | ||
function Subscription(broker, vhost, subscriptionConfig, counter) { | ||
const timer = backoff(subscriptionConfig.retry); | ||
const subscriberError = new SubscriberError(broker, vhost); | ||
@@ -27,6 +27,6 @@ const sequentialChannelOperations = async.queue((task, next) => { | ||
this.name = config.name; | ||
this.name = subscriptionConfig.name; | ||
this.init = function (next) { | ||
debug('Initialising subscription: %s', config.name); | ||
debug('Initialising subscription: %s', subscriptionConfig.name); | ||
return next(null, self); | ||
@@ -36,4 +36,4 @@ }; | ||
this.subscribe = function (overrides, next) { | ||
const session = new SubscriberSession(sequentialChannelOperations, config); | ||
subscribeLater(session, _.defaultsDeep(overrides, config)); | ||
const session = new SubscriberSession(sequentialChannelOperations, subscriptionConfig); | ||
subscribeLater(session, _.defaultsDeep(overrides, subscriptionConfig)); | ||
return next(null, session); | ||
@@ -147,3 +147,3 @@ }; | ||
function redeliveriesExceeded(message) { | ||
return message.properties.headers.rascal.redeliveries > config.redeliveries.limit; | ||
return message.properties.headers.rascal.redeliveries > subscriptionConfig.redeliveries.limit; | ||
} | ||
@@ -159,3 +159,3 @@ | ||
function handleRedeliveriesExceeded(session, message) { | ||
const err = new Error(format('Message %s has exceeded %d redeliveries', message.properties.messageId, config.redeliveries.limit)); | ||
const err = new Error(format('Message %s has exceeded %d redeliveries', message.properties.messageId, subscriptionConfig.redeliveries.limit)); | ||
debug(err.message); | ||
@@ -178,3 +178,3 @@ if (session.emit('redeliveries_exceeded', err, message, getAckOrNack(session, message))) return; | ||
message.properties.headers.rascal = message.properties.headers.rascal || {}; | ||
message.properties.headers.rascal.originalQueue = config.source; | ||
message.properties.headers.rascal.originalQueue = subscriptionConfig.source; | ||
message.properties.headers.rascal.originalVhost = vhost.name; | ||
@@ -190,4 +190,4 @@ | ||
const timeout = setTimeoutUnref(() => { | ||
once(new Error(format('Redeliveries timed out after %dms', config.redeliveries.timeout))); | ||
}, config.redeliveries.timeout); | ||
once(new Error(format('Redeliveries timed out after %dms', subscriptionConfig.redeliveries.timeout))); | ||
}, subscriptionConfig.redeliveries.timeout); | ||
countRedeliveries(message, (err, redeliveries) => { | ||
@@ -204,3 +204,3 @@ clearTimeout(timeout); | ||
if (!message.properties.messageId) return next(null, 0); | ||
counter.incrementAndGet(config.name + '/' + message.properties.messageId, next); | ||
counter.incrementAndGet(`${subscriptionConfig.name}/${message.properties.messageId}`, next); | ||
} | ||
@@ -214,4 +214,4 @@ | ||
function getAckOrNack(session, message) { | ||
if (!broker.promises || config.promisifyAckOrNack === false) return ackOrNack.bind(null, session, message); | ||
if (config.promisifyAckOrNack) return ackOrNackP.bind(null, session, message); | ||
if (!broker.promises || subscriptionConfig.promisifyAckOrNack === false) return ackOrNack.bind(null, session, message); | ||
if (subscriptionConfig.promisifyAckOrNack) return ackOrNackP.bind(null, session, message); | ||
return ackOrNack.bind(null, session, message); | ||
@@ -218,0 +218,0 @@ } |
@@ -1,25 +0,25 @@ | ||
exports.applyBindings = require('./applyBindings.js'); | ||
exports.assertExchanges = require('./assertExchanges.js'); | ||
exports.assertQueues = require('./assertQueues.js'); | ||
exports.assertVhost = require('./assertVhost.js'); | ||
exports.bounceVhost = require('./bounceVhost.js'); | ||
exports.checkExchanges = require('./checkExchanges.js'); | ||
exports.checkQueues = require('./checkQueues.js'); | ||
exports.checkVhost = require('./checkVhost.js'); | ||
exports.closeChannel = require('./closeChannel.js'); | ||
exports.closeConnection = require('./closeConnection.js'); | ||
exports.createChannel = require('./createChannel.js'); | ||
exports.createConnection = require('./createConnection.js'); | ||
exports.deleteExchanges = require('./deleteExchanges.js'); | ||
exports.deleteQueues = require('./deleteQueues.js'); | ||
exports.deleteVhost = require('./deleteVhost.js'); | ||
exports.initCounters = require('./initCounters.js'); | ||
exports.initPublications = require('./initPublications.js'); | ||
exports.initShovels = require('./initShovels.js'); | ||
exports.initSubscriptions = require('./initSubscriptions.js'); | ||
exports.initVhosts = require('./initVhosts.js'); | ||
exports.nukeVhost = require('./nukeVhost.js'); | ||
exports.purgeQueues = require('./purgeQueues.js'); | ||
exports.purgeVhost = require('./purgeVhost.js'); | ||
exports.forewarnVhost = require('./forewarnVhost.js'); | ||
exports.shutdownVhost = require('./shutdownVhost.js'); | ||
exports.applyBindings = require('./applyBindings'); | ||
exports.assertExchanges = require('./assertExchanges'); | ||
exports.assertQueues = require('./assertQueues'); | ||
exports.assertVhost = require('./assertVhost'); | ||
exports.bounceVhost = require('./bounceVhost'); | ||
exports.checkExchanges = require('./checkExchanges'); | ||
exports.checkQueues = require('./checkQueues'); | ||
exports.checkVhost = require('./checkVhost'); | ||
exports.closeChannel = require('./closeChannel'); | ||
exports.closeConnection = require('./closeConnection'); | ||
exports.createChannel = require('./createChannel'); | ||
exports.createConnection = require('./createConnection'); | ||
exports.deleteExchanges = require('./deleteExchanges'); | ||
exports.deleteQueues = require('./deleteQueues'); | ||
exports.deleteVhost = require('./deleteVhost'); | ||
exports.initCounters = require('./initCounters'); | ||
exports.initPublications = require('./initPublications'); | ||
exports.initShovels = require('./initShovels'); | ||
exports.initSubscriptions = require('./initSubscriptions'); | ||
exports.initVhosts = require('./initVhosts'); | ||
exports.nukeVhost = require('./nukeVhost'); | ||
exports.purgeQueues = require('./purgeQueues'); | ||
exports.purgeVhost = require('./purgeVhost'); | ||
exports.forewarnVhost = require('./forewarnVhost'); | ||
exports.shutdownVhost = require('./shutdownVhost'); |
@@ -7,5 +7,5 @@ const debug = require('debug')('rascal:Vhost'); | ||
const genericPool = require('generic-pool'); | ||
const tasks = require('./tasks'); | ||
const uuid = require('uuid').v4; | ||
const _ = require('lodash'); | ||
const tasks = require('./tasks'); | ||
const backoff = require('../backoff'); | ||
@@ -22,3 +22,3 @@ const setTimeoutUnref = require('../utils/setTimeoutUnref'); | ||
function Vhost(config, components) { | ||
function Vhost(vhostConfig, components) { | ||
const self = this; | ||
@@ -40,3 +40,3 @@ let connection; | ||
this.name = config.name; | ||
this.name = vhostConfig.name; | ||
this.connectionIndex = 0; | ||
@@ -55,3 +55,3 @@ | ||
init(config, { connectionIndex: self.connectionIndex, components }, (err, config, ctx) => { | ||
init(vhostConfig, { connectionIndex: self.connectionIndex, components }, (err, config, ctx) => { | ||
if (err) return next(err); | ||
@@ -102,3 +102,3 @@ | ||
if (err) return next(err); | ||
nuke(config, { connectionIndex: self.connectionIndex }, (err) => { | ||
nuke(vhostConfig, { connectionIndex: self.connectionIndex }, (err) => { | ||
if (err) return next(err); | ||
@@ -113,3 +113,3 @@ debug('Finished nuking vhost: %s', self.name); | ||
debug('Purging vhost: %s', self.name); | ||
purge(config, { purge: true, connectionIndex: self.connectionIndex }, (err) => { | ||
purge(vhostConfig, { purge: true, connectionIndex: self.connectionIndex }, (err) => { | ||
if (err) return next(err); | ||
@@ -131,3 +131,3 @@ debug('Finished purging vhost: %s', self.name); | ||
debug('Connecting to vhost: %s', self.name); | ||
connect(config, { connectionIndex: self.connectionIndex }, (err, config, ctx) => { | ||
connect(vhostConfig, { connectionIndex: self.connectionIndex }, (err, config, ctx) => { | ||
return next(err, ctx.connection); | ||
@@ -200,4 +200,4 @@ }); | ||
const mode = getChannelMode(options.confirm); | ||
// eslint-disable-next-line prefer-const | ||
let pool, poolQueue; | ||
let pool; | ||
let poolQueue; | ||
let busy = false; | ||
@@ -208,3 +208,3 @@ | ||
return new Promise((resolve, reject) => { | ||
debug('Creating pooled %s channel for vhost: %s', mode, config.name); | ||
debug('Creating pooled %s channel for vhost: %s', mode, vhostConfig.name); | ||
createChannelWhenInitialised(options.confirm, (err, channel) => { | ||
@@ -214,7 +214,7 @@ if (err) return deferRejection(reject, err); | ||
const destroyChannel = _.once(() => { | ||
debug('Destroying %s channel: %s for vhost: %s due to error or close event', mode, channel._rascal_id, config.name); | ||
debug('Destroying %s channel: %s for vhost: %s due to error or close event', mode, channel._rascal_id, vhostConfig.name); | ||
channel._rascal_closed = true; | ||
if (pool.isBorrowedResource(channel)) { | ||
pool.destroy(channel).catch((err) => { | ||
debug('Error destroying %s channel: %s for vhost: %s. %s', mode, channel._rascal_id, config.name, err.message); | ||
debug('Error destroying %s channel: %s for vhost: %s. %s', mode, channel._rascal_id, vhostConfig.name, err.message); | ||
}); | ||
@@ -231,4 +231,7 @@ } | ||
return new Promise((resolve, reject) => { | ||
debug('Destroying %s channel: %s for vhost: %s', mode, channel._rascal_id, config.name); | ||
if (channel._rascal_closed) return resolve(); | ||
debug('Destroying %s channel: %s for vhost: %s', mode, channel._rascal_id, vhostConfig.name); | ||
if (channel._rascal_closed) { | ||
resolve(); | ||
return; | ||
} | ||
channel.removeAllListeners(); | ||
@@ -246,3 +249,3 @@ channel.on('error', reject); | ||
setTimeoutUnref(() => { | ||
once(new Error(format('Timeout after %dms closing %s channel: %s for vhost: %s', options.pool.destroyTimeoutMillis, mode, channel._rascal_id, config.name))); | ||
once(new Error(format('Timeout after %dms closing %s channel: %s for vhost: %s', options.pool.destroyTimeoutMillis, mode, channel._rascal_id, vhostConfig.name))); | ||
}, 1000); | ||
@@ -463,3 +466,3 @@ channel.close(once); | ||
confirm: false, | ||
pool: config.publicationChannelPools.regularPool, | ||
pool: vhostConfig.publicationChannelPools.regularPool, | ||
}); | ||
@@ -470,3 +473,3 @@ confirmChannelPool = | ||
confirm: true, | ||
pool: config.publicationChannelPools.confirmPool, | ||
pool: vhostConfig.publicationChannelPools.confirmPool, | ||
}); | ||
@@ -473,0 +476,0 @@ } |
@@ -0,4 +1,7 @@ | ||
const exponential = require('./exponential'); | ||
const linear = require('./linear'); | ||
const strategies = { | ||
exponential: require('./exponential'), | ||
linear: require('./linear'), | ||
exponential, | ||
linear, | ||
}; | ||
@@ -5,0 +8,0 @@ |
@@ -6,5 +6,5 @@ const debug = require('debug')('rascal:config:configure'); | ||
const uuid = require('uuid').v4; | ||
const XRegExp = require('xregexp'); | ||
const baseline = require('./baseline'); | ||
const fqn = require('./fqn'); | ||
const XRegExp = require('xregexp'); | ||
@@ -93,3 +93,3 @@ module.exports = _.curry((rascalConfig, next) => { | ||
function getAuth(user, password) { | ||
return user && password ? user + ':' + password : undefined; | ||
return user && password ? `${user}:${password}` : undefined; | ||
} | ||
@@ -116,2 +116,3 @@ | ||
vhosts, | ||
/* eslint-disable-next-line no-shadow */ | ||
(publications, vhost) => { | ||
@@ -166,2 +167,3 @@ _.each(vhost.exchanges, (exchange) => { | ||
vhosts, | ||
/* eslint-disable-next-line no-shadow */ | ||
(subscriptions, vhost) => { | ||
@@ -223,3 +225,3 @@ _.each(vhost.queues, (queue) => { | ||
const counterType = counterConfig.type || name; | ||
const counterDefaultConfigPath = 'defaults.redeliveries.counters.' + counterType; | ||
const counterDefaultConfigPath = `defaults.redeliveries.counters.${counterType}`; | ||
const counterDefaults = _.get(rascalConfig, counterDefaultConfigPath); | ||
@@ -317,3 +319,3 @@ rascalConfig.redeliveries.counters[name] = _.defaultsDeep(counterConfig, { name, type: name }, counterDefaults); | ||
.map((item) => { | ||
return _.isString(item) ? { name: item } : _.defaults(item, { name: 'unnamed-' + uuid() }); | ||
return _.isString(item) ? { name: item } : _.defaults(item, { name: `unnamed-${uuid()}` }); | ||
}) | ||
@@ -320,0 +322,0 @@ .keyBy('name') |
@@ -14,8 +14,8 @@ module.exports = { | ||
function prefix(prefix, name, separator) { | ||
return prefix ? prefix + (separator || ':') + name : name; | ||
function prefix(text, name, separator) { | ||
return text ? text + (separator || ':') + name : name; | ||
} | ||
function suffix(suffix, name, separator) { | ||
return suffix ? name + (separator || ':') + suffix : name; | ||
function suffix(text, name, separator) { | ||
return text ? name + (separator || ':') + text : name; | ||
} |
@@ -0,5 +1,9 @@ | ||
const stub = require('./stub'); | ||
const inMemory = require('./inMemory'); | ||
const inMemoryCluster = require('./inMemoryCluster'); | ||
module.exports = { | ||
stub: require('./stub'), | ||
inMemory: require('./inMemory'), | ||
inMemoryCluster: require('./inMemoryCluster'), | ||
stub, | ||
inMemory, | ||
inMemoryCluster, | ||
}; |
const cluster = require('cluster'); | ||
const inMemory = require('./inMemory'); | ||
const uuid = require('uuid').v4; | ||
const Stashback = require('stashback'); | ||
const inMemory = require('./inMemory'); | ||
const debug = 'rascal:counters:inMemoryCluster'; | ||
@@ -6,0 +7,0 @@ |
{ | ||
"name": "rascal", | ||
"version": "14.4.5", | ||
"version": "15.0.0", | ||
"description": "A config driven wrapper for amqplib supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption, channel pooling and publication timeouts", | ||
"main": "index.js", | ||
"dependencies": { | ||
"async": "^3.2.3", | ||
"async": "^3.2.4", | ||
"debug": "^4.3.4", | ||
@@ -20,9 +20,10 @@ "forward-emitter": "^0.1.1", | ||
"devDependencies": { | ||
"amqplib": "^0.9.1", | ||
"amqplib": "^0.10.2", | ||
"chalk": "^4.1.2", | ||
"chance": "^1.1.8", | ||
"eslint": "^7.32.0", | ||
"eslint": "^8.21.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"husky": "^6.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"husky": "^8.0.1", | ||
"lint-staged": "^11.2.4", | ||
@@ -39,3 +40,3 @@ "nyc": "^15.1.0", | ||
"engines": { | ||
"node": ">=10.0.0" | ||
"node": ">=12.0.0" | ||
}, | ||
@@ -45,3 +46,5 @@ "scripts": { | ||
"prettier": "prettier --check .", | ||
"prettier:fix": "prettier --write .", | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix .", | ||
"lint-staged": "lint-staged", | ||
@@ -53,3 +56,4 @@ "coverage": "nyc --report html --reporter lcov --reporter text-summary zUnit", | ||
"lint-staged": { | ||
"**/*": "prettier --write --ignore-unknown" | ||
"**/*": "prettier --write --ignore-unknown", | ||
"**/*.js": "eslint --fix" | ||
}, | ||
@@ -56,0 +60,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
236207
76
4246
14
Updatedasync@^3.2.4