Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LATENCY LATEST #2514

Merged
merged 7 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/client/lib/client/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import * as KEYS from '../commands/KEYS';
import * as LASTSAVE from '../commands/LASTSAVE';
import * as LATENCY_DOCTOR from '../commands/LATENCY_DOCTOR';
import * as LATENCY_GRAPH from '../commands/LATENCY_GRAPH';
import * as LATENCY_LATEST from '../commands/LATENCY_LATEST';
import * as LOLWUT from '../commands/LOLWUT';
import * as MEMORY_DOCTOR from '../commands/MEMORY_DOCTOR';
import * as MEMORY_MALLOC_STATS from '../commands/MEMORY_MALLOC-STATS';
Expand Down Expand Up @@ -290,6 +291,8 @@ export default {
latencyDoctor: LATENCY_DOCTOR,
LATENCY_GRAPH,
latencyGraph: LATENCY_GRAPH,
LATENCY_LATEST,
latencyLatest: LATENCY_LATEST,
LOLWUT,
lolwut: LOLWUT,
MEMORY_DOCTOR,
Expand Down
27 changes: 27 additions & 0 deletions packages/client/lib/commands/LATENCY_LATEST.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {strict as assert} from 'assert';
import testUtils, {GLOBAL} from '../test-utils';
import { transformArguments } from './LATENCY_LATEST';

describe('LATENCY LATEST', () => {
it('transformArguments', () => {
assert.deepEqual(
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 event of latency) {
assert.ok(typeof event.name === 'string', 'Name should be a string');
assert.ok(typeof event.timestamp === 'number', 'Timestamp should be a number');
assert.ok(typeof event.latestLatency === 'number', 'Latest latency should be a number');
assert.ok(typeof event.allTimeLatency === 'number', 'All-time latency should be a number');
}
Karnav123 marked this conversation as resolved.
Show resolved Hide resolved
}, GLOBAL.SERVERS.OPEN);
});
12 changes: 12 additions & 0 deletions packages/client/lib/commands/LATENCY_LATEST.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { RedisCommandArguments } from '.';

export function transformArguments(): RedisCommandArguments {
return ['LATENCY', 'LATEST'];
}

export declare function transformReply(): Array<[
name: string,
timestamp: number,
latestLatency: number,
allTimeLatency: number
]>;