kafka4rs
Pure‑Rust client for Apache Kafka 4.0+ – drop‑in replacement for
librdkafka, powered by Tokio and zero‑copy buffers.
| CI | Crate | Docs |
|---|---|---|
✨ Key Features
- Kafka 4.0 protocol – supports the new KRaft‑only clusters, consumer rebalance v2 (KIP‑848), idempotent producer by default and duration‑based offset resets (KIP‑1106).
- Async‑first – built on Tokio; one runtime thread can drive hundreds of broker sockets.
- Zero‑copy performance –
bytes::Bytespools, gather‑write and adaptive batching; targets ≥ librdkafka throughput. - Secure by default – opt‑in TLS (Rustls) and SASL mechanisms (PLAIN, SCRAM, OAUTHBEARER).
- Feature‑gated crates – compile only what you need (e.g. producer‑only binary without TLS or Zstd keeps size tiny).
- Native Rust safety – no C FFI or
unsafein the hot path; memory‑safe networking from day one.
🚀 Quick Start
Add the dependency (until crates.io release use the Git branch):
[]
= { = "https://github.com/Arend-Jan/kafka4rs", = ["producer"] }
Minimal Producer example:
use ;
async
Minimal Consumer example (new rebalance protocol):
use ;
async
🗂 Workspace Layout
.
├─ kafka-protocol/ # auto‑generated wire structs & enc/dec traits
├─ kafka-io/ # framed TCP/TLS transport
├─ kafka-core/ # Client, connection manager, metadata cache
├─ kafka-producer/ # High‑level async Producer API
├─ kafka-consumer/ # High‑level async Consumer (groups)
├─ kafka-admin/ # (later) Admin client
└─ docs/ # project docs → architecture.md, ADRs, diagrams
🛣 Roadmap
| Milestone | Status | Notes |
|---|---|---|
| Core networking + simple producer/consumer | 🔧 in progress | see docs/architecture.md |
| Consumer groups (KIP‑848) | ⏳ | |
| Batching, compression, idempotence | ⏳ | |
| TLS & SASL authentication | ⏳ | |
| Transactions / EOS | ⏳ | |
| Admin & metrics | ⏳ |
Detailed backlog lives in docs/architecture.md and GitHub Issues.
🤝 Contributing
- Fork & clone the repo.
cargo test– all tests must pass.- Follow the coding style (
cargo fmt,clippy --all-targets). - Open a PR; the CI pipeline will run integration tests against a Kafka 4.0 docker‑compose cluster.
- Feedback is welcome – design discussions → GitHub Discussions.
📜 License
Dual‑licensed under MIT or Apache‑2.0 – choose either at your discretion.
Happy streaming – the Rust‑way!