Skip to content

Conversation

@romange
Copy link
Collaborator

@romange romange commented Dec 6, 2025

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.

Copy link

@augmentcode augmentcode bot left a 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.

Copy link
Contributor

Copilot AI left a 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::ParsedArgs wrapper class with methods Front(), Tail(), ToSlice(), size(), and empty()
  • Updated DispatchCommand() and DispatchManyCommands() interfaces to accept ParsedArgs instead of ArgSlice
  • Converted arguments to ArgSlice (via ToSlice()) 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

Copy link
Contributor

Copilot AI left a 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.

Copy link
Contributor

Copilot AI left a 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]>
Comment on lines +1434 to +1435
string cmd = absl::AsciiStrToUpper(args.Front());
const auto [cid, args_no_cmd] = registry_.FindExtended(cmd, args.Tail());
Copy link
Contributor

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

@romange romange merged commit 627805f into main Dec 7, 2025
17 of 18 checks passed
@romange romange deleted the Pr6 branch December 7, 2025 08:22
romange added a commit that referenced this pull request Dec 8, 2025
Following #6171 and #6169 we implement Memcache::Command using BackedArguments.

Signed-off-by: Roman Gershman <[email protected]>
romange added a commit that referenced this pull request Dec 8, 2025
Following #6171 and #6169 we implement Memcache::Command using BackedArguments.

Signed-off-by: Roman Gershman <[email protected]>
romange added a commit that referenced this pull request Dec 8, 2025
Following #6171 and #6169 we implement Memcache::Command using BackedArguments.

Signed-off-by: Roman Gershman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants