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 latency reset command #2655

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/client/lib/client/commands.ts
Expand Up @@ -88,6 +88,7 @@ import * as LATENCY_DOCTOR from '../commands/LATENCY_DOCTOR';
import * as LATENCY_GRAPH from '../commands/LATENCY_GRAPH';
import * as LATENCY_HISTORY from '../commands/LATENCY_HISTORY';
import * as LATENCY_LATEST from '../commands/LATENCY_LATEST';
import * as LATENCY_RESET from '../commands/LATENCY_RESET';
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 @@ -303,6 +304,8 @@ export default {
latencyHistory: LATENCY_HISTORY,
LATENCY_LATEST,
latencyLatest: LATENCY_LATEST,
LATENCY_RESET,
latencyReset: LATENCY_RESET,
LOLWUT,
lolwut: LOLWUT,
MEMORY_DOCTOR,
Expand Down
21 changes: 21 additions & 0 deletions packages/client/lib/commands/LATENCY_RESET.spec.ts
@@ -0,0 +1,21 @@
import { strict as assert } from "assert";
import testUtils, { GLOBAL } from "../test-utils";
import { transformArguments } from "./LATENCY_RESET";

describe("LATENCY RESET", () => {
it("transformArguments", () => {
assert.deepEqual(transformArguments("command"), ["LATENCY", "RESET", "command"]);
assert.deepEqual(transformArguments(), ["LATENCY", "RESET"]);
assert.deepEqual(transformArguments(["command", "aof-stat"]), ["LATENCY", "RESET", "command", "aof-stat"]);
});

testUtils.testWithClient(
"client.latencyReset",
async (client) => {
await Promise.all([client.configSet("latency-monitor-threshold", "1"), client.sendCommand(["DEBUG", "SLEEP", "0.001"])]);

assert.equal(typeof (await client.latencyReset("command")), "number");
},
GLOBAL.SERVERS.OPEN
);
});
28 changes: 28 additions & 0 deletions packages/client/lib/commands/LATENCY_RESET.ts
@@ -0,0 +1,28 @@
import { RedisCommandArguments } from ".";
import { pushVerdictArguments } from "./generic-transformers";

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 function transformArguments(events?: EventType | Array<EventType>): RedisCommandArguments {
if (events === undefined) return ["LATENCY", "RESET"];

return pushVerdictArguments(["LATENCY", "RESET"], events);
}

export declare function transformReply(): number;