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

Function streamCreateCG

src/t_stream.cpp:2269–2280  ·  view source on GitHub ↗

Create a new consumer group in the context of the stream 's', having the * specified name and last server ID. If a consumer group with the same name * already existed NULL is returned, otherwise the pointer to the consumer * group is returned. */

Source from the content-addressed store, hash-verified

2267 * already existed NULL is returned, otherwise the pointer to the consumer
2268 * group is returned. */
2269streamCG *streamCreateCG(stream *s, char *name, size_t namelen, streamID *id) {
2270 if (s->cgroups == NULL) s->cgroups = raxNew();
2271 if (raxFind(s->cgroups,(unsigned char*)name,namelen) != raxNotFound)
2272 return NULL;
2273
2274 streamCG *cg = (streamCG*)zmalloc(sizeof(*cg), MALLOC_SHARED);
2275 cg->pel = raxNew();
2276 cg->consumers = raxNew();
2277 cg->last_id = *id;
2278 raxInsert(s->cgroups,(unsigned char*)name,namelen,cg,NULL);
2279 return cg;
2280}
2281
2282/* Free a consumer group and all its associated data. */
2283void streamFreeCG(streamCG *cg) {

Callers 3

rdbLoadObjectFunction · 0.85
streamDupFunction · 0.85
xgroupCommandFunction · 0.85

Calls 4

raxNewFunction · 0.85
raxFindFunction · 0.85
zmallocFunction · 0.85
raxInsertFunction · 0.85

Tested by

no test coverage detected