Skip to content

Commit 94dbcc8

Browse files
authored
fix #1912 - CLIENT PAUSE (#2125)
* fix #1912 - CLIENT PAUSE * fix client pause * Update commands.ts
1 parent 53a96cc commit 94dbcc8

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

packages/client/lib/client/commands.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import * as CLIENT_GETREDIR from '../commands/CLIENT_GETREDIR';
2222
import * as CLIENT_ID from '../commands/CLIENT_ID';
2323
import * as CLIENT_KILL from '../commands/CLIENT_KILL';
2424
import * as CLIENT_NO_EVICT from '../commands/CLIENT_NO-EVICT';
25+
import * as CLIENT_PAUSE from '../commands/CLIENT_PAUSE';
2526
import * as CLIENT_SETNAME from '../commands/CLIENT_SETNAME';
2627
import * as CLIENT_INFO from '../commands/CLIENT_INFO';
2728
import * as CLUSTER_ADDSLOTS from '../commands/CLUSTER_ADDSLOTS';
@@ -157,10 +158,12 @@ export default {
157158
clientId: CLIENT_ID,
158159
CLIENT_KILL,
159160
clientKill: CLIENT_KILL,
160-
CLIENT_SETNAME,
161-
clientSetName: CLIENT_SETNAME,
162161
'CLIENT_NO-EVICT': CLIENT_NO_EVICT,
163162
clientNoEvict: CLIENT_NO_EVICT,
163+
CLIENT_PAUSE,
164+
clientPause: CLIENT_PAUSE,
165+
CLIENT_SETNAME,
166+
clientSetName: CLIENT_SETNAME,
164167
CLIENT_INFO,
165168
clientInfo: CLIENT_INFO,
166169
CLUSTER_ADDSLOTS,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments } from './CLIENT_PAUSE';
4+
5+
describe('CLIENT PAUSE', () => {
6+
describe('transformArguments', () => {
7+
it('simple', () => {
8+
assert.deepEqual(
9+
transformArguments(0),
10+
['CLIENT', 'PAUSE', '0']
11+
);
12+
});
13+
14+
it('with mode', () => {
15+
assert.deepEqual(
16+
transformArguments(0, 'ALL'),
17+
['CLIENT', 'PAUSE', '0', 'ALL']
18+
);
19+
});
20+
});
21+
22+
testUtils.testWithClient('client.clientPause', async client => {
23+
assert.equal(
24+
await client.clientPause(0),
25+
'OK'
26+
);
27+
}, GLOBAL.SERVERS.OPEN);
28+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { RedisCommandArguments } from '.';
2+
3+
export function transformArguments(
4+
timeout: number,
5+
mode?: 'WRITE' | 'ALL'
6+
): RedisCommandArguments {
7+
const args = [
8+
'CLIENT',
9+
'PAUSE',
10+
timeout.toString()
11+
];
12+
13+
if (mode) {
14+
args.push(mode);
15+
}
16+
17+
return args;
18+
}
19+
20+
export declare function transformReply(): 'OK' | Buffer;

0 commit comments

Comments
 (0)