Expand description
Record-payload generator.
The first 24 bytes of every produced record hold (magic_be, scenario_id_be, send_unix_nanos_be), so a consumer can compute the end-to-end latency when
it re-reads the embedded send_unix_nanos. The remaining bytes are a
deterministic filler, so the wire size is exactly the scenario’s message
size.
The header is 24 bytes and not the 16 the plan sketched, because it needs a magic to detect “this is one of ours”. Kafka’s own producers leave their own headers in there, and this driver must not misread their bytes.
Constants§
- HEADER_
LEN - MAGIC
- Magic prefix on every record, so a consumer can confirm that this driver produced the record and that it is not data already in the topic.
Functions§
- key
- Builds a record key of exactly
key_sizebytes, distinct persequence. - read_
send_ nanos - Reads the embedded
send_unix_nanosif the record is one of ours. ReturnsNoneif the magic does not match, and also if the record is too short. The consumer skips both cases silently. - stamp_
into - Stamps the magic, the
scenario_id, and the currentunix_nanosinto the first 24 bytes ofbuf. Returns the value as aBytes, which the caller clones cheaply with aBytesMut::freeze-style copy. - template
- Builds a reusable filler template of exactly
msg_sizebytes, or of the header length if that is larger.