Skip to content

Commit 7196b90

Browse files
authored
fix #1915 - CLIENT TRACKINGINFO (#2127)
* fix #1915 - CLIENT TRACKINGINFO * remove .only
1 parent d8db974 commit 7196b90

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

packages/client/lib/client/commands.ts

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import * as CLIENT_NO_EVICT from '../commands/CLIENT_NO-EVICT';
2525
import * as CLIENT_PAUSE from '../commands/CLIENT_PAUSE';
2626
import * as CLIENT_SETNAME from '../commands/CLIENT_SETNAME';
2727
import * as CLIENT_TRACKING from '../commands/CLIENT_TRACKING';
28+
import * as CLIENT_TRACKINGINFO from '../commands/CLIENT_TRACKINGINFO';
2829
import * as CLIENT_UNPAUSE from '../commands/CLIENT_UNPAUSE';
2930
import * as CLIENT_INFO from '../commands/CLIENT_INFO';
3031
import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS';
@@ -168,6 +169,8 @@ export default {
168169
clientSetName: CLIENT_SETNAME,
169170
CLIENT_TRACKING,
170171
clientTracking: CLIENT_TRACKING,
172+
CLIENT_TRACKINGINFO,
173+
clientTrackingInfo: CLIENT_TRACKINGINFO,
171174
CLIENT_UNPAUSE,
172175
clientUnpause: CLIENT_UNPAUSE,
173176
CLIENT_INFO,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './CLIENT_TRACKINGINFO';
4+
5+
describe('CLIENT TRACKINGINFO', () => {
6+
testUtils.isVersionGreaterThanHook([6, 2]);
7+
8+
it('transformArguments', () => {
9+
assert.deepEqual(
10+
transformArguments(),
11+
['CLIENT', 'TRACKINGINFO']
12+
);
13+
});
14+
15+
testUtils.testWithClient('client.clientTrackingInfo', async client => {
16+
assert.deepEqual(
17+
await client.clientTrackingInfo(),
18+
{
19+
flags: new Set(['off']),
20+
redirect: -1,
21+
prefixes: []
22+
}
23+
);
24+
}, GLOBAL.SERVERS.OPEN);
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { RedisCommandArguments } from '.';
2+
3+
export function transformArguments(): RedisCommandArguments {
4+
return ['CLIENT', 'TRACKINGINFO'];
5+
}
6+
7+
type RawReply = [
8+
'flags',
9+
Array<string>,
10+
'redirect',
11+
number,
12+
'prefixes',
13+
Array<string>
14+
];
15+
16+
interface Reply {
17+
flags: Set<string>;
18+
redirect: number;
19+
prefixes: Array<string>;
20+
}
21+
22+
export function transformReply(reply: RawReply): Reply {
23+
return {
24+
flags: new Set(reply[1]),
25+
redirect: reply[3],
26+
prefixes: reply[5]
27+
};
28+
}

0 commit comments

Comments
 (0)