Skip to content

Commit cc08446

Browse files
authored
Update LATENCY_RESET.ts
1 parent 0a0d5c8 commit cc08446

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed
Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,31 @@
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+
45

5-
// Exporting them for convenience, as they are relevant to LATENCY commands
66
export { LATENCY_EVENTS, LatencyEvent };
77

88
// This object defines the LATENCY RESET command's behavior for the Redis client.
99
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+
1211
NOT_KEYED_COMMAND: true,
1312

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+
1614
IS_READ_ONLY: false,
1715

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+
2819
const args: Array<string> = ['LATENCY', 'RESET'];
2920

30-
// If specific event names are provided, append them to the arguments array.
31-
// This allows resetting only particular latency event types.
21+
3222
if (events.length > 0) {
3323
args.push(...events);
3424
}
3525

36-
// Push the constructed arguments to the parser. The parser will then
37-
// handle the serialization into the RESP (Redis Serialization Protocol) format.
26+
3827
parser.push(...args);
3928
},
4029

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-
*/
5130
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

Comments
 (0)