-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat:Subcommands support separate command id #24
Conversation
src/client.cc
Outdated
return 0; | ||
} | ||
|
||
if (!cmdPtr->CheckArg(params.size())) { | ||
ReplyError(PError_param, &reply_); | ||
if (cmdPtr.first->CheckArg(params.size())) { |
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.
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.
是判断错了,等我改一下
if (ctx.argv_.size() < 2) { | ||
return std::pair(nullptr, CmdRes::kInvalidParameter); | ||
} | ||
return std::pair(cmd->second->GetSubCmd(ctx.argv_[1]), CmdRes::kSyntaxErr); |
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.
这里没太明白逻辑,当没有subcommand时,状态应该返回kSyntaxErr
吗?
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.
在调用GetCommand
的地方会判断,如果有子命令,但是返回的是null, 状态是kSyntaxErr
, 如果返回的指针不是null, 这个状态会被忽略
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.
好嘞,谢谢~
src/client.cc
Outdated
return 0; | ||
} | ||
|
||
if (!cmdPtr->CheckArg(params.size())) { | ||
ReplyError(PError_param, &reply_); | ||
if (cmdPtr->CheckArg(params.size())) { |
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.
if (cmdPtr->CheckArg(params.size())) { | |
if (!cmdPtr->CheckArg(params.size())) { |
这里的判断条件应该是反了
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.
对,这里是判断错了
每个拥有子命令的命令 (比如 config get, config set) 这样的命令, 以前的时候是一个
config
命令, 通过 第二个参数来区分具体执行哪个,config set
,config get
这些命令id是同一个.这样会带来一个问题,
config set
在ACL中属于写命令,config get
在ACL中属于 读命令, 如果使用 之前那种所有子命令id相同的时, 无法为子命令区分 不同的ACL类型现在改成了 每个子命令(和redis 处理方式一样) 有单独的id, 可以为不同的子命令 区分不同的 ACL类型, 方便 权限划分
std::pair<BaseCmd*, CmdRes::CmdRet> CmdTableManager::GetCommand(const std::string& cmdName, CmdContext& ctx)
这里的返回值使用了
std::pair
, 来同时返回两个值, 不知出否妥当, 如有更好的解决方法,还请指正