Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/cluster/ConnectionPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class ConnectionPool extends EventEmitter {
* Find or create a connection to the node
*/
findOrCreate(node: RedisOptions, readOnly = false): Redis {
const key = getNodeKey(node);
const key = this.getNodeKey(node);
readOnly = Boolean(readOnly);

if (this.specifiedOptions[key]) {
Expand Down Expand Up @@ -113,7 +113,7 @@ export default class ConnectionPool extends EventEmitter {
debug("Reset with %O", nodes);
const newNodes = {};
nodes.forEach((node) => {
const key = getNodeKey(node);
const key = this.getNodeKey(node);

// Don't override the existing (master) node
// when the current one is slave.
Expand Down Expand Up @@ -147,4 +147,8 @@ export default class ConnectionPool extends EventEmitter {
delete nodes.master[key];
delete nodes.slave[key];
}

private getNodeKey(options: RedisOptions) {
return getNodeKey(options) + ':' + options.nodeId;
}
}
1 change: 1 addition & 0 deletions lib/cluster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ class Cluster extends Commander {
port: items[j][1],
});
node.readOnly = j !== 2;
node.nodeId = items[j][2];
nodes.push(node);
keys.push(node.host + ":" + node.port);
}
Expand Down
1 change: 1 addition & 0 deletions lib/cluster/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface RedisOptions {
host: string;
username?: string;
password?: string;
nodeId?: string;
[key: string]: any;
}

Expand Down