-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: introduce ParsedArguments class #6169
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review completed. 1 suggestion posted.
Comment augment review to trigger a new review at any time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new ParsedArgs class to provide a cleaner, more explicit API for handling command arguments during dispatch, replacing the generic ArgSlice type at interface boundaries. The change improves code readability by making it clearer when arguments have been parsed and are ready for command dispatch, as opposed to being raw argument slices.
Key changes:
- Introduced
facade::ParsedArgswrapper class with methodsFront(),Tail(),ToSlice(),size(), andempty() - Updated
DispatchCommand()andDispatchManyCommands()interfaces to acceptParsedArgsinstead ofArgSlice - Converted arguments to
ArgSlice(viaToSlice()) only when executing commands, maintaining clear separation between parsing and execution phases
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/facade/facade_types.h | Added new ParsedArgs wrapper class with implicit constructor from ArgSlice |
| src/facade/service_interface.h | Updated virtual interface methods to use ParsedArgs instead of ArgSlice |
| src/facade/command_id.h | Removed unused CmdArgList typedef and facade_types.h include to reduce coupling |
| src/facade/cmd_arg_parser.h | Changed constructor and Tail() return type from CmdArgList to ArgSlice; made HasError() const |
| src/facade/ok_main.cc | Updated OkService implementations to use ParsedArgs parameter type |
| src/facade/dragonfly_connection.cc | Updated dispatch calls to use brace-initialization for ParsedArgs construction |
| src/server/command_registry.h | Updated FindExtended() to accept and return ParsedArgs instead of ArgSlice; added CmdArgList alias |
| src/server/command_registry.cc | Updated FindExtended() implementation to use ParsedArgs API methods |
| src/server/main_service.h | Updated service method signatures to use ParsedArgs |
| src/server/main_service.cc | Converted to use ParsedArgs API throughout dispatch logic; calls ToSlice() when passing to command execution |
| src/server/rdb_load.cc | Updated DispatchCommand() call to use brace-initialization |
| src/server/http_api.cc | Updated DispatchCommand() call to use brace-initialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Currently we use ArgSlice, CmdArgList everywhere where we want a span on string_views. As a result, it's very hard to understand the requirements from the passed classes. This PR introduces a new ParsedArguments class and reduces the API surface for the passed object. Make sure to unwind ParsedArguments to ArgSlice only when we start executing the command. We will clean-up redundant aliases in the futures. Signed-off-by: Roman Gershman <[email protected]>
| string cmd = absl::AsciiStrToUpper(args.Front()); | ||
| const auto [cid, args_no_cmd] = registry_.FindExtended(cmd, args.Tail()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once we have them packed, we can refactor registry interface to pick front() one by one
Following #6171 and #6169 we implement Memcache::Command using BackedArguments. Signed-off-by: Roman Gershman <[email protected]>
Following #6171 and #6169 we implement Memcache::Command using BackedArguments. Signed-off-by: Roman Gershman <[email protected]>
Following #6171 and #6169 we implement Memcache::Command using BackedArguments. Signed-off-by: Roman Gershman <[email protected]>
Currently we use ArgSlice, CmdArgList everywhere where we want a span on string_views. As a result, it's very hard to understand the requirements from the passed classes.
This PR introduces a new ParsedArguments class and reduces the API surface for the passed object. Make sure to unwind ParsedArguments to ArgSlice only when we start executing the command.
We will clean-up redundant aliases in the futures.