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

Function streamDelConsumer

src/t_stream.cpp:2324–2347  ·  view source on GitHub ↗

Delete the consumer specified in the consumer group 'cg'. The consumer * may have pending messages: they are removed from the PEL, and the number * of pending messages "lost" is returned. */

Source from the content-addressed store, hash-verified

2322 * may have pending messages: they are removed from the PEL, and the number
2323 * of pending messages "lost" is returned. */
2324uint64_t streamDelConsumer(streamCG *cg, sds name) {
2325 streamConsumer *consumer =
2326 streamLookupConsumer(cg,name,SLC_NOCREAT|SLC_NOREFRESH,NULL);
2327 if (consumer == NULL) return 0;
2328
2329 uint64_t retval = raxSize(consumer->pel);
2330
2331 /* Iterate all the consumer pending messages, deleting every corresponding
2332 * entry from the global entry. */
2333 raxIterator ri;
2334 raxStart(&ri,consumer->pel);
2335 raxSeek(&ri,"^",NULL,0);
2336 while(raxNext(&ri)) {
2337 streamNACK *nack = (streamNACK*)ri.data;
2338 raxRemove(cg->pel,ri.key,ri.key_len,NULL);
2339 streamFreeNACK(nack);
2340 }
2341 raxStop(&ri);
2342
2343 /* Deallocate the consumer. */
2344 raxRemove(cg->consumers,(unsigned char*)name,sdslen(name),NULL);
2345 streamFreeConsumer(consumer);
2346 return retval;
2347}
2348
2349/* -----------------------------------------------------------------------
2350 * Consumer groups commands

Callers 1

xgroupCommandFunction · 0.85

Calls 10

streamLookupConsumerFunction · 0.85
raxSizeFunction · 0.85
raxStartFunction · 0.85
raxSeekFunction · 0.85
raxNextFunction · 0.85
raxRemoveFunction · 0.85
streamFreeNACKFunction · 0.85
raxStopFunction · 0.85
sdslenFunction · 0.85
streamFreeConsumerFunction · 0.85

Tested by

no test coverage detected