git-hulk commented on code in PR #1870:
URL: https://github.com/apache/kvrocks/pull/1870#discussion_r1382409890
##########
src/commands/cmd_stream.cc:
##########
@@ -472,6 +488,82 @@ 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};
+ }
+
+ if (result_vector.empty()) {
+ output->append(redis::SimpleString("(empty array)"));
+ return Status::OK();
+ }
+
+ 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));
+ }
+
+ return Status::OK();
+ }
+
+ Status getConsumerInfo(Server *srv, Connection *conn, std::string *output) {
+ redis::Stream stream_db(srv->storage, conn->GetNamespace());
+ std::vector<std::pair<std::string, redis::StreamConsumerMetadata>>
result_vector;
+ auto s = stream_db.GetConsumerInfo(args_[2], args_[3], result_vector);
+
+ if (!s.ok() && !s.IsNotFound()) {
+ return {Status::RedisExecErr, s.ToString()};
+ }
+
+ if (s.IsNotFound()) {
+ return {Status::RedisExecErr, errNoSuchKey};
+ }
+
+ if (result_vector.empty()) {
Review Comment:
Same as above
--
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]