From bc29eb1b36f2118f5195cdbfe6fd618df5495b24 Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Mon, 29 Nov 2021 22:17:06 +0800 Subject: [PATCH 1/2] Add the `event` doc Please help me to improve the writing, my English is so bad :( --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index cc2edec9e77..76553f7411b 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,18 @@ await Promise.all([ Check out the [Clustering Guide](./docs/clustering.md) when using Node Redis to connect to a Redis Cluster. +### Events + +Node Redis client class extends Node.js's `EventEmitter` class, and the client emits an event each time the network status changes: + +| Event name | Scenes | Parameters | +| ------------ | ------ | ---------- | +| connect | The client is initiating a connection to the server. | _undefined_ +| ready | The client successfully initiated the connection to the server. | _undefined_ +| end | The client disconnected the connection to the server via `.quit()` or `.disconnect()`. | _undefined_ +| error | When a network error has occurred, such as unable to connect to the server or the connection closed unexpectedly | The error object, such as `SocketClosedUnexpectedlyError: Socket closed unexpectedly` or `Error: connect ECONNREFUSED [IP]:[PORT]` | +| reconnecting | The client is trying to reconnect to the server. | _undefined_ + ## Supported Redis versions Node Redis is supported with the following versions of Redis: From 588b8a8609d27b4bd92858981814065eb3549909 Mon Sep 17 00:00:00 2001 From: AnnAngela Date: Mon, 29 Nov 2021 22:22:35 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 76553f7411b..6eb143f0352 100644 --- a/README.md +++ b/README.md @@ -289,6 +289,8 @@ Node Redis client class extends Node.js's `EventEmitter` class, and the client e | error | When a network error has occurred, such as unable to connect to the server or the connection closed unexpectedly | The error object, such as `SocketClosedUnexpectedlyError: Socket closed unexpectedly` or `Error: connect ECONNREFUSED [IP]:[PORT]` | | reconnecting | The client is trying to reconnect to the server. | _undefined_ +Except for the network, the client will not emmit any events any more. + ## Supported Redis versions Node Redis is supported with the following versions of Redis: