Skip to content

Commit

Permalink
refactor: Remove AmqpConnectionManager.connectionAttempts
Browse files Browse the repository at this point in the history
  • Loading branch information
jwalton committed Jan 7, 2022
1 parent 0f05987 commit 9fdf6ac
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,6 @@ Returns true if the AmqpConnectionManager is connected to a broker, false otherw

Close this AmqpConnectionManager and free all associated resources.

### AmqpConnectionManager#connectionAttempts

This is the number of times we've tried to connect to a broker.

### ChannelWrapper events

- `connect` - emitted every time this channel connects or reconnects.
Expand Down
12 changes: 0 additions & 12 deletions src/AmqpConnectionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,6 @@ export default class AmqpConnectionManager extends EventEmitter implements IAmqp
public heartbeatIntervalInSeconds: number;
public reconnectTimeInSeconds: number;

private _connectionAttempts = 0;

/**
* The number of connection attempts this connection manager has made,
* successful, failed, or in-progress..
*/
get connectionAttempts(): number {
return this._connectionAttempts;
}

/**
* Create a new AmqplibConnectionManager.
*
Expand Down Expand Up @@ -339,8 +329,6 @@ export default class AmqpConnectionManager extends EventEmitter implements IAmqp
return Promise.resolve(null);
}

this._connectionAttempts++;

let attemptedUrl: string | amqp.Options.Connect | undefined;

const result = (this._connectPromise = Promise.resolve()
Expand Down
3 changes: 1 addition & 2 deletions test/AmqpConnectionManagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ describe('AmqpConnectionManager', function () {
return Promise.resolve(null);
},
});

amqp.connect();
const [{ err }] = await once(amqp, 'connectFailed');
expect(err.message).to.contain('No servers found');
expect(amqp.connectionAttempts).to.equal(1);
return amqp?.close();
});

Expand Down Expand Up @@ -204,7 +204,6 @@ describe('AmqpConnectionManager', function () {

const [{ connection, url }] = await once(amqp, 'connect');
expect(connectFailedSeen).to.equal(1);
expect(amqp.connectionAttempts).to.equal(2);

// Verify that we round-robined to the next server, since the first was unavailable.
expect(url, 'url').to.equal('amqp://rabbit2');
Expand Down

0 comments on commit 9fdf6ac

Please sign in to comment.