Yangsx-1 commented on code in PR #1870:
URL: https://github.com/apache/kvrocks/pull/1870#discussion_r1383071746


##########
src/commands/cmd_stream.cc:
##########
@@ -472,6 +488,72 @@ class CommandXInfo : public Commander {
 
     return Status::OK();
   }
+
+  Status getGroupInfo(Server *srv, Connection *conn, std::string *output) {
+    redis::Stream stream_db(srv->storage, conn->GetNamespace());
+    std::vector<std::pair<std::string, StreamConsumerGroupMetadata>> 
result_vector;
+    auto s = stream_db.GetGroupInfo(args_[2], result_vector);
+    if (!s.ok() && !s.IsNotFound()) {
+      return {Status::RedisExecErr, s.ToString()};
+    }
+
+    if (s.IsNotFound()) {
+      return {Status::RedisExecErr, errNoSuchKey};
+    }
+
+    output->append(redis::MultiLen(result_vector.size()));
+    for (auto const &it : result_vector) {
+      output->append(redis::MultiLen(12));
+      output->append(redis::BulkString("name"));
+      output->append(redis::BulkString(it.first));
+      output->append(redis::BulkString("consumers"));
+      output->append(redis::Integer(it.second.consumer_number));
+      output->append(redis::BulkString("pending"));
+      output->append(redis::Integer(it.second.pending_number));
+      output->append(redis::BulkString("last-delivered-id"));
+      
output->append(redis::BulkString(it.second.last_delivered_id.ToString()));
+      output->append(redis::BulkString("entries-read"));
+      if (it.second.entries_read == -1) {
+        output->append(redis::NilString());
+      } else {
+        output->append(redis::Integer(it.second.entries_read));
+      }
+      output->append(redis::BulkString("lag"));
+      output->append(redis::Integer(it.second.lag));

Review Comment:
   We don't have these cases now, i'll add it later.



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