Skip to content

Commit

Permalink
Merge pull request #103 from Kaseaa/master
Browse files Browse the repository at this point in the history
Able to pass object as url
  • Loading branch information
Jason Walton authored Dec 6, 2019
2 parents 39f287d + 9df9883 commit 16fd97c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/npm-debug.log
/coverage
/.nyc_output
/.vscode
20 changes: 14 additions & 6 deletions src/AmqpConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,22 @@ export default class AmqpConnectionManager extends EventEmitter {
const urlString = url.url || url;
const connectionOptions = url.connectionOptions || this.connectionOptions;

const amqpUrl = urlUtils.parse(urlString);
if(amqpUrl.search) {
amqpUrl.search += `&heartbeat=${this.heartbeatIntervalInSeconds}`;
} else {
amqpUrl.search = `?heartbeat=${this.heartbeatIntervalInSeconds}`;
let amqpUrl = null;

if(typeof urlString === "object") {
amqpUrl = url;
}else {
amqpUrl = urlUtils.parse(urlString);
if(amqpUrl.search) {
amqpUrl.search += `&heartbeat=${this.heartbeatIntervalInSeconds}`;
} else {
amqpUrl.search = `?heartbeat=${this.heartbeatIntervalInSeconds}`;
}
amqpUrl = urlUtils.format(amqpUrl);
}

return amqp.connect(urlUtils.format(amqpUrl), connectionOptions)

return amqp.connect(amqpUrl, connectionOptions)
.then(connection => {
this._currentConnection = connection;

Expand Down
15 changes: 15 additions & 0 deletions src/ChannelWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,19 @@ export default class ChannelWrapper extends EventEmitter {
nackAll() {
return this._channel && this._channel.nackAll.apply(this._channel, arguments);
}

// Send a `purgeQueue` to the underlying channel.
purgeQueue() {
return this._channel && this._channel.purgeQueue.apply(this._channel, arguments);
}

// Send a `checkQueue` to the underlying channel.
checkQueue() {
return this._channel && this._channel.checkQueue.apply(this._channel, arguments);
}

// Send a `assertQueue` to the underlying channel.
assertQueue() {
return this._channel && this._channel.assertQueue.apply(this._channel, arguments);
}
}

0 comments on commit 16fd97c

Please sign in to comment.