amqplib 0.10.5 → 0.10.6

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change log for amqplib
2
2
 
3
+ ## v0.10.6
4
+ - Replace references to the old squaremo/amqp.name repo with ones to amqp-node/amqplib
5
+ - Use a frame_max of 131072 by default for RabbitMQ 4.1.0 compatibility
6
+
3
7
  ## Changes in v0.10.5
4
8
 
5
9
  git log v0.10.4..v0.10.5
package/README.md CHANGED
@@ -16,8 +16,8 @@
16
16
  A library for making AMQP 0-9-1 clients for Node.JS, and an AMQP 0-9-1 client for Node.JS v10+.
17
17
 
18
18
  This library does not implement [AMQP
19
- 1.0](https://github.com/squaremo/amqp.node/issues/63) or [AMQP
20
- 0-10](https://github.com/squaremo/amqp.node/issues/94).
19
+ 1.0](https://github.com/amqp-node/amqplib/issues/63) or [AMQP
20
+ 0-10](https://github.com/amqp-node/amqplib/issues/94).
21
21
 
22
22
  Project status:
23
23
 
@@ -112,7 +112,7 @@ println(
112
112
  '/** @preserve This file is generated by the script\n',
113
113
  '* ../bin/generate-defs.js, which is not in general included in a\n',
114
114
  '* distribution, but is available in the source repository e.g. at\n',
115
- '* https://github.com/squaremo/amqp.node/\n',
115
+ '* https://github.com/amqp-node/amqplib/\n',
116
116
  '*/');
117
117
 
118
118
  println("'use strict';"); nl();
@@ -28,8 +28,13 @@ class CallbackModel extends EventEmitter {
28
28
  this.connection._updateSecret(newSecret, reason, cb);
29
29
  }
30
30
 
31
- createChannel (cb) {
31
+ createChannel (options, cb) {
32
+ if (arguments.length === 1) {
33
+ cb = options;
34
+ options = undefined;
35
+ }
32
36
  var ch = new Channel(this.connection);
37
+ ch.setOptions(options);
33
38
  ch.open(function (err, ok) {
34
39
  if (err === null)
35
40
  cb && cb(null, ch);
@@ -39,8 +44,13 @@ class CallbackModel extends EventEmitter {
39
44
  return ch;
40
45
  }
41
46
 
42
- createConfirmChannel (cb) {
47
+ createConfirmChannel (options, cb) {
48
+ if (arguments.length === 1) {
49
+ cb = options;
50
+ options = undefined;
51
+ }
43
52
  var ch = new ConfirmChannel(this.connection);
53
+ ch.setOptions(options);
44
54
  ch.open(function (err) {
45
55
  if (err !== null)
46
56
  return cb && cb(err);
package/lib/channel.js CHANGED
@@ -47,8 +47,12 @@ class Channel extends EventEmitter {
47
47
  this.handleMessage = acceptDeliveryOrReturn;
48
48
  }
49
49
 
50
+ setOptions(options) {
51
+ this.options = options;
52
+ }
53
+
50
54
  allocate () {
51
- this.ch = this.connection.freshChannel(this);
55
+ this.ch = this.connection.freshChannel(this, this.options);
52
56
  return this;
53
57
  }
54
58
 
@@ -30,14 +30,16 @@ class ChannelModel extends EventEmitter {
30
30
  return promisify(this.connection._updateSecret.bind(this.connection))(newSecret, reason);
31
31
  }
32
32
 
33
- async createChannel() {
33
+ async createChannel(options) {
34
34
  const channel = new Channel(this.connection);
35
+ channel.setOptions(options);
35
36
  await channel.open();
36
37
  return channel;
37
38
  }
38
39
 
39
- async createConfirmChannel() {
40
+ async createConfirmChannel(options) {
40
41
  const channel = new ConfirmChannel(this.connection);
42
+ channel.setOptions(options);
41
43
  await channel.open();
42
44
  await channel.rpc(defs.ConfirmSelect, {nowait: false}, defs.ConfirmSelectOk);
43
45
  return channel;
package/lib/connect.js CHANGED
@@ -31,7 +31,7 @@ var CLIENT_PROPERTIES = {
31
31
  "product": "amqplib",
32
32
  "version": require('../package.json').version,
33
33
  "platform": fmt('Node.JS %s', process.version),
34
- "information": "http://squaremo.github.io/amqp.node",
34
+ "information": "https://amqp-node.github.io/amqplib/",
35
35
  "capabilities": {
36
36
  "publisher_confirms": true,
37
37
  "exchange_exchange_bindings": true,
@@ -66,7 +66,7 @@ function openFrames(vhost, query, credentials, extraClientProperties) {
66
66
 
67
67
  // tune-ok
68
68
  'channelMax': intOrDefault(query.channelMax, 0),
69
- 'frameMax': intOrDefault(query.frameMax, 0x1000),
69
+ 'frameMax': intOrDefault(query.frameMax, 131072),
70
70
  'heartbeat': intOrDefault(query.heartbeat, 0),
71
71
 
72
72
  // open
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "amqplib",
3
3
  "homepage": "http://amqp-node.github.io/amqplib/",
4
4
  "main": "./channel_api.js",
5
- "version": "0.10.5",
5
+ "version": "0.10.6",
6
6
  "description": "An AMQP 0-9-1 (e.g., RabbitMQ) library and client.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -72,10 +72,14 @@ suite('updateSecret', function() {
72
72
  });
73
73
 
74
74
  function channel_test_fn(method) {
75
- return function(name, chfun) {
75
+ return function(name, options, chfun) {
76
+ if (arguments.length === 2) {
77
+ chfun = options;
78
+ options = {};
79
+ }
76
80
  test(name, function(done) {
77
81
  connect(kCallback(function(c) {
78
- c[method](kCallback(function(ch) {
82
+ c[method](options, kCallback(function(ch) {
79
83
  chfun(ch, done);
80
84
  }, done));
81
85
  }, done));
@@ -210,6 +214,33 @@ suite('sending messages', function() {
210
214
  });
211
215
  });
212
216
 
217
+ var channelOptions = {};
218
+
219
+ channel_test('find high watermark', function(ch, done) {
220
+ var msg = randomString();
221
+ var baseline = 0;
222
+ ch.assertQueue('', {exclusive: true}, function(e, q) {
223
+ if (e !== null) return done(e);
224
+ while (ch.sendToQueue(q.queue, Buffer.from(msg))) {
225
+ baseline++;
226
+ };
227
+ channelOptions.highWaterMark = baseline * 2;
228
+ done();
229
+ })
230
+ });
231
+
232
+ channel_test('set high watermark', channelOptions, function(ch, done) {
233
+ var msg = randomString();
234
+ ch.assertQueue('', {exclusive: true}, function(e, q) {
235
+ if (e !== null) return done(e);
236
+ var ok;
237
+ for (var i = 0; i < channelOptions.highWaterMark; i++) {
238
+ ok = ch.sendToQueue(q.queue, Buffer.from(msg));
239
+ assert.equal(ok, true);
240
+ }
241
+ done();
242
+ });
243
+ });
213
244
  });
214
245
 
215
246
  suite('ConfirmChannel', function() {
@@ -228,6 +259,34 @@ suite('ConfirmChannel', function() {
228
259
  ch.waitForConfirms(done);
229
260
  });
230
261
 
262
+ var channelOptions = {};
263
+
264
+ confirm_channel_test('find high watermark', function(ch, done) {
265
+ var msg = randomString();
266
+ var baseline = 0;
267
+ ch.assertQueue('', {exclusive: true}, function(e, q) {
268
+ if (e !== null) return done(e);
269
+ while (ch.sendToQueue(q.queue, Buffer.from(msg))) {
270
+ baseline++;
271
+ };
272
+ channelOptions.highWaterMark = baseline * 2;
273
+ done();
274
+ })
275
+ });
276
+
277
+ confirm_channel_test('set high watermark', channelOptions, function(ch, done) {
278
+ var msg = randomString();
279
+ ch.assertQueue('', {exclusive: true}, function(e, q) {
280
+ if (e !== null) return done(e);
281
+ var ok;
282
+ for (var i = 0; i < channelOptions.highWaterMark; i++) {
283
+ ok = ch.sendToQueue(q.queue, Buffer.from(msg));
284
+ assert.equal(ok, true);
285
+ }
286
+ done();
287
+ });
288
+ });
289
+
231
290
  });
232
291
 
233
292
  suite("Error handling", function() {