node-nats-streaming-buffered-client
Advanced tools
Comparing version 1.3.5 to 1.3.6
@@ -53,10 +53,13 @@ "use strict"; | ||
* @param {*} [logger=console] The console logger to use | ||
* @param {number} [reconnectDelay=5000] If reconnect fails retry after this amount of time. Default is 5 seconds | ||
* @memberof NatsBufferedClient | ||
*/ | ||
function NatsBufferedClient(bufferSize, waitForInitialConnection, logger) { | ||
function NatsBufferedClient(bufferSize, waitForInitialConnection, logger, reconnectDelay) { | ||
if (bufferSize === void 0) { bufferSize = 10; } | ||
if (waitForInitialConnection === void 0) { waitForInitialConnection = false; } | ||
if (logger === void 0) { logger = console; } | ||
if (reconnectDelay === void 0) { reconnectDelay = 5000; } | ||
var _this = this; | ||
this.waitForInitialConnection = waitForInitialConnection; | ||
this.reconnectDelay = reconnectDelay; | ||
/** | ||
@@ -243,2 +246,4 @@ * Indicates if we're processing the buffer | ||
return __awaiter(this, void 0, void 0, function () { | ||
var disconnectError_1, connectError_1; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
@@ -250,11 +255,30 @@ switch (_a.label) { | ||
this.logger.log('[NATS-BUFFERED-CLIENT] Reconnect requested. Disconnecting...'); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.disconnect()]; | ||
case 1: | ||
case 2: | ||
_a.sent(); | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
disconnectError_1 = _a.sent(); | ||
this.logger.warn('[NATS-BUFFERED-CLIENT] Error during disconnect', disconnectError_1); | ||
return [3 /*break*/, 4]; | ||
case 4: | ||
// Create a new connection | ||
// | ||
this.logger.log('[NATS-BUFFERED-CLIENT] Disconnected trying to connect again...'); | ||
_a.label = 5; | ||
case 5: | ||
_a.trys.push([5, 7, , 8]); | ||
return [4 /*yield*/, this.connect(this.clusterId, this.clientId, this.clientOptions)]; | ||
case 2: | ||
case 6: | ||
_a.sent(); | ||
return [3 /*break*/, 8]; | ||
case 7: | ||
connectError_1 = _a.sent(); | ||
this.logger.warn('[NATS-BUFFERED-CLIENT] Error during connect. Retry in 5 seconds', connectError_1); | ||
setTimeout(function () { return _this.reconnect(); }, this.reconnectDelay); | ||
return [3 /*break*/, 8]; | ||
case 8: | ||
this.logger.log('[NATS-BUFFERED-CLIENT] Reconnect completed'); | ||
@@ -261,0 +285,0 @@ return [2 /*return*/]; |
@@ -11,2 +11,3 @@ /// <reference types="node" /> | ||
private waitForInitialConnection; | ||
private reconnectDelay; | ||
/** | ||
@@ -79,5 +80,6 @@ * The connection to the NATS server | ||
* @param {*} [logger=console] The console logger to use | ||
* @param {number} [reconnectDelay=5000] If reconnect fails retry after this amount of time. Default is 5 seconds | ||
* @memberof NatsBufferedClient | ||
*/ | ||
constructor(bufferSize?: number, waitForInitialConnection?: boolean, logger?: Console); | ||
constructor(bufferSize?: number, waitForInitialConnection?: boolean, logger?: Console, reconnectDelay?: number); | ||
/** | ||
@@ -84,0 +86,0 @@ * Connect to the NATS server |
{ | ||
"name": "node-nats-streaming-buffered-client", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
Sorry, the diff of this file is not supported yet
36046
531