MCPcopy Create free account
hub / github.com/F-Stack/f-stack / streamPropagateXCLAIM

Function streamPropagateXCLAIM

app/redis-6.2.6/src/t_stream.c:1370–1403  ·  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

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

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

Tested by

no test coverage detected