You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Formatting
This commit is contained in:
18
index.js
18
index.js
@@ -55,10 +55,10 @@ function RedisClient(stream, options) {
|
|||||||
if (typeof this.options.enable_offline_queue === "boolean") {
|
if (typeof this.options.enable_offline_queue === "boolean") {
|
||||||
this.enable_offline_queue = this.options.enable_offline_queue;
|
this.enable_offline_queue = this.options.enable_offline_queue;
|
||||||
}
|
}
|
||||||
this.retry_max_delay = null;
|
this.retry_max_delay = null;
|
||||||
if (options.retry_max_delay !== undefined && !isNaN(options.retry_max_delay) && options.retry_max_delay > 0) {
|
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.retry_max_delay = options.retry_max_delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialize_retry_vars();
|
this.initialize_retry_vars();
|
||||||
this.pub_sub_mode = false;
|
this.pub_sub_mode = false;
|
||||||
@@ -432,11 +432,11 @@ RedisClient.prototype.connection_gone = function (why) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.retry_max_delay !== null && this.retry_delay > this.retry_max_delay) {
|
if (this.retry_max_delay !== null && this.retry_delay > this.retry_max_delay) {
|
||||||
this.retry_delay = this.retry_max_delay;
|
this.retry_delay = this.retry_max_delay;
|
||||||
} else {
|
} else {
|
||||||
this.retry_delay = Math.floor(this.retry_delay * this.retry_backoff);
|
this.retry_delay = Math.floor(this.retry_delay * this.retry_backoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exports.debug_mode) {
|
if (exports.debug_mode) {
|
||||||
console.log("Retry connection in " + this.retry_delay + " ms");
|
console.log("Retry connection in " + this.retry_delay + " ms");
|
||||||
|
38
test.js
38
test.js
@@ -1799,25 +1799,25 @@ tests.auth = function () {
|
|||||||
};
|
};
|
||||||
|
|
||||||
tests.reconnectRetryMaxDelay = function() {
|
tests.reconnectRetryMaxDelay = function() {
|
||||||
var time = new Date().getTime(),
|
var time = new Date().getTime(),
|
||||||
name = 'reconnectRetryMaxDelay',
|
name = 'reconnectRetryMaxDelay',
|
||||||
reconnecting = false;
|
reconnecting = false;
|
||||||
var client = redis.createClient(PORT, HOST, {
|
var client = redis.createClient(PORT, HOST, {
|
||||||
retry_max_delay: 1
|
retry_max_delay: 1
|
||||||
});
|
});
|
||||||
client.on('ready', function() {
|
client.on('ready', function() {
|
||||||
if (!reconnecting) {
|
if (!reconnecting) {
|
||||||
reconnecting = true;
|
reconnecting = true;
|
||||||
client.retry_delay = 1000;
|
client.retry_delay = 1000;
|
||||||
client.retry_backoff = 1;
|
client.retry_backoff = 1;
|
||||||
client.stream.end();
|
client.stream.end();
|
||||||
} else {
|
} else {
|
||||||
client.end();
|
client.end();
|
||||||
var lasted = new Date().getTime() - time;
|
var lasted = new Date().getTime() - time;
|
||||||
assert.ok(lasted < 1000);
|
assert.ok(lasted < 1000);
|
||||||
next(name);
|
next(name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
all_tests = Object.keys(tests);
|
all_tests = Object.keys(tests);
|
||||||
|
Reference in New Issue
Block a user