Skip to content

refactor(gateways): split long files in the Kafka gateway - #5145

Open
thepatrykk wants to merge 3 commits into
masterfrom
refactor/file-length-kafka
Open

thepatrykk wants to merge 3 commits into
masterfrom
refactor/file-length-kafka

Conversation

@thepatrykk

@thepatrykk thepatrykk commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

scripts/ci/file-length.sh caps a Rust file at 2500 lines of code.
Three files of the Kafka gateway sat over the cap on the allowlist.

The group/state.rs tests alone came to 3327 lines, more than one file
can hold under the cap. They move into group/state/tests/, one file
per topic: join, describe, delete and list, pricing, membership,
leave, commit and static members. The fetch handler tests move into
fetch/tests.rs.

tests/kafka_client_e2e_tests.rs moves its tests into sasl,
client_versions, admin_tools, kcat_records, groups,
offsets_for_times, tls, failover and stalls. The file is a test crate
root, so a plain mod declaration looks for the child next to it.
Cargo takes a file there for a test crate of its own. The children
are declared with #[path] instead, as the common modules already are.

A helper that serves one topic moves with it, and the shared helpers
and fixtures stay in the parent. The code moves as it is, apart from
the line wraps that rustfmt makes at the new indent. The same 911
unit tests pass before and after, and the e2e crate lists the same
37 tests. The three files leave the allowlist.

group/state.rs ran past the 2500 line limit of file-length.sh, and its
tests alone came to 3327 lines. They move into group/state/tests/, one
file per topic: join, describe, delete_and_list, pricing, membership,
leave, commit and static_members. A helper that serves one topic moves
with it, and the shared helpers and imports stay in tests/mod.rs.
protocol/handlers/fetch.rs ran past the 2500 line limit of
file-length.sh. Its tests move unchanged into fetch/tests.rs.
kafka_client_e2e_tests.rs ran past the 2500 line limit of
file-length.sh. Its tests move into sasl, client_versions, admin_tools,
kcat_records, groups, offsets_for_times, tls, failover and stalls. The
file is a test crate root, so the children are declared with #[path],
as the common modules already are, and cargo does not take them for
test crates of their own. The shared fixtures stay in the root.
@thepatrykk
thepatrykk marked this pull request as ready for review December 1, 2026 18:34

This branch has not been deployed

No deployments
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.

1 participant