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

Add a connection timeout of 24h as new default for maximum reconnecting

This commit is contained in:
Ruben Bridgewater
2015-09-10 17:59:25 +02:00
parent 04c986a4cd
commit f2ee8dbc9e
2 changed files with 4 additions and 5 deletions

View File

@@ -194,8 +194,9 @@ with an error, or an error will be thrown if no callback is specified.
* `retry_max_delay`: defaults to `null`. By default every time the client tries to connect and fails time before * `retry_max_delay`: defaults to `null`. By default every time the client tries to connect and fails time before
reconnection (delay) almost doubles. This delay normally grows infinitely, but setting `retry_max_delay` limits delay reconnection (delay) almost doubles. This delay normally grows infinitely, but setting `retry_max_delay` limits delay
to maximum value, provided in milliseconds. to maximum value, provided in milliseconds.
* `connect_timeout` defaults to `false`. By default client will try reconnecting until connected. Setting `connect_timeout` * `connect_timeout` defaults to `86400000`. Setting `connect_timeout` limits total time for client to reconnect.
limits total time for client to reconnect. Value is provided in milliseconds and is counted once the disconnect occured. Value is provided in milliseconds and is counted once the disconnect occured. The last retry is going to happen once after the connect_timeout value is exceeded.
That way the default is to try reconnecting until at least 24h passed.
* `max_attempts` defaults to `null`. By default client will try reconnecting until connected. Setting `max_attempts` * `max_attempts` defaults to `null`. By default client will try reconnecting until connected. Setting `max_attempts`
limits total amount of reconnects. limits total amount of reconnects.
* `auth_pass` defaults to `null`. By default client will try connecting without auth. If set, client will run redis auth command on connect. * `auth_pass` defaults to `null`. By default client will try connecting without auth. If set, client will run redis auth command on connect.

View File

@@ -58,9 +58,7 @@ function RedisClient(stream, options) {
this.command_queue = new Queue(); // holds sent commands to de-pipeline them this.command_queue = new Queue(); // holds sent commands to de-pipeline them
this.offline_queue = new Queue(); // holds commands issued but not able to be sent this.offline_queue = new Queue(); // holds commands issued but not able to be sent
this.commands_sent = 0; this.commands_sent = 0;
if (options.connect_timeout && options.connect_timeout > 0) { this.connect_timeout = +options.connect_timeout || 86400000; // 24 * 60 * 60 * 1000 ms
this.connect_timeout = +options.connect_timeout;
}
this.enable_offline_queue = true; this.enable_offline_queue = true;
if (this.options.enable_offline_queue === false) { if (this.options.enable_offline_queue === false) {
this.enable_offline_queue = false; this.enable_offline_queue = false;