1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

fix #1864 - cluster.quit (#1886)

This commit is contained in:
Leibale Eidelman
2022-01-31 08:35:35 -05:00
committed by GitHub
parent 8160fa7d65
commit 46b831c922
2 changed files with 19 additions and 4 deletions

View File

@ -232,10 +232,21 @@ export default class RedisClusterSlots<M extends RedisModules, S extends RedisSc
return this.#nodeByUrl.get(url);
}
async disconnect(): Promise<void> {
await Promise.all(
[...this.#nodeByUrl.values()].map(({ client }) => client.disconnect())
);
quit(): Promise<void> {
return this.#destroy(client => client.quit());
}
disconnect(): Promise<void> {
return this.#destroy(client => client.disconnect());
}
async #destroy(fn: (client: RedisClientType<M, S>) => Promise<unknown>): Promise<void> {
const promises = [];
for (const { client } of this.#nodeByUrl.values()) {
promises.push(fn(client));
}
await Promise.all(promises);
this.#nodeByUrl.clear();
this.#slots.splice(0);

View File

@ -191,6 +191,10 @@ export default class RedisCluster<M extends RedisModules, S extends RedisScripts
return this.#slots.getSlotMaster(slot);
}
quit(): Promise<void> {
return this.#slots.quit();
}
disconnect(): Promise<void> {
return this.#slots.disconnect();
}