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