support all Redis.Cluster node types (#22500)

This commit is contained in:
Shahar Mor
2018-01-02 22:46:47 +02:00
committed by Mohamed Hegazy
parent 20bad0bb87
commit cc7f9b4e0c
2 changed files with 30 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
// Christopher Eck <https://github.com/chrisleck>
// Yoga Aliarham <https://github.com/aliarham11>
// Ebrahim <https://github.com/br8h>
// Shahar Mor <https://github.com/shaharmor>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -744,8 +745,15 @@ declare namespace IORedis {
pfcount(...keys: string[]): Pipeline;
}
interface NodeConfiguration {
host?: string;
port?: number;
}
type ClusterNode = string | number | NodeConfiguration;
interface Cluster extends NodeJS.EventEmitter, Commander {
new(nodes: Array<{ host: string; port: number; }>, options?: ClusterOptions): Redis;
new(nodes: ClusterNode[], options?: ClusterOptions): Redis;
connect(callback: () => void): Promise<any>;
disconnect(): void;
nodes(role: string): Redis[];

View File

@@ -107,3 +107,24 @@ redis.multi([
const keys = [ 'foo', 'bar' ];
redis.mget(...keys);
new Redis.Cluster([
'localhost'
]);
new Redis.Cluster([
6379
]);
new Redis.Cluster([{
host: 'localhost'
}]);
new Redis.Cluster([{
port: 6379
}]);
new Redis.Cluster([{
host: 'localhost',
port: 6379
}]);