From 9fdf6ac0e3d93f547ba97469214b4bfe13d5dfc2 Mon Sep 17 00:00:00 2001 From: Jason Walton Date: Fri, 7 Jan 2022 13:13:47 -0500 Subject: [PATCH] refactor: Remove AmqpConnectionManager.connectionAttempts --- README.md | 4 ---- src/AmqpConnectionManager.ts | 12 ------------ test/AmqpConnectionManagerTest.ts | 3 +-- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/README.md b/README.md index c9ed351..f59edea 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/AmqpConnectionManager.ts b/src/AmqpConnectionManager.ts index be39f56..b190cd6 100644 --- a/src/AmqpConnectionManager.ts +++ b/src/AmqpConnectionManager.ts @@ -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. * @@ -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() diff --git a/test/AmqpConnectionManagerTest.ts b/test/AmqpConnectionManagerTest.ts index 1349a85..34a9254 100644 --- a/test/AmqpConnectionManagerTest.ts +++ b/test/AmqpConnectionManagerTest.ts @@ -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(); }); @@ -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');