amqplib 0.9.0 → 0.10.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.
@@ -20,7 +20,7 @@ jobs:
20
20
 
21
21
  strategy:
22
22
  matrix:
23
- node-version: [10.x, 12.x, 14.x, 16.x]
23
+ node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
24
24
  # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
25
25
 
26
26
  steps:
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Change log for amqplib
2
2
 
3
+ ## Changes in v0.10.1
4
+
5
+ git log v0.10.0..v0.10.1
6
+
7
+ * Allow servername to be specified via socket options as discussed in as discussed in
8
+ [issue 697](https://github.com/squaremo/amqp.node/issues/697)
9
+
10
+ ## Changes in v0.10.0
11
+
12
+ git log v0.9.1..v0.10.0
13
+
14
+ * Use Native promises ([PR
15
+ 689](https://github.com/amqp-node/amqplib/pull/689), thank you
16
+ @mohd-akram and @kibertoad)
17
+
18
+ ## Changes in v0.9.1
19
+
20
+ git log v0.9.0..v0.9.1
21
+
22
+ * Assorted readme changes
23
+ * Use Array.prototype.push.apply instead of concat in Mux ([PR
24
+ 658](https://github.com/squaremo/amqp.node/pull/658), thank you
25
+ @Uzlopak and @kibertoad)
26
+ * Use Map instead of Object for BaseChannel.consumers ([PR
27
+ 660](https://github.com/squaremo/amqp.node/pull/660), thank you
28
+ @Uzlopak)
29
+ * Delete consumer callback after cancellation to free memory ([PR
30
+ 659](https://github.com/squaremo/amqp.node/pull/659), thank you
31
+ @Uzlopak and @kibertoad)
32
+
33
+
3
34
  ## Changes in v0.9.0
4
35
 
5
36
  git log v0.8.0..v0.9.0
package/Makefile CHANGED
@@ -3,7 +3,7 @@ JSON=amqp-rabbitmq-0.9.1.json
3
3
  RABBITMQ_CODEGEN=https://raw.githubusercontent.com/rabbitmq/rabbitmq-codegen
4
4
  AMQP_JSON=$(RABBITMQ_CODEGEN)/$(RABBITMQ_SRC_VERSION)/$(JSON)
5
5
 
6
- NODEJS_VERSIONS='10.21' '11.15' '12.18' '13.14' '14.5' '15.8'
6
+ NODEJS_VERSIONS='10.21' '11.15' '12.18' '13.14' '14.5' '15.8' '16.3.0' '18.1.0'
7
7
 
8
8
  MOCHA=./node_modules/.bin/mocha
9
9
  _MOCHA=./node_modules/.bin/_mocha
package/README.md CHANGED
@@ -1,14 +1,19 @@
1
1
  # AMQP 0-9-1 library and client for Node.JS
2
2
 
3
- [![Build Status](https://travis-ci.org/squaremo/amqp.node.png)](https://travis-ci.org/squaremo/amqp.node)
3
+ [![NPM version](https://img.shields.io/npm/v/amqplib.svg?style=flat-square)](https://www.npmjs.com/package/amqplib)
4
+ [![NPM downloads](https://img.shields.io/npm/dm/amqplib.svg?style=flat-square)](https://www.npmjs.com/package/amqplib)
5
+ [![Node.js CI](https://github.com/amqp-node/amqplib/workflows/Node.js%20CI/badge.svg)](https://github.com/amqp-node/amqplib/actions?query=workflow%3A%22Node.js+CI%22)
6
+ [![amqplib](https://snyk.io/advisor/npm-package/amqplib/badge.svg)](https://snyk.io/advisor/npm-package/amqplib)
4
7
 
5
8
  npm install amqplib
6
9
 
7
10
  * [Change log][changelog]
8
11
  * [GitHub pages][gh-pages]
9
12
  * [API reference][gh-pages-apiref]
13
+ * [Troubleshooting][gh-pages-trouble]
10
14
  * [Examples from RabbitMQ tutorials][tutes]
11
15
 
16
+
12
17
  A library for making AMQP 0-9-1 clients for Node.JS, and an AMQP 0-9-1 client for Node.JS v10+.
13
18
 
14
19
  This library does not implement [AMQP
@@ -32,75 +37,71 @@ Still working on:
32
37
  ## Callback API example
33
38
 
34
39
  ```javascript
35
- var q = 'tasks';
36
-
37
- function bail(err) {
38
- console.error(err);
39
- process.exit(1);
40
- }
41
-
42
- // Publisher
43
- function publisher(conn) {
44
- conn.createChannel(on_open);
45
- function on_open(err, ch) {
46
- if (err != null) bail(err);
47
- ch.assertQueue(q);
48
- ch.sendToQueue(q, Buffer.from('something to do'));
49
- }
50
- }
51
-
52
- // Consumer
53
- function consumer(conn) {
54
- var ok = conn.createChannel(on_open);
55
- function on_open(err, ch) {
56
- if (err != null) bail(err);
57
- ch.assertQueue(q);
58
- ch.consume(q, function(msg) {
40
+ const amqplib = require('amqplib/callback_api');
41
+ const queue = 'tasks';
42
+
43
+ amqplib.connect('amqp://localhost', (err, conn) => {
44
+ if (err) throw err;
45
+
46
+ // Listener
47
+ conn.createChannel((err, ch2) => {
48
+ if (err) throw err;
49
+
50
+ ch2.assertQueue(queue);
51
+
52
+ ch2.consume(queue, (msg) => {
59
53
  if (msg !== null) {
60
54
  console.log(msg.content.toString());
61
- ch.ack(msg);
55
+ ch2.ack(msg);
56
+ } else {
57
+ console.log('Consumer cancelled by server');
62
58
  }
63
59
  });
64
- }
65
- }
66
-
67
- require('amqplib/callback_api')
68
- .connect('amqp://localhost', function(err, conn) {
69
- if (err != null) bail(err);
70
- consumer(conn);
71
- publisher(conn);
72
60
  });
61
+
62
+ // Sender
63
+ conn.createChannel((err, ch1) => {
64
+ if (err) throw err;
65
+
66
+ ch1.assertQueue(queue);
67
+
68
+ setInterval(() => {
69
+ ch1.sendToQueue(queue, Buffer.from('something to do'));
70
+ }, 1000);
71
+ });
72
+ });
73
73
  ```
74
74
 
75
- ## Promise API example
75
+ ## Promise/Async API example
76
76
 
77
77
  ```javascript
78
- var q = 'tasks';
78
+ const amqplib = require('amqplib');
79
+
80
+ (async () => {
81
+ const queue = 'tasks';
82
+ const conn = await amqplib.connect('amqp://localhost');
83
+
84
+ const ch1 = await conn.createChannel();
85
+ await ch1.assertQueue(queue);
86
+
87
+ // Listener
88
+ ch1.consume(queue, (msg) => {
89
+ if (msg !== null) {
90
+ console.log('Recieved:', msg.content.toString());
91
+ ch1.ack(msg);
92
+ } else {
93
+ console.log('Consumer cancelled by server');
94
+ }
95
+ });
79
96
 
80
- var open = require('amqplib').connect('amqp://localhost');
97
+ // Sender
98
+ const ch2 = await conn.createChannel();
99
+
100
+ setInterval(() => {
101
+ ch2.sendToQueue(queue, Buffer.from('something to do'));
102
+ }, 1000);
103
+ })();
81
104
 
82
- // Publisher
83
- open.then(function(conn) {
84
- return conn.createChannel();
85
- }).then(function(ch) {
86
- return ch.assertQueue(q).then(function(ok) {
87
- return ch.sendToQueue(q, Buffer.from('something to do'));
88
- });
89
- }).catch(console.warn);
90
-
91
- // Consumer
92
- open.then(function(conn) {
93
- return conn.createChannel();
94
- }).then(function(ch) {
95
- return ch.assertQueue(q).then(function(ok) {
96
- return ch.consume(q, function(msg) {
97
- if (msg !== null) {
98
- console.log(msg.content.toString());
99
- ch.ack(msg);
100
- }
101
- });
102
- });
103
- }).catch(console.warn);
104
105
  ```
105
106
 
106
107
  ## Running tests
@@ -127,7 +128,7 @@ dev.rabbitmq.com instance.
127
128
 
128
129
  You can run it under different versions of Node.JS using [nave][]:
129
130
 
130
- nave use 0.8 npm test
131
+ nave use 10 npm test
131
132
 
132
133
  or run the tests on all supported versions of Node.JS in one go:
133
134
 
@@ -146,10 +147,11 @@ really only useful for checking the kind and formatting of the errors.
146
147
  make coverage
147
148
  open file://`pwd`/coverage/lcov-report/index.html
148
149
 
149
- [gh-pages]: http://www.squaremobius.net/amqp.node/
150
- [gh-pages-apiref]: http://www.squaremobius.net/amqp.node/channel_api.html
150
+ [gh-pages]: https://amqp-node.github.io/amqplib/
151
+ [gh-pages-apiref]: https://amqp-node.github.io/amqplib/channel_api.html
152
+ [gh-pages-trouble]: https://amqp-node.github.io/amqplib/#troubleshooting
151
153
  [nave]: https://github.com/isaacs/nave
152
- [tutes]: https://github.com/squaremo/amqp.node/tree/main/examples/tutorials
154
+ [tutes]: https://github.com/amqp-node/amqplib/tree/main/examples/tutorials
153
155
  [rabbitmq-tutes]: http://www.rabbitmq.com/getstarted.html
154
- [changelog]: https://github.com/squaremo/amqp.node/blob/main/CHANGELOG.md
156
+ [changelog]: https://github.com/amqp-node/amqplib/blob/main/CHANGELOG.md
155
157
  [docker]: https://www.docker.com/
package/channel_api.js CHANGED
@@ -1,11 +1,11 @@
1
1
  var raw_connect = require('./lib/connect').connect;
2
2
  var ChannelModel = require('./lib/channel_model').ChannelModel;
3
- var Promise = require('bluebird');
3
+ var promisify = require('util').promisify;
4
4
 
5
5
  function connect(url, connOptions) {
6
- return Promise.fromCallback(function(cb) {
6
+ return promisify(function(cb) {
7
7
  return raw_connect(url, connOptions, cb);
8
- })
8
+ })()
9
9
  .then(function(conn) {
10
10
  return new ChannelModel(conn);
11
11
  });
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  var amqp = require('amqplib');
4
- var all = require('bluebird').all;
5
4
  var basename = require('path').basename;
6
5
 
7
6
  var severities = process.argv.slice(2);
@@ -24,7 +23,7 @@ amqp.connect('amqp://localhost').then(function(conn) {
24
23
 
25
24
  ok = ok.then(function(qok) {
26
25
  var queue = qok.queue;
27
- return all(severities.map(function(sev) {
26
+ return Promise.all(severities.map(function(sev) {
28
27
  ch.bindQueue(queue, ex, sev);
29
28
  })).then(function() { return queue; });
30
29
  });
@@ -2,7 +2,6 @@
2
2
 
3
3
  var amqp = require('amqplib');
4
4
  var basename = require('path').basename;
5
- var all = require('bluebird').all;
6
5
 
7
6
  var keys = process.argv.slice(2);
8
7
  if (keys.length < 1) {
@@ -23,7 +22,7 @@ amqp.connect('amqp://localhost').then(function(conn) {
23
22
 
24
23
  ok = ok.then(function(qok) {
25
24
  var queue = qok.queue;
26
- return all(keys.map(function(rk) {
25
+ return Promise.all(keys.map(function(rk) {
27
26
  ch.bindQueue(queue, ex, rk);
28
27
  })).then(function() { return queue; });
29
28
  });
@@ -2,7 +2,6 @@
2
2
 
3
3
  var amqp = require('amqplib');
4
4
  var basename = require('path').basename;
5
- var Promise = require('bluebird');
6
5
  var uuid = require('node-uuid');
7
6
 
8
7
  // I've departed from the form of the original RPC tutorial, which
@@ -5,7 +5,6 @@
5
5
  'use strict';
6
6
 
7
7
  var defs = require('./defs');
8
- var Promise = require('bluebird');
9
8
  var inherits = require('util').inherits;
10
9
  var EventEmitter = require('events').EventEmitter;
11
10
  var BaseChannel = require('./channel').BaseChannel;
package/lib/channel.js CHANGED
@@ -460,7 +460,7 @@ C.onBufferDrain = function() {
460
460
  // low-level machinery.
461
461
  function BaseChannel(connection) {
462
462
  Channel.call(this, connection);
463
- this.consumers = {};
463
+ this.consumers = new Map();
464
464
  }
465
465
  inherits(BaseChannel, Channel);
466
466
 
@@ -469,16 +469,16 @@ module.exports.BaseChannel = BaseChannel;
469
469
  // Not sure I like the ff, it's going to be changing hidden classes
470
470
  // all over the place. On the other hand, whaddya do.
471
471
  BaseChannel.prototype.registerConsumer = function(tag, callback) {
472
- this.consumers[tag] = callback;
472
+ this.consumers.set(tag, callback);
473
473
  };
474
474
 
475
475
  BaseChannel.prototype.unregisterConsumer = function(tag) {
476
- delete this.consumers[tag];
476
+ this.consumers.delete(tag);
477
477
  };
478
478
 
479
479
  BaseChannel.prototype.dispatchMessage = function(fields, message) {
480
480
  var consumerTag = fields.consumerTag;
481
- var consumer = this.consumers[consumerTag];
481
+ var consumer = this.consumers.get(consumerTag);
482
482
  if (consumer) {
483
483
  return consumer(message);
484
484
  }
@@ -493,5 +493,7 @@ BaseChannel.prototype.handleDelivery = function(message) {
493
493
  };
494
494
 
495
495
  BaseChannel.prototype.handleCancel = function(fields) {
496
- return this.dispatchMessage(fields, null);
496
+ var result = this.dispatchMessage(fields, null);
497
+ this.unregisterConsumer(fields.consumerTag);
498
+ return result;
497
499
  };
@@ -5,7 +5,7 @@
5
5
  'use strict';
6
6
 
7
7
  const EventEmitter = require('events');
8
- const Promise = require('bluebird');
8
+ const promisify = require('util').promisify;
9
9
  const defs = require('./defs');
10
10
  const {BaseChannel} = require('./channel');
11
11
  const {acceptMessage} = require('./channel');
@@ -23,7 +23,7 @@ class ChannelModel extends EventEmitter {
23
23
  }
24
24
 
25
25
  close() {
26
- return Promise.fromCallback(this.connection.close.bind(this.connection));
26
+ return promisify(this.connection.close.bind(this.connection))();
27
27
  }
28
28
 
29
29
  async createChannel() {
@@ -53,27 +53,25 @@ class Channel extends BaseChannel {
53
53
  // response's fields; this is intended to be suitable for implementing
54
54
  // API procedures.
55
55
  async rpc(method, fields, expect) {
56
- const f = await Promise.fromCallback(cb => {
56
+ const f = await promisify(cb => {
57
57
  return this._rpc(method, fields, expect, cb);
58
- })
58
+ })();
59
59
 
60
60
  return f.fields;
61
61
  }
62
62
 
63
63
  // Do the remarkably simple channel open handshake
64
- open() {
65
- return Promise.try(this.allocate.bind(this)).then(
66
- ch => {
67
- return ch.rpc(defs.ChannelOpen, {outOfBand: ""},
68
- defs.ChannelOpenOk);
69
- });
64
+ async open() {
65
+ const ch = await this.allocate.bind(this)();
66
+ return ch.rpc(defs.ChannelOpen, {outOfBand: ""},
67
+ defs.ChannelOpenOk);
70
68
  }
71
69
 
72
70
  close() {
73
- return Promise.fromCallback(cb => {
71
+ return promisify(cb => {
74
72
  return this.closeBecause("Goodbye", defs.constants.REPLY_SUCCESS,
75
73
  cb);
76
- });
74
+ })();
77
75
  }
78
76
 
79
77
  // === Public API, declaring queues and stuff ===
@@ -162,21 +160,21 @@ class Channel extends BaseChannel {
162
160
  // NB we want the callback to be run synchronously, so that we've
163
161
  // registered the consumerTag before any messages can arrive.
164
162
  const fields = Args.consume(queue, options);
165
- return Promise.fromCallback(cb => {
166
- this._rpc(defs.BasicConsume, fields, defs.BasicConsumeOk, cb);
167
- })
168
- .then(ok => {
169
- this.registerConsumer(ok.fields.consumerTag, callback);
170
- return ok.fields;
163
+ return new Promise((resolve, reject) => {
164
+ this._rpc(defs.BasicConsume, fields, defs.BasicConsumeOk, (err, ok) => {
165
+ if (err) return reject(err);
166
+ this.registerConsumer(ok.fields.consumerTag, callback);
167
+ resolve(ok.fields);
168
+ });
171
169
  });
172
170
  }
173
171
 
174
172
  async cancel(consumerTag) {
175
- const ok = await Promise.fromCallback(cb => {
173
+ const ok = await promisify(cb => {
176
174
  this._rpc(defs.BasicCancel, Args.cancel(consumerTag),
177
175
  defs.BasicCancelOk,
178
176
  cb);
179
- })
177
+ })()
180
178
  .then(ok => {
181
179
  this.unregisterConsumer(consumerTag);
182
180
  return ok.fields;
@@ -185,25 +183,23 @@ class Channel extends BaseChannel {
185
183
 
186
184
  get(queue, options) {
187
185
  const fields = Args.get(queue, options);
188
- return Promise.fromCallback(cb => {
189
- return this.sendOrEnqueue(defs.BasicGet, fields, cb);
190
- })
191
- .then(f => {
192
- if (f.id === defs.BasicGetEmpty) {
193
- return false;
194
- }
195
- else if (f.id === defs.BasicGetOk) {
196
- const fields = f.fields;
197
- return new Promise(resolve => {
186
+ return new Promise((resolve, reject) => {
187
+ this.sendOrEnqueue(defs.BasicGet, fields, (err, f) => {
188
+ if (err) return reject(err);
189
+ if (f.id === defs.BasicGetEmpty) {
190
+ return resolve(false);
191
+ }
192
+ else if (f.id === defs.BasicGetOk) {
193
+ const fields = f.fields;
198
194
  this.handleMessage = acceptMessage(m => {
199
195
  m.fields = fields;
200
196
  resolve(m);
201
197
  });
202
- });
203
- }
204
- else {
205
- throw new Error(`Unexpected response to BasicGet: ${inspect(f)}`);
206
- }
198
+ }
199
+ else {
200
+ reject(new Error(`Unexpected response to BasicGet: ${inspect(f)}`));
201
+ }
202
+ });
207
203
  });
208
204
  }
209
205
 
@@ -290,6 +286,13 @@ class ConfirmChannel extends Channel {
290
286
  awaiting.push(confirmed);
291
287
  }
292
288
  });
289
+ // Channel closed
290
+ if (!this.pending) {
291
+ var cb;
292
+ while (cb = this.unconfirmed.shift()) {
293
+ if (cb) cb(new Error('channel closed'));
294
+ }
295
+ }
293
296
  return Promise.all(awaiting);
294
297
  }
295
298
  }
package/lib/connect.js CHANGED
@@ -106,7 +106,7 @@ function connect(url, socketOptions, openCallback) {
106
106
  if (typeof url === 'object') {
107
107
  protocol = (url.protocol || 'amqp') + ':';
108
108
  sockopts.host = url.hostname;
109
- sockopts.servername = url.hostname;
109
+ sockopts.servername = sockopts.servername || url.hostname;
110
110
  sockopts.port = url.port || ((protocol === 'amqp:') ? 5672 : 5671);
111
111
 
112
112
  var user, pass;
@@ -131,7 +131,7 @@ function connect(url, socketOptions, openCallback) {
131
131
  var parts = URL(url, true); // yes, parse the query string
132
132
  protocol = parts.protocol;
133
133
  sockopts.host = parts.hostname;
134
- sockopts.servername = parts.hostname;
134
+ sockopts.servername = sockopts.servername || parts.hostname;
135
135
  sockopts.port = parseInt(parts.port) || ((protocol === 'amqp:') ? 5672 : 5671);
136
136
  var vhost = parts.pathname ? parts.pathname.substr(1) : null;
137
137
  fields = openFrames(vhost, parts.query, sockopts.credentials || credentialsFromUrl(parts), extraClientProperties);
package/lib/mux.js CHANGED
@@ -8,7 +8,6 @@
8
8
  // it then writes 'packets' from the upstreams to the given
9
9
  // downstream.
10
10
 
11
- var inherits = require('util').inherits;
12
11
  var assert = require('assert');
13
12
 
14
13
  var schedule = (typeof setImmediate === 'function') ?
@@ -47,7 +46,6 @@ Mux.prototype._readIncoming = function() {
47
46
  // become readable
48
47
  if (this.blocked) return;
49
48
 
50
- var self = this;
51
49
  var accepting = true;
52
50
  var out = this.out;
53
51
 
@@ -79,7 +77,7 @@ Mux.prototype._readIncoming = function() {
79
77
  }
80
78
  else { // ran out of room
81
79
  assert(this.newStreams.length > 0, "Expect some new streams to remain");
82
- this.oldStreams = this.oldStreams.concat(this.newStreams);
80
+ Array.prototype.push.apply(this.oldStreams, this.newStreams);
83
81
  this.newStreams = [];
84
82
  }
85
83
  // We may have exhausted all the old queues, or run out of room;
package/package.json CHANGED
@@ -1,19 +1,18 @@
1
1
  {
2
2
  "name": "amqplib",
3
- "homepage": "http://squaremo.github.io/amqp.node/",
3
+ "homepage": "http://amqp-node.github.io/amqplib/",
4
4
  "main": "./channel_api.js",
5
- "version": "0.9.0",
5
+ "version": "0.10.1",
6
6
  "description": "An AMQP 0-9-1 (e.g., RabbitMQ) library and client.",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/squaremo/amqp.node.git"
9
+ "url": "https://github.com/amqp-node/amqplib.git"
10
10
  },
11
11
  "engines": {
12
12
  "node": ">=10"
13
13
  },
14
14
  "dependencies": {
15
15
  "bitsyntax": "~0.1.0",
16
- "bluebird": "^3.7.2",
17
16
  "buffer-more-ints": "~1.0.0",
18
17
  "readable-stream": "1.x >=1.1.9",
19
18
  "url-parse": "~1.5.10"
package/test/channel.js CHANGED
@@ -3,7 +3,7 @@
3
3
  'use strict';
4
4
 
5
5
  var assert = require('assert');
6
- var Promise = require('bluebird');
6
+ var promisify = require('util').promisify;
7
7
  var Channel = require('../lib/channel').Channel;
8
8
  var Connection = require('../lib/connection').Connection;
9
9
  var util = require('./util');
@@ -76,12 +76,10 @@ var DELIVER_FIELDS = {
76
76
  };
77
77
 
78
78
  function open(ch) {
79
- return Promise.try(function() {
80
- ch.allocate();
81
- return Promise.fromCallback(function(cb) {
82
- ch._rpc(defs.ChannelOpen, {outOfBand: ''}, defs.ChannelOpenOk, cb);
83
- });
84
- });
79
+ ch.allocate();
80
+ return promisify(function(cb) {
81
+ ch._rpc(defs.ChannelOpen, {outOfBand: ''}, defs.ChannelOpenOk, cb);
82
+ })();
85
83
  }
86
84
 
87
85
  suite("channel open and close", function() {
@@ -285,7 +283,7 @@ test("RPC on closed channel", channelTest(
285
283
  failureCb(resolve, reject));
286
284
  });
287
285
 
288
- Promise.join(close, fail1, fail2)
286
+ Promise.all([close, fail1, fail2])
289
287
  .then(succeed(done))
290
288
  .catch(fail(done));
291
289
  },
@@ -6,7 +6,7 @@ var util = require('./util');
6
6
  var succeed = util.succeed, fail = util.fail;
7
7
  var schedule = util.schedule;
8
8
  var randomString = util.randomString;
9
- var Promise = require('bluebird');
9
+ var promisify = require('util').promisify;
10
10
 
11
11
  var URL = process.env.URL || 'amqp://localhost';
12
12
 
@@ -118,9 +118,9 @@ chtest("channel break on publishing to non-exchange", function(ch) {
118
118
 
119
119
  chtest("delete queue", function(ch) {
120
120
  var q = 'test.delete-queue';
121
- return Promise.join(
121
+ return Promise.all([
122
122
  ch.assertQueue(q, QUEUE_OPTS),
123
- ch.checkQueue(q))
123
+ ch.checkQueue(q)])
124
124
  .then(function() {
125
125
  return ch.deleteQueue(q);})
126
126
  .then(function() {
@@ -129,9 +129,9 @@ chtest("delete queue", function(ch) {
129
129
 
130
130
  chtest("delete exchange", function(ch) {
131
131
  var ex = 'test.delete-exchange';
132
- return Promise.join(
132
+ return Promise.all([
133
133
  ch.assertExchange(ex, 'fanout', EX_OPTS),
134
- ch.checkExchange(ex))
134
+ ch.checkExchange(ex)])
135
135
  .then(function() {
136
136
  return ch.deleteExchange(ex);})
137
137
  .then(function() {
@@ -177,7 +177,7 @@ suite("sendMessage", function() {
177
177
  chtest("send to queue and get from queue", function(ch) {
178
178
  var q = 'test.send-to-q';
179
179
  var msg = randomString();
180
- return Promise.join(ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q))
180
+ return Promise.all([ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q)])
181
181
  .then(function() {
182
182
  ch.sendToQueue(q, Buffer.from(msg));
183
183
  return waitForMessages(q);
@@ -194,9 +194,9 @@ chtest("send to queue and get from queue", function(ch) {
194
194
  chtest("send (and get) zero content to queue", function(ch) {
195
195
  var q = 'test.send-to-q';
196
196
  var msg = Buffer.alloc(0);
197
- return Promise.join(
197
+ return Promise.all([
198
198
  ch.assertQueue(q, QUEUE_OPTS),
199
- ch.purgeQueue(q))
199
+ ch.purgeQueue(q)])
200
200
  .then(function() {
201
201
  ch.sendToQueue(q, msg);
202
202
  return waitForMessages(q);})
@@ -218,11 +218,11 @@ chtest("route message", function(ch) {
218
218
  var q = 'test.route-message-q';
219
219
  var msg = randomString();
220
220
 
221
- return Promise.join(
221
+ return Promise.all([
222
222
  ch.assertExchange(ex, 'fanout', EX_OPTS),
223
223
  ch.assertQueue(q, QUEUE_OPTS),
224
224
  ch.purgeQueue(q),
225
- ch.bindQueue(q, ex, '', {}))
225
+ ch.bindQueue(q, ex, '', {})])
226
226
  .then(function() {
227
227
  ch.publish(ex, '', Buffer.from(msg));
228
228
  return waitForMessages(q);})
@@ -256,11 +256,11 @@ chtest("unbind queue", function(ch) {
256
256
  var viabinding = randomString();
257
257
  var direct = randomString();
258
258
 
259
- return Promise.join(
259
+ return Promise.all([
260
260
  ch.assertExchange(ex, 'fanout', EX_OPTS),
261
261
  ch.assertQueue(q, QUEUE_OPTS),
262
262
  ch.purgeQueue(q),
263
- ch.bindQueue(q, ex, '', {}))
263
+ ch.bindQueue(q, ex, '', {})])
264
264
  .then(function() {
265
265
  ch.publish(ex, '', Buffer.from('foobar'));
266
266
  return waitForMessages(q);})
@@ -289,14 +289,14 @@ chtest("consume via exchange-exchange binding", function(ch) {
289
289
  var ex1 = 'test.ex-ex-binding1', ex2 = 'test.ex-ex-binding2';
290
290
  var q = 'test.ex-ex-binding-q';
291
291
  var rk = 'test.routing.key', msg = randomString();
292
- return Promise.join(
292
+ return Promise.all([
293
293
  ch.assertExchange(ex1, 'direct', EX_OPTS),
294
294
  ch.assertExchange(ex2, 'fanout',
295
295
  {durable: false, internal: true}),
296
296
  ch.assertQueue(q, QUEUE_OPTS),
297
297
  ch.purgeQueue(q),
298
298
  ch.bindExchange(ex2, ex1, rk, {}),
299
- ch.bindQueue(q, ex2, '', {}))
299
+ ch.bindQueue(q, ex2, '', {})])
300
300
  .then(function() {
301
301
  return new Promise(function(resolve, reject) {
302
302
  function delivery(m) {
@@ -319,13 +319,13 @@ chtest("unbind exchange", function(ch) {
319
319
  var viabinding = randomString();
320
320
  var direct = randomString();
321
321
 
322
- return Promise.join(
322
+ return Promise.all([
323
323
  ch.assertExchange(source, 'fanout', EX_OPTS),
324
324
  ch.assertExchange(dest, 'fanout', EX_OPTS),
325
325
  ch.assertQueue(q, QUEUE_OPTS),
326
326
  ch.purgeQueue(q),
327
327
  ch.bindExchange(dest, source, '', {}),
328
- ch.bindQueue(q, dest, '', {}))
328
+ ch.bindQueue(q, dest, '', {})])
329
329
  .then(function() {
330
330
  ch.publish(source, '', Buffer.from('foobar'));
331
331
  return waitForMessages(q);})
@@ -353,7 +353,7 @@ chtest("cancel consumer", function(ch) {
353
353
  var q = 'test.consumer-cancel';
354
354
  var ctag;
355
355
  var recv1 = new Promise(function (resolve, reject) {
356
- Promise.join(
356
+ Promise.all([
357
357
  ch.assertQueue(q, QUEUE_OPTS),
358
358
  ch.purgeQueue(q),
359
359
  // My callback is 'resolve the promise in `arrived`'
@@ -361,17 +361,17 @@ chtest("cancel consumer", function(ch) {
361
361
  .then(function(ok) {
362
362
  ctag = ok.consumerTag;
363
363
  ch.sendToQueue(q, Buffer.from('foo'));
364
- }));
364
+ })]);
365
365
  });
366
366
 
367
367
  // A message should arrive because of the consume
368
368
  return recv1.then(function() {
369
- var recv2 = Promise.join(
369
+ var recv2 = Promise.all([
370
370
  ch.cancel(ctag).then(function() {
371
371
  return ch.sendToQueue(q, Buffer.from('bar'));
372
372
  }),
373
373
  // but check a message did arrive in the queue
374
- waitForMessages(q))
374
+ waitForMessages(q)])
375
375
  .then(function() {
376
376
  return ch.get(q, {noAck:true});
377
377
  })
@@ -390,13 +390,13 @@ chtest("cancel consumer", function(ch) {
390
390
  chtest("cancelled consumer", function(ch) {
391
391
  var q = 'test.cancelled-consumer';
392
392
  return new Promise(function(resolve, reject) {
393
- return Promise.join(
393
+ return Promise.all([
394
394
  ch.assertQueue(q),
395
395
  ch.purgeQueue(q),
396
396
  ch.consume(q, function(msg) {
397
397
  if (msg === null) resolve();
398
398
  else reject(new Error('Message not expected'));
399
- }))
399
+ })])
400
400
  .then(function() {
401
401
  return ch.deleteQueue(q);
402
402
  });
@@ -408,9 +408,9 @@ chtest("ack", function(ch) {
408
408
  var q = 'test.ack';
409
409
  var msg1 = randomString(), msg2 = randomString();
410
410
 
411
- return Promise.join(
411
+ return Promise.all([
412
412
  ch.assertQueue(q, QUEUE_OPTS),
413
- ch.purgeQueue(q))
413
+ ch.purgeQueue(q)])
414
414
  .then(function() {
415
415
  ch.sendToQueue(q, Buffer.from(msg1));
416
416
  ch.sendToQueue(q, Buffer.from(msg2));
@@ -438,8 +438,8 @@ chtest("nack", function(ch) {
438
438
  var q = 'test.nack';
439
439
  var msg1 = randomString();
440
440
 
441
- return Promise.join(
442
- ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q))
441
+ return Promise.all([
442
+ ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q)])
443
443
  .then(function() {
444
444
  ch.sendToQueue(q, Buffer.from(msg1));
445
445
  return waitForMessages(q);})
@@ -463,8 +463,8 @@ chtest("reject", function(ch) {
463
463
  var q = 'test.reject';
464
464
  var msg1 = randomString();
465
465
 
466
- return Promise.join(
467
- ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q))
466
+ return Promise.all([
467
+ ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q)])
468
468
  .then(function() {
469
469
  ch.sendToQueue(q, Buffer.from(msg1));
470
470
  return waitForMessages(q);})
@@ -484,9 +484,9 @@ chtest("reject", function(ch) {
484
484
 
485
485
  chtest("prefetch", function(ch) {
486
486
  var q = 'test.prefetch';
487
- return Promise.join(
487
+ return Promise.all([
488
488
  ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q),
489
- ch.prefetch(1))
489
+ ch.prefetch(1)])
490
490
  .then(function() {
491
491
  ch.sendToQueue(q, Buffer.from('foobar'));
492
492
  ch.sendToQueue(q, Buffer.from('foobar'));
@@ -523,8 +523,8 @@ suite("confirms", function() {
523
523
 
524
524
  confirmtest('message is confirmed', function(ch) {
525
525
  var q = 'test.confirm-message';
526
- return Promise.join(
527
- ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q))
526
+ return Promise.all([
527
+ ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q)])
528
528
  .then(function() {
529
529
  return ch.sendToQueue(q, Buffer.from('bleep'));
530
530
  });
@@ -537,8 +537,8 @@ confirmtest('message is confirmed', function(ch) {
537
537
  // multi-ack.
538
538
  confirmtest('multiple confirms', function(ch) {
539
539
  var q = 'test.multiple-confirms';
540
- return Promise.join(
541
- ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q))
540
+ return Promise.all([
541
+ ch.assertQueue(q, QUEUE_OPTS), ch.purgeQueue(q)])
542
542
  .then(function() {
543
543
  var multipleRainbows = false;
544
544
  ch.on('ack', function(a) {
@@ -549,9 +549,9 @@ confirmtest('multiple confirms', function(ch) {
549
549
  var cs = [];
550
550
 
551
551
  function sendAndPushPromise() {
552
- var conf = Promise.fromCallback(function(cb) {
552
+ var conf = promisify(function(cb) {
553
553
  return ch.sendToQueue(q, Buffer.from('bleep'), {}, cb);
554
- });
554
+ })();
555
555
  cs.push(conf);
556
556
  }
557
557
 
package/test/util.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var Promise = require('bluebird');
4
3
  var crypto = require('crypto');
5
4
  var Connection = require('../lib/connection').Connection;
6
5
  var PassThrough =