From ed8339f37600d6f5f36d05d9d128c8331408d07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Thu, 10 Sep 2020 18:08:45 +0300 Subject: [PATCH] Add support for IORedis.Cluster type in ConnectionOptions for TypeScript (#438) * Add support for IORedis.Cluster type in ConnectionOptions for TypeScript * Add brief documentation that redisCluster is also supported --- README.md | 4 ++++ src/core/connection.ts | 2 +- src/types/options.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a58bf85e..44c20268 100644 --- a/README.md +++ b/README.md @@ -261,10 +261,14 @@ You can also pass redis client directly. ```javascript // assume you already initialized redis client before +// the "redis" key can be IORedis.Redis or IORedis.Cluster instance var redisClient = new Redis(); var connectionDetails = { redis: redisClient }; +var redisCluster = new Cluster(); +var connectionDetails = { redis: redisCluster }; + var worker = new NodeResque.Worker( { connection: connectionDetails, queues: "math" }, jobs diff --git a/src/core/connection.ts b/src/core/connection.ts index 36fe689e..e2bf6568 100644 --- a/src/core/connection.ts +++ b/src/core/connection.ts @@ -12,7 +12,7 @@ export class Connection extends EventEmitter { options: ConnectionOptions | null; private eventListeners: EventListeners; connected: boolean; - redis: IORedis.Redis; + redis: IORedis.Redis | IORedis.Cluster; constructor(options: ConnectionOptions = {}) { super(); diff --git a/src/types/options.ts b/src/types/options.ts index fa9987b2..0eb9b773 100644 --- a/src/types/options.ts +++ b/src/types/options.ts @@ -10,7 +10,7 @@ export interface ConnectionOptions { namespace?: string; looping?: boolean; options?: any; - redis?: IORedis.Redis; + redis?: IORedis.Redis | IORedis.Cluster; scanCount?: number; }