diff --git a/src/cluster/cluster.cc b/src/cluster/cluster.cc index 1244ea4a8fc..f2451eaa87f 100644 --- a/src/cluster/cluster.cc +++ b/src/cluster/cluster.cc @@ -32,7 +32,9 @@ #include "fmt/format.h" #include "parse_util.h" #include "replication.h" +#include "server/redis_connection.h" #include "server/server.h" +#include "status.h" #include "string_util.h" #include "time_util.h" diff --git a/src/commands/cmd_cluster.cc b/src/commands/cmd_cluster.cc index e371e78f1cf..8ada4e8eec0 100644 --- a/src/commands/cmd_cluster.cc +++ b/src/commands/cmd_cluster.cc @@ -338,9 +338,19 @@ class CommandReadWrite : public Commander { } }; +class CommandAsking : public Commander { + public: + Status Execute(Server *srv, Connection *conn, std::string *output) override { + conn->EnableFlag(redis::Connection::kAsking); + *output = redis::SimpleString("OK"); + return Status::OK(); + } +}; + REDIS_REGISTER_COMMANDS(MakeCmdAttr("cluster", -2, "cluster no-script", 0, 0, 0, GenerateClusterFlag), MakeCmdAttr("clusterx", -2, "cluster no-script", 0, 0, 0, GenerateClusterFlag), MakeCmdAttr("readonly", 1, "cluster no-multi", 0, 0, 0), - MakeCmdAttr("readwrite", 1, "cluster no-multi", 0, 0, 0), ) + MakeCmdAttr("readwrite", 1, "cluster no-multi", 0, 0, 0), + MakeCmdAttr("asking", 1, "cluster", 0, 0, 0), ) } // namespace redis diff --git a/src/server/redis_connection.h b/src/server/redis_connection.h index c206a1583bc..f3015fcfd6c 100644 --- a/src/server/redis_connection.h +++ b/src/server/redis_connection.h @@ -46,6 +46,7 @@ class Connection : public EvbufCallbackBase { kCloseAsync = 1 << 7, kMultiExec = 1 << 8, kReadOnly = 1 << 9, + kAsking = 1 << 10, }; explicit Connection(bufferevent *bev, Worker *owner);