1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-17 19:41:06 +03:00

better cluster nodes discorvery strategy after MOVED error, add PubSub test

This commit is contained in:
leibale
2021-06-11 17:29:20 -04:00
parent 71242304bc
commit c29c1bb7d2
7 changed files with 312 additions and 9 deletions

View File

@@ -32,9 +32,17 @@ export default class RedisClusterSlots {
throw new Error('None of the root nodes is available');
}
async discover(): Promise<void> {
// TODO: shuffle?
async discover(startWith: RedisClient): Promise<void> {
try {
await this.#discoverNodes(startWith.options?.socket);
return;
} catch (err) {
// this.emit('error', err);
}
for (const client of this.#clientByKey.values()) {
if (client === startWith) continue;
try {
await this.#discoverNodes(client.options?.socket);
return;