Skip to content

Commit c091f2e

Browse files
committed
feat(cluster): re-select subscriber when the currenct one is failed
1 parent 69712c4 commit c091f2e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/cluster/ClusterSubscriber.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,20 @@ export default class ClusterSubscriber {
5555
const {options} = sampleNode
5656
debug('selected a subscriber %s:%s', options.host, options.port)
5757

58-
// Create a specialized Redis connection for the subscription.
59-
// Note that auto reconnection is enabled here.
60-
// `enableReadyCheck` is disabled because subscription is allowed
61-
// when redis is loading data from the disk.
58+
/*
59+
* Create a specialized Redis connection for the subscription.
60+
* Note that auto reconnection is enabled here.
61+
*
62+
* `enableReadyCheck` is also enabled because although subscription is allowed
63+
* while redis is loading data from the disk, we can check if the password
64+
* provided for the subscriber is correct, and if not, the current subscriber
65+
* will be disconnected and a new subscriber will be selected.
66+
*/
6267
this.subscriber = new Redis({
6368
port: options.port,
6469
host: options.host,
6570
password: options.password,
66-
enableReadyCheck: false,
71+
enableReadyCheck: true,
6772
connectionName: SUBSCRIBER_CONNECTION_NAME,
6873
lazyConnect: true
6974
})

0 commit comments

Comments
 (0)