You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
wip
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './ASKING';
|
||||
import ASKING from './ASKING';
|
||||
|
||||
describe('ASKING', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(),
|
||||
['ASKING']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
ASKING.transformArguments(),
|
||||
['ASKING']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@@ -1,11 +1,19 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './BGREWRITEAOF';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import BGREWRITEAOF from './BGREWRITEAOF';
|
||||
|
||||
describe('BGREWRITEAOF', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(),
|
||||
['BGREWRITEAOF']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
BGREWRITEAOF.transformArguments(),
|
||||
['BGREWRITEAOF']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.bgRewriteAof', async client => {
|
||||
assert.equal(
|
||||
typeof await client.bgRewriteAof(),
|
||||
'string'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,23 +1,30 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { describe } from 'mocha';
|
||||
import { transformArguments } from './BGSAVE';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import BGSAVE from './BGSAVE';
|
||||
|
||||
describe('BGSAVE', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(),
|
||||
['BGSAVE']
|
||||
);
|
||||
});
|
||||
|
||||
it('with SCHEDULE', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments({
|
||||
SCHEDULE: true
|
||||
}),
|
||||
['BGSAVE', 'SCHEDULE']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
BGSAVE.transformArguments(),
|
||||
['BGSAVE']
|
||||
);
|
||||
});
|
||||
|
||||
it('with SCHEDULE', () => {
|
||||
assert.deepEqual(
|
||||
BGSAVE.transformArguments({
|
||||
SCHEDULE: true
|
||||
}),
|
||||
['BGSAVE', 'SCHEDULE']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.bgSave', async client => {
|
||||
assert.equal(
|
||||
typeof await client.bgSave(),
|
||||
'string'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,10 +1,20 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export interface BgSaveOptions {
|
||||
SCHEDULE?: boolean;
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['BGSAVE'];
|
||||
transformArguments(options?: BgSaveOptions) {
|
||||
const args = ['BGSAVE'];
|
||||
|
||||
if (options?.SCHEDULE) {
|
||||
args.push('SCHEDULE');
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,22 +1,21 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './CLUSTER_COUNT-FAILURE-REPORTS';
|
||||
import CLUSTER_COUNT_FAILURE_REPORTS from './CLUSTER_COUNT-FAILURE-REPORTS';
|
||||
|
||||
describe('CLUSTER COUNT-FAILURE-REPORTS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('0'),
|
||||
['CLUSTER', 'COUNT-FAILURE-REPORTS', '0']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_COUNT_FAILURE_REPORTS.transformArguments('0'),
|
||||
['CLUSTER', 'COUNT-FAILURE-REPORTS', '0']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithCluster('clusterNode.clusterCountFailureReports', async cluster => {
|
||||
const client = await cluster.nodeClient(cluster.masters[0]);
|
||||
assert.equal(
|
||||
typeof await client.clusterCountFailureReports(
|
||||
await client.clusterMyId()
|
||||
),
|
||||
'number'
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testWithCluster('clusterNode.clusterCountFailureReports', async cluster => {
|
||||
const [master] = cluster.masters,
|
||||
client = await cluster.nodeClient(master);
|
||||
assert.equal(
|
||||
typeof await client.clusterCountFailureReports(master.id),
|
||||
'number'
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
});
|
||||
|
@@ -1,20 +1,20 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './CLUSTER_COUNTKEYSINSLOT';
|
||||
import CLUSTER_COUNTKEYSINSLOT from './CLUSTER_COUNTKEYSINSLOT';
|
||||
|
||||
describe('CLUSTER COUNTKEYSINSLOT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(0),
|
||||
['CLUSTER', 'COUNTKEYSINSLOT', '0']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_COUNTKEYSINSLOT.transformArguments(0),
|
||||
['CLUSTER', 'COUNTKEYSINSLOT', '0']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithCluster('clusterNode.clusterCountKeysInSlot', async cluster => {
|
||||
const client = await cluster.nodeClient(cluster.masters[0]);
|
||||
assert.equal(
|
||||
typeof await client.clusterCountKeysInSlot(0),
|
||||
'number'
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testWithCluster('clusterNode.clusterCountKeysInSlot', async cluster => {
|
||||
const client = await cluster.nodeClient(cluster.masters[0]);
|
||||
assert.equal(
|
||||
typeof await client.clusterCountKeysInSlot(0),
|
||||
'number'
|
||||
);
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
});
|
||||
|
@@ -4,7 +4,7 @@ export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(slot: number) {
|
||||
return ['CLUSTER', 'COUNT-FAILURE-REPORTS', slot.toString()];
|
||||
return ['CLUSTER', 'COUNTKEYSINSLOT', slot.toString()];
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,20 +1,20 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './CLUSTER_DELSLOTS';
|
||||
import CLUSTER_DELSLOTS from './CLUSTER_DELSLOTS';
|
||||
|
||||
describe('CLUSTER DELSLOTS', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('single', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(0),
|
||||
['CLUSTER', 'DELSLOTS', '0']
|
||||
);
|
||||
});
|
||||
|
||||
it('multiple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments([0, 1]),
|
||||
['CLUSTER', 'DELSLOTS', '0', '1']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('single', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_DELSLOTS.transformArguments(0),
|
||||
['CLUSTER', 'DELSLOTS', '0']
|
||||
);
|
||||
});
|
||||
|
||||
it('multiple', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_DELSLOTS.transformArguments([0, 1]),
|
||||
['CLUSTER', 'DELSLOTS', '0', '1']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,29 +1,29 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './CLUSTER_DELSLOTSRANGE';
|
||||
import CLUSTER_DELSLOTSRANGE from './CLUSTER_DELSLOTSRANGE';
|
||||
|
||||
describe('CLUSTER DELSLOTSRANGE', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('single', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments({
|
||||
start: 0,
|
||||
end: 1
|
||||
}),
|
||||
['CLUSTER', 'DELSLOTSRANGE', '0', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('multiple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments([{
|
||||
start: 0,
|
||||
end: 1
|
||||
}, {
|
||||
start: 2,
|
||||
end: 3
|
||||
}]),
|
||||
['CLUSTER', 'DELSLOTSRANGE', '0', '1', '2', '3']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('single', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_DELSLOTSRANGE.transformArguments({
|
||||
start: 0,
|
||||
end: 1
|
||||
}),
|
||||
['CLUSTER', 'DELSLOTSRANGE', '0', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('multiple', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_DELSLOTSRANGE.transformArguments([{
|
||||
start: 0,
|
||||
end: 1
|
||||
}, {
|
||||
start: 2,
|
||||
end: 3
|
||||
}]),
|
||||
['CLUSTER', 'DELSLOTSRANGE', '0', '1', '2', '3']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,20 +1,22 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { FailoverModes, transformArguments } from './CLUSTER_FAILOVER';
|
||||
import CLUSTER_FAILOVER, { FAILOVER_MODES } from './CLUSTER_FAILOVER';
|
||||
|
||||
describe('CLUSTER FAILOVER', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(),
|
||||
['CLUSTER', 'FAILOVER']
|
||||
);
|
||||
});
|
||||
|
||||
it('with mode', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(FailoverModes.FORCE),
|
||||
['CLUSTER', 'FAILOVER', 'FORCE']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_FAILOVER.transformArguments(),
|
||||
['CLUSTER', 'FAILOVER']
|
||||
);
|
||||
});
|
||||
|
||||
it('with mode', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_FAILOVER.transformArguments({
|
||||
mode: FAILOVER_MODES.FORCE
|
||||
}),
|
||||
['CLUSTER', 'FAILOVER', 'FORCE']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -5,16 +5,20 @@ export const FAILOVER_MODES = {
|
||||
TAKEOVER: 'TAKEOVER'
|
||||
} as const;
|
||||
|
||||
export type FailoverModes = typeof FAILOVER_MODES[keyof typeof FAILOVER_MODES];
|
||||
export type FailoverMode = typeof FAILOVER_MODES[keyof typeof FAILOVER_MODES];
|
||||
|
||||
export interface ClusterFailoverOptions {
|
||||
mode?: FailoverMode;
|
||||
}
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(mode?: FailoverModes) {
|
||||
transformArguments(options?: ClusterFailoverOptions) {
|
||||
const args = ['CLUSTER', 'FAILOVER'];
|
||||
|
||||
if (mode) {
|
||||
args.push(mode);
|
||||
if (options?.mode) {
|
||||
args.push(options.mode);
|
||||
}
|
||||
|
||||
return args;
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './CLUSTER_FLUSHSLOTS';
|
||||
import CLUSTER_FLUSHSLOTS from './CLUSTER_FLUSHSLOTS';
|
||||
|
||||
describe('CLUSTER FLUSHSLOTS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(),
|
||||
['CLUSTER', 'FLUSHSLOTS']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_FLUSHSLOTS.transformArguments(),
|
||||
['CLUSTER', 'FLUSHSLOTS']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { transformArguments } from './CLUSTER_FORGET';
|
||||
import CLUSTER_FORGET from './CLUSTER_FORGET';
|
||||
|
||||
describe('CLUSTER FORGET', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('0'),
|
||||
['CLUSTER', 'FORGET', '0']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_FORGET.transformArguments('0'),
|
||||
['CLUSTER', 'FORGET', '0']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@@ -1,21 +1,25 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './CLUSTER_GETKEYSINSLOT';
|
||||
import CLUSTER_GETKEYSINSLOT from './CLUSTER_GETKEYSINSLOT';
|
||||
|
||||
describe('CLUSTER GETKEYSINSLOT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(0, 10),
|
||||
['CLUSTER', 'GETKEYSINSLOT', '0', '10']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_GETKEYSINSLOT.transformArguments(0, 10),
|
||||
['CLUSTER', 'GETKEYSINSLOT', '0', '10']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithCluster('clusterNode.clusterGetKeysInSlot', async cluster => {
|
||||
const client = await cluster.nodeClient(cluster.masters[0]),
|
||||
reply = await client.clusterGetKeysInSlot(0, 1);
|
||||
assert.ok(Array.isArray(reply));
|
||||
for (const item of reply) {
|
||||
assert.equal(typeof item, 'string');
|
||||
}
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testWithCluster('clusterNode.clusterGetKeysInSlot', async cluster => {
|
||||
const slot = 12539, // "key" slot
|
||||
client = await cluster.nodeClient(cluster.slots[slot].master),
|
||||
[, reply] = await Promise.all([
|
||||
client.set('key', 'value'),
|
||||
client.clusterGetKeysInSlot(slot, 1),
|
||||
])
|
||||
assert.ok(Array.isArray(reply));
|
||||
for (const item of reply) {
|
||||
assert.equal(typeof item, 'string');
|
||||
}
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
});
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { Command, NumberReply, RedisArgument } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(key: RedisArgument) {
|
||||
return ['CLUSTER', 'KEYSLOT', key];
|
||||
},
|
||||
|
@@ -1,28 +1,28 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './CLUSTER_LINKS';
|
||||
import CLUSTER_LINKS from './CLUSTER_LINKS';
|
||||
|
||||
describe('CLUSTER LINKS', () => {
|
||||
testUtils.isVersionGreaterThanHook([7]);
|
||||
testUtils.isVersionGreaterThanHook([7]);
|
||||
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(),
|
||||
['CLUSTER', 'LINKS']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CLUSTER_LINKS.transformArguments(),
|
||||
['CLUSTER', 'LINKS']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithCluster('clusterNode.clusterLinks', async cluster => {
|
||||
const client = await cluster.nodeClient(cluster.masters[0]),
|
||||
links = await client.clusterLinks();
|
||||
assert.ok(Array.isArray(links));
|
||||
for (const link of links) {
|
||||
assert.equal(typeof link.direction, 'string');
|
||||
assert.equal(typeof link.node, 'string');
|
||||
assert.equal(typeof link.createTime, 'number');
|
||||
assert.equal(typeof link.events, 'string');
|
||||
assert.equal(typeof link.sendBufferAllocated, 'number');
|
||||
assert.equal(typeof link.sendBufferUsed, 'number');
|
||||
}
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
testUtils.testWithCluster('clusterNode.clusterLinks', async cluster => {
|
||||
const client = await cluster.nodeClient(cluster.masters[0]),
|
||||
links = await client.clusterLinks();
|
||||
assert.ok(Array.isArray(links));
|
||||
for (const link of links) {
|
||||
assert.equal(typeof link.direction, 'string');
|
||||
assert.equal(typeof link.node, 'string');
|
||||
assert.equal(typeof link['create-time'], 'number');
|
||||
assert.equal(typeof link.events, 'string');
|
||||
assert.equal(typeof link['send-buffer-allocated'], 'number');
|
||||
assert.equal(typeof link['send-buffer-used'], 'number');
|
||||
}
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
});
|
||||
|
@@ -1,38 +1,29 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
import { ArrayReply, TuplesToMapReply, BlobStringReply, NumberReply, Resp2Reply, Command } from '../RESP/types';
|
||||
|
||||
type ClusterLinksReply = ArrayReply<TuplesToMapReply<[
|
||||
[BlobStringReply<'direction'>, BlobStringReply],
|
||||
[BlobStringReply<'node'>, BlobStringReply],
|
||||
[BlobStringReply<'create-time'>, NumberReply],
|
||||
[BlobStringReply<'events'>, BlobStringReply],
|
||||
[BlobStringReply<'send-buffer-allocated'>, NumberReply],
|
||||
[BlobStringReply<'send-buffer-used'>, NumberReply],
|
||||
]>>;
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLUSTER', 'LINKS'];
|
||||
}
|
||||
|
||||
type ClusterLinksRawReply = Array<[
|
||||
'direction',
|
||||
string,
|
||||
'node',
|
||||
string,
|
||||
'createTime',
|
||||
number,
|
||||
'events',
|
||||
string,
|
||||
'send-buffer-allocated',
|
||||
number,
|
||||
'send-buffer-used',
|
||||
number
|
||||
]>;
|
||||
|
||||
type ClusterLinksReply = Array<{
|
||||
direction: string;
|
||||
node: string;
|
||||
createTime: number;
|
||||
events: string;
|
||||
sendBufferAllocated: number;
|
||||
sendBufferUsed: number;
|
||||
}>;
|
||||
|
||||
export function transformReply(reply: ClusterLinksRawReply): ClusterLinksReply {
|
||||
return reply.map(peerLink => ({
|
||||
direction: peerLink[1],
|
||||
node: peerLink[3],
|
||||
createTime: Number(peerLink[5]),
|
||||
events: peerLink[7],
|
||||
sendBufferAllocated: Number(peerLink[9]),
|
||||
sendBufferUsed: Number(peerLink[11])
|
||||
}));
|
||||
}
|
||||
},
|
||||
transformReply: {
|
||||
2: (reply: Resp2Reply<ClusterLinksReply>) => reply.map(link => ({
|
||||
direction: link[1],
|
||||
node: link[3],
|
||||
'create-time': link[5],
|
||||
events: link[7],
|
||||
'send-buffer-allocated': link[9],
|
||||
'send-buffer-used': link[11]
|
||||
})),
|
||||
3: undefined as unknown as () => ClusterLinksReply
|
||||
}
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(host: string, port: number) {
|
||||
return ['CLUSTER', 'MEET', host, port.toString()];
|
||||
},
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { BlobStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CLUSTER', 'MYID'];
|
||||
},
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(nodeId: RedisArgument) {
|
||||
return ['CLUSTER', 'REPLICATE', nodeId];
|
||||
},
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
import { RedisArgument, SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export const CLUSTER_SLOT_STATES = {
|
||||
IMPORTING: 'IMPORTING',
|
||||
@@ -7,13 +7,13 @@ export const CLUSTER_SLOT_STATES = {
|
||||
NODE: 'NODE'
|
||||
} as const;
|
||||
|
||||
export type ClusterSlotStates = typeof CLUSTER_SLOT_STATES[keyof typeof CLUSTER_SLOT_STATES];
|
||||
export type ClusterSlotState = typeof CLUSTER_SLOT_STATES[keyof typeof CLUSTER_SLOT_STATES];
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(slot: number, state: ClusterSlotStates, nodeId?: string) {
|
||||
const args = ['CLUSTER', 'SETSLOT', slot.toString(), state];
|
||||
transformArguments(slot: number, state: ClusterSlotState, nodeId?: RedisArgument) {
|
||||
const args: Array<RedisArgument> = ['CLUSTER', 'SETSLOT', slot.toString(), state];
|
||||
|
||||
if (nodeId) {
|
||||
args.push(nodeId);
|
||||
|
@@ -26,5 +26,5 @@ describe('CLUSTER SLOTS', () => {
|
||||
assert.equal(typeof replica.id, 'string');
|
||||
}
|
||||
}
|
||||
}, GLOBAL.CLUSTERS.OPEN);
|
||||
}, GLOBAL.CLUSTERS.WITH_REPLICAS);
|
||||
});
|
||||
|
@@ -1,19 +1,19 @@
|
||||
// import { strict as assert } from 'assert';
|
||||
// import testUtils, { GLOBAL } from '../test-utils';
|
||||
// import { transformArguments } from './COMMAND_COUNT';
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import COMMAND_COUNT from './COMMAND_COUNT';
|
||||
|
||||
// describe('COMMAND COUNT', () => {
|
||||
// it('transformArguments', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments(),
|
||||
// ['COMMAND', 'COUNT']
|
||||
// );
|
||||
// });
|
||||
describe('COMMAND COUNT', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
COMMAND_COUNT.transformArguments(),
|
||||
['COMMAND', 'COUNT']
|
||||
);
|
||||
});
|
||||
|
||||
// testUtils.testWithClient('client.commandCount', async client => {
|
||||
// assert.equal(
|
||||
// typeof await client.commandCount(),
|
||||
// 'number'
|
||||
// );
|
||||
// }, GLOBAL.SERVERS.OPEN);
|
||||
// });
|
||||
testUtils.testWithClient('client.commandCount', async client => {
|
||||
assert.equal(
|
||||
typeof await client.commandCount(),
|
||||
'number'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,9 +1,10 @@
|
||||
// import { RedisCommandArguments } from '.';
|
||||
import { NumberReply, Command } from '../RESP/types';
|
||||
|
||||
// export const IS_READ_ONLY = true;
|
||||
|
||||
// export function transformArguments(): RedisCommandArguments {
|
||||
// return ['COMMAND', 'COUNT'];
|
||||
// }
|
||||
|
||||
// export declare function transformReply(): number;
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['COMMAND', 'COUNT'];
|
||||
},
|
||||
transformReply: undefined as unknown as () => NumberReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,19 @@
|
||||
// import { strict as assert } from 'assert';
|
||||
// import testUtils, { GLOBAL } from '../test-utils';
|
||||
// import { transformArguments } from './COMMAND_GETKEYS';
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import COMMAND_GETKEYS from './COMMAND_GETKEYS';
|
||||
|
||||
// describe('COMMAND GETKEYS', () => {
|
||||
// it('transformArguments', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments(['GET', 'key']),
|
||||
// ['COMMAND', 'GETKEYS', 'GET', 'key']
|
||||
// );
|
||||
// });
|
||||
describe('COMMAND GETKEYS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
COMMAND_GETKEYS.transformArguments(['GET', 'key']),
|
||||
['COMMAND', 'GETKEYS', 'GET', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
// testUtils.testWithClient('client.commandGetKeys', async client => {
|
||||
// assert.deepEqual(
|
||||
// await client.commandGetKeys(['GET', 'key']),
|
||||
// ['key']
|
||||
// );
|
||||
// }, GLOBAL.SERVERS.OPEN);
|
||||
// });
|
||||
testUtils.testWithClient('client.commandGetKeys', async client => {
|
||||
assert.deepEqual(
|
||||
await client.commandGetKeys(['GET', 'key']),
|
||||
['key']
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,9 +1,10 @@
|
||||
// import { RedisCommandArgument, RedisCommandArguments } from '.';
|
||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||
|
||||
// export const IS_READ_ONLY = true;
|
||||
|
||||
// export function transformArguments(args: Array<RedisCommandArgument>): RedisCommandArguments {
|
||||
// return ['COMMAND', 'GETKEYS', ...args];
|
||||
// }
|
||||
|
||||
// export declare function transformReply(): Array<RedisCommandArgument>;
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(args: Array<RedisArgument>) {
|
||||
return ['COMMAND', 'GETKEYS', ...args];
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,11 +1,31 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import CONFIG_GET from './CONFIG_GET';
|
||||
|
||||
describe('CONFIG GET', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
CONFIG_GET.transformArguments('*'),
|
||||
['CONFIG', 'GET', '*']
|
||||
);
|
||||
describe('transformArguments', () => {
|
||||
it('string', () => {
|
||||
assert.deepEqual(
|
||||
CONFIG_GET.transformArguments('*'),
|
||||
['CONFIG', 'GET', '*']
|
||||
);
|
||||
});
|
||||
|
||||
it('Array', () => {
|
||||
assert.deepEqual(
|
||||
CONFIG_GET.transformArguments(['1', '2']),
|
||||
['CONFIG', 'GET', '1', '2']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
testUtils.testWithClient('client.configGet', async client => {
|
||||
const config = await client.configGet('*');
|
||||
assert.equal(typeof config, 'object');
|
||||
for (const [key, value] of Object.entries(config)) {
|
||||
assert.equal(typeof key, 'string');
|
||||
assert.equal(typeof value, 'string');
|
||||
}
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,11 +1,14 @@
|
||||
import { RedisArgument, Command } from '../RESP/types';
|
||||
import { transformTuplesReply } from './generic-transformers';
|
||||
import { MapReply, BlobStringReply, Command } from '../RESP/types';
|
||||
import { RedisVariadicArgument, pushVariadicArguments, transformTuplesReply } from './generic-transformers';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(parameter: RedisArgument) {
|
||||
return ['CONFIG', 'GET', parameter];
|
||||
transformArguments(parameters: RedisVariadicArgument) {
|
||||
return pushVariadicArguments(['CONFIG', 'GET'], parameters);
|
||||
},
|
||||
transformReply: transformTuplesReply
|
||||
transformReply: {
|
||||
2: transformTuplesReply,
|
||||
3: undefined as unknown as () => MapReply<BlobStringReply, BlobStringReply>
|
||||
}
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CONFIG', 'RESETSTAT'];
|
||||
},
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['CONFIG', 'REWRITE'];
|
||||
},
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import CONFIG_SET from './CONFIG_SET';
|
||||
|
||||
describe('CONFIG SET', () => {
|
||||
@@ -21,4 +22,11 @@ describe('CONFIG SET', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.configSet', async client => {
|
||||
assert.equal(
|
||||
await client.configSet('maxmemory', '0'),
|
||||
'OK'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -5,6 +5,8 @@ type SingleParameter = [parameter: RedisArgument, value: RedisArgument];
|
||||
type MultipleParameters = [config: Record<string, RedisArgument>];
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(
|
||||
...[parameterOrConfig, value]: SingleParameter | MultipleParameters
|
||||
) {
|
||||
|
@@ -5,12 +5,12 @@ export const REDIS_FLUSH_MODES = {
|
||||
SYNC: 'SYNC'
|
||||
} as const;
|
||||
|
||||
export type RedisFlushModes = typeof REDIS_FLUSH_MODES[keyof typeof REDIS_FLUSH_MODES];
|
||||
export type RedisFlushMode = typeof REDIS_FLUSH_MODES[keyof typeof REDIS_FLUSH_MODES];
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(mode?: RedisFlushModes) {
|
||||
transformArguments(mode?: RedisFlushMode) {
|
||||
const args = ['FLUSHALL'];
|
||||
|
||||
if (mode) {
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
import { RedisFlushModes } from './FLUSHALL';
|
||||
import { RedisFlushMode } from './FLUSHALL';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(mode?: RedisFlushModes) {
|
||||
transformArguments(mode?: RedisFlushMode) {
|
||||
const args = ['FLUSHDB'];
|
||||
|
||||
if (mode) {
|
||||
|
@@ -1,10 +1,10 @@
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
import { RedisFlushModes } from './FLUSHALL';
|
||||
import { RedisFlushMode } from './FLUSHALL';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(mode?: RedisFlushModes) {
|
||||
transformArguments(mode?: RedisFlushMode) {
|
||||
const args = ['FUNCTION', 'FLUSH'];
|
||||
|
||||
if (mode) {
|
||||
|
@@ -1,19 +1,19 @@
|
||||
import {strict as assert} from 'assert';
|
||||
import testUtils, {GLOBAL} from '../test-utils';
|
||||
import { transformArguments } from './LATENCY_DOCTOR';
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import LATENCY_DOCTOR from './LATENCY_DOCTOR';
|
||||
|
||||
describe('LATENCY DOCTOR', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(),
|
||||
['LATENCY', 'DOCTOR']
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LATENCY_DOCTOR.transformArguments(),
|
||||
['LATENCY', 'DOCTOR']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.latencyDoctor', async client => {
|
||||
assert.equal(
|
||||
typeof (await client.latencyDoctor()),
|
||||
'string'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
testUtils.testWithClient('client.latencyDoctor', async client => {
|
||||
assert.equal(
|
||||
typeof await client.latencyDoctor(),
|
||||
'string'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,5 +1,10 @@
|
||||
export function transformArguments(): Array<string> {
|
||||
return ['LATENCY', 'DOCTOR'];
|
||||
}
|
||||
import { BlobStringReply, Command } from '../RESP/types';
|
||||
|
||||
export declare function transformReply(): string;
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['LATENCY', 'DOCTOR'];
|
||||
},
|
||||
transformReply: undefined as unknown as () => BlobStringReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,28 +1,28 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './LATENCY_GRAPH';
|
||||
import LATENCY_GRAPH from './LATENCY_GRAPH';
|
||||
|
||||
describe('LATENCY GRAPH', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('command'),
|
||||
[
|
||||
'LATENCY',
|
||||
'GRAPH',
|
||||
'command'
|
||||
]
|
||||
);
|
||||
});
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LATENCY_GRAPH.transformArguments('command'),
|
||||
[
|
||||
'LATENCY',
|
||||
'GRAPH',
|
||||
'command'
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.latencyGraph', async client => {
|
||||
await Promise.all([
|
||||
client.configSet('latency-monitor-threshold', '1'),
|
||||
client.sendCommand(['DEBUG', 'SLEEP', '0.001'])
|
||||
]);
|
||||
testUtils.testWithClient('client.latencyGraph', async client => {
|
||||
await Promise.all([
|
||||
client.configSet('latency-monitor-threshold', '1'),
|
||||
client.sendCommand(['DEBUG', 'SLEEP', '0.001'])
|
||||
]);
|
||||
|
||||
assert.equal(
|
||||
typeof await client.latencyGraph('command'),
|
||||
'string'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
assert.equal(
|
||||
typeof await client.latencyGraph('command'),
|
||||
'string'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,25 +1,31 @@
|
||||
// import { RedisCommandArguments } from '.';
|
||||
import { SimpleStringReply, Command, BlobStringReply } from '../RESP/types';
|
||||
|
||||
// export type EventType =
|
||||
// 'active-defrag-cycle'
|
||||
// | 'aof-fsync-always'
|
||||
// | 'aof-stat'
|
||||
// | 'aof-rewrite-diff-write'
|
||||
// | 'aof-rename'
|
||||
// | 'aof-write'
|
||||
// | 'aof-write-active-child'
|
||||
// | 'aof-write-alone'
|
||||
// | 'aof-write-pending-fsync'
|
||||
// | 'command'
|
||||
// | 'expire-cycle'
|
||||
// | 'eviction-cycle'
|
||||
// | 'eviction-del'
|
||||
// | 'fast-command'
|
||||
// | 'fork'
|
||||
// | 'rdb-unlink-temp-file';
|
||||
export const LATENCY_EVENTS = {
|
||||
ACTIVE_DEFRAG_CYCLE: 'active-defrag-cycle',
|
||||
AOF_FSYNC_ALWAYS: 'aof-fsync-always',
|
||||
AOF_STAT: 'aof-stat',
|
||||
AOF_REWRITE_DIFF_WRITE: 'aof-rewrite-diff-write',
|
||||
AOF_RENAME: 'aof-rename',
|
||||
AOF_WRITE: 'aof-write',
|
||||
AOF_WRITE_ACTIVE_CHILD: 'aof-write-active-child',
|
||||
AOF_WRITE_ALONE: 'aof-write-alone',
|
||||
AOF_WRITE_PENDING_FSYNC: 'aof-write-pending-fsync',
|
||||
COMMAND: 'command',
|
||||
EXPIRE_CYCLE: 'expire-cycle',
|
||||
EVICTION_CYCLE: 'eviction-cycle',
|
||||
EVICTION_DEL: 'eviction-del',
|
||||
FAST_COMMAND: 'fast-command',
|
||||
FORK: 'fork',
|
||||
RDB_UNLINK_TEMP_FILE: 'rdb-unlink-temp-file'
|
||||
} as const;
|
||||
|
||||
// export function transformArguments(event: EventType): RedisCommandArguments {
|
||||
// return ['LATENCY', 'GRAPH', event];
|
||||
// }
|
||||
export type LatencyEvent = typeof LATENCY_EVENTS[keyof typeof LATENCY_EVENTS];
|
||||
|
||||
// export declare function transformReply(): string;
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments(event: LatencyEvent) {
|
||||
return ['LATENCY', 'GRAPH', event];
|
||||
},
|
||||
transformReply: undefined as unknown as () => BlobStringReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,27 +1,27 @@
|
||||
// import {strict as assert} from 'assert';
|
||||
// import testUtils, {GLOBAL} from '../test-utils';
|
||||
// import { transformArguments } from './LATENCY_LATEST';
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import LATENCY_LATEST from './LATENCY_LATEST';
|
||||
|
||||
// describe('LATENCY LATEST', () => {
|
||||
// it('transformArguments', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments(),
|
||||
// ['LATENCY', 'LATEST']
|
||||
// );
|
||||
// });
|
||||
describe('LATENCY LATEST', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
LATENCY_LATEST.transformArguments(),
|
||||
['LATENCY', 'LATEST']
|
||||
);
|
||||
});
|
||||
|
||||
// testUtils.testWithClient('client.latencyLatest', async client => {
|
||||
// await Promise.all([
|
||||
// client.configSet('latency-monitor-threshold', '100'),
|
||||
// client.sendCommand(['DEBUG', 'SLEEP', '1'])
|
||||
// ]);
|
||||
// const latency = await client.latencyLatest();
|
||||
// assert.ok(Array.isArray(latency));
|
||||
// for (const [name, timestamp, latestLatency, allTimeLatency] of latency) {
|
||||
// assert.equal(typeof name, 'string');
|
||||
// assert.equal(typeof timestamp, 'number');
|
||||
// assert.equal(typeof latestLatency, 'number');
|
||||
// assert.equal(typeof allTimeLatency, 'number');
|
||||
// }
|
||||
// }, GLOBAL.SERVERS.OPEN);
|
||||
// });
|
||||
testUtils.testWithClient('client.latencyLatest', async client => {
|
||||
await Promise.all([
|
||||
client.configSet('latency-monitor-threshold', '100'),
|
||||
client.sendCommand(['DEBUG', 'SLEEP', '1'])
|
||||
]);
|
||||
const latency = await client.latencyLatest();
|
||||
assert.ok(Array.isArray(latency));
|
||||
for (const [name, timestamp, latestLatency, allTimeLatency] of latency) {
|
||||
assert.equal(typeof name, 'string');
|
||||
assert.equal(typeof timestamp, 'number');
|
||||
assert.equal(typeof latestLatency, 'number');
|
||||
assert.equal(typeof allTimeLatency, 'number');
|
||||
}
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,12 +1,16 @@
|
||||
// import { RedisCommandArguments } from '.';
|
||||
import { ArrayReply, BlobStringReply, NumberReply, Command } from '../RESP/types';
|
||||
|
||||
// export function transformArguments(): RedisCommandArguments {
|
||||
// return ['LATENCY', 'LATEST'];
|
||||
// }
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['LATENCY', 'LATEST'];
|
||||
},
|
||||
transformReply: undefined as unknown as () => ArrayReply<[
|
||||
name: BlobStringReply,
|
||||
timestamp: NumberReply,
|
||||
latestLatency: NumberReply,
|
||||
allTimeLatency: NumberReply
|
||||
]>
|
||||
} as const satisfies Command;
|
||||
|
||||
// export declare function transformReply(): Array<[
|
||||
// name: string,
|
||||
// timestamp: number,
|
||||
// latestLatency: number,
|
||||
// allTimeLatency: number
|
||||
// ]>;
|
||||
|
@@ -1,43 +1,43 @@
|
||||
// import { strict as assert } from 'assert';
|
||||
// import testUtils, { GLOBAL } from '../test-utils';
|
||||
// import MEMORY_STATS from './MEMORY_STATS';
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import MEMORY_STATS from './MEMORY_STATS';
|
||||
|
||||
// describe('MEMORY STATS', () => {
|
||||
// it('transformArguments', () => {
|
||||
// assert.deepEqual(
|
||||
// MEMORY_STATS.transformArguments(),
|
||||
// ['MEMORY', 'STATS']
|
||||
// );
|
||||
// });
|
||||
describe('MEMORY STATS', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
MEMORY_STATS.transformArguments(),
|
||||
['MEMORY', 'STATS']
|
||||
);
|
||||
});
|
||||
|
||||
// testUtils.testWithClient('client.memoryStats', async client => {
|
||||
// const memoryStats = await client.memoryStats();
|
||||
// assert.equal(typeof memoryStats['peak.allocated'], 'number');
|
||||
// assert.equal(typeof memoryStats['total.allocated'], 'number');
|
||||
// assert.equal(typeof memoryStats['startup.allocated'], 'number');
|
||||
// assert.equal(typeof memoryStats['replication.backlog'], 'number');
|
||||
// assert.equal(typeof memoryStats['clients.slaves'], 'number');
|
||||
// assert.equal(typeof memoryStats['clients.normal'], 'number');
|
||||
// assert.equal(typeof memoryStats['cluster.links'], 'number');
|
||||
// assert.equal(typeof memoryStats['aof.buffer'], 'number');
|
||||
// assert.equal(typeof memoryStats['lua.caches'], 'number');
|
||||
// assert.equal(typeof memoryStats['functions.caches'], 'number');
|
||||
// assert.equal(typeof memoryStats['overhead.total'], 'number');
|
||||
// assert.equal(typeof memoryStats['keys.count'], 'number');
|
||||
// assert.equal(typeof memoryStats['keys.bytes-per-key'], 'number');
|
||||
// assert.equal(typeof memoryStats['dataset.bytes'], 'number');
|
||||
// assert.equal(typeof memoryStats['dataset.percentage'], 'string');
|
||||
// assert.equal(typeof memoryStats['peak.percentage'], 'string');
|
||||
// assert.equal(typeof memoryStats['allocator.allocated'], 'number');
|
||||
// assert.equal(typeof memoryStats['allocator.active'], 'number');
|
||||
// assert.equal(typeof memoryStats['allocator.resident'], 'number');
|
||||
// assert.equal(typeof memoryStats['allocator-fragmentation.ratio'], 'string');
|
||||
// assert.equal(typeof memoryStats['allocator-fragmentation.bytes'], 'number');
|
||||
// assert.equal(typeof memoryStats['allocator-rss.ratio'], 'string');
|
||||
// assert.equal(typeof memoryStats['allocator-rss.bytes'], 'number');
|
||||
// assert.equal(typeof memoryStats['rss-overhead.ratio'], 'string');
|
||||
// assert.equal(typeof memoryStats['rss-overhead.bytes'], 'number');
|
||||
// assert.equal(typeof memoryStats['fragmentation'], 'string');
|
||||
// assert.equal(typeof memoryStats['fragmentation.bytes'], 'number');
|
||||
// }, GLOBAL.SERVERS.OPEN);
|
||||
// });
|
||||
testUtils.testWithClient('client.memoryStats', async client => {
|
||||
const memoryStats = await client.memoryStats();
|
||||
assert.equal(typeof memoryStats['peak.allocated'], 'number');
|
||||
assert.equal(typeof memoryStats['total.allocated'], 'number');
|
||||
assert.equal(typeof memoryStats['startup.allocated'], 'number');
|
||||
assert.equal(typeof memoryStats['replication.backlog'], 'number');
|
||||
assert.equal(typeof memoryStats['clients.slaves'], 'number');
|
||||
assert.equal(typeof memoryStats['clients.normal'], 'number');
|
||||
assert.equal(typeof memoryStats['cluster.links'], 'number');
|
||||
assert.equal(typeof memoryStats['aof.buffer'], 'number');
|
||||
assert.equal(typeof memoryStats['lua.caches'], 'number');
|
||||
assert.equal(typeof memoryStats['functions.caches'], 'number');
|
||||
assert.equal(typeof memoryStats['overhead.total'], 'number');
|
||||
assert.equal(typeof memoryStats['keys.count'], 'number');
|
||||
assert.equal(typeof memoryStats['keys.bytes-per-key'], 'number');
|
||||
assert.equal(typeof memoryStats['dataset.bytes'], 'number');
|
||||
assert.equal(typeof memoryStats['dataset.percentage'], 'string');
|
||||
assert.equal(typeof memoryStats['peak.percentage'], 'string');
|
||||
assert.equal(typeof memoryStats['allocator.allocated'], 'number');
|
||||
assert.equal(typeof memoryStats['allocator.active'], 'number');
|
||||
assert.equal(typeof memoryStats['allocator.resident'], 'number');
|
||||
assert.equal(typeof memoryStats['allocator-fragmentation.ratio'], 'string');
|
||||
assert.equal(typeof memoryStats['allocator-fragmentation.bytes'], 'number');
|
||||
assert.equal(typeof memoryStats['allocator-rss.ratio'], 'string');
|
||||
assert.equal(typeof memoryStats['allocator-rss.bytes'], 'number');
|
||||
assert.equal(typeof memoryStats['rss-overhead.ratio'], 'string');
|
||||
assert.equal(typeof memoryStats['rss-overhead.bytes'], 'number');
|
||||
assert.equal(typeof memoryStats['fragmentation'], 'string');
|
||||
assert.equal(typeof memoryStats['fragmentation.bytes'], 'number');
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,53 +1,53 @@
|
||||
// import { TuplesToMapReply, BlobStringReply, NumberReply, DoubleReply, Command, Resp2Reply } from '../RESP/types';
|
||||
import { TuplesToMapReply, BlobStringReply, NumberReply, DoubleReply, Command, Resp2Reply } from '../RESP/types';
|
||||
|
||||
// export type MemoryStatsReply = TuplesToMapReply<[
|
||||
// [BlobStringReply<'peak.allocated'>, NumberReply],
|
||||
// [BlobStringReply<'total.allocated'>, NumberReply],
|
||||
// [BlobStringReply<'startup.allocated'>, NumberReply],
|
||||
// [BlobStringReply<'replication.backlog'>, NumberReply],
|
||||
// [BlobStringReply<'clients.slaves'>, NumberReply],
|
||||
// [BlobStringReply<'clients.normal'>, NumberReply],
|
||||
// [BlobStringReply<'cluster.links'>, NumberReply],
|
||||
// [BlobStringReply<'aof.buffer'>, NumberReply],
|
||||
// [BlobStringReply<'lua.caches'>, NumberReply],
|
||||
// [BlobStringReply<'functions.caches'>, NumberReply],
|
||||
// [BlobStringReply<'overhead.total'>, NumberReply],
|
||||
// [BlobStringReply<'keys.count'>, NumberReply],
|
||||
// [BlobStringReply<'keys.bytes-per-key'>, NumberReply],
|
||||
// [BlobStringReply<'dataset.bytes'>, NumberReply],
|
||||
// [BlobStringReply<'dataset.percentage'>, DoubleReply],
|
||||
// [BlobStringReply<'peak.percentage'>, DoubleReply],
|
||||
// [BlobStringReply<'allocator.allocated'>, NumberReply],
|
||||
// [BlobStringReply<'allocator.active'>, NumberReply],
|
||||
// [BlobStringReply<'allocator.resident'>, NumberReply],
|
||||
// [BlobStringReply<'allocator-fragmentation.ratio'>, DoubleReply],
|
||||
// [BlobStringReply<'allocator-fragmentation.bytes'>, NumberReply],
|
||||
// [BlobStringReply<'allocator-rss.ratio'>, DoubleReply],
|
||||
// [BlobStringReply<'allocator-rss.bytes'>, NumberReply],
|
||||
// [BlobStringReply<'rss-overhead.ratio'>, DoubleReply],
|
||||
// [BlobStringReply<'rss-overhead.bytes'>, NumberReply],
|
||||
// [BlobStringReply<'fragmentation'>, DoubleReply],
|
||||
// [BlobStringReply<'fragmentation.bytes'>, NumberReply]
|
||||
// ]>;
|
||||
export type MemoryStatsReply = TuplesToMapReply<[
|
||||
[BlobStringReply<'peak.allocated'>, NumberReply],
|
||||
[BlobStringReply<'total.allocated'>, NumberReply],
|
||||
[BlobStringReply<'startup.allocated'>, NumberReply],
|
||||
[BlobStringReply<'replication.backlog'>, NumberReply],
|
||||
[BlobStringReply<'clients.slaves'>, NumberReply],
|
||||
[BlobStringReply<'clients.normal'>, NumberReply],
|
||||
[BlobStringReply<'cluster.links'>, NumberReply],
|
||||
[BlobStringReply<'aof.buffer'>, NumberReply],
|
||||
[BlobStringReply<'lua.caches'>, NumberReply],
|
||||
[BlobStringReply<'functions.caches'>, NumberReply],
|
||||
[BlobStringReply<'overhead.total'>, NumberReply],
|
||||
[BlobStringReply<'keys.count'>, NumberReply],
|
||||
[BlobStringReply<'keys.bytes-per-key'>, NumberReply],
|
||||
[BlobStringReply<'dataset.bytes'>, NumberReply],
|
||||
[BlobStringReply<'dataset.percentage'>, DoubleReply],
|
||||
[BlobStringReply<'peak.percentage'>, DoubleReply],
|
||||
[BlobStringReply<'allocator.allocated'>, NumberReply],
|
||||
[BlobStringReply<'allocator.active'>, NumberReply],
|
||||
[BlobStringReply<'allocator.resident'>, NumberReply],
|
||||
[BlobStringReply<'allocator-fragmentation.ratio'>, DoubleReply],
|
||||
[BlobStringReply<'allocator-fragmentation.bytes'>, NumberReply],
|
||||
[BlobStringReply<'allocator-rss.ratio'>, DoubleReply],
|
||||
[BlobStringReply<'allocator-rss.bytes'>, NumberReply],
|
||||
[BlobStringReply<'rss-overhead.ratio'>, DoubleReply],
|
||||
[BlobStringReply<'rss-overhead.bytes'>, NumberReply],
|
||||
[BlobStringReply<'fragmentation'>, DoubleReply],
|
||||
[BlobStringReply<'fragmentation.bytes'>, NumberReply]
|
||||
]>;
|
||||
|
||||
// export default {
|
||||
// FIRST_KEY_INDEX: undefined,
|
||||
// IS_READ_ONLY: true,
|
||||
// transformArguments() {
|
||||
// return ['MEMORY', 'STATS'];
|
||||
// },
|
||||
// transformReply: {
|
||||
// 2: (rawReply: Array<BlobStringReply | NumberReply>) => {
|
||||
// const reply: Partial<Resp2Reply<MemoryStatsReply['DEFAULT']>> = {};
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['MEMORY', 'STATS'];
|
||||
},
|
||||
transformReply: {
|
||||
2: (rawReply: Array<BlobStringReply | NumberReply>) => {
|
||||
const reply: Partial<Resp2Reply<MemoryStatsReply['DEFAULT']>> = {};
|
||||
|
||||
// let i = 0;
|
||||
// while (i < rawReply.length) {
|
||||
// const key = rawReply[i++] as keyof MemoryStatsReply['DEFAULT'];
|
||||
// reply[key] = rawReply[i++] as any;
|
||||
// }
|
||||
let i = 0;
|
||||
while (i < rawReply.length) {
|
||||
const key = rawReply[i++] as keyof MemoryStatsReply['DEFAULT'];
|
||||
reply[key] = rawReply[i++] as any;
|
||||
}
|
||||
|
||||
// return reply as MemoryStatsReply['DEFAULT'];
|
||||
// },
|
||||
// 3: undefined as unknown as () => MemoryStatsReply
|
||||
// }
|
||||
// } as const satisfies Command;
|
||||
return reply as MemoryStatsReply['DEFAULT'];
|
||||
},
|
||||
3: undefined as unknown as () => MemoryStatsReply
|
||||
}
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,69 +1,69 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments, transformReply } from './ROLE';
|
||||
import ROLE from './ROLE';
|
||||
|
||||
describe('ROLE', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments(),
|
||||
['ROLE']
|
||||
);
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
ROLE.transformArguments(),
|
||||
['ROLE']
|
||||
);
|
||||
});
|
||||
|
||||
describe('transformReply', () => {
|
||||
it('master', () => {
|
||||
assert.deepEqual(
|
||||
ROLE.transformReply(['master', 3129659, [['127.0.0.1', '9001', '3129242'], ['127.0.0.1', '9002', '3129543']]] as any),
|
||||
{
|
||||
role: 'master',
|
||||
replicationOffest: 3129659,
|
||||
replicas: [{
|
||||
host: '127.0.0.1',
|
||||
port: 9001,
|
||||
replicationOffest: 3129242
|
||||
}, {
|
||||
host: '127.0.0.1',
|
||||
port: 9002,
|
||||
replicationOffest: 3129543
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('transformReply', () => {
|
||||
it('master', () => {
|
||||
assert.deepEqual(
|
||||
transformReply(['master', 3129659, [['127.0.0.1', '9001', '3129242'], ['127.0.0.1', '9002', '3129543']]]),
|
||||
{
|
||||
role: 'master',
|
||||
replicationOffest: 3129659,
|
||||
replicas: [{
|
||||
ip: '127.0.0.1',
|
||||
port: 9001,
|
||||
replicationOffest: 3129242
|
||||
}, {
|
||||
ip: '127.0.0.1',
|
||||
port: 9002,
|
||||
replicationOffest: 3129543
|
||||
}]
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('replica', () => {
|
||||
assert.deepEqual(
|
||||
transformReply(['slave', '127.0.0.1', 9000, 'connected', 3167038]),
|
||||
{
|
||||
role: 'slave',
|
||||
master: {
|
||||
ip: '127.0.0.1',
|
||||
port: 9000
|
||||
},
|
||||
state: 'connected',
|
||||
dataReceived: 3167038
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
it('sentinel', () => {
|
||||
assert.deepEqual(
|
||||
transformReply(['sentinel', ['resque-master', 'html-fragments-master', 'stats-master', 'metadata-master']]),
|
||||
{
|
||||
role: 'sentinel',
|
||||
masterNames: ['resque-master', 'html-fragments-master', 'stats-master', 'metadata-master']
|
||||
}
|
||||
);
|
||||
});
|
||||
it('replica', () => {
|
||||
assert.deepEqual(
|
||||
ROLE.transformReply(['slave', '127.0.0.1', 9000, 'connected', 3167038] as any),
|
||||
{
|
||||
role: 'slave',
|
||||
master: {
|
||||
host: '127.0.0.1',
|
||||
port: 9000
|
||||
},
|
||||
state: 'connected',
|
||||
dataReceived: 3167038
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.role', async client => {
|
||||
assert.deepEqual(
|
||||
await client.role(),
|
||||
{
|
||||
role: 'master',
|
||||
replicationOffest: 0,
|
||||
replicas: []
|
||||
}
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('sentinel', () => {
|
||||
assert.deepEqual(
|
||||
ROLE.transformReply(['sentinel', ['resque-master', 'html-fragments-master', 'stats-master', 'metadata-master']] as any),
|
||||
{
|
||||
role: 'sentinel',
|
||||
masterNames: ['resque-master', 'html-fragments-master', 'stats-master', 'metadata-master']
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.role', async client => {
|
||||
assert.deepEqual(
|
||||
await client.role(),
|
||||
{
|
||||
role: 'master',
|
||||
replicationOffest: 0,
|
||||
replicas: []
|
||||
}
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -3,7 +3,7 @@ import { ArrayReply, BlobStringReply, Command, NumberReply } from '../RESP/types
|
||||
type MasterRole = [
|
||||
role: BlobStringReply<'master'>,
|
||||
replicationOffest: NumberReply,
|
||||
replicas: ArrayReply<[host: BlobStringReply, port: NumberReply, replicationOffest: NumberReply]>,
|
||||
replicas: ArrayReply<[host: BlobStringReply, port: BlobStringReply, replicationOffest: BlobStringReply]>
|
||||
];
|
||||
|
||||
type SlaveRole = [
|
||||
@@ -36,8 +36,8 @@ export default {
|
||||
replicationOffest,
|
||||
replicas: replicas.map(([host, port, replicationOffest]) => ({
|
||||
host,
|
||||
port,
|
||||
replicationOffest,
|
||||
port: Number(port),
|
||||
replicationOffest: Number(replicationOffest)
|
||||
})),
|
||||
};
|
||||
}
|
||||
@@ -48,7 +48,7 @@ export default {
|
||||
role,
|
||||
master: {
|
||||
host: masterHost,
|
||||
port: masterPort,
|
||||
port: masterPort
|
||||
},
|
||||
state,
|
||||
dataReceived,
|
||||
@@ -59,7 +59,7 @@ export default {
|
||||
const [role, masterNames] = reply as SentinelRole;
|
||||
return {
|
||||
role,
|
||||
masterNames,
|
||||
masterNames
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -1,27 +1,49 @@
|
||||
// import { strict as assert } from 'assert';
|
||||
// import { transformArguments } from './SHUTDOWN';
|
||||
import { strict as assert } from 'assert';
|
||||
import SHUTDOWN from './SHUTDOWN';
|
||||
|
||||
// describe('SHUTDOWN', () => {
|
||||
// describe('transformArguments', () => {
|
||||
// it('simple', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments(),
|
||||
// ['SHUTDOWN']
|
||||
// );
|
||||
// });
|
||||
describe('SHUTDOWN', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
SHUTDOWN.transformArguments(),
|
||||
['SHUTDOWN']
|
||||
);
|
||||
});
|
||||
|
||||
// it('NOSAVE', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments('NOSAVE'),
|
||||
// ['SHUTDOWN', 'NOSAVE']
|
||||
// );
|
||||
// });
|
||||
it('with mode', () => {
|
||||
assert.deepEqual(
|
||||
SHUTDOWN.transformArguments({
|
||||
mode: 'NOSAVE'
|
||||
}),
|
||||
['SHUTDOWN', 'NOSAVE']
|
||||
);
|
||||
});
|
||||
|
||||
// it('SAVE', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments('SAVE'),
|
||||
// ['SHUTDOWN', 'SAVE']
|
||||
// );
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
it('with NOW', () => {
|
||||
assert.deepEqual(
|
||||
SHUTDOWN.transformArguments({
|
||||
NOW: true
|
||||
}),
|
||||
['SHUTDOWN', 'NOW']
|
||||
);
|
||||
});
|
||||
|
||||
it('with FORCE', () => {
|
||||
assert.deepEqual(
|
||||
SHUTDOWN.transformArguments({
|
||||
FORCE: true
|
||||
}),
|
||||
['SHUTDOWN', 'FORCE']
|
||||
);
|
||||
});
|
||||
|
||||
it('with ABORT', () => {
|
||||
assert.deepEqual(
|
||||
SHUTDOWN.transformArguments({
|
||||
ABORT: true
|
||||
}),
|
||||
['SHUTDOWN', 'ABORT']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,11 +1,35 @@
|
||||
// export function transformArguments(mode?: 'NOSAVE' | 'SAVE'): Array<string> {
|
||||
// const args = ['SHUTDOWN'];
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
// if (mode) {
|
||||
// args.push(mode);
|
||||
// }
|
||||
export interface ShutdownOptions {
|
||||
mode?: 'NOSAVE' | 'SAVE';
|
||||
NOW?: boolean;
|
||||
FORCE?: boolean;
|
||||
ABORT?: boolean;
|
||||
}
|
||||
|
||||
// return args;
|
||||
// }
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(options?: ShutdownOptions) {
|
||||
const args = ['SHUTDOWN']
|
||||
|
||||
// export declare function transformReply(): void;
|
||||
if (options?.mode) {
|
||||
args.push(options.mode);
|
||||
}
|
||||
|
||||
if (options?.NOW) {
|
||||
args.push('NOW');
|
||||
}
|
||||
|
||||
if (options?.FORCE) {
|
||||
args.push('FORCE');
|
||||
}
|
||||
|
||||
if (options?.ABORT) {
|
||||
args.push('ABORT');
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
transformReply: undefined as unknown as () => void | SimpleStringReply
|
||||
} as const satisfies Command;
|
||||
|
@@ -1,19 +1,19 @@
|
||||
// import { strict as assert } from 'assert';
|
||||
// import testUtils, { GLOBAL } from '../test-utils';
|
||||
// import { transformArguments } from './SWAPDB';
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import SWAPDB from './SWAPDB';
|
||||
|
||||
// describe('SWAPDB', () => {
|
||||
// it('transformArguments', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments(0, 1),
|
||||
// ['SWAPDB', '0', '1']
|
||||
// );
|
||||
// });
|
||||
describe('SWAPDB', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
SWAPDB.transformArguments(0, 1),
|
||||
['SWAPDB', '0', '1']
|
||||
);
|
||||
});
|
||||
|
||||
// testUtils.testWithClient('client.swapDb', async client => {
|
||||
// assert.equal(
|
||||
// await client.swapDb(0, 1),
|
||||
// 'OK'
|
||||
// );
|
||||
// }, GLOBAL.SERVERS.OPEN);
|
||||
// });
|
||||
testUtils.testWithClient('client.swapDb', async client => {
|
||||
assert.equal(
|
||||
await client.swapDb(0, 1),
|
||||
'OK'
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,5 +1,11 @@
|
||||
// export function transformArguments(index1: number, index2: number): Array<string> {
|
||||
// return ['SWAPDB', index1.toString(), index2.toString()];
|
||||
// }
|
||||
import { SimpleStringReply, Command } from '../RESP/types';
|
||||
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: false,
|
||||
transformArguments(index1: number, index2: number) {
|
||||
return ['SWAPDB', index1.toString(), index2.toString()];
|
||||
},
|
||||
transformReply: undefined as unknown as () => SimpleStringReply<'OK'>
|
||||
} as const satisfies Command;
|
||||
|
||||
// export declare function transformReply(): string;
|
||||
|
@@ -1,18 +1,19 @@
|
||||
// import { strict as assert } from 'assert';
|
||||
// import testUtils, { GLOBAL } from '../test-utils';
|
||||
// import { transformArguments } from './TIME';
|
||||
import { strict as assert } from 'assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import TIME from './TIME';
|
||||
|
||||
// describe('TIME', () => {
|
||||
// it('transformArguments', () => {
|
||||
// assert.deepEqual(
|
||||
// transformArguments(),
|
||||
// ['TIME']
|
||||
// );
|
||||
// });
|
||||
describe('TIME', () => {
|
||||
it('transformArguments', () => {
|
||||
assert.deepEqual(
|
||||
TIME.transformArguments(),
|
||||
['TIME']
|
||||
);
|
||||
});
|
||||
|
||||
// testUtils.testWithClient('client.time', async client => {
|
||||
// const reply = await client.time();
|
||||
// assert.ok(reply instanceof Date);
|
||||
// assert.ok(typeof reply.microseconds === 'number');
|
||||
// }, GLOBAL.SERVERS.OPEN);
|
||||
// });
|
||||
testUtils.testWithClient('client.time', async client => {
|
||||
const reply = await client.time();
|
||||
assert.ok(Array.isArray(reply));
|
||||
assert.equal(typeof reply[0], 'string');
|
||||
assert.equal(typeof reply[1], 'string');
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
@@ -1,15 +1,13 @@
|
||||
// export function transformArguments(): Array<string> {
|
||||
// return ['TIME'];
|
||||
// }
|
||||
import { BlobStringReply, Command } from '../RESP/types';
|
||||
|
||||
// interface TimeReply extends Date {
|
||||
// microseconds: number;
|
||||
// }
|
||||
|
||||
// export function transformReply(reply: [string, string]): TimeReply {
|
||||
// const seconds = Number(reply[0]),
|
||||
// microseconds = Number(reply[1]),
|
||||
// d: Partial<TimeReply> = new Date(seconds * 1000 + microseconds / 1000);
|
||||
// d.microseconds = microseconds;
|
||||
// return d as TimeReply;
|
||||
// }
|
||||
export default {
|
||||
FIRST_KEY_INDEX: undefined,
|
||||
IS_READ_ONLY: true,
|
||||
transformArguments() {
|
||||
return ['TIME'];
|
||||
},
|
||||
transformReply: undefined as unknown as () => [
|
||||
unixTimestamp: BlobStringReply<`${number}`>,
|
||||
microseconds: BlobStringReply<`${number}`>
|
||||
]
|
||||
} as const satisfies Command;
|
||||
|
@@ -52,7 +52,7 @@ import CLUSTER_FORGET from './CLUSTER_FORGET';
|
||||
import CLUSTER_GETKEYSINSLOT from './CLUSTER_GETKEYSINSLOT';
|
||||
// import CLUSTER_INFO from './CLUSTER_INFO';
|
||||
import CLUSTER_KEYSLOT from './CLUSTER_KEYSLOT';
|
||||
// import CLUSTER_LINKS from './CLUSTER_LINKS';
|
||||
import CLUSTER_LINKS from './CLUSTER_LINKS';
|
||||
import CLUSTER_MEET from './CLUSTER_MEET';
|
||||
import CLUSTER_MYID from './CLUSTER_MYID';
|
||||
// import CLUSTER_NODES from './CLUSTER_NODES';
|
||||
@@ -63,6 +63,10 @@ import CLUSTER_SAVECONFIG from './CLUSTER_SAVECONFIG';
|
||||
import CLUSTER_SET_CONFIG_EPOCH from './CLUSTER_SET-CONFIG-EPOCH';
|
||||
import CLUSTER_SETSLOT from './CLUSTER_SETSLOT';
|
||||
import CLUSTER_SLOTS from './CLUSTER_SLOTS';
|
||||
import CONFIG_GET from './CONFIG_GET';
|
||||
import CONFIG_RESETASTAT from './CONFIG_RESETSTAT';
|
||||
import CONFIG_REWRITE from './CONFIG_REWRITE';
|
||||
import CONFIG_SET from './CONFIG_SET';
|
||||
import COPY from './COPY';
|
||||
import DBSIZE from './DBSIZE';
|
||||
import DECR from './DECR';
|
||||
@@ -138,6 +142,9 @@ import INCRBYFLOAT from './INCRBYFLOAT';
|
||||
import INFO from './INFO';
|
||||
import KEYS from './KEYS';
|
||||
import LASTSAVE from './LASTSAVE';
|
||||
import LATENCY_DOCTOR from './LATENCY_DOCTOR';
|
||||
import LATENCY_GRAPH from './LATENCY_GRAPH';
|
||||
import LATENCY_LATEST from './LATENCY_LATEST';
|
||||
import LCS_IDX_WITHMATCHLEN from './LCS_IDX_WITHMATCHLEN';
|
||||
import LCS_IDX from './LCS_IDX';
|
||||
import LCS_LEN from './LCS_LEN';
|
||||
@@ -161,7 +168,7 @@ import LTRIM from './LTRIM';
|
||||
import MEMORY_DOCTOR from './MEMORY_DOCTOR';
|
||||
import MEMORY_MALLOC_STATS from './MEMORY_MALLOC-STATS';
|
||||
import MEMORY_PURGE from './MEMORY_PURGE';
|
||||
// import MEMORY_STATS from './MEMORY_STATS';
|
||||
import MEMORY_STATS from './MEMORY_STATS';
|
||||
import MEMORY_USAGE from './MEMORY_USAGE';
|
||||
import MGET from './MGET';
|
||||
import MODULE_LIST from './MODULE_LIST';
|
||||
@@ -193,6 +200,7 @@ import RANDOMKEY from './RANDOMKEY';
|
||||
import READONLY from './READONLY';
|
||||
import RENAME from './RENAME';
|
||||
import RENAMENX from './RENAMENX';
|
||||
import ROLE from './ROLE';
|
||||
import RPOP_COUNT from './RPOP_COUNT';
|
||||
import RPOP from './RPOP';
|
||||
import RPOPLPUSH from './RPOPLPUSH';
|
||||
@@ -233,6 +241,8 @@ import SSCAN from './SSCAN';
|
||||
import STRLEN from './STRLEN';
|
||||
import SUNION from './SUNION';
|
||||
import SUNIONSTORE from './SUNIONSTORE';
|
||||
import SWAPDB from './SWAPDB';
|
||||
import TIME from './TIME';
|
||||
import TOUCH from './TOUCH';
|
||||
import TTL from './TTL';
|
||||
import TYPE from './TYPE';
|
||||
@@ -335,7 +345,7 @@ type CLUSTER_FORGET = typeof import('./CLUSTER_FORGET').default;
|
||||
type CLUSTER_GETKEYSINSLOT = typeof import('./CLUSTER_GETKEYSINSLOT').default;
|
||||
// type CLUSTER_INFO = typeof import('./CLUSTER_INFO').default;
|
||||
type CLUSTER_KEYSLOT = typeof import('./CLUSTER_KEYSLOT').default;
|
||||
// type CLUSTER_LINKS = typeof import('./CLUSTER_LINKS').default;
|
||||
type CLUSTER_LINKS = typeof import('./CLUSTER_LINKS').default;
|
||||
type CLUSTER_MEET = typeof import('./CLUSTER_MEET').default;
|
||||
type CLUSTER_MYID = typeof import('./CLUSTER_MYID').default;
|
||||
// type CLUSTER_NODES = typeof import('./CLUSTER_NODES').default;
|
||||
@@ -346,6 +356,10 @@ type CLUSTER_SAVECONFIG = typeof import('./CLUSTER_SAVECONFIG').default;
|
||||
type CLUSTER_SET_CONFIG_EPOCH = typeof import('./CLUSTER_SET-CONFIG-EPOCH').default;
|
||||
type CLUSTER_SETSLOT = typeof import('./CLUSTER_SETSLOT').default;
|
||||
type CLUSTER_SLOTS = typeof import('./CLUSTER_SLOTS').default;
|
||||
type CONFIG_GET = typeof import('./CONFIG_GET').default;
|
||||
type CONFIG_RESETASTAT = typeof import('./CONFIG_RESETSTAT').default;
|
||||
type CONFIG_REWRITE = typeof import('./CONFIG_REWRITE').default;
|
||||
type CONFIG_SET = typeof import('./CONFIG_SET').default;
|
||||
type COPY = typeof import('./COPY').default;
|
||||
type DBSIZE = typeof DBSIZE;
|
||||
type DECR = typeof import('./DECR').default;
|
||||
@@ -421,6 +435,9 @@ type INCRBYFLOAT = typeof import('./INCRBYFLOAT').default;
|
||||
type INFO = typeof import('./INFO').default;
|
||||
type KEYS = typeof import('./KEYS').default;
|
||||
type LASTSAVE = typeof import('./LASTSAVE').default;
|
||||
type LATENCY_DOCTOR = typeof import('./LATENCY_DOCTOR').default;
|
||||
type LATENCY_GRAPH = typeof import('./LATENCY_GRAPH').default;
|
||||
type LATENCY_LATEST = typeof import('./LATENCY_LATEST').default;
|
||||
type LCS_IDX_WITHMATCHLEN = typeof import('./LCS_IDX_WITHMATCHLEN').default;
|
||||
type LCS_IDX = typeof import('./LCS_IDX').default;
|
||||
type LCS_LEN = typeof import('./LCS_LEN').default;
|
||||
@@ -444,7 +461,7 @@ type LTRIM = typeof import('./LTRIM').default;
|
||||
type MEMORY_DOCTOR = typeof import('./MEMORY_DOCTOR').default;
|
||||
type MEMORY_MALLOC_STATS = typeof import('./MEMORY_MALLOC-STATS').default;
|
||||
type MEMORY_PURGE = typeof import('./MEMORY_PURGE').default;
|
||||
// type MEMORY_STATS = typeof import('./MEMORY_STATS').default;
|
||||
type MEMORY_STATS = typeof import('./MEMORY_STATS').default;
|
||||
type MEMORY_USAGE = typeof import('./MEMORY_USAGE').default;
|
||||
type MGET = typeof import('./MGET').default;
|
||||
type MODULE_LIST = typeof import('./MODULE_LIST').default;
|
||||
@@ -477,6 +494,7 @@ type READONLY = typeof import('./READONLY').default;
|
||||
type RENAME = typeof import('./RENAME').default;
|
||||
type RENAMENX = typeof import('./RENAMENX').default;
|
||||
type RPOP_COUNT = typeof import('./RPOP_COUNT').default;
|
||||
type ROLE = typeof import('./ROLE').default;
|
||||
type RPOP = typeof import('./RPOP').default;
|
||||
type RPOPLPUSH = typeof import('./RPOPLPUSH').default;
|
||||
type RPUSH = typeof import('./RPUSH').default;
|
||||
@@ -516,6 +534,8 @@ type SSCAN = typeof import('./SSCAN').default;
|
||||
type STRLEN = typeof import('./STRLEN').default;
|
||||
type SUNION = typeof import('./SUNION').default;
|
||||
type SUNIONSTORE = typeof import('./SUNIONSTORE').default;
|
||||
type SWAPDB = typeof import('./SWAPDB').default;
|
||||
type TIME = typeof import('./TIME').default;
|
||||
type TOUCH = typeof import('./TOUCH').default;
|
||||
type TTL = typeof import('./TTL').default;
|
||||
type TYPE = typeof import('./TYPE').default;
|
||||
@@ -672,8 +692,8 @@ type Commands = {
|
||||
// clusterInfo: CLUSTER_INFO;
|
||||
CLUSTER_KEYSLOT: CLUSTER_KEYSLOT;
|
||||
clusterKeySlot: CLUSTER_KEYSLOT;
|
||||
// CLUSTER_LINKS: CLUSTER_LINKS;
|
||||
// clusterLinks: CLUSTER_LINKS;
|
||||
CLUSTER_LINKS: CLUSTER_LINKS;
|
||||
clusterLinks: CLUSTER_LINKS;
|
||||
CLUSTER_MEET: CLUSTER_MEET;
|
||||
clusterMeet: CLUSTER_MEET;
|
||||
CLUSTER_MYID: CLUSTER_MYID;
|
||||
@@ -694,6 +714,14 @@ type Commands = {
|
||||
clusterSetSlot: CLUSTER_SETSLOT;
|
||||
CLUSTER_SLOTS: CLUSTER_SLOTS;
|
||||
clusterSlots: CLUSTER_SLOTS;
|
||||
CONFIG_GET: CONFIG_GET;
|
||||
configGet: CONFIG_GET;
|
||||
CONFIG_RESETASTAT: CONFIG_RESETASTAT;
|
||||
configResetStat: CONFIG_RESETASTAT;
|
||||
CONFIG_REWRITE: CONFIG_REWRITE;
|
||||
configRewrite: CONFIG_REWRITE;
|
||||
CONFIG_SET: CONFIG_SET;
|
||||
configSet: CONFIG_SET;
|
||||
COPY: COPY;
|
||||
copy: COPY;
|
||||
DBSIZE: DBSIZE;
|
||||
@@ -844,6 +872,12 @@ type Commands = {
|
||||
keys: KEYS;
|
||||
LASTSAVE: LASTSAVE;
|
||||
lastSave: LASTSAVE;
|
||||
LATENCY_DOCTOR: LATENCY_DOCTOR;
|
||||
latencyDoctor: LATENCY_DOCTOR;
|
||||
LATENCY_GRAPH: LATENCY_GRAPH;
|
||||
latencyGraph: LATENCY_GRAPH;
|
||||
LATENCY_LATEST: LATENCY_LATEST;
|
||||
latencyLatest: LATENCY_LATEST;
|
||||
LCS_IDX_WITHMATCHLEN: LCS_IDX_WITHMATCHLEN;
|
||||
lcsIdxWithMatchLen: LCS_IDX_WITHMATCHLEN;
|
||||
LCS_IDX: LCS_IDX;
|
||||
@@ -889,8 +923,8 @@ type Commands = {
|
||||
memoryMallocStats: MEMORY_MALLOC_STATS;
|
||||
MEMORY_PURGE: MEMORY_PURGE;
|
||||
memoryPurge: MEMORY_PURGE;
|
||||
// MEMORY_STATS: MEMORY_STATS;
|
||||
// memoryStats: MEMORY_STATS;
|
||||
MEMORY_STATS: MEMORY_STATS;
|
||||
memoryStats: MEMORY_STATS;
|
||||
MEMORY_USAGE: MEMORY_USAGE;
|
||||
memoryUsage: MEMORY_USAGE;
|
||||
MGET: MGET;
|
||||
@@ -958,6 +992,8 @@ type Commands = {
|
||||
renameNX: RENAMENX;
|
||||
RPOP_COUNT: RPOP_COUNT;
|
||||
rPopCount: RPOP_COUNT;
|
||||
ROLE: ROLE;
|
||||
role: ROLE;
|
||||
RPOP: RPOP;
|
||||
rPop: RPOP;
|
||||
RPOPLPUSH: RPOPLPUSH;
|
||||
@@ -1036,6 +1072,10 @@ type Commands = {
|
||||
sUnion: SUNION;
|
||||
SUNIONSTORE: SUNIONSTORE;
|
||||
sUnionStore: SUNIONSTORE;
|
||||
SWAPDB: SWAPDB;
|
||||
swapDb: SWAPDB;
|
||||
TIME: TIME;
|
||||
time: TIME;
|
||||
TOUCH: TOUCH;
|
||||
touch: TOUCH;
|
||||
TTL: TTL;
|
||||
@@ -1239,8 +1279,8 @@ export default {
|
||||
// clusterInfo: CLUSTER_INFO,
|
||||
CLUSTER_KEYSLOT,
|
||||
clusterKeySlot: CLUSTER_KEYSLOT,
|
||||
// CLUSTER_LINKS,
|
||||
// clusterLinks: CLUSTER_LINKS,
|
||||
CLUSTER_LINKS,
|
||||
clusterLinks: CLUSTER_LINKS,
|
||||
CLUSTER_MEET,
|
||||
clusterMeet: CLUSTER_MEET,
|
||||
CLUSTER_MYID,
|
||||
@@ -1261,6 +1301,14 @@ export default {
|
||||
clusterSetSlot: CLUSTER_SETSLOT,
|
||||
CLUSTER_SLOTS,
|
||||
clusterSlots: CLUSTER_SLOTS,
|
||||
CONFIG_GET,
|
||||
configGet: CONFIG_GET,
|
||||
CONFIG_RESETASTAT,
|
||||
configResetStat: CONFIG_RESETASTAT,
|
||||
CONFIG_REWRITE,
|
||||
configRewrite: CONFIG_REWRITE,
|
||||
CONFIG_SET,
|
||||
configSet: CONFIG_SET,
|
||||
COPY,
|
||||
copy: COPY,
|
||||
DBSIZE,
|
||||
@@ -1313,8 +1361,8 @@ export default {
|
||||
functionList: FUNCTION_LIST,
|
||||
FUNCTION_LOAD,
|
||||
functionLoad: FUNCTION_LOAD,
|
||||
// FUNCTION_RESTORE,
|
||||
// functionRestore: FUNCTION_RESTORE,
|
||||
FUNCTION_RESTORE,
|
||||
functionRestore: FUNCTION_RESTORE,
|
||||
// FUNCTION_STATS,
|
||||
// functionStats: FUNCTION_STATS,
|
||||
GEOADD,
|
||||
@@ -1411,6 +1459,12 @@ export default {
|
||||
keys: KEYS,
|
||||
LASTSAVE,
|
||||
lastSave: LASTSAVE,
|
||||
LATENCY_DOCTOR,
|
||||
latencyDoctor: LATENCY_DOCTOR,
|
||||
LATENCY_GRAPH,
|
||||
latencyGraph: LATENCY_GRAPH,
|
||||
LATENCY_LATEST,
|
||||
latencyLatest: LATENCY_LATEST,
|
||||
LCS_IDX_WITHMATCHLEN,
|
||||
lcsIdxWithMatchLen: LCS_IDX_WITHMATCHLEN,
|
||||
LCS_IDX,
|
||||
@@ -1456,8 +1510,8 @@ export default {
|
||||
memoryMallocStats: MEMORY_MALLOC_STATS,
|
||||
MEMORY_PURGE,
|
||||
memoryPurge: MEMORY_PURGE,
|
||||
// MEMORY_STATS,
|
||||
// memoryStats: MEMORY_STATS,
|
||||
MEMORY_STATS,
|
||||
memoryStats: MEMORY_STATS,
|
||||
MEMORY_USAGE,
|
||||
memoryUsage: MEMORY_USAGE,
|
||||
MGET,
|
||||
@@ -1525,6 +1579,8 @@ export default {
|
||||
renameNX: RENAMENX,
|
||||
RPOP_COUNT,
|
||||
rPopCount: RPOP_COUNT,
|
||||
ROLE,
|
||||
role: ROLE,
|
||||
RPOP,
|
||||
rPop: RPOP,
|
||||
RPOPLPUSH,
|
||||
@@ -1603,6 +1659,10 @@ export default {
|
||||
sUnion: SUNION,
|
||||
SUNIONSTORE,
|
||||
sUnionStore: SUNIONSTORE,
|
||||
SWAPDB,
|
||||
swapDb: SWAPDB,
|
||||
TIME,
|
||||
time: TIME,
|
||||
TOUCH,
|
||||
touch: TOUCH,
|
||||
TTL,
|
||||
|
Reference in New Issue
Block a user