Skip to content

Commit 237912f

Browse files
committed
adding cluster events docs section
1 parent 787aa6b commit 237912f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/clustering.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,24 @@ createCluster({
120120

121121
> This is a common problem when using ElastiCache. See [Accessing ElastiCache from outside AWS](https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/accessing-elasticache.html) for more information on that.
122122
123+
### Events
124+
125+
The Node Redis cluster class is an Nodejs EventEmitter and emits following events:
126+
127+
| Name | When | Listener arguments |
128+
| ----------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------- |
129+
| `connect` | The cluster connected and ready to use | _No arguments_ |
130+
| `disconnect` | The cluster has disconnected | _No arguments_ |
131+
| `error` | The cluster has errored | `(error: Error)` |
132+
| `node-connect` | One of the cluster's nodes has connected | `(node: { host: string, port: number })` |
133+
| `node-disconnect` | One of the cluster's nodes has disconnected | `(node: { host: string, port: number })` |
134+
| `node-ready` | One of the cluster's nodes is ready to connect | `(node: { host: string, port: number })` |
135+
| `node-reconnecting` | One of the cluster's nodes is trying to reconnect after error has occurred | `(node: { host: string, port: number })` |
136+
| `node-error` | One of the cluster's nodes has errored, usually during TCP connection | `(error: Error, node: { host: string, port: number }` |
137+
138+
> :warning: You **MUST** listen to `error` events. If a cluster doesn't have at least one `error` listener registered and
139+
> an `error` occurs, that error will be thrown and the Node.js process will exit. See the [ > `EventEmitter` docs](https://nodejs.org/api/events.html#events_error_events) for more details.
140+
123141
## Command Routing
124142

125143
### Commands that operate on Redis Keys

0 commit comments

Comments
 (0)