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

Function streamLookupConsumer

src/t_stream.cpp:2301–2319  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

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. */
2301streamConsumer *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

Callers 8

rdbLoadObjectFunction · 0.85
xreadCommandFunction · 0.85
streamDelConsumerFunction · 0.85
xgroupCommandFunction · 0.85
xpendingCommandFunction · 0.85
xclaimCommandFunction · 0.85
xautoclaimCommandFunction · 0.85

Calls 7

raxFindFunction · 0.85
sdslenFunction · 0.85
zmallocFunction · 0.85
sdsdupFunction · 0.85
raxNewFunction · 0.85
raxInsertFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected