geetanshjuneja opened a new pull request, #3558:
URL: https://github.com/apache/kvrocks/pull/3558

   ## Description
   
   This commit introduces subcommands as a first-class abstraction in the 
Kvrocks command framework, and migrates `NAMESPACE` as the initial reference 
implementation.
   
   This change adds explicit subcommand registration and resolution to the 
command framework:
   
   - **`MakeSubCmdAttr()`** — registers subcommands under a parent command with 
canonical internal names like `namespace|get`
   - **`CommandTable::Resolve()`** — resolves a full command token vector (e.g. 
`{"namespace", "get", "ns"}`) to the correct root + subcommand attributes
   - **`ResolvedCommand`** — carries both the parent command name and the 
resolved attributes of the subcommand
   - **`Commander::GetRootName()` / `SetRootName()`** — preserves the canonical 
root name when commands are invoked via renamed aliases
   
   Command lookup paths are updated to use full token resolution:
   
   - Client command execution (`redis_connection.cc`)
   - Lua `redis.call` / `redis.pcall` (`scripting.cc`)
   - `COMMAND GETKEYS` (`cmd_server.cc`)
   - `Server::LookupAndCreateCommand()` now accepts the full token vector
   
   ### Reference implementation: `NAMESPACE`
   
   The monolithic `CommandNamespace` dispatcher is split into dedicated 
handlers:
   
   - `CommandNamespace` — root stub that returns the legacy invalid-subcommand 
error
   - `CommandNamespaceGet`, `Set`, `Add`, `Del`, `Current` — individually 
registered subcommands with their own arity, flags, and handlers
   
   ## Tests added 
   
   ### C++ unit tests — `tests/cppunit/subcommand_resolution_test.cc`
   
   - [ ] `SubcommandResolution.ResolveRootCommandWithoutSubcommand`
   - [ ] `SubcommandResolution.ResolveRegisteredNamespaceSubcommand`
   - [ ] `SubcommandResolution.RegisteredSubcommandUsesSubcommandKeyRange`
   - [ ] `SubcommandResolution.MissingNamespaceSubcommandRejectsArity`
   - [ ] `SubcommandResolution.ResolveRenamedRootCommandWithSubcommand`
   - [ ] `SubcommandResolution.RenamedRootCommandUsesSubcommandKeyRange`
   
   ### Go integration tests — `tests/gocase/unit/command/command_test.go`
   
   - [ ] `TestCommandGetKeysWithRenamedCommand`
   
   ### Go integration tests — `tests/gocase/unit/namespace/namespace_test.go`
   
   - [ ] `TestCommandNamespaceSubcommands`
     - [ ] `NAMESPACE keeps legacy invalid subcommand error`
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to