You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/09/17 03:05:32 UTC

[GitHub] [incubator-kvrocks] git-hulk commented on a diff in pull request #881: [WIP] Implement the command `hello`

git-hulk commented on code in PR #881:
URL: https://github.com/apache/incubator-kvrocks/pull/881#discussion_r973531504


##########
src/redis_cmd.cc:
##########
@@ -4132,6 +4132,52 @@ class CommandEcho : public Commander {
   }
 };
 
+class CommandHello final : public Commander {
+public:
+  Status Execute(Server *svr, Connection *conn, std::string *output) override {
+    std::cout << "Execute is called" << std::endl;
+    if (args_.size() == 2) {
+      int64_t protocol;
+      try {
+        protocol = std::stoll(args_[1]);
+      } catch (std::exception& e) {
+        // std::invalid_argument or std::out_of_range
+        *output = Redis::Error("Protocol version is not an integer or out of range");
+        return Status::OK();
+      }
+
+      // In redis, it will check protocol < 2 or protocol > 3,
+      // but kvrocks only supports REPL2 by now.
+      if (protocol != 2) {
+        *output = Redis::Error("-NOPROTO unsupported protocol version");
+        return Status::OK();
+      }
+    }
+
+    // TODO(mapleFU): do we need to implement auth and setname?

Review Comment:
   Yes, setname can use [Connection::SetName](https://github.com/apache/incubator-kvrocks/blob/40132067bc7bb696f96675e8a396f0473321a454/src/redis_connection.h#L80)



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org