Lookup the consumer with the specified name in the group 'cg': if the * consumer does not exist it is created unless SLC_NOCREAT flag was specified. * Its last seen time is updated unless SLC_NOREFRESH flag was specified. */
| 2297 | * consumer does not exist it is created unless SLC_NOCREAT flag was specified. |
| 2298 | * Its last seen time is updated unless SLC_NOREFRESH flag was specified. */ |
| 2299 | streamConsumer *streamLookupConsumer(streamCG *cg, sds name, int flags, int *created) { |
| 2300 | if (created) *created = 0; |
| 2301 | int create = !(flags & SLC_NOCREAT); |
| 2302 | int refresh = !(flags & SLC_NOREFRESH); |
| 2303 | streamConsumer *consumer = raxFind(cg->consumers,(unsigned char*)name, |
| 2304 | sdslen(name)); |
| 2305 | if (consumer == raxNotFound) { |
| 2306 | if (!create) return NULL; |
| 2307 | consumer = zmalloc(sizeof(*consumer)); |
| 2308 | consumer->name = sdsdup(name); |
| 2309 | consumer->pel = raxNew(); |
| 2310 | raxInsert(cg->consumers,(unsigned char*)name,sdslen(name), |
| 2311 | consumer,NULL); |
| 2312 | consumer->seen_time = mstime(); |
| 2313 | if (created) *created = 1; |
| 2314 | } else if (refresh) |
| 2315 | consumer->seen_time = mstime(); |
| 2316 | return consumer; |
| 2317 | } |
| 2318 | |
| 2319 | /* Delete the consumer specified in the consumer group 'cg'. The consumer |
| 2320 | * may have pending messages: they are removed from the PEL, and the number |
no test coverage detected