rascal 14.4.1 → 14.4.4
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/CHANGELOG.md +22 -0
- package/lib/amqp/Publication.js +41 -12
- package/lib/amqp/Vhost.js +3 -5
- package/lib/counters/inMemoryCluster.js +1 -1
- package/package.json +12 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 14.4.4
|
|
4
|
+
|
|
5
|
+
- Fixed issue where channels were not returned to the pool after publishing a large messag - See https://github.com/guidesmiths/rascal/issues/199
|
|
6
|
+
|
|
7
|
+
## 14.4.3
|
|
8
|
+
|
|
9
|
+
- Bump dependencies
|
|
10
|
+
- superagent
|
|
11
|
+
- chance
|
|
12
|
+
- zUnit
|
|
13
|
+
- debug
|
|
14
|
+
- generic-pool
|
|
15
|
+
- lru-cache
|
|
16
|
+
- xregexp
|
|
17
|
+
- stashback
|
|
18
|
+
- chalk
|
|
19
|
+
- amqplib
|
|
20
|
+
|
|
21
|
+
## 14.4.2
|
|
22
|
+
|
|
23
|
+
- Remove timeout for filling the channel pool since generic-pool already has this option.
|
|
24
|
+
|
|
3
25
|
## 14.4.1
|
|
4
26
|
|
|
5
27
|
- Bump dependencies / fix audit warnings
|
package/lib/amqp/Publication.js
CHANGED
|
@@ -169,6 +169,7 @@ function addListeners(channel, errorHandler, returnHandler) {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
function removeListeners(channel, errorHandler, returnHandler) {
|
|
172
|
+
channel.removeAllListeners('drain');
|
|
172
173
|
channel.removeListener('error', errorHandler);
|
|
173
174
|
channel.removeListener('return', returnHandler);
|
|
174
175
|
channel.connection.removeListener('error', errorHandler);
|
|
@@ -177,37 +178,65 @@ function removeListeners(channel, errorHandler, returnHandler) {
|
|
|
177
178
|
|
|
178
179
|
function publishToExchange(channel, content, config, next) {
|
|
179
180
|
debug('Publishing %d bytes to exchange: %s with routingKeys: %s', content.length, config.exchange, _.compact([].concat(config.routingKey, config.options.CC, config.options.BCC)).join(', '));
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
|
|
182
|
+
const fn = () => {
|
|
183
|
+
return channel.publish(config.destination, config.routingKey, content, config.options);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
publishNoConfirm(fn, channel, next);
|
|
182
187
|
}
|
|
183
188
|
|
|
184
189
|
function publishToConfirmExchange(channel, content, config, next) {
|
|
185
190
|
debug('Publishing %d bytes to confirm exchange: %s with routingKeys: %s', content.length, config.exchange, _.compact([].concat(config.routingKey, config.options.CC, config.options.BCC)).join(', '));
|
|
186
191
|
|
|
187
|
-
const
|
|
188
|
-
|
|
192
|
+
const fn = (cb) => {
|
|
193
|
+
return channel.publish(config.destination, config.routingKey, content, config.options, cb);
|
|
194
|
+
};
|
|
189
195
|
|
|
190
|
-
|
|
191
|
-
clearTimeout(timeout);
|
|
192
|
-
once(err, ok);
|
|
193
|
-
});
|
|
196
|
+
publishAndConfirm(fn, channel, config, next);
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
function sendToQueue(channel, content, config, next) {
|
|
197
200
|
debug('Publishing %d bytes to queue: %s', content.length, config.queue);
|
|
198
|
-
|
|
199
|
-
|
|
201
|
+
|
|
202
|
+
const fn = () => {
|
|
203
|
+
return channel.sendToQueue(config.destination, content, config.options);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
publishNoConfirm(fn, channel, next);
|
|
200
207
|
}
|
|
201
208
|
|
|
202
209
|
function sendToConfirmQueue(channel, content, config, next) {
|
|
203
210
|
debug('Publishing %d bytes to queue: %s', content.length, config.queue);
|
|
204
211
|
|
|
212
|
+
const fn = (cb) => {
|
|
213
|
+
return channel.sendToQueue(config.destination, content, config.options, cb);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
publishAndConfirm(fn, channel, config, next);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function publishNoConfirm(fn, channel, next) {
|
|
220
|
+
let drained = false;
|
|
221
|
+
channel.once('drain', () => {
|
|
222
|
+
drained = true;
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
const ok = fn();
|
|
226
|
+
next(null, ok || drained);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function publishAndConfirm(fn, channel, config, next) {
|
|
205
230
|
const once = _.once(next);
|
|
206
231
|
const timeout = config.timeout ? setConfirmationTimeout(config.timeout, config.destination, once) : null;
|
|
232
|
+
let drained = false;
|
|
233
|
+
channel.once('drain', () => {
|
|
234
|
+
drained = true;
|
|
235
|
+
});
|
|
207
236
|
|
|
208
|
-
const ok =
|
|
237
|
+
const ok = fn((err) => {
|
|
209
238
|
clearTimeout(timeout);
|
|
210
|
-
next(err, ok);
|
|
239
|
+
next(err, ok || drained);
|
|
211
240
|
});
|
|
212
241
|
}
|
|
213
242
|
|
package/lib/amqp/Vhost.js
CHANGED
|
@@ -357,15 +357,13 @@ function Vhost(config, components) {
|
|
|
357
357
|
function createChannelWhenInitialised(confirm, next) {
|
|
358
358
|
if (connection) return createChannel(confirm, next);
|
|
359
359
|
debug('Vhost: %s is not initialised. Deferring channel creation', self.name);
|
|
360
|
-
setTimeoutUnref(() => {
|
|
361
|
-
self.removeListener('vhost_initialised', onVhostInitialised);
|
|
362
|
-
next(new Error('Timedout acquiring channel'), 5000);
|
|
363
|
-
});
|
|
364
360
|
function onVhostInitialised() {
|
|
365
361
|
debug('Vhost: %s was initialised. Resuming channel creation', self.name);
|
|
366
362
|
createChannel(confirm, next);
|
|
367
363
|
}
|
|
368
|
-
self.once('vhost_initialised',
|
|
364
|
+
self.once('vhost_initialised', () => {
|
|
365
|
+
onVhostInitialised();
|
|
366
|
+
});
|
|
369
367
|
}
|
|
370
368
|
|
|
371
369
|
function createChannel(confirm, next) {
|
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
|
35
35
|
});
|
|
36
36
|
},
|
|
37
37
|
worker: function worker(options) {
|
|
38
|
-
if (!cluster.isWorker) throw new Error("You cannot use Rascal's in
|
|
38
|
+
if (!cluster.isWorker) throw new Error("You cannot use Rascal's in memory cluster counter outside of a cluster");
|
|
39
39
|
if (!options) return worker({});
|
|
40
40
|
const timeout = options.timeout || 100;
|
|
41
41
|
const stashback = Stashback({ timeout });
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rascal",
|
|
3
|
-
"version": "14.4.
|
|
3
|
+
"version": "14.4.4",
|
|
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
7
|
"async": "^3.2.3",
|
|
8
|
-
"debug": "^4.
|
|
8
|
+
"debug": "^4.3.4",
|
|
9
9
|
"forward-emitter": "^0.1.1",
|
|
10
|
-
"generic-pool": "^3.
|
|
10
|
+
"generic-pool": "^3.8.2",
|
|
11
11
|
"lodash": "^4.17.21",
|
|
12
|
-
"lru-cache": "^
|
|
12
|
+
"lru-cache": "^7.10.1",
|
|
13
13
|
"safe-json-parse": "^4.0.0",
|
|
14
|
-
"stashback": "^
|
|
15
|
-
"superagent": "^
|
|
14
|
+
"stashback": "^2.0.1",
|
|
15
|
+
"superagent": "^7.1.3",
|
|
16
16
|
"uuid": "^8.3.2",
|
|
17
|
-
"xregexp": "^5.0
|
|
17
|
+
"xregexp": "^5.1.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"amqplib": "^0.
|
|
21
|
-
"chalk": "^4.
|
|
22
|
-
"chance": "^1.1.
|
|
20
|
+
"amqplib": "^0.9.1",
|
|
21
|
+
"chalk": "^4.1.2",
|
|
22
|
+
"chance": "^1.1.8",
|
|
23
23
|
"eslint": "^7.32.0",
|
|
24
24
|
"eslint-config-prettier": "^8.3.0",
|
|
25
25
|
"eslint-plugin-prettier": "^4.0.0",
|
|
26
26
|
"husky": "^6.0.0",
|
|
27
27
|
"lint-staged": "^11.2.4",
|
|
28
28
|
"nyc": "^15.1.0",
|
|
29
|
-
"prettier": "2.4.1",
|
|
29
|
+
"prettier": "^2.4.1",
|
|
30
30
|
"random-readable": "^1.0.1",
|
|
31
31
|
"superagent-defaults": "^0.1.14",
|
|
32
|
-
"zunit": "^3.
|
|
32
|
+
"zunit": "^3.2.1"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"amqplib": ">=0.5.5"
|