mirror of
https://github.com/fluencelabs/redis
synced 2025-03-23 02:50:50 +00:00
CG: XINFO GROUPS + output format changes.
XINFO is mainly an observability command that will be used more by humans than computers, and even when used by computers it will be a very low traffic command. For this reason the format was changed in order to have field names. They'll consume some bandwidth and CPU cycles, but in this context this is much better than having to understand what the numbers in the output array are.
This commit is contained in:
parent
0cf6b1e3ae
commit
d7d8cd0b2f
@ -1863,6 +1863,7 @@ void xinfoCommand(client *c) {
|
||||
"<key> CONSUMERS <groupname> -- Show consumer groups of group <groupname>.",
|
||||
"<key> GROUPS -- Show the stream consumer groups.",
|
||||
"<key> STREAM -- Show information about the stream.",
|
||||
"<key> (without subcommand) -- Alias for <key> STREAM.",
|
||||
"<key> HELP -- Prints this help.",
|
||||
NULL
|
||||
};
|
||||
@ -1878,6 +1879,8 @@ NULL
|
||||
|
||||
/* Dispatch the different subcommands. */
|
||||
if (!strcasecmp(opt,"CONSUMERS") && c->argc == 4) {
|
||||
/* XINFO <key> CONSUMERS <group>. */
|
||||
|
||||
streamCG *cg = streamLookupCG(s,c->argv[3]->ptr);
|
||||
if (cg == NULL) {
|
||||
addReplyErrorFormat(c, "-NOGROUP No such consumer group '%s' "
|
||||
@ -1896,16 +1899,42 @@ NULL
|
||||
mstime_t idle = now - consumer->seen_time;
|
||||
if (idle < 0) idle = 0;
|
||||
|
||||
addReplyMultiBulkLen(c,3);
|
||||
addReplyMultiBulkLen(c,6);
|
||||
addReplyStatus(c,"name");
|
||||
addReplyBulkCBuffer(c,consumer->name,sdslen(consumer->name));
|
||||
addReplyStatus(c,"pending");
|
||||
addReplyLongLong(c,raxSize(consumer->pel));
|
||||
addReplyStatus(c,"idle");
|
||||
addReplyLongLong(c,idle);
|
||||
}
|
||||
raxStop(&ri);
|
||||
} else if (!strcasecmp(opt,"GROUPS") && c->argc == 3) {
|
||||
/* XINFO <key> GROUPS. */
|
||||
|
||||
if (s->cgroups == NULL) {
|
||||
addReplyMultiBulkLen(c,0);
|
||||
return;
|
||||
}
|
||||
|
||||
addReplyMultiBulkLen(c,raxSize(s->cgroups));
|
||||
raxIterator ri;
|
||||
raxStart(&ri,s->cgroups);
|
||||
raxSeek(&ri,"^",NULL,0);
|
||||
while(raxNext(&ri)) {
|
||||
streamCG *cg = ri.data;
|
||||
addReplyMultiBulkLen(c,6);
|
||||
addReplyStatus(c,"name");
|
||||
addReplyBulkCBuffer(c,ri.key,ri.key_len);
|
||||
addReplyStatus(c,"consumers");
|
||||
addReplyLongLong(c,raxSize(cg->consumers));
|
||||
addReplyStatus(c,"pending");
|
||||
addReplyLongLong(c,raxSize(cg->pel));
|
||||
}
|
||||
raxStop(&ri);
|
||||
} else if (!strcasecmp(opt,"HELP")) {
|
||||
addReplyHelp(c, help);
|
||||
} else {
|
||||
addReply(c,shared.syntaxerr);
|
||||
addReplyError(c,"syntax error, try 'XINFO anykey HELP'");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user