diff --git a/README.md b/README.md index 0e1d444..b44d522 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,11 @@ then replayed just before this event is emitted. is set. If this options is set, `connect` will be emitted when the stream is connected, and then you are free to try to send commands. +### "reconnecting" + +`client` will emit `reconnecting` when trying to reconnect to the Redis server after losing the connection. Listeners +are passed an object containing `delay` (in ms) and `attempt` (the attempt #) attributes. + ### "error" `client` will emit `error` when encountering an error connecting to the Redis server. diff --git a/index.js b/index.js index 0011ef2..28c88a5 100644 --- a/index.js +++ b/index.js @@ -463,9 +463,7 @@ RedisClient.prototype.connection_gone = function (why) { if (this.max_attempts && this.attempts >= this.max_attempts) { this.retry_timer = null; - // TODO - some people need a "Redis is Broken mode" for future commands that errors immediately, and others - // want the program to exit. Right now, we just log, which doesn't really help in either case. - debug("Couldn't get Redis connection after " + this.max_attempts + " attempts."); + this.emit('error', new Error("Redis connection in broken state: maximum connection attempts exceeded.")); return; } @@ -481,8 +479,7 @@ RedisClient.prototype.connection_gone = function (why) { if (self.connect_timeout && self.retry_totaltime >= self.connect_timeout) { self.retry_timer = null; - // TODO - engage Redis is Broken mode for future commands, or whatever - debug("Couldn't get Redis connection after " + self.retry_totaltime + "ms."); + this.emit('error', new Error("Redis connection in broken state: connection timeout exceeded.")); return; }