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

Function streamPropagateXCLAIM

src/t_stream.cpp:1368–1404  ·  view source on GitHub ↗

As a result of an explicit XCLAIM or XREADGROUP command, new entries * are created in the pending list of the stream and consumers. We need * to propagate this changes in the form of XCLAIM commands. */

Source from the content-addressed store, hash-verified

1366 * are created in the pending list of the stream and consumers. We need
1367 * to propagate this changes in the form of XCLAIM commands. */
1368void streamPropagateXCLAIM(client *c, robj *key, streamCG *group, robj *groupname, robj *id, streamNACK *nack) {
1369 /* We need to generate an XCLAIM that will work in a idempotent fashion:
1370 *
1371 * XCLAIM <key> <group> <consumer> 0 <id> TIME <milliseconds-unix-time>
1372 * RETRYCOUNT <count> FORCE JUSTID LASTID <id>.
1373 *
1374 * Note that JUSTID is useful in order to avoid that XCLAIM will do
1375 * useless work in the replica side, trying to fetch the stream item. */
1376 if (FInReplicaReplay())
1377 return;
1378
1379 robj *argv[14];
1380 argv[0] = shared.xclaim;
1381 argv[1] = key;
1382 argv[2] = groupname;
1383 argv[3] = createStringObject(nack->consumer->name,sdslen(nack->consumer->name));
1384 argv[4] = shared.integers[0];
1385 argv[5] = id;
1386 argv[6] = shared.time;
1387 argv[7] = createStringObjectFromLongLong(nack->delivery_time);
1388 argv[8] = shared.retrycount;
1389 argv[9] = createStringObjectFromLongLong(nack->delivery_count);
1390 argv[10] = shared.force;
1391 argv[11] = shared.justid;
1392 argv[12] = shared.lastid;
1393 argv[13] = createObjectFromStreamID(&group->last_id);
1394
1395 /* We use progagate() because this code path is not always called from
1396 * the command execution context. Moreover this will just alter the
1397 * consumer group state, and we don't need MULTI/EXEC wrapping because
1398 * there is no message state cross-message atomicity required. */
1399 propagate(cserver.xclaimCommand,c->db->id,argv,14,PROPAGATE_AOF|PROPAGATE_REPL);
1400 decrRefCount(argv[3]);
1401 decrRefCount(argv[7]);
1402 decrRefCount(argv[9]);
1403 decrRefCount(argv[13]);
1404}
1405
1406/* We need this when we want to propoagate the new last-id of a consumer group
1407 * that was consumed by XREADGROUP with the NOACK option: in that case we can't

Callers 3

streamReplyWithRangeFunction · 0.85
xclaimCommandFunction · 0.85
xautoclaimCommandFunction · 0.85

Calls 7

FInReplicaReplayFunction · 0.85
sdslenFunction · 0.85
createObjectFromStreamIDFunction · 0.85
propagateFunction · 0.85
decrRefCountFunction · 0.85
createStringObjectFunction · 0.70

Tested by

no test coverage detected