Skip to content

Commit c11d2ec

Browse files
committed
add back getMasters and getSlotMaster as deprecated functions
1 parent b007316 commit c11d2ec

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

packages/client/lib/cluster/index.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,31 @@ describe('Cluster', () => {
140140
assert.equal(ids.size, totalNodes);
141141
}, GLOBAL.CLUSTERS.WITH_REPLICAS);
142142

143+
testUtils.testWithCluster('getMasters should be backwards competiable (without `minimizeConnections`)', async cluster => {
144+
const masters = cluster.getMasters();
145+
assert.ok(Array.isArray(masters));
146+
for (const master of masters) {
147+
assert.equal(typeof master.id, 'string');
148+
assert.ok(master.client instanceof RedisClient);
149+
}
150+
}, {
151+
...GLOBAL.CLUSTERS.OPEN,
152+
clusterConfiguration: {
153+
minimizeConnections: undefined // reset to default
154+
}
155+
});
156+
157+
testUtils.testWithCluster('getSlotMaster should be backwards competiable (without `minimizeConnections`)', async cluster => {
158+
const master = cluster.getSlotMaster(0);
159+
assert.equal(typeof master.id, 'string');
160+
assert.ok(master.client instanceof RedisClient);
161+
}, {
162+
...GLOBAL.CLUSTERS.OPEN,
163+
clusterConfiguration: {
164+
minimizeConnections: undefined // reset to default
165+
}
166+
});
167+
143168
describe('minimizeConnections', () => {
144169
testUtils.testWithCluster('false', async cluster => {
145170
for (const master of cluster.masters) {

packages/client/lib/cluster/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,20 @@ export default class RedisCluster<
398398
getSlotRandomNode(slot: number) {
399399
return this.#slots.getSlotRandomNode(slot);
400400
}
401+
402+
/**
403+
* @deprecated use `.masters` instead
404+
*/
405+
getMasters() {
406+
return this.masters;
407+
}
408+
409+
/**
410+
* @deprecated use `.slots[<SLOT>]` instead
411+
*/
412+
getSlotMaster(slot: number) {
413+
return this.slots[slot].master;
414+
}
401415
}
402416

403417
attachCommands({

0 commit comments

Comments
 (0)