MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / xpendingCommand

Function xpendingCommand

src/t_stream.cpp:2604–2780  ·  view source on GitHub ↗

XPENDING [[IDLE ] [ ]] * * If start and stop are omitted, the command just outputs information about * the amount of pending messages for the key/group pair, together with * the minimum and maximum ID of pending messages. * * If start and stop are provided instead, the pending messages are returned * with information about the current owne

Source from the content-addressed store, hash-verified

2602 * with information about the current owner, number of deliveries and last
2603 * delivery time and so forth. */
2604void xpendingCommand(client *c) {
2605 int justinfo = c->argc == 3; /* Without the range just outputs general
2606 informations about the PEL. */
2607 robj *key = c->argv[1];
2608 robj *groupname = c->argv[2];
2609 robj *consumername = NULL;
2610 streamID startid, endid;
2611 long long count = 0;
2612 long long minidle = 0;
2613 int startex = 0, endex = 0;
2614
2615 /* Start and stop, and the consumer, can be omitted. Also the IDLE modifier. */
2616 if (c->argc != 3 && (c->argc < 6 || c->argc > 9)) {
2617 addReplyErrorObject(c,shared.syntaxerr);
2618 return;
2619 }
2620
2621 /* Parse start/end/count arguments ASAP if needed, in order to report
2622 * syntax errors before any other error. */
2623 if (c->argc >= 6) {
2624 int startidx = 3; /* Without IDLE */
2625
2626 if (!strcasecmp(szFromObj(c->argv[3]), "IDLE")) {
2627 if (getLongLongFromObjectOrReply(c, c->argv[4], &minidle, NULL) == C_ERR)
2628 return;
2629 if (c->argc < 8) {
2630 /* If IDLE was provided we must have at least 'start end count' */
2631 addReplyErrorObject(c,shared.syntaxerr);
2632 return;
2633 }
2634 /* Search for rest of arguments after 'IDLE <idle>' */
2635 startidx += 2;
2636 }
2637
2638 /* count argument. */
2639 if (getLongLongFromObjectOrReply(c,c->argv[startidx+2],&count,NULL) == C_ERR)
2640 return;
2641 if (count < 0) count = 0;
2642
2643 /* start and end arguments. */
2644 if (streamParseIntervalIDOrReply(c,c->argv[startidx],&startid,&startex,0) != C_OK)
2645 return;
2646 if (startex && streamIncrID(&startid) != C_OK) {
2647 addReplyError(c,"invalid start ID for the interval");
2648 return;
2649 }
2650 if (streamParseIntervalIDOrReply(c,c->argv[startidx+1],&endid,&endex,UINT64_MAX) != C_OK)
2651 return;
2652 if (endex && streamDecrID(&endid) != C_OK) {
2653 addReplyError(c,"invalid end ID for the interval");
2654 return;
2655 }
2656
2657 if (startidx+3 < c->argc) {
2658 /* 'consumer' was provided */
2659 consumername = c->argv[startidx+3];
2660 }
2661 }

Callers

nothing calls this directly

Calls 15

addReplyErrorObjectFunction · 0.85
szFromObjFunction · 0.85
streamIncrIDFunction · 0.85
addReplyErrorFunction · 0.85
streamDecrIDFunction · 0.85
lookupKeyReadFunction · 0.85
checkTypeFunction · 0.85
streamLookupCGFunction · 0.85
ptrFromObjFunction · 0.85
addReplyErrorFormatFunction · 0.85

Tested by

no test coverage detected