kafka-rust

rustfs-kafka-async

Rust crates.io docs.rs License Crates.io

Async wrappers for rustfs-kafka, built on top of tokio.

This crate provides:

The current implementation uses native tokio async I/O for metadata, produce/fetch, and commit request paths. AsyncKafkaClient::send_raw_protocol_request is available for advanced typed access to generated kafka-protocol request/response pairs. Telemetry and share-consumer session helper types are re-exported from the sync crate for native async callers that compose those low-level requests.

Security flow supports TLS and SASL authentication in native async mode, including PLAIN, SCRAM-SHA-256, and SCRAM-SHA-512.

Installation

[dependencies]
rustfs-kafka-async = "1.4.0"

Default builds include gzip, snappy, lz4, and zstd record batch codecs. With default-features = false, enable individual codec features such as gzip or zstd when those formats are required.

Quick Example

use rustfs_kafka::producer::Record;
use rustfs_kafka_async::AsyncProducer;

#[tokio::main]
async fn main() -> rustfs_kafka::Result<()> {
    let producer = AsyncProducer::builder(vec!["localhost:9092".to_owned()])
        .with_client_id("example-async-producer".to_owned())
        .build()
        .await?;
    producer.send(&Record::from_value("my-topic", b"hello async")).await?;
    producer.flush().await?;
    producer.close().await?;
    Ok(())
}

Notes