🦀 Krafka

A pure Rust, async-native Apache Kafka client designed for high performance, safety, and ease of use.

Get Started View on GitHub


✨ Features

Feature Description
🦀 Pure Rust No librdkafka or C dependencies
Async-native Built on Tokio for true async I/O
🔒 Zero unsafe Safe Rust by default
🚀 High performance Zero-copy buffers, inline hot paths, efficient batching
📦 Full protocol Kafka protocol with all compression codecs
🔐 TLS/SSL Using rustls for secure connections
🔑 SASL PLAIN, SCRAM-SHA-256/512 mechanisms
💯 Transactions Exactly-once semantics
☁️ Cloud-native AWS MSK support with IAM auth
🛡️ Security hardened Secret zeroization, constant-time auth, decompression limits

🚀 Quick Start

Add Krafka to your Cargo.toml:

[dependencies]
krafka = "0.2"
tokio = { version = "1", features = ["full"] }

Producer Example

use krafka::producer::Producer;

#[tokio::main]
async fn main() -> krafka::error::Result<()> {
    let producer = Producer::builder()
        .bootstrap_servers("localhost:9092")
        .build()
        .await?;

    producer.send("my-topic", Some(b"key"), b"Hello, Kafka!").await?;
    producer.close().await;
    Ok(())
}

Consumer Example

use krafka::consumer::{Consumer, AutoOffsetReset};
use std::time::Duration;

#[tokio::main]
async fn main() -> krafka::error::Result<()> {
    let consumer = Consumer::builder()
        .bootstrap_servers("localhost:9092")
        .group_id("my-group")
        .auto_offset_reset(AutoOffsetReset::Earliest)
        .build()
        .await?;

    consumer.subscribe(&["my-topic"]).await?;

    loop {
        let records = consumer.poll(Duration::from_secs(1)).await?;
        for record in records {
            println!("{:?}", record);
        }
    }
}

🏗️ Architecture

Krafka is designed with performance and safety as primary goals:

  • Zero-copy buffers using the bytes crate
  • Inline hot paths for minimal overhead
  • Lazy deserialization for on-demand record parsing
  • Priority request channels prevent group ejection during backpressure
  • Multi-connection bundles for extreme high-throughput scenarios
  • Connection pooling for efficient broker communication
  • murmur2 hashing matching Java client for consistent partitioning

📄 License

Krafka is licensed under the MIT License.


Back to top

Licensed under MIT. Copyright © 2026 Krafka Contributors.