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. */
| 2322 | * may have pending messages: they are removed from the PEL, and the number |
| 2323 | * of pending messages "lost" is returned. */ |
| 2324 | uint64_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 |
no test coverage detected