Skip to content

Commit

Permalink
pr review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sasidharan-Gopal committed Aug 30, 2024
1 parent 8713624 commit 3157e89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct SupportedCommands {
"zscore", "rpoplpush", "smove", "sunion", "sdiff", "sinter", "sinterstore", "zunionstore",
"zinterstore", "pfmerge", "georadius", "georadiusbymember", "rename", "getex", "sort", "zmscore", "sdiffstore", "msetnx", "substr",
"zrangestore", "zunion", "echo", "zdiff", "sunionstore", "smismember",
"hrandfield", "geosearchstore", "zdiffstore", "geosearch", "randomkey", "zinter", "zrandmember",
"hrandfield", "geosearchstore", "zdiffstore", "geosearch", "zinter", "zrandmember",
"bitop", "lpos", "renamenx","xread_simple_command");
}

Expand Down Expand Up @@ -106,7 +106,7 @@ struct SupportedCommands {
* @return commands which handle Redis commands without keys.
*/
static const absl::flat_hash_set<std::string>& adminNokeyCommands() {
CONSTRUCT_ON_FIRST_USE(absl::flat_hash_set<std::string>, "script", "flushall", "flushdb", "publish","pubsub", "keys", "slowlog", "config","client","info","cluster","select", "unwatch");
CONSTRUCT_ON_FIRST_USE(absl::flat_hash_set<std::string>, "script", "flushall", "flushdb", "publish","pubsub", "keys", "slowlog", "config","client","info","cluster","select", "unwatch", "randomkey");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ AdminRespHandlerType getresponseHandlerType(const std::string& command_name) {
{"flushdb", AdminRespHandlerType::allresponses_mustbe_same},
{"rename", AdminRespHandlerType::singleshardresponse},
{"unwatch", AdminRespHandlerType::allresponses_mustbe_same},
{"randomkey", AdminRespHandlerType::singleshardresponse},
// Add more mappings as needed
};

Expand Down Expand Up @@ -269,21 +270,11 @@ SplitRequestPtr SimpleRequest::create(Router& router,
callbacks.onResponse(Common::Redis::Utility::makeError(fmt::format("unexpected command format")));
return nullptr;
}
std::string key;
if (Common::Redis::SupportedCommands::noArgCommands().count(command_name) == 0) {
key =incoming_request->asArray()[shardKeyIndex].asString();;
}else{
key = std::string();
}
std::string key =incoming_request->asArray()[shardKeyIndex].asString();;
std::unique_ptr<SimpleRequest> request_ptr{
new SimpleRequest(callbacks, command_stats, time_source, delay_command_latency)};

RouteSharedPtr route;
if (Common::Redis::SupportedCommands::noArgCommands().count(command_name) == 0) {
route = router.upstreamPool(incoming_request->asArray()[shardKeyIndex].asString(), stream_info);
}else{
route = router.upstreamPool(key, stream_info);
}

const auto route = router.upstreamPool(incoming_request->asArray()[shardKeyIndex].asString(), stream_info);
if (route) {
Common::Redis::RespValueSharedPtr base_request = std::move(incoming_request);
request_ptr->handle_ = makeSingleServerRequest(
Expand Down Expand Up @@ -1702,7 +1693,7 @@ SplitRequestPtr TransactionRequest::create(Router& router,

RouteSharedPtr route;
if (transaction.key_.empty()) {
transaction.key_ = incoming_request->asArray()[1].asString();
transaction.key_ = incoming_request->asArray()[1].asString();
route = router.upstreamPool(transaction.key_, stream_info);
Common::Redis::RespValueSharedPtr multi_request =
std::make_shared<Common::Redis::Client::MultiRequest>();
Expand Down

0 comments on commit 3157e89

Please sign in to comment.