Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
cressie176 committed Feb 11, 2024
1 parent 17e1773 commit 161ac3f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 17.0.3

- Dedupe channel poole ready check
- Remove unnecessary subscription config from busy publisher example

## 17.0.2

- Update guidesmiths references to onebeyond.
Expand Down
5 changes: 0 additions & 5 deletions examples/busy-publisher/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
"persistent": false
}
}
},
"subscriptions": {
"demo_sub": {
"queue": "demo_q"
}
}
}
}
Expand Down
21 changes: 10 additions & 11 deletions lib/amqp/Vhost.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ function Vhost(vhostConfig, components) {
createChannelWhenInitialised(options.confirm, (err, channel) => {
if (err) return deferRejection(reject, err);
if (!channel) return deferRejection(reject, new Error('Vhost is shutting down'));
const destroyChannel = _.once(() => {
const destroyChannel = _.once((err) => {
console.log('Destroying channel', err);

Check warning on line 205 in lib/amqp/Vhost.js

View workflow job for this annotation

GitHub Actions / build (14.x)

Unexpected console statement

Check warning on line 205 in lib/amqp/Vhost.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected console statement

Check warning on line 205 in lib/amqp/Vhost.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected console statement

Check warning on line 205 in lib/amqp/Vhost.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected console statement
debug('Destroying %s channel: %s for vhost: %s due to error or close event', mode, channel._rascal_id, vhostConfig.name);
channel._rascal_closed = true;
if (pool.isBorrowedResource(channel)) {
Expand Down Expand Up @@ -289,11 +290,7 @@ function Vhost(vhostConfig, components) {
.catch((err) => {
debug('Error releasing %s channel: %s. %s', mode, channel._rascal_id, err.message);
})
.then(() => {
if (poolQueue.length() > 0 || !busy) return;
busy = false;
self.emit('ready', stats());
});
.then(() => checkReady());
}

function destroy(channel) {
Expand All @@ -303,11 +300,13 @@ function Vhost(vhostConfig, components) {
.catch((err) => {
debug('Error destroying %s channel: %s. %s', mode, channel._rascal_id, err.message);
})
.then(() => {
if (poolQueue.length() > 0 || !busy) return;
busy = false;
self.emit('ready', stats());
});
.then(() => checkReady());
}

function checkReady() {
if (poolQueue.length() > 0 || !busy) return;
busy = false;
self.emit('ready', stats());
}

function drain(next) {
Expand Down

0 comments on commit 161ac3f

Please sign in to comment.