1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Merge branch 'add-retry-max' of https://github.com/tomaszdurka/node_redis into tomaszdurka-add-retry-max

This commit is contained in:
Bryce Baril
2013-03-17 15:59:40 -07:00
3 changed files with 34 additions and 2 deletions

View File

@@ -51,11 +51,14 @@ function RedisClient(stream, options) {
if (options.connect_timeout && !isNaN(options.connect_timeout) && options.connect_timeout > 0) {
this.connect_timeout = +options.connect_timeout;
}
this.enable_offline_queue = true;
if (typeof this.options.enable_offline_queue === "boolean") {
this.enable_offline_queue = this.options.enable_offline_queue;
}
this.retry_max_delay = null;
if (options.retry_max_delay !== undefined && !isNaN(options.retry_max_delay) && options.retry_max_delay > 0) {
this.retry_max_delay = options.retry_max_delay;
}
this.initialize_retry_vars();
this.pub_sub_mode = false;
@@ -429,7 +432,11 @@ RedisClient.prototype.connection_gone = function (why) {
return;
}
this.retry_delay = Math.floor(this.retry_delay * this.retry_backoff);
if (this.retry_max_delay !== null && this.retry_delay > this.retry_max_delay) {
this.retry_delay = this.retry_max_delay;
} else {
this.retry_delay = Math.floor(this.retry_delay * this.retry_backoff);
}
if (exports.debug_mode) {
console.log("Retry connection in " + this.retry_delay + " ms");