| Crates.io | kafka4rs |
| lib.rs | kafka4rs |
| version | 0.1.0 |
| created_at | 2025-05-24 13:06:06.482109+00 |
| updated_at | 2025-05-24 13:06:06.482109+00 |
| description | Pure‑Rust client for Apache Kafka 4.0+ – drop‑in replacement for librdkafka, powered by Tokio and zero‑copy buffers. |
| homepage | https://github.com/Arend-Jan/kafka4rs |
| repository | https://github.com/Arend-Jan/kafka4rs |
| max_upload_size | |
| id | 1687401 |
| size | 29,367 |
Pure‑Rust client for Apache Kafka 4.0+ – drop‑in replacement for
librdkafka, powered by Tokio and zero‑copy buffers.
| CI | Crate | Docs |
|---|---|---|
bytes::Bytes pools, gather‑write and adaptive batching; targets ≥ librdkafka throughput.unsafe in the hot path; memory‑safe networking from day one.Add the dependency (until crates.io release use the Git branch):
[dependencies]
kafka4rs = { git = "https://github.com/Arend-Jan/kafka4rs", features = ["producer"] }
Minimal Producer example:
use kafka4rs::{ClientConfig, Producer};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// 1. Build a shared client configuration
let client_cfg = ClientConfig::new()
.bootstrap_servers("localhost:9092")
.build()?;
// 2. Create a producer – idempotence enabled by default
let producer = Producer::new(client_cfg)?;
// 3. Fire‑and‑forget (future resolves on ACK)
producer.send("demo-topic", "hello‑world").await?;
producer.flush().await?;
Ok(())
}
Minimal Consumer example (new rebalance protocol):
use kafka4rs::{ClientConfig, Consumer, OffsetReset};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cfg = ClientConfig::new()
.bootstrap_servers("localhost:9092")
.group_id("demo-group")
.auto_offset_reset(OffsetReset::Earliest)
.build()?;
let mut consumer = Consumer::subscribe(cfg, ["demo-topic"])?;
loop {
for record in consumer.poll(std::time::Duration::from_secs(1)).await? {
println!("{} => {}", record.partition, String::from_utf8_lossy(&record.value));
}
}
}
.
├─ 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
| 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.
cargo test – all tests must pass.cargo fmt, clippy --all-targets).Dual‑licensed under MIT or Apache‑2.0 – choose either at your discretion.
Happy streaming – the Rust‑way!