WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sentinel.md
+46Lines changed: 46 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,51 @@ await sentinel.close();
24
24
25
25
In the above example, we configure the sentinel object to fetch the configuration for the database Redis Sentinel is monitoring as "sentinel-db" with one of the sentinels being located at `example:1234`, then using it like a regular Redis client.
26
26
27
+
## Node Address Map
28
+
29
+
A mapping between the addresses returned by sentinel and the addresses the client should connect to.
30
+
Useful when the sentinel nodes are running on a different network to the client.
31
+
32
+
```javascript
33
+
import { createSentinel } from'redis';
34
+
35
+
// Use either a static mapping:
36
+
constsentinel=awaitcreateSentinel({
37
+
name:'sentinel-db',
38
+
sentinelRootNodes: [{
39
+
host:'example',
40
+
port:1234
41
+
}],
42
+
nodeAddressMap: {
43
+
'10.0.0.1:6379': {
44
+
host:'external-host.io',
45
+
port:6379
46
+
},
47
+
'10.0.0.2:6379': {
48
+
host:'external-host.io',
49
+
port:6380
50
+
}
51
+
}
52
+
}).connect();
53
+
54
+
// or create the mapping dynamically, as a function:
55
+
constsentinel=awaitcreateSentinel({
56
+
name:'sentinel-db',
57
+
sentinelRootNodes: [{
58
+
host:'example',
59
+
port:1234
60
+
}],
61
+
nodeAddressMap(address) {
62
+
const [host, port] =address.split(':');
63
+
64
+
return {
65
+
host:`external-${host}.io`,
66
+
port:Number(port)
67
+
};
68
+
}
69
+
}).connect();
70
+
```
71
+
27
72
## `createSentinel` configuration
28
73
29
74
| Property | Default | Description |
@@ -35,6 +80,7 @@ In the above example, we configure the sentinel object to fetch the configuratio
35
80
| sentinelClientOptions || The configuration values for every sentinel in the cluster. Use this for example when specifying an ACL user to connect with |
36
81
| masterPoolSize |`1`| The number of clients connected to the master node |
37
82
| replicaPoolSize |`0`| The number of clients connected to each replica node. When greater than 0, the client will distribute the load by executing read-only commands (such as `GET`, `GEOSEARCH`, etc.) across all the cluster nodes. |
83
+
| nodeAddressMap || Defines the [node address mapping](#node-address-map)|
38
84
| scanInterval |`10000`| Interval in milliseconds to periodically scan for changes in the sentinel topology. The client will query the sentinel for changes at this interval. |
39
85
| passthroughClientErrorEvents |`false`| When `true`, error events from client instances inside the sentinel will be propagated to the sentinel instance. This allows handling all client errors through a single error handler on the sentinel instance. |
40
86
| reserveClient |`false`| When `true`, one client will be reserved for the sentinel object. When `false`, the sentinel object will wait for the first available client from the pool. |
* When greater than 0, the client will distribute the load by executing read-only commands (such as `GET`, `GEOSEARCH`, etc.) across all the cluster nodes.
50
54
*/
51
55
replicaPoolSize?: number;
56
+
/**
57
+
* Mapping between the addresses returned by sentinel and the addresses the client should connect to
58
+
* Useful when the sentinel nodes are running on another network
59
+
*/
60
+
nodeAddressMap?: NodeAddressMap;
52
61
/**
53
62
* Interval in milliseconds to periodically scan for changes in the sentinel topology.
54
63
* The client will query the sentinel for changes at this interval.
0 commit comments