Skip to content

feat(gateways): map Kafka records to Iggy messages and back - #4229

Merged
krishvishal merged 6 commits into
masterfrom
kafka-record-codec
Sep 22, 2026
Merged

krishvishal merged 6 commits into
masterfrom
kafka-record-codec

Conversation

@krishvishal

@krishvishal krishvishal commented Sep 19, 2026

Copy link
Copy Markdown
Member

Part of #3560. This is the record codec that #3535 (Produce) and #3536 (Fetch) both sit on, and it writes the mapping document that was the last open scope item of #3533.

to_iggy takes one Kafka record and returns one Iggy message. The value becomes the payload. The key and each header become kafka. user headers. A null or empty value is stored as a single placeholder byte plus a marker that says which of the two it was, so a tombstone stays on the fast path. Kafka counts timestamps in milliseconds and Iggy counts them in microseconds, so the value is multiplied by 1000 on the way in and divided on the way out.

Some records do not fit. Iggy rejects an empty header value, caps a name and a value at 255 bytes, and caps all headers of one message at 100 KB. A record that trips any of those is written into an envelope instead, at the byte layout the document fixes. from_iggy reads both forms, and a caller cannot tell them apart.

A message that no Kafka producer wrote is handled too. If it carries no kafka. headers, an Iggy client wrote it, so it becomes a record with a null key and its own headers.

The batch layer sits on top. decode_batches drains a whole partition blob, because one blob holds several batches back to back. encode_batch writes one uncompressed batch for Fetch. Reading a compressed batch needs the four codecs, so gzip, lz4, snappy and zstd are turned back on for kafka-protocol.

Compressed input needs a limit. max_frame_size only bounds the compressed bytes, and zstd reaches 1000 to 1 on repetitive input without being asked. One frame also holds up to 4096 partition entries, so a limit applied to each batch on its own still admits 4096 times that much. The budget therefore covers the whole request.

@github-actions github-actions Bot added the S-waiting-on-review PR is waiting on a reviewer label Sep 19, 2026
@codecov

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.43%. Comparing base (7bae8ec) to head (e110b04).

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4229      +/-   ##
============================================
- Coverage     87.64%   86.43%   -1.21%     
  Complexity     1575     1575              
============================================
  Files          1284     1283       -1     
  Lines        225457   217064    -8393     
  Branches     188820   180429    -8391     
============================================
- Hits         197593   187611    -9982     
- Misses        23135    24512    +1377     
- Partials       4729     4941     +212     
Components Coverage Δ
Rust Core 87.31% <ø> (-1.44%) ⬇️
Java SDK 68.68% <ø> (ø)
C# SDK 77.41% <ø> (+0.06%) ⬆️
Python SDK 90.97% <ø> (ø)
PHP SDK 85.67% <ø> (ø)
Node SDK 96.43% <ø> (+0.06%) ⬆️
Go SDK 70.11% <ø> (+0.05%) ⬆️
see 186 files with indirect coverage changes
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ryerraguntla
ryerraguntla self-requested a review September 20, 2026 23:17
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs
Comment thread gateways/kafka/src/records.rs
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/docs/BRIDGE_MAPPING.md Outdated
Comment thread Cargo.toml Outdated

@ryerraguntla ryerraguntla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Fix the header_count cap and few other minors.

@github-actions github-actions Bot added S-waiting-on-author PR is waiting on author response and removed S-waiting-on-review PR is waiting on a reviewer labels Sep 20, 2026
@ryerraguntla

Copy link
Copy Markdown
Contributor

Mention the issue it is trying to fix and close. Also PR needs to be in the expected format with the required details.

Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs
Comment thread gateways/kafka/docs/BRIDGE_MAPPING.md Outdated
Comment thread gateways/kafka/src/records.rs
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/docs/BRIDGE_MAPPING.md Outdated
Comment thread gateways/kafka/src/records.rs Outdated
Comment thread gateways/kafka/src/records.rs
@krishvishal
krishvishal dismissed ryerraguntla’s stale review September 22, 2026 11:53

All review comments addressed.

@krishvishal
krishvishal merged commit 2894368 into master Sep 22, 2026
103 checks passed
@krishvishal
krishvishal deleted the kafka-record-codec branch September 22, 2026 11:55
@github-actions github-actions Bot removed the S-waiting-on-author PR is waiting on author response label Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants