Path
The way of a Kinesis record through a RustStream service: the read, the delivery, the handler, the reply and the checkpoint, one at a time or in batches.
The diagram as text
- One at a time: GetRecords up to 1000 records; Channel 64 deliveries, every shard; KinesisMessage headers, a place; Handler decodes and runs; Reply: PutRecord the resolved key; ack checkpoint if contiguous
- Batches: GetRecords limit n, up to 10,000; Channel 64 deliveries; A batch n records, or 50 ms; Batch handler one call per batch; Each element settles on its own
- GetRecords up to 1000 records → Channel 64 deliveries, every shard: records
- Channel 64 deliveries, every shard → KinesisMessage headers, a place
- KinesisMessage headers, a place → Handler decodes and runs
- Handler decodes and runs → Reply: PutRecord the resolved key
- Reply: PutRecord the resolved key → ack checkpoint if contiguous
- GetRecords limit n, up to 10,000 → Channel 64 deliveries
- Channel 64 deliveries → A batch n records, or 50 ms
- A batch n records, or 50 ms → Batch handler one call per batch
- Batch handler one call per batch → Each element settles on its own
A shard's reader asks for up to 1,000 records per GetRecords. Each record becomes a
KinesisMessage: the payload is copied out of the SDK's
answer and the envelope is read off it when there is one. The partition key,
the sequence number and the shard id become headers. The delivery also takes its place in the
shard's watermark, which decides its checkpoint. These are a few allocations per record, and
Benchmarks publishes what a record costs.
Every reader of the subscription sends its deliveries into one channel of 64. A reader waits while the channel is full, so the handlers set the pace of the reads. A read is stamped before it is sent: if the subscription repositions while the read is in flight, its records are dropped on their way out of the channel and are never handed to a handler.
A batch subscription makes its batch size the limit of every read, capped at the 10,000 a read can return. The batch closes when it holds that many records, or 50 milliseconds after its first record, so a batch is often smaller than the size. A batch may hold records of several shards. Every element settles on its own, with its own checkpoint.
A reply is encoded into a buffer the dispatch loop reuses. The partition key comes from the publish
call, then from a partition-key header, then from the policy, and a record nobody keyed gets a key
that spreads records over the shards. User headers go into the envelope, and a reply without them is
the encoded buffer as it stands. The KinesisPublisher
writes it with one PutRecord, through the SDK client of the runtime that publishes.
The delivery settles after the reply. An ack writes a checkpoint only when it moves the shard's
watermark, which Settlement draws.