amqp-connection-manager
Advanced tools
Comparing version 3.4.5 to 3.5.0
@@ -118,2 +118,25 @@ "use strict"; | ||
} | ||
/** Force reconnect - noop unless connected */ | ||
reconnect() { | ||
if (this._closed) { | ||
throw new Error('cannot reconnect after close'); | ||
} | ||
// If we have a connection, close it and immediately connect again. | ||
// Wait for ordinary reconnect otherwise. | ||
if (this._currentConnection) { | ||
this._currentConnection.removeAllListeners(); | ||
this._currentConnection | ||
.close() | ||
.catch(() => { | ||
// noop | ||
}) | ||
.then(() => { | ||
this._currentConnection = undefined; | ||
this._disconnectSent = true; | ||
this.emit('disconnect', { err: new Error('forced reconnect') }); | ||
return this._connect(); | ||
}) | ||
.catch(neverThrows); | ||
} | ||
} | ||
/** The current connection. */ | ||
@@ -158,3 +181,4 @@ get connection() { | ||
this._currentUrl++; | ||
let connectionOptions; | ||
// Set connectionOptions to the setting in the class instance (which came via the constructor) | ||
let connectionOptions = this.connectionOptions; | ||
let originalUrl; | ||
@@ -164,3 +188,5 @@ let connect; | ||
originalUrl = connect = url.url; | ||
connectionOptions = url.connectionOptions || connectionOptions; | ||
// If URL is an object, pull out any specific URL connectionOptions for it or use the | ||
// instance connectionOptions if none were provided for this specific URL. | ||
connectionOptions = url.connectionOptions || this.connectionOptions; | ||
} | ||
@@ -167,0 +193,0 @@ else if (typeof url === 'string') { |
@@ -154,2 +154,4 @@ /// <reference types="node" /> | ||
isConnected(): boolean; | ||
/** Force reconnect - noop unless connected */ | ||
reconnect(): void; | ||
/** The current connection. */ | ||
@@ -156,0 +158,0 @@ get connection(): Connection | undefined; |
@@ -113,2 +113,25 @@ import amqp from 'amqplib'; | ||
} | ||
/** Force reconnect - noop unless connected */ | ||
reconnect() { | ||
if (this._closed) { | ||
throw new Error('cannot reconnect after close'); | ||
} | ||
// If we have a connection, close it and immediately connect again. | ||
// Wait for ordinary reconnect otherwise. | ||
if (this._currentConnection) { | ||
this._currentConnection.removeAllListeners(); | ||
this._currentConnection | ||
.close() | ||
.catch(() => { | ||
// noop | ||
}) | ||
.then(() => { | ||
this._currentConnection = undefined; | ||
this._disconnectSent = true; | ||
this.emit('disconnect', { err: new Error('forced reconnect') }); | ||
return this._connect(); | ||
}) | ||
.catch(neverThrows); | ||
} | ||
} | ||
/** The current connection. */ | ||
@@ -153,3 +176,4 @@ get connection() { | ||
this._currentUrl++; | ||
let connectionOptions; | ||
// Set connectionOptions to the setting in the class instance (which came via the constructor) | ||
let connectionOptions = this.connectionOptions; | ||
let originalUrl; | ||
@@ -159,3 +183,5 @@ let connect; | ||
originalUrl = connect = url.url; | ||
connectionOptions = url.connectionOptions || connectionOptions; | ||
// If URL is an object, pull out any specific URL connectionOptions for it or use the | ||
// instance connectionOptions if none were provided for this specific URL. | ||
connectionOptions = url.connectionOptions || this.connectionOptions; | ||
} | ||
@@ -162,0 +188,0 @@ else if (typeof url === 'string') { |
{ | ||
"name": "amqp-connection-manager", | ||
"version": "3.4.5", | ||
"version": "3.5.0", | ||
"description": "Auto-reconnect and round robin support for amqplib.", | ||
@@ -5,0 +5,0 @@ "module": "./dist/esm/index.js", |
Sorry, the diff of this file is not supported yet
112030
1883