PragmaTwice commented on code in PR #2472:
URL: https://github.com/apache/kvrocks/pull/2472#discussion_r1708529349


##########
src/commands/cmd_server.cc:
##########
@@ -1265,6 +1265,64 @@ class CommandDump : public Commander {
   }
 };
 
+class CommandPollUpdates : public Commander {
+ public:
+  Status Parse(const std::vector<std::string> &args) override {
+    CommandParser parser(args, 1);
+    sequence_ = GET_OR_RET(parser.TakeInt<uint64_t>());
+
+    while (parser.Good()) {
+      if (parser.EatEqICase("MAX")) {
+        max_ = GET_OR_RET(parser.TakeInt<int64_t>(NumericRange<int64_t>{1, 
1000}));
+      } else if (parser.EatEqICase("STRICT")) {
+        is_strict_ = true;
+      } else if (parser.EatEqICase("FORMAT")) {
+        auto format = GET_OR_RET(parser.TakeStr());
+        if (util::EqualICase(format, "RAW")) {
+          format_ = Format::Raw;
+        } else {
+          return {Status::RedisParseErr, "invalid FORMAT option, only support 
RAW"};
+        }
+      } else {
+        return {Status::RedisParseErr, errInvalidSyntax};
+      }
+    }
+    return Status::OK();
+  }
+
+  Status Execute(Server *srv, Connection *conn, std::string *output) override {
+    // sequence + 1 is for excluding the current sequence to avoid getting 
duplicate updates
+    auto batches = GET_OR_RET(srv->PollUpdates(sequence_ + 1, max_, 
is_strict_));
+
+    *output = redis::MultiLen(8);
+    *output += redis::BulkString("latest_sequence");
+    *output += redis::Integer(srv->storage->LatestSeqNumber());
+    *output += redis::BulkString("format");
+    *output += redis::BulkString("RAW");

Review Comment:
   Users MUST know the context because they should know they've send a 
POLLUPDATES command.



-- 
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