Skip to content

Commit b46f082

Browse files
committed
wip
1 parent 4894c26 commit b46f082

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+826
-625
lines changed

docs/v4-to-v5.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ Some command arguments/replies have changed to align more closely to data types
165165
- `CLUSETER SETSLOT`: `ClusterSlotStates` -> `CLUSTER_SLOT_STATES` [^enum-to-constants]
166166
- `FUNCTION RESTORE`: the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
167167
- `CLUSTER RESET`: the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
168+
- `CLUSTER FAILOVER`: `enum FailoverModes` -> `const FAILOVER_MODES` [^enum-to-constants], the second argument is `{ mode: string; }` instead of `string` [^future-proofing]
169+
- `CLUSTER LINKS`: `createTime` -> `create-time`, `sendBufferAllocated` -> `send-buffer-allocated`, `sendBufferUsed` -> `send-buffer-used` [^map-keys]
170+
- `TIME`: `Date` -> `[unixTimestamp: string, microseconds: string]`
168171

169172
[^enum-to-constants]: TODO
170173

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { strict as assert } from 'assert';
2-
import { transformArguments } from './ASKING';
2+
import ASKING from './ASKING';
33

44
describe('ASKING', () => {
5-
it('transformArguments', () => {
6-
assert.deepEqual(
7-
transformArguments(),
8-
['ASKING']
9-
);
10-
});
5+
it('transformArguments', () => {
6+
assert.deepEqual(
7+
ASKING.transformArguments(),
8+
['ASKING']
9+
);
10+
});
1111
});
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import { strict as assert } from 'assert';
2-
import { transformArguments } from './BGREWRITEAOF';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import BGREWRITEAOF from './BGREWRITEAOF';
34

45
describe('BGREWRITEAOF', () => {
5-
it('transformArguments', () => {
6-
assert.deepEqual(
7-
transformArguments(),
8-
['BGREWRITEAOF']
9-
);
10-
});
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
BGREWRITEAOF.transformArguments(),
9+
['BGREWRITEAOF']
10+
);
11+
});
12+
13+
testUtils.testWithClient('client.bgRewriteAof', async client => {
14+
assert.equal(
15+
typeof await client.bgRewriteAof(),
16+
'string'
17+
);
18+
}, GLOBAL.SERVERS.OPEN);
1119
});
Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
import { strict as assert } from 'assert';
2-
import { describe } from 'mocha';
3-
import { transformArguments } from './BGSAVE';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import BGSAVE from './BGSAVE';
44

55
describe('BGSAVE', () => {
6-
describe('transformArguments', () => {
7-
it('simple', () => {
8-
assert.deepEqual(
9-
transformArguments(),
10-
['BGSAVE']
11-
);
12-
});
6+
describe('transformArguments', () => {
7+
it('simple', () => {
8+
assert.deepEqual(
9+
BGSAVE.transformArguments(),
10+
['BGSAVE']
11+
);
12+
});
1313

14-
it('with SCHEDULE', () => {
15-
assert.deepEqual(
16-
transformArguments({
17-
SCHEDULE: true
18-
}),
19-
['BGSAVE', 'SCHEDULE']
20-
);
21-
});
14+
it('with SCHEDULE', () => {
15+
assert.deepEqual(
16+
BGSAVE.transformArguments({
17+
SCHEDULE: true
18+
}),
19+
['BGSAVE', 'SCHEDULE']
20+
);
2221
});
22+
});
23+
24+
testUtils.testWithClient('client.bgSave', async client => {
25+
assert.equal(
26+
typeof await client.bgSave(),
27+
'string'
28+
);
29+
}, GLOBAL.SERVERS.OPEN);
2330
});
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import { SimpleStringReply, Command } from '../RESP/types';
22

3+
export interface BgSaveOptions {
4+
SCHEDULE?: boolean;
5+
}
6+
37
export default {
48
FIRST_KEY_INDEX: undefined,
59
IS_READ_ONLY: true,
6-
transformArguments() {
7-
return ['BGSAVE'];
10+
transformArguments(options?: BgSaveOptions) {
11+
const args = ['BGSAVE'];
12+
13+
if (options?.SCHEDULE) {
14+
args.push('SCHEDULE');
15+
}
16+
17+
return args;
818
},
919
transformReply: undefined as unknown as () => SimpleStringReply
1020
} as const satisfies Command;
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
import { strict as assert } from 'assert';
22
import testUtils, { GLOBAL } from '../test-utils';
3-
import { transformArguments } from './CLUSTER_COUNT-FAILURE-REPORTS';
3+
import CLUSTER_COUNT_FAILURE_REPORTS from './CLUSTER_COUNT-FAILURE-REPORTS';
44

55
describe('CLUSTER COUNT-FAILURE-REPORTS', () => {
6-
it('transformArguments', () => {
7-
assert.deepEqual(
8-
transformArguments('0'),
9-
['CLUSTER', 'COUNT-FAILURE-REPORTS', '0']
10-
);
11-
});
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
CLUSTER_COUNT_FAILURE_REPORTS.transformArguments('0'),
9+
['CLUSTER', 'COUNT-FAILURE-REPORTS', '0']
10+
);
11+
});
1212

13-
testUtils.testWithCluster('clusterNode.clusterCountFailureReports', async cluster => {
14-
const client = await cluster.nodeClient(cluster.masters[0]);
15-
assert.equal(
16-
typeof await client.clusterCountFailureReports(
17-
await client.clusterMyId()
18-
),
19-
'number'
20-
);
21-
}, GLOBAL.CLUSTERS.OPEN);
13+
testUtils.testWithCluster('clusterNode.clusterCountFailureReports', async cluster => {
14+
const [master] = cluster.masters,
15+
client = await cluster.nodeClient(master);
16+
assert.equal(
17+
typeof await client.clusterCountFailureReports(master.id),
18+
'number'
19+
);
20+
}, GLOBAL.CLUSTERS.OPEN);
2221
});
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { strict as assert } from 'assert';
22
import testUtils, { GLOBAL } from '../test-utils';
3-
import { transformArguments } from './CLUSTER_COUNTKEYSINSLOT';
3+
import CLUSTER_COUNTKEYSINSLOT from './CLUSTER_COUNTKEYSINSLOT';
44

55
describe('CLUSTER COUNTKEYSINSLOT', () => {
6-
it('transformArguments', () => {
7-
assert.deepEqual(
8-
transformArguments(0),
9-
['CLUSTER', 'COUNTKEYSINSLOT', '0']
10-
);
11-
});
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
CLUSTER_COUNTKEYSINSLOT.transformArguments(0),
9+
['CLUSTER', 'COUNTKEYSINSLOT', '0']
10+
);
11+
});
1212

13-
testUtils.testWithCluster('clusterNode.clusterCountKeysInSlot', async cluster => {
14-
const client = await cluster.nodeClient(cluster.masters[0]);
15-
assert.equal(
16-
typeof await client.clusterCountKeysInSlot(0),
17-
'number'
18-
);
19-
}, GLOBAL.CLUSTERS.OPEN);
13+
testUtils.testWithCluster('clusterNode.clusterCountKeysInSlot', async cluster => {
14+
const client = await cluster.nodeClient(cluster.masters[0]);
15+
assert.equal(
16+
typeof await client.clusterCountKeysInSlot(0),
17+
'number'
18+
);
19+
}, GLOBAL.CLUSTERS.OPEN);
2020
});

packages/client/lib/commands/CLUSTER_COUNTKEYSINSLOT.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
FIRST_KEY_INDEX: undefined,
55
IS_READ_ONLY: true,
66
transformArguments(slot: number) {
7-
return ['CLUSTER', 'COUNT-FAILURE-REPORTS', slot.toString()];
7+
return ['CLUSTER', 'COUNTKEYSINSLOT', slot.toString()];
88
},
99
transformReply: undefined as unknown as () => NumberReply
1010
} as const satisfies Command;
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { strict as assert } from 'assert';
2-
import { transformArguments } from './CLUSTER_DELSLOTS';
2+
import CLUSTER_DELSLOTS from './CLUSTER_DELSLOTS';
33

44
describe('CLUSTER DELSLOTS', () => {
5-
describe('transformArguments', () => {
6-
it('single', () => {
7-
assert.deepEqual(
8-
transformArguments(0),
9-
['CLUSTER', 'DELSLOTS', '0']
10-
);
11-
});
5+
describe('transformArguments', () => {
6+
it('single', () => {
7+
assert.deepEqual(
8+
CLUSTER_DELSLOTS.transformArguments(0),
9+
['CLUSTER', 'DELSLOTS', '0']
10+
);
11+
});
1212

13-
it('multiple', () => {
14-
assert.deepEqual(
15-
transformArguments([0, 1]),
16-
['CLUSTER', 'DELSLOTS', '0', '1']
17-
);
18-
});
13+
it('multiple', () => {
14+
assert.deepEqual(
15+
CLUSTER_DELSLOTS.transformArguments([0, 1]),
16+
['CLUSTER', 'DELSLOTS', '0', '1']
17+
);
1918
});
19+
});
2020
});
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
import { strict as assert } from 'assert';
2-
import { transformArguments } from './CLUSTER_DELSLOTSRANGE';
2+
import CLUSTER_DELSLOTSRANGE from './CLUSTER_DELSLOTSRANGE';
33

44
describe('CLUSTER DELSLOTSRANGE', () => {
5-
describe('transformArguments', () => {
6-
it('single', () => {
7-
assert.deepEqual(
8-
transformArguments({
9-
start: 0,
10-
end: 1
11-
}),
12-
['CLUSTER', 'DELSLOTSRANGE', '0', '1']
13-
);
14-
});
5+
describe('transformArguments', () => {
6+
it('single', () => {
7+
assert.deepEqual(
8+
CLUSTER_DELSLOTSRANGE.transformArguments({
9+
start: 0,
10+
end: 1
11+
}),
12+
['CLUSTER', 'DELSLOTSRANGE', '0', '1']
13+
);
14+
});
1515

16-
it('multiple', () => {
17-
assert.deepEqual(
18-
transformArguments([{
19-
start: 0,
20-
end: 1
21-
}, {
22-
start: 2,
23-
end: 3
24-
}]),
25-
['CLUSTER', 'DELSLOTSRANGE', '0', '1', '2', '3']
26-
);
27-
});
16+
it('multiple', () => {
17+
assert.deepEqual(
18+
CLUSTER_DELSLOTSRANGE.transformArguments([{
19+
start: 0,
20+
end: 1
21+
}, {
22+
start: 2,
23+
end: 3
24+
}]),
25+
['CLUSTER', 'DELSLOTSRANGE', '0', '1', '2', '3']
26+
);
2827
});
28+
});
2929
});

0 commit comments

Comments
 (0)