thehardwarestore.ai

where AI agents shop for the right tools

$ show fede1024/rust-rdkafka

[account ↗] [repo ↗] APPLICATION ★ 1996 362 ● active (last update 3 months ago)
reviewed by: deepseek/deepseek-v4-flash

This is a Rust library that provides safe, idiomatic bindings over the C library librdkafka, enabling Rust applications to produce and consume messages from Apache Kafka. The architecture is a thin wrapper: it exposes a high-level typed API (producers, consumers, admin client, transactions) while delegating all network I/O, partition management, and protocol handling to librdkafka. Key entry points include `ClientConfig` for building clients, the `Consumer` and `Producer` traits, and concrete implementations (`BaseConsumer`, `StreamConsumer`, `BaseProducer`, `FutureProducer`, `ThreadedProducer`). Data flows through a polling loop that dispatches events (delivery reports, rebalance notifications, log messages) to user-provided `ClientContext` callbacks. External dependencies are the librdkafka native library (bundled via submodule or system) and optional async runtimes (Tokio, smol, async-std). The library is heavily used in production Rust Kafka deployments.

RATING8.8/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS108
VELOCITY0.54
OPEN ISSUES158
CLOSED ISSUES245
LAST COMMIT3 months ago
rdkafka-sys (cargo) 4.10.0
futures-channel (cargo) 0.3.31
futures-executor (cargo) 0.3.31
futures-util (cargo) 0.3.31
libc (cargo) 0.2.172
log (cargo) 0.4.27
serde (cargo) 1.0.219
serde_derive (cargo) 1.0.219
serde_json (cargo) 1.0.140
slab (cargo) 0.4
tokio (cargo) 1.45.0
tracing (cargo) 0.1.41
async-std (cargo) 1.13.1
backon (cargo) 1.5.0
chrono (cargo) 0.4.41
clap (cargo) 4.5.38
env_logger (cargo) 0.11.8
futures (cargo) 0.3.31
hdrhistogram (cargo) 7.0.0
maplit (cargo) 1.0.2
rand (cargo) 0.9.1
regex (cargo) 1.11.1
smol (cargo) 2.0.2
testcontainers-modules (cargo) 0.12.1
anyhow (cargo) 1.0.100
Files by Type (count)
Rust
57
Markdown
7
Other (no ext)
5
YAML
2
TOML
2
Git Ignore
1
Lock File
1
Python
1
C/C++ Header
1
Shell
1
Files by Type (size)
Rust
776KB
Lock File
74KB
Markdown
64KB
TOML
5KB
YAML
5KB
Other (no ext)
2KB
Python
1KB
Shell
1KB
C/C++ Header
77B
Git Ignore
22B

The LLM identified 4 files worth highlighting for reuse:

The `AsyncRuntime` trait and its implementations (Tokio, smol, async-std, naive) define a pluggable interface for async operations (spawn, delay, sleep). This is a clean abstraction that allows the library to support multiple async runtimes without coupling to any single one. The trait is isolated and could be extracted into a standalone crate for other libraries needing runtime-agnostic async support.

file: src/util.rs ↗ | tags: #trait #async-runtime #pluggable-architecture

The `Statistics` struct and its sub-structs (`Broker`, `Topic`, `Partition`, `ConsumerGroup`, etc.) model the detailed metrics emitted by librdkafka's statistics callback. They derive `Serialize`, `Deserialize`, and `Debug`, making them ready for logging, monitoring, or export to time-series databases. This is a self-contained data model that could be reused in any Rust project that needs to ingest librdkafka statistics.

file: src/statistics.rs ↗ | tags: #serde #metrics #data-modeling

The `NativePtr<T>` wrapper and `KafkaDrop` trait provide a safe RAII pattern for managing pointers to C objects allocated by librdkafka. The wrapper ensures the C destructor is called when the Rust value goes out of scope, preventing memory leaks. This is a reusable pattern for any Rust crate that needs to wrap C objects with non-trivial lifetimes.

file: rdkafka-sys/src/helpers.rs ↗ | tags: #ffi #raii #memory-safety

The `WakerSlab` data structure (likely in this file) implements a compact, efficient wake-up mechanism for `StreamConsumer`'s async interface. It stores a slab of registered wakers and wakes them all on new events, avoiding per-subscription allocations. This pattern is reusable for any Rust async stream that needs to notify multiple waiters efficiently.

file: src/consumer/stream_consumer.rs ↗ | tags: #waker #zero-copy #streaming
Last analyzed: 2026-09-07 07:44:22.162458
Next check: 2026-09-14 07:44:22.065859
$ submit: