Skip to content

Commit

Permalink
Fix hostname randomisation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cressie176 committed Feb 11, 2024
1 parent ecbd658 commit aa61cbf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Update guidesmiths references to onebeyond.
- Dedupe channel poole ready check
- Remove unnecessary subscription config from busy publisher example
- Fixed bug where hostname connection order was not properly randomised

## 17.0.1

Expand Down
2 changes: 1 addition & 1 deletion lib/config/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module.exports = _.curry((rascalConfig, next) => {
}

function setConnectionIndex(connection, strategy, index) {
connection.index = strategy === 'fixed' ? index : getConnectionIndex(strategy, `${connection.host}:${connection.port}`);
connection.index = strategy === 'fixed' ? index : getConnectionIndex(strategy, `${connection.hostname}:${connection.port}`);
}

function getConnectionIndex(strategy, hostname) {
Expand Down
4 changes: 2 additions & 2 deletions test/config.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe('Configuration', () => {

it('should randomise the order of connections, but maintain order across vhosts by host', () => {
const results = [];
for (let i = 0; i < 10; i++) {
for (let i = 0; i < 100; i++) {
configure(
{
vhosts: {
Expand Down Expand Up @@ -336,7 +336,7 @@ describe('Configuration', () => {
},
);
}
assert.ok(_.uniq(results).length > 1);
assert.ok(_.uniq(results).length > 10);
});

it('should honour the order of connections with fixed connection strategy', () => {
Expand Down

0 comments on commit aa61cbf

Please sign in to comment.