rascal 14.4.4 → 15.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +25 -0
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/index.js +2 -1
- package/lib/amqp/Broker.js +8 -4
- package/lib/amqp/BrokerAsPromised.js +2 -1
- package/lib/amqp/SubscriberError.js +2 -2
- package/lib/amqp/SubscriberSession.js +1 -1
- package/lib/amqp/Subscription.js +17 -17
- package/lib/amqp/Vhost.js +20 -17
- package/lib/amqp/tasks/index.js +25 -25
- package/lib/amqp/tasks/initVhosts.js +2 -0
- package/lib/backoff/index.js +5 -2
- package/lib/config/configure.js +7 -5
- package/lib/config/fqn.js +4 -4
- package/lib/counters/inMemoryCluster.js +2 -1
- package/lib/counters/index.js +7 -3
- package/package.json +12 -8
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["eslint-config-airbnb-base", "prettier"],
|
|
3
|
+
"env": {
|
|
4
|
+
"node": true
|
|
5
|
+
},
|
|
6
|
+
"parserOptions": {
|
|
7
|
+
"ecmaVersion": "2015"
|
|
8
|
+
},
|
|
9
|
+
"rules": {
|
|
10
|
+
"arrow-body-style": 0,
|
|
11
|
+
"consistent-return": 0,
|
|
12
|
+
"func-names": 0,
|
|
13
|
+
"no-param-reassign": 0,
|
|
14
|
+
"no-plusplus": 0,
|
|
15
|
+
"no-restricted-properties": 0,
|
|
16
|
+
"no-shadow": ["error", { "allow": ["cb", "err"] }],
|
|
17
|
+
"no-underscore-dangle": 0,
|
|
18
|
+
"no-unused-expressions": 0,
|
|
19
|
+
"no-unused-vars": ["error", { "varsIgnorePattern": "^debug$", "argsIgnorePattern": "^_\\w+" }],
|
|
20
|
+
"no-use-before-define": 0,
|
|
21
|
+
"prefer-destructuring": 0,
|
|
22
|
+
"prefer-exponentiation-operator": 0,
|
|
23
|
+
"prefer-rest-params": 0
|
|
24
|
+
}
|
|
25
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 15.0.1
|
|
4
|
+
|
|
5
|
+
- Fix MaxListenersExceeded warning when there are more than 10 vhosts - See https://github.com/guidesmiths/rascal/issues/206
|
|
6
|
+
|
|
7
|
+
## 15.0.0
|
|
8
|
+
|
|
9
|
+
- Drop support for Node 10
|
|
10
|
+
- Introduce eslint-config-airbnb-base
|
|
11
|
+
|
|
12
|
+
## 14.4.5
|
|
13
|
+
|
|
14
|
+
- Fixed issue where a partial password could be logged in debug - See https://github.com/guidesmiths/rascal/issues/200 - thanks @matt1097
|
|
15
|
+
|
|
3
16
|
## 14.4.4
|
|
4
17
|
|
|
5
18
|
- Fixed issue where channels were not returned to the pool after publishing a large messag - See https://github.com/guidesmiths/rascal/issues/199
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ Rascal seeks to either solve these problems, make them easier to deal with or br
|
|
|
40
40
|
|
|
41
41
|
## Concepts
|
|
42
42
|
|
|
43
|
-
Rascal extends the existing [RabbitMQ Concepts](https://www.rabbitmq.com/tutorials/amqp-concepts.html) of Brokers, Vhosts, Exchanges, Queues, Channels and Connections with
|
|
43
|
+
Rascal extends the existing [RabbitMQ Concepts](https://www.rabbitmq.com/tutorials/amqp-concepts.html) of Brokers, Vhosts, Exchanges, Queues, Channels and Connections with two new ones
|
|
44
44
|
|
|
45
45
|
1. Publications
|
|
46
46
|
1. Subscriptions
|
package/index.js
CHANGED
|
@@ -3,6 +3,7 @@ const defaultConfig = require('./lib/config/defaults');
|
|
|
3
3
|
const testConfig = require('./lib/config/tests');
|
|
4
4
|
const Broker = require('./lib/amqp/Broker');
|
|
5
5
|
const BrokerAsPromised = require('./lib/amqp/BrokerAsPromised');
|
|
6
|
+
const counters = require('./lib/counters');
|
|
6
7
|
|
|
7
8
|
module.exports = (function () {
|
|
8
9
|
return {
|
|
@@ -18,6 +19,6 @@ module.exports = (function () {
|
|
|
18
19
|
withTestConfig(config) {
|
|
19
20
|
return _.defaultsDeep({}, config, testConfig);
|
|
20
21
|
},
|
|
21
|
-
counters
|
|
22
|
+
counters,
|
|
22
23
|
};
|
|
23
24
|
})();
|
package/lib/amqp/Broker.js
CHANGED
|
@@ -8,11 +8,12 @@ const tasks = require('./tasks');
|
|
|
8
8
|
const configure = require('../config/configure');
|
|
9
9
|
const validate = require('../config/validate');
|
|
10
10
|
const fqn = require('../config/fqn');
|
|
11
|
+
|
|
11
12
|
const preflight = async.compose(validate, configure);
|
|
12
13
|
const stub = require('../counters/stub');
|
|
13
14
|
const inMemory = require('../counters/inMemory');
|
|
14
15
|
const inMemoryCluster = require('../counters/inMemoryCluster').worker;
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
const maxInterval = 2147483647;
|
|
17
18
|
|
|
18
19
|
module.exports = {
|
|
@@ -25,9 +26,9 @@ module.exports = {
|
|
|
25
26
|
inMemoryCluster,
|
|
26
27
|
});
|
|
27
28
|
|
|
28
|
-
preflight(_.cloneDeep(config), (err,
|
|
29
|
+
preflight(_.cloneDeep(config), (err, augmentedConfig) => {
|
|
29
30
|
if (err) return next(err);
|
|
30
|
-
new Broker(
|
|
31
|
+
new Broker(augmentedConfig, _.assign({}, components, { counters }))._init(next);
|
|
31
32
|
});
|
|
32
33
|
},
|
|
33
34
|
};
|
|
@@ -141,7 +142,9 @@ function Broker(config, components) {
|
|
|
141
142
|
},
|
|
142
143
|
(err) => {
|
|
143
144
|
if (err) return next(err);
|
|
144
|
-
vhosts =
|
|
145
|
+
vhosts = {};
|
|
146
|
+
publications = {};
|
|
147
|
+
subscriptions = {};
|
|
145
148
|
clearInterval(self.keepActive);
|
|
146
149
|
debug('Finished nuking broker');
|
|
147
150
|
next();
|
|
@@ -209,6 +212,7 @@ function Broker(config, components) {
|
|
|
209
212
|
});
|
|
210
213
|
};
|
|
211
214
|
|
|
215
|
+
/* eslint-disable-next-line no-multi-assign */
|
|
212
216
|
this.getFullyQualifiedName = this.qualify = function (vhost, name) {
|
|
213
217
|
return fqn.qualify(name, config.vhosts[vhost].namespace);
|
|
214
218
|
};
|
|
@@ -15,7 +15,7 @@ module.exports = {
|
|
|
15
15
|
broker.promises = true;
|
|
16
16
|
const brokerAsPromised = new BrokerAsPromised(broker);
|
|
17
17
|
if (!err) return resolve(brokerAsPromised);
|
|
18
|
-
err.broker = Symbol();
|
|
18
|
+
err.broker = Symbol('broker-as-promised');
|
|
19
19
|
Object.defineProperty(err, err.broker, {
|
|
20
20
|
enumerable: false,
|
|
21
21
|
value: brokerAsPromised,
|
|
@@ -80,6 +80,7 @@ function BrokerAsPromised(broker) {
|
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
+
/* eslint-disable-next-line no-multi-assign */
|
|
83
84
|
this.getFullyQualifiedName = this.qualify = function (vhost, name) {
|
|
84
85
|
return broker.qualify(vhost, name);
|
|
85
86
|
};
|
|
@@ -87,7 +87,7 @@ module.exports = function SubscriptionRecovery(broker, vhost) {
|
|
|
87
87
|
|
|
88
88
|
vhost.getConfirmChannel((err, publisherChannel) => {
|
|
89
89
|
const nackMessage = (err) => {
|
|
90
|
-
session._nack(message, (
|
|
90
|
+
session._nack(message, (_nackErr) => {
|
|
91
91
|
// nackError just means the channel was already closed meaning the original message would have been rolled back
|
|
92
92
|
once(err);
|
|
93
93
|
});
|
|
@@ -140,7 +140,7 @@ module.exports = function SubscriptionRecovery(broker, vhost) {
|
|
|
140
140
|
_.set(forwardOverrides, 'options.headers.rascal.error.code', err.code);
|
|
141
141
|
|
|
142
142
|
const nackMessage = (err) => {
|
|
143
|
-
session._nack(message, (
|
|
143
|
+
session._nack(message, (_nackErr) => {
|
|
144
144
|
// nackError just means the channel was already closed meaning the original message would have been rolled back
|
|
145
145
|
once(err);
|
|
146
146
|
});
|
|
@@ -133,7 +133,7 @@ function SubscriberSession(sequentialChannelOperations, config) {
|
|
|
133
133
|
function withCurrentChannel(fn, altFn) {
|
|
134
134
|
const entry = _.chain(channels)
|
|
135
135
|
.values()
|
|
136
|
-
.filter((
|
|
136
|
+
.filter((e) => !e.doomed)
|
|
137
137
|
.sortBy('index')
|
|
138
138
|
.last()
|
|
139
139
|
.value();
|
package/lib/amqp/Subscription.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const debug = require('debug')('rascal:Subscription');
|
|
2
2
|
const _ = require('lodash');
|
|
3
|
+
const format = require('util').format;
|
|
4
|
+
const crypto = require('crypto');
|
|
5
|
+
const async = require('async');
|
|
3
6
|
const safeParse = require('safe-json-parse/callback');
|
|
4
7
|
const SubscriberSession = require('./SubscriberSession');
|
|
5
8
|
const SubscriberError = require('./SubscriberError');
|
|
6
|
-
const format = require('util').format;
|
|
7
9
|
const backoff = require('../backoff');
|
|
8
|
-
const crypto = require('crypto');
|
|
9
|
-
const async = require('async');
|
|
10
10
|
const setTimeoutUnref = require('../utils/setTimeoutUnref');
|
|
11
11
|
|
|
12
12
|
module.exports = {
|
|
@@ -15,24 +15,24 @@ module.exports = {
|
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
function Subscription(broker, vhost,
|
|
19
|
-
const timer = backoff(
|
|
18
|
+
function Subscription(broker, vhost, subscriptionConfig, counter) {
|
|
19
|
+
const timer = backoff(subscriptionConfig.retry);
|
|
20
20
|
const subscriberError = new SubscriberError(broker, vhost);
|
|
21
21
|
const sequentialChannelOperations = async.queue((task, next) => {
|
|
22
22
|
task(next);
|
|
23
23
|
}, 1);
|
|
24
24
|
const self = this;
|
|
25
25
|
|
|
26
|
-
this.name =
|
|
26
|
+
this.name = subscriptionConfig.name;
|
|
27
27
|
|
|
28
28
|
this.init = function (next) {
|
|
29
|
-
debug('Initialising subscription: %s',
|
|
29
|
+
debug('Initialising subscription: %s', subscriptionConfig.name);
|
|
30
30
|
return next(null, self);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
this.subscribe = function (overrides, next) {
|
|
34
|
-
const session = new SubscriberSession(sequentialChannelOperations,
|
|
35
|
-
subscribeLater(session, _.defaultsDeep(overrides,
|
|
34
|
+
const session = new SubscriberSession(sequentialChannelOperations, subscriptionConfig);
|
|
35
|
+
subscribeLater(session, _.defaultsDeep(overrides, subscriptionConfig));
|
|
36
36
|
return next(null, session);
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -141,7 +141,7 @@ function Subscription(broker, vhost, config, counter) {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
function redeliveriesExceeded(message) {
|
|
144
|
-
return message.properties.headers.rascal.redeliveries >
|
|
144
|
+
return message.properties.headers.rascal.redeliveries > subscriptionConfig.redeliveries.limit;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
function handleRedeliveriesError(err, session, message) {
|
|
@@ -152,7 +152,7 @@ function Subscription(broker, vhost, config, counter) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
function handleRedeliveriesExceeded(session, message) {
|
|
155
|
-
const err = new Error(format('Message %s has exceeded %d redeliveries', message.properties.messageId,
|
|
155
|
+
const err = new Error(format('Message %s has exceeded %d redeliveries', message.properties.messageId, subscriptionConfig.redeliveries.limit));
|
|
156
156
|
debug(err.message);
|
|
157
157
|
if (session.emit('redeliveries_exceeded', err, message, getAckOrNack(session, message))) return;
|
|
158
158
|
if (session.emit('redeliveries_error', err, message, getAckOrNack(session, message))) return;
|
|
@@ -170,7 +170,7 @@ function Subscription(broker, vhost, config, counter) {
|
|
|
170
170
|
function decorateWithRoutingHeaders(message) {
|
|
171
171
|
message.properties.headers = message.properties.headers || {};
|
|
172
172
|
message.properties.headers.rascal = message.properties.headers.rascal || {};
|
|
173
|
-
message.properties.headers.rascal.originalQueue =
|
|
173
|
+
message.properties.headers.rascal.originalQueue = subscriptionConfig.source;
|
|
174
174
|
message.properties.headers.rascal.originalVhost = vhost.name;
|
|
175
175
|
|
|
176
176
|
if (!message.properties.headers.rascal.restoreRoutingHeaders) return;
|
|
@@ -181,8 +181,8 @@ function Subscription(broker, vhost, config, counter) {
|
|
|
181
181
|
function decorateWithRedeliveries(message, next) {
|
|
182
182
|
const once = _.once(next);
|
|
183
183
|
const timeout = setTimeoutUnref(() => {
|
|
184
|
-
once(new Error(format('Redeliveries timed out after %dms',
|
|
185
|
-
},
|
|
184
|
+
once(new Error(format('Redeliveries timed out after %dms', subscriptionConfig.redeliveries.timeout)));
|
|
185
|
+
}, subscriptionConfig.redeliveries.timeout);
|
|
186
186
|
countRedeliveries(message, (err, redeliveries) => {
|
|
187
187
|
clearTimeout(timeout);
|
|
188
188
|
if (err) return once(err);
|
|
@@ -194,7 +194,7 @@ function Subscription(broker, vhost, config, counter) {
|
|
|
194
194
|
function countRedeliveries(message, next) {
|
|
195
195
|
if (!message.fields.redelivered) return next(null, 0);
|
|
196
196
|
if (!message.properties.messageId) return next(null, 0);
|
|
197
|
-
counter.incrementAndGet(
|
|
197
|
+
counter.incrementAndGet(`${subscriptionConfig.name}/${message.properties.messageId}`, next);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
function immediateNack(message) {
|
|
@@ -203,8 +203,8 @@ function Subscription(broker, vhost, config, counter) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
function getAckOrNack(session, message) {
|
|
206
|
-
if (!broker.promises ||
|
|
207
|
-
if (
|
|
206
|
+
if (!broker.promises || subscriptionConfig.promisifyAckOrNack === false) return ackOrNack.bind(null, session, message);
|
|
207
|
+
if (subscriptionConfig.promisifyAckOrNack) return ackOrNackP.bind(null, session, message);
|
|
208
208
|
return ackOrNack.bind(null, session, message);
|
|
209
209
|
}
|
|
210
210
|
|
package/lib/amqp/Vhost.js
CHANGED
|
@@ -4,9 +4,9 @@ const inherits = require('util').inherits;
|
|
|
4
4
|
const EventEmitter = require('events').EventEmitter;
|
|
5
5
|
const async = require('async');
|
|
6
6
|
const genericPool = require('generic-pool');
|
|
7
|
-
const tasks = require('./tasks');
|
|
8
7
|
const uuid = require('uuid').v4;
|
|
9
8
|
const _ = require('lodash');
|
|
9
|
+
const tasks = require('./tasks');
|
|
10
10
|
const backoff = require('../backoff');
|
|
11
11
|
const setTimeoutUnref = require('../utils/setTimeoutUnref');
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
|
|
19
19
|
inherits(Vhost, EventEmitter);
|
|
20
20
|
|
|
21
|
-
function Vhost(
|
|
21
|
+
function Vhost(vhostConfig, components) {
|
|
22
22
|
const self = this;
|
|
23
23
|
let connection;
|
|
24
24
|
let connectionConfig;
|
|
@@ -35,7 +35,7 @@ function Vhost(config, components) {
|
|
|
35
35
|
let shuttingDown = false;
|
|
36
36
|
let reconnectTimeout;
|
|
37
37
|
|
|
38
|
-
this.name =
|
|
38
|
+
this.name = vhostConfig.name;
|
|
39
39
|
this.connectionIndex = 0;
|
|
40
40
|
|
|
41
41
|
pauseChannelAllocation();
|
|
@@ -49,7 +49,7 @@ function Vhost(config, components) {
|
|
|
49
49
|
debug('Initialising vhost: %s', self.name);
|
|
50
50
|
pauseChannelAllocation();
|
|
51
51
|
|
|
52
|
-
init(
|
|
52
|
+
init(vhostConfig, { connectionIndex: self.connectionIndex, components }, (err, config, ctx) => {
|
|
53
53
|
if (err) return next(err);
|
|
54
54
|
|
|
55
55
|
connection = ctx.connection;
|
|
@@ -95,7 +95,7 @@ function Vhost(config, components) {
|
|
|
95
95
|
pauseChannelAllocation();
|
|
96
96
|
drainChannelPools((err) => {
|
|
97
97
|
if (err) return next(err);
|
|
98
|
-
nuke(
|
|
98
|
+
nuke(vhostConfig, { connectionIndex: self.connectionIndex }, (err) => {
|
|
99
99
|
if (err) return next(err);
|
|
100
100
|
debug('Finished nuking vhost: %s', self.name);
|
|
101
101
|
setImmediate(next);
|
|
@@ -105,7 +105,7 @@ function Vhost(config, components) {
|
|
|
105
105
|
|
|
106
106
|
this.purge = function (next) {
|
|
107
107
|
debug('Purging vhost: %s', self.name);
|
|
108
|
-
purge(
|
|
108
|
+
purge(vhostConfig, { purge: true, connectionIndex: self.connectionIndex }, (err) => {
|
|
109
109
|
if (err) return next(err);
|
|
110
110
|
debug('Finished purging vhost: %s', self.name);
|
|
111
111
|
setImmediate(next);
|
|
@@ -122,7 +122,7 @@ function Vhost(config, components) {
|
|
|
122
122
|
|
|
123
123
|
this.connect = function (next) {
|
|
124
124
|
debug('Connecting to vhost: %s', self.name);
|
|
125
|
-
connect(
|
|
125
|
+
connect(vhostConfig, { connectionIndex: self.connectionIndex }, (err, config, ctx) => {
|
|
126
126
|
return next(err, ctx.connection);
|
|
127
127
|
});
|
|
128
128
|
};
|
|
@@ -190,23 +190,23 @@ function Vhost(config, components) {
|
|
|
190
190
|
|
|
191
191
|
function createChannelPool(options) {
|
|
192
192
|
const mode = getChannelMode(options.confirm);
|
|
193
|
-
|
|
194
|
-
let
|
|
193
|
+
let pool;
|
|
194
|
+
let poolQueue;
|
|
195
195
|
let busy = false;
|
|
196
196
|
|
|
197
197
|
const factory = {
|
|
198
198
|
create() {
|
|
199
199
|
return new Promise((resolve, reject) => {
|
|
200
|
-
debug('Creating pooled %s channel for vhost: %s', mode,
|
|
200
|
+
debug('Creating pooled %s channel for vhost: %s', mode, vhostConfig.name);
|
|
201
201
|
createChannelWhenInitialised(options.confirm, (err, channel) => {
|
|
202
202
|
if (err) return deferRejection(reject, err);
|
|
203
203
|
if (!channel) return deferRejection(reject, new Error('Vhost is shutting down'));
|
|
204
204
|
const destroyChannel = _.once(() => {
|
|
205
|
-
debug('Destroying %s channel: %s for vhost: %s due to error or close event', mode, channel._rascal_id,
|
|
205
|
+
debug('Destroying %s channel: %s for vhost: %s due to error or close event', mode, channel._rascal_id, vhostConfig.name);
|
|
206
206
|
channel._rascal_closed = true;
|
|
207
207
|
if (pool.isBorrowedResource(channel)) {
|
|
208
208
|
pool.destroy(channel).catch((err) => {
|
|
209
|
-
debug('Error destroying %s channel: %s for vhost: %s. %s', mode, channel._rascal_id,
|
|
209
|
+
debug('Error destroying %s channel: %s for vhost: %s. %s', mode, channel._rascal_id, vhostConfig.name, err.message);
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
});
|
|
@@ -218,8 +218,11 @@ function Vhost(config, components) {
|
|
|
218
218
|
},
|
|
219
219
|
destroy(channel) {
|
|
220
220
|
return new Promise((resolve, reject) => {
|
|
221
|
-
debug('Destroying %s channel: %s for vhost: %s', mode, channel._rascal_id,
|
|
222
|
-
if (channel._rascal_closed)
|
|
221
|
+
debug('Destroying %s channel: %s for vhost: %s', mode, channel._rascal_id, vhostConfig.name);
|
|
222
|
+
if (channel._rascal_closed) {
|
|
223
|
+
resolve();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
223
226
|
channel.removeAllListeners();
|
|
224
227
|
channel.on('error', reject);
|
|
225
228
|
const closeChannelCb = (err) => {
|
|
@@ -232,7 +235,7 @@ function Vhost(config, components) {
|
|
|
232
235
|
// will never receive a response from the broker, and the callback will never yield.
|
|
233
236
|
const once = _.once(closeChannelCb);
|
|
234
237
|
setTimeoutUnref(() => {
|
|
235
|
-
once(new Error(format('Timeout after %dms closing %s channel: %s for vhost: %s', options.pool.destroyTimeoutMillis, mode, channel._rascal_id,
|
|
238
|
+
once(new Error(format('Timeout after %dms closing %s channel: %s for vhost: %s', options.pool.destroyTimeoutMillis, mode, channel._rascal_id, vhostConfig.name)));
|
|
236
239
|
}, 1000);
|
|
237
240
|
channel.close(once);
|
|
238
241
|
});
|
|
@@ -448,13 +451,13 @@ function Vhost(config, components) {
|
|
|
448
451
|
regularChannelPool ||
|
|
449
452
|
createChannelPool({
|
|
450
453
|
confirm: false,
|
|
451
|
-
pool:
|
|
454
|
+
pool: vhostConfig.publicationChannelPools.regularPool,
|
|
452
455
|
});
|
|
453
456
|
confirmChannelPool =
|
|
454
457
|
confirmChannelPool ||
|
|
455
458
|
createChannelPool({
|
|
456
459
|
confirm: true,
|
|
457
|
-
pool:
|
|
460
|
+
pool: vhostConfig.publicationChannelPools.confirmPool,
|
|
458
461
|
});
|
|
459
462
|
}
|
|
460
463
|
|
package/lib/amqp/tasks/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
exports.applyBindings = require('./applyBindings
|
|
2
|
-
exports.assertExchanges = require('./assertExchanges
|
|
3
|
-
exports.assertQueues = require('./assertQueues
|
|
4
|
-
exports.assertVhost = require('./assertVhost
|
|
5
|
-
exports.bounceVhost = require('./bounceVhost
|
|
6
|
-
exports.checkExchanges = require('./checkExchanges
|
|
7
|
-
exports.checkQueues = require('./checkQueues
|
|
8
|
-
exports.checkVhost = require('./checkVhost
|
|
9
|
-
exports.closeChannel = require('./closeChannel
|
|
10
|
-
exports.closeConnection = require('./closeConnection
|
|
11
|
-
exports.createChannel = require('./createChannel
|
|
12
|
-
exports.createConnection = require('./createConnection
|
|
13
|
-
exports.deleteExchanges = require('./deleteExchanges
|
|
14
|
-
exports.deleteQueues = require('./deleteQueues
|
|
15
|
-
exports.deleteVhost = require('./deleteVhost
|
|
16
|
-
exports.initCounters = require('./initCounters
|
|
17
|
-
exports.initPublications = require('./initPublications
|
|
18
|
-
exports.initShovels = require('./initShovels
|
|
19
|
-
exports.initSubscriptions = require('./initSubscriptions
|
|
20
|
-
exports.initVhosts = require('./initVhosts
|
|
21
|
-
exports.nukeVhost = require('./nukeVhost
|
|
22
|
-
exports.purgeQueues = require('./purgeQueues
|
|
23
|
-
exports.purgeVhost = require('./purgeVhost
|
|
24
|
-
exports.forewarnVhost = require('./forewarnVhost
|
|
25
|
-
exports.shutdownVhost = require('./shutdownVhost
|
|
1
|
+
exports.applyBindings = require('./applyBindings');
|
|
2
|
+
exports.assertExchanges = require('./assertExchanges');
|
|
3
|
+
exports.assertQueues = require('./assertQueues');
|
|
4
|
+
exports.assertVhost = require('./assertVhost');
|
|
5
|
+
exports.bounceVhost = require('./bounceVhost');
|
|
6
|
+
exports.checkExchanges = require('./checkExchanges');
|
|
7
|
+
exports.checkQueues = require('./checkQueues');
|
|
8
|
+
exports.checkVhost = require('./checkVhost');
|
|
9
|
+
exports.closeChannel = require('./closeChannel');
|
|
10
|
+
exports.closeConnection = require('./closeConnection');
|
|
11
|
+
exports.createChannel = require('./createChannel');
|
|
12
|
+
exports.createConnection = require('./createConnection');
|
|
13
|
+
exports.deleteExchanges = require('./deleteExchanges');
|
|
14
|
+
exports.deleteQueues = require('./deleteQueues');
|
|
15
|
+
exports.deleteVhost = require('./deleteVhost');
|
|
16
|
+
exports.initCounters = require('./initCounters');
|
|
17
|
+
exports.initPublications = require('./initPublications');
|
|
18
|
+
exports.initShovels = require('./initShovels');
|
|
19
|
+
exports.initSubscriptions = require('./initSubscriptions');
|
|
20
|
+
exports.initVhosts = require('./initVhosts');
|
|
21
|
+
exports.nukeVhost = require('./nukeVhost');
|
|
22
|
+
exports.purgeQueues = require('./purgeQueues');
|
|
23
|
+
exports.purgeVhost = require('./purgeVhost');
|
|
24
|
+
exports.forewarnVhost = require('./forewarnVhost');
|
|
25
|
+
exports.shutdownVhost = require('./shutdownVhost');
|
|
@@ -6,6 +6,8 @@ const Vhost = require('../Vhost');
|
|
|
6
6
|
|
|
7
7
|
module.exports = _.curry((config, ctx, next) => {
|
|
8
8
|
ctx.vhosts = {};
|
|
9
|
+
const maxListeners = Math.max(ctx.broker.getMaxListeners(), Object.keys(config.vhosts).length);
|
|
10
|
+
ctx.broker.setMaxListeners(maxListeners);
|
|
9
11
|
async.eachSeries(
|
|
10
12
|
_.values(config.vhosts),
|
|
11
13
|
(vhostConfig, callback) => {
|
package/lib/backoff/index.js
CHANGED
package/lib/config/configure.js
CHANGED
|
@@ -3,9 +3,9 @@ const format = require('util').format;
|
|
|
3
3
|
const url = require('url');
|
|
4
4
|
const _ = require('lodash');
|
|
5
5
|
const uuid = require('uuid').v4;
|
|
6
|
+
const XRegExp = require('xregexp');
|
|
6
7
|
const baseline = require('./baseline');
|
|
7
8
|
const fqn = require('./fqn');
|
|
8
|
-
const XRegExp = require('xregexp');
|
|
9
9
|
|
|
10
10
|
module.exports = _.curry((rascalConfig, next) => {
|
|
11
11
|
rascalConfig = _.defaultsDeep(rascalConfig, baseline);
|
|
@@ -76,7 +76,7 @@ module.exports = _.curry((rascalConfig, next) => {
|
|
|
76
76
|
connection.pathname = connection.vhost === '/' ? '' : connection.vhost;
|
|
77
77
|
connection.query = connection.options;
|
|
78
78
|
connection.url = connection.url || url.format(connection);
|
|
79
|
-
connection.loggableUrl = connection.url.replace(/:[^:]
|
|
79
|
+
connection.loggableUrl = connection.url.replace(/:[^:]*@/, ':***@');
|
|
80
80
|
connection.index = getConnectionIndex(vhostConfig.connectionStrategy, connection, index);
|
|
81
81
|
configureManagementConnection(vhostConfig, vhostName, connection);
|
|
82
82
|
}
|
|
@@ -89,7 +89,7 @@ module.exports = _.curry((rascalConfig, next) => {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function getAuth(user, password) {
|
|
92
|
-
return user && password ? user
|
|
92
|
+
return user && password ? `${user}:${password}` : undefined;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
function getConnectionIndex(strategy, connection, index) {
|
|
@@ -111,6 +111,7 @@ module.exports = _.curry((rascalConfig, next) => {
|
|
|
111
111
|
function configurePublications(publications, vhosts) {
|
|
112
112
|
const defaultPublications = _.reduce(
|
|
113
113
|
vhosts,
|
|
114
|
+
/* eslint-disable-next-line no-shadow */
|
|
114
115
|
(publications, vhost) => {
|
|
115
116
|
_.each(vhost.exchanges, (exchange) => {
|
|
116
117
|
const name = vhost.name === '/' ? format('/%s', exchange.name) : format('%s/%s', vhost.name, exchange.name);
|
|
@@ -160,6 +161,7 @@ module.exports = _.curry((rascalConfig, next) => {
|
|
|
160
161
|
function configureSubscriptions(subscriptions, vhosts) {
|
|
161
162
|
const defaultSubscriptions = _.reduce(
|
|
162
163
|
vhosts,
|
|
164
|
+
/* eslint-disable-next-line no-shadow */
|
|
163
165
|
(subscriptions, vhost) => {
|
|
164
166
|
_.each(vhost.queues, (queue) => {
|
|
165
167
|
const name = vhost.name === '/' ? format('/%s', queue.name) : format('%s/%s', vhost.name, queue.name);
|
|
@@ -216,7 +218,7 @@ module.exports = _.curry((rascalConfig, next) => {
|
|
|
216
218
|
function configureCounter(counterConfig, name) {
|
|
217
219
|
debug('Configuring counter: %s', name);
|
|
218
220
|
const counterType = counterConfig.type || name;
|
|
219
|
-
const counterDefaultConfigPath =
|
|
221
|
+
const counterDefaultConfigPath = `defaults.redeliveries.counters.${counterType}`;
|
|
220
222
|
const counterDefaults = _.get(rascalConfig, counterDefaultConfigPath);
|
|
221
223
|
rascalConfig.redeliveries.counters[name] = _.defaultsDeep(counterConfig, { name, type: name }, counterDefaults);
|
|
222
224
|
}
|
|
@@ -309,7 +311,7 @@ module.exports = _.curry((rascalConfig, next) => {
|
|
|
309
311
|
if (!_.isArray(collection)) return collection;
|
|
310
312
|
return _.chain(collection)
|
|
311
313
|
.map((item) => {
|
|
312
|
-
return _.isString(item) ? { name: item } : _.defaults(item, { name:
|
|
314
|
+
return _.isString(item) ? { name: item } : _.defaults(item, { name: `unnamed-${uuid()}` });
|
|
313
315
|
})
|
|
314
316
|
.keyBy('name')
|
|
315
317
|
.value();
|
package/lib/config/fqn.js
CHANGED
|
@@ -11,10 +11,10 @@ function qualify(name, namespace, unique) {
|
|
|
11
11
|
return name;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function prefix(
|
|
15
|
-
return
|
|
14
|
+
function prefix(text, name, separator) {
|
|
15
|
+
return text ? text + (separator || ':') + name : name;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function suffix(
|
|
19
|
-
return
|
|
18
|
+
function suffix(text, name, separator) {
|
|
19
|
+
return text ? name + (separator || ':') + text : name;
|
|
20
20
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const cluster = require('cluster');
|
|
2
|
-
const inMemory = require('./inMemory');
|
|
3
2
|
const uuid = require('uuid').v4;
|
|
4
3
|
const Stashback = require('stashback');
|
|
4
|
+
const inMemory = require('./inMemory');
|
|
5
|
+
|
|
5
6
|
const debug = 'rascal:counters:inMemoryCluster';
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
package/lib/counters/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
const stub = require('./stub');
|
|
2
|
+
const inMemory = require('./inMemory');
|
|
3
|
+
const inMemoryCluster = require('./inMemoryCluster');
|
|
4
|
+
|
|
1
5
|
module.exports = {
|
|
2
|
-
stub
|
|
3
|
-
inMemory
|
|
4
|
-
inMemoryCluster
|
|
6
|
+
stub,
|
|
7
|
+
inMemory,
|
|
8
|
+
inMemoryCluster,
|
|
5
9
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rascal",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "15.0.1",
|
|
4
4
|
"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",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"async": "^3.2.
|
|
7
|
+
"async": "^3.2.4",
|
|
8
8
|
"debug": "^4.3.4",
|
|
9
9
|
"forward-emitter": "^0.1.1",
|
|
10
10
|
"generic-pool": "^3.8.2",
|
|
@@ -17,13 +17,14 @@
|
|
|
17
17
|
"xregexp": "^5.1.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"amqplib": "^0.
|
|
20
|
+
"amqplib": "^0.10.2",
|
|
21
21
|
"chalk": "^4.1.2",
|
|
22
22
|
"chance": "^1.1.8",
|
|
23
|
-
"eslint": "^
|
|
23
|
+
"eslint": "^8.21.0",
|
|
24
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
24
25
|
"eslint-config-prettier": "^8.3.0",
|
|
25
|
-
"eslint-plugin-
|
|
26
|
-
"husky": "^
|
|
26
|
+
"eslint-plugin-import": "^2.26.0",
|
|
27
|
+
"husky": "^8.0.1",
|
|
27
28
|
"lint-staged": "^11.2.4",
|
|
28
29
|
"nyc": "^15.1.0",
|
|
29
30
|
"prettier": "^2.4.1",
|
|
@@ -35,19 +36,22 @@
|
|
|
35
36
|
"amqplib": ">=0.5.5"
|
|
36
37
|
},
|
|
37
38
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
39
|
+
"node": ">=12.0.0"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"test": "zUnit",
|
|
42
43
|
"prettier": "prettier --check .",
|
|
44
|
+
"prettier:fix": "prettier --write .",
|
|
43
45
|
"lint": "eslint .",
|
|
46
|
+
"lint:fix": "eslint --fix .",
|
|
44
47
|
"lint-staged": "lint-staged",
|
|
45
48
|
"coverage": "nyc --report html --reporter lcov --reporter text-summary zUnit",
|
|
46
49
|
"docker": "docker run -d --name rascal-rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management",
|
|
47
50
|
"prepare": "husky install"
|
|
48
51
|
},
|
|
49
52
|
"lint-staged": {
|
|
50
|
-
"**/*": "prettier --write --ignore-unknown"
|
|
53
|
+
"**/*": "prettier --write --ignore-unknown",
|
|
54
|
+
"**/*.js": "eslint --fix"
|
|
51
55
|
},
|
|
52
56
|
"keywords": [
|
|
53
57
|
"amqplib",
|