|
1 |
| -import { CommandParser } from '../client/parser'; // Ensure CommandParser is imported |
2 |
| -import { Command } from '../RESP/types'; // Assuming 'Command' type from RESP/types |
3 |
| -import { LATENCY_EVENTS, LatencyEvent } from './LATENCY_GRAPH'; // Reusing these constants |
| 1 | +import { CommandParser } from '../client/parser'; |
| 2 | +import { Command } from '../RESP/types'; |
| 3 | +import { LATENCY_EVENTS, LatencyEvent } from './LATENCY_GRAPH'; |
| 4 | + |
4 | 5 |
|
5 |
| -// Exporting them for convenience, as they are relevant to LATENCY commands |
6 | 6 | export { LATENCY_EVENTS, LatencyEvent };
|
7 | 7 |
|
8 | 8 | // This object defines the LATENCY RESET command's behavior for the Redis client.
|
9 | 9 | export default {
|
10 |
| - // NOT_KEYED_COMMAND: true indicates that this command does not operate on a specific Redis key. |
11 |
| - // This is important for client-side routing and command categorization. |
| 10 | + |
12 | 11 | NOT_KEYED_COMMAND: true,
|
13 | 12 |
|
14 |
| - // IS_READ_ONLY: false indicates that this command modifies the server's internal state. |
15 |
| - // The LATENCY RESET command clears latency statistics, thus it's not read-only. |
| 13 | + |
16 | 14 | IS_READ_ONLY: false,
|
17 | 15 |
|
18 |
| - /** |
19 |
| - * Constructs the LATENCY RESET command by pushing arguments to the parser. |
20 |
| - * This method is used by the Redis client to build the command before sending it to the server. |
21 |
| - * |
22 |
| - * @param parser - The command parser instance provided by the client. |
23 |
| - * @param events - Optional latency event names to reset. If none are provided, all events are reset. |
24 |
| - * @see https://redis.io/commands/latency-reset/ |
25 |
| - */ |
26 |
| - parseCommand(parser: CommandParser, ...events: Array<LatencyEvent>) { // Changed from transformArguments to parseCommand |
27 |
| - // Start with the base command 'LATENCY' and its subcommand 'RESET' |
| 16 | + |
| 17 | + parseCommand(parser: CommandParser, ...events: Array<LatencyEvent>) { |
| 18 | + |
28 | 19 | const args: Array<string> = ['LATENCY', 'RESET'];
|
29 | 20 |
|
30 |
| - // If specific event names are provided, append them to the arguments array. |
31 |
| - // This allows resetting only particular latency event types. |
| 21 | + |
32 | 22 | if (events.length > 0) {
|
33 | 23 | args.push(...events);
|
34 | 24 | }
|
35 | 25 |
|
36 |
| - // Push the constructed arguments to the parser. The parser will then |
37 |
| - // handle the serialization into the RESP (Redis Serialization Protocol) format. |
| 26 | + |
38 | 27 | parser.push(...args);
|
39 | 28 | },
|
40 | 29 |
|
41 |
| - /** |
42 |
| - * Transforms the reply received from the Redis server for the LATENCY RESET command. |
43 |
| - * |
44 |
| - * The LATENCY RESET command returns an Integer Reply (the oldest timestamp of the |
45 |
| - * events that were reset, or 0 if no events were reset). |
46 |
| - * Node-redis typically handles basic RESP Integer replies automatically, |
47 |
| - * so a custom transformation function might not be strictly necessary for simple cases. |
48 |
| - * |
49 |
| - * @returns A number representing the oldest timestamp of the reset events. |
50 |
| - */ |
51 | 30 | transformReply: undefined as unknown as () => number
|
52 |
| -} as const satisfies Command; // 'satisfies Command' ensures this object conforms to the 'Command' interface |
| 31 | +} as const satisfies Command; |
0 commit comments