Skip to content

Commit

Permalink
return error callback
Browse files Browse the repository at this point in the history
  • Loading branch information
t2013anurag committed Jun 30, 2018
1 parent cb20e46 commit f1c0234
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ function Client(url, retryAttempts) {
/** @type {Number} */
this._reopenTimeout = null;
/** @type {Number} */
this._retryAttempts = retryAttempts || 3;;
this._retryAttempts = retryAttempts || 3;
/** @type {Number} */
this._counter = 0;
/** @type {Function} */
this._errorCallback = null;
}

Client.prototype.onCaptureError = function(callback) {
this._errorCallback = callback;
};

Client.prototype.open = function() {
clearTimeout(this._reopenTimeout);
this._reopenTimeout = null;
Expand All @@ -47,7 +53,9 @@ Client.prototype._reopen = function() {
this._counter++;
this.open();
} else {
throw new Error('Reached max retryAttempts');
if (typeof this._errorCallback === 'function') {
this._errorCallback(new Error('Reached max retryAttempts'));
}
}
}.bind(this), 1000 * this._counter);
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "socket-redis",
"version": "3.3.1",
"version": "3.3.2",
"description": "Redis to SockJS relay",
"main": "socket-redis.js",
"bin": {
Expand Down

0 comments on commit f1c0234

Please sign in to comment.