Skip to content

Commit 8ecfd3e

Browse files
e920528leibale
andauthored
Add support for CLUSTER MYSHARDID (#2528)
* Add support for CLUSTER.MYSHARDID command * Update CLUSTER_MYSHARDID.ts * Update CLUSTER_MYSHARDID.spec.ts * add test and clean code --------- Co-authored-by: Leibale Eidelman <[email protected]>
1 parent d8ae8cf commit 8ecfd3e

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

packages/client/lib/client/commands.ts

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import * as CLUSTER_KEYSLOT from '../commands/CLUSTER_KEYSLOT';
4646
import * as CLUSTER_LINKS from '../commands/CLUSTER_LINKS';
4747
import * as CLUSTER_MEET from '../commands/CLUSTER_MEET';
4848
import * as CLUSTER_MYID from '../commands/CLUSTER_MYID';
49+
import * as CLUSTER_MYSHARDID from '../commands/CLUSTER_MYSHARDID';
4950
import * as CLUSTER_NODES from '../commands/CLUSTER_NODES';
5051
import * as CLUSTER_REPLICAS from '../commands/CLUSTER_REPLICAS';
5152
import * as CLUSTER_REPLICATE from '../commands/CLUSTER_REPLICATE';
@@ -216,6 +217,8 @@ export default {
216217
clusterMeet: CLUSTER_MEET,
217218
CLUSTER_MYID,
218219
clusterMyId: CLUSTER_MYID,
220+
CLUSTER_MYSHARDID,
221+
clusterMyShardId: CLUSTER_MYSHARDID,
219222
CLUSTER_NODES,
220223
clusterNodes: CLUSTER_NODES,
221224
CLUSTER_REPLICAS,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './CLUSTER_MYSHARDID';
4+
5+
describe('CLUSTER MYSHARDID', () => {
6+
testUtils.isVersionGreaterThanHook([7, 2]);
7+
8+
it('transformArguments', () => {
9+
assert.deepEqual(
10+
transformArguments(),
11+
['CLUSTER', 'MYSHARDID']
12+
);
13+
});
14+
15+
testUtils.testWithCluster('clusterNode.clusterMyShardId', async cluster => {
16+
const client = await cluster.nodeClient(cluster.masters[0]);
17+
assert.equal(
18+
typeof await client.clusterMyShardId(),
19+
'string'
20+
);
21+
}, GLOBAL.CLUSTERS.OPEN);
22+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const IS_READ_ONLY = true;
2+
3+
export function transformArguments() {
4+
return ['CLUSTER', 'MYSHARDID'];
5+
}
6+
7+
export declare function transformReply(): string | Buffer;

0 commit comments

Comments
 (0)