From 59725e3f20f1fb753abb2dc077a2382ffb00ee88 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 17 Dec 2016 17:42:03 +0100 Subject: [PATCH] Remove deprecated max_delay --- README.md | 1 - index.js | 23 ----------------------- test/connection.spec.js | 13 ------------- test/node_redis.spec.js | 28 ---------------------------- 4 files changed, 65 deletions(-) diff --git a/README.md b/README.md index 07b0727e26..9c3fc78c57 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,6 @@ __Tip:__ If the Redis server runs on the same machine as the client consider usi | socket_keepalive | true | If set to `true`, the keep-alive functionality is enabled on the underlying socket. | | no_ready_check | false | When a connection is established to the Redis server, the server might still be loading the database from disk. While loading, the server will not respond to any commands. To work around this, `node_redis` has a "ready check" which sends the `INFO` command to the server. The response from the `INFO` command indicates whether the server is ready for more commands. When ready, `node_redis` emits a `ready` event. Setting `no_ready_check` to `true` will inhibit this check. | | enable_offline_queue | true | By default, if there is no active connection to the Redis server, commands are added to a queue and are executed once the connection has been established. Setting `enable_offline_queue` to `false` will disable this feature and the callback will be executed immediately with an error, or an error will be emitted if no callback is specified. | -| retry_max_delay | null | __Deprecated__ _Please use `retry_strategy` instead._ By default, every time the client tries to connect and fails, the reconnection delay almost doubles. This delay normally grows infinitely, but setting `retry_max_delay` limits it to the maximum value provided in milliseconds. | | connect_timeout | 3600000 | __Deprecated__ _Please use `retry_strategy` instead._ Setting `connect_timeout` limits the total time for the client to connect and reconnect. The value is provided in milliseconds and is counted from the moment a new client is created or from the time the connection is lost. The last retry is going to happen exactly at the timeout time. Default is to try connecting until the default system socket timeout has been exceeded and to try reconnecting until 1h has elapsed. | | retry_unfulfilled_commands | false | If set to `true`, all commands that were unfulfilled while the connection is lost will be retried after the connection has been reestablished. Use this with caution if you use state altering commands (e.g. `incr`). This is especially useful if you use blocking commands. | | password | null | If set, client will run Redis auth command on connect. Alias `auth_pass` __Note__ `node_redis` < 2.5 must use `auth_pass` | diff --git a/index.js b/index.js index 176c5c7f72..83014be58d 100644 --- a/index.js +++ b/index.js @@ -66,14 +66,6 @@ function RedisClient (options, stream) { cnx_options.family = (!options.family && net.isIP(cnx_options.host)) || (options.family === 'IPv6' ? 6 : 4); this.address = cnx_options.host + ':' + cnx_options.port; } - // Warn on misusing deprecated functions - if (typeof options.retry_strategy === 'function') { - if ('retry_max_delay' in options) { - self.warn('WARNING: You activated the retry_strategy and retry_max_delay at the same time. This is not possible and retry_max_delay will be ignored.'); - // Do not print deprecation warnings twice - delete options.retry_max_delay; - } - } this.connection_options = cnx_options; this.connection_id = RedisClient.connection_id++; @@ -104,14 +96,6 @@ function RedisClient (options, stream) { // This should be done by the retry_strategy. Instead it should only be the timeout for connecting to redis this.connect_timeout = +options.connect_timeout || 3600000; // 60 * 60 * 1000 ms this.enable_offline_queue = options.enable_offline_queue === false ? false : true; - this.retry_max_delay = +options.retry_max_delay || null; - if ('retry_max_delay' in options) { - self.warn( - 'retry_max_delay is deprecated and will be removed in v.3.0.0.\n' + - 'To reduce the amount of options and the improve the reconnection handling please use the new `retry_strategy` option instead.\n' + - 'This replaces the max_attempts and retry_max_delay option.' - ); - } this.initialize_retry_vars(); this.pub_sub_mode = 0; this.subscription_set = {}; @@ -606,13 +590,6 @@ RedisClient.prototype.connection_gone = function (why, error) { }); } - if (this.retry_max_delay !== null && this.retry_delay > this.retry_max_delay) { - this.retry_delay = this.retry_max_delay; - } else if (this.retry_totaltime + this.retry_delay > this.connect_timeout) { - // Do not exceed the maximum - this.retry_delay = this.connect_timeout - this.retry_totaltime; - } - debug('Retry connection in ' + this.retry_delay + ' ms'); this.retry_timer = setTimeout(retry_connection, this.retry_delay, this, error); diff --git a/test/connection.spec.js b/test/connection.spec.js index 1659eb9073..e8791f6fc6 100644 --- a/test/connection.spec.js +++ b/test/connection.spec.js @@ -204,11 +204,6 @@ describe('connection tests', function () { }); it('retryStrategy used to reconnect with individual error', function (done) { - var text = ''; - var unhookIntercept = intercept(function (data) { - text += data; - return ''; - }); client = redis.createClient({ retryStrategy: function (options) { if (options.totalRetryTime > 150) { @@ -222,16 +217,8 @@ describe('connection tests', function () { } return Math.min(options.attempt * 25, 200); }, - retryMaxDelay: 123, port: 9999 }); - process.nextTick(function () { - assert.strictEqual( - text, - 'node_redis: WARNING: You activated the retry_strategy and retry_max_delay at the same time. This is not possible and retry_max_delay will be ignored.\n' - ); - unhookIntercept(); - }); }); it('retry_strategy used to reconnect', function (done) { diff --git a/test/node_redis.spec.js b/test/node_redis.spec.js index 2ffcd6a740..e63ae2029b 100644 --- a/test/node_redis.spec.js +++ b/test/node_redis.spec.js @@ -757,34 +757,6 @@ describe('The node_redis client', function () { // }); }); - describe('retry_max_delay', function () { - it('sets upper bound on how long client waits before reconnecting', function (done) { - var time; - var timeout = process.platform !== 'win32' ? 20 : 100; - - client = redis.createClient.apply(null, config.configureClient(parser, ip, { - retry_max_delay: 1 // ms - })); - client.on('ready', function () { - if (this.times_connected === 1) { - this.stream.end(); - time = Date.now(); - } else { - done(); - } - }); - client.on('reconnecting', function () { - time = Date.now() - time; - assert(time < timeout, 'The reconnect should not have taken longer than ' + timeout + ' but it took ' + time); - }); - client.on('error', function (err) { - // This is rare but it might be triggered. - // So let's have a robust test - assert.strictEqual(err.code, 'ECONNRESET'); - }); - }); - }); - describe('protocol error', function () { it('should gracefully recover and only fail on the already send commands', function (done) {