Connection management and request dispatch for Apache Kafka in Rust.
This crate provides the first I/O-doing layer of Crabka. It wraps
crabka-protocol's typed request/response messages in a tokio-based
TCP client that:
- Opens one connection per broker, multiplexing requests via correlation ID.
- Negotiates API versions on connect.
- Manages a [
BrokerPool] keyed on broker id with lazy connect. - Resolves bootstrap addresses on builder.
Quick start
use crabka_client_core::Client;
use crabka_protocol::owned::api_versions_request::ApiVersionsRequest;
# async fn run() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::builder()
.bootstrap("localhost:9092")
.client_id("my-app")
.build()
.await?;
let resp = client.send(ApiVersionsRequest::default()).await?;
println!("broker supports {} APIs", resp.api_keys.len());
client.close();
# Ok(())
# }
Out of scope
- Producer / consumer semantics.
- Transactions.
- Partition-aware routing.
- Automatic mid-request retry.
TLS / SASL: a client-side security surface lives in [security] and
[sasl] — set [ConnectionOptions::security] (or the Client
builder's .security(...)) to negotiate TLS then SASL before the
API-versions bootstrap. None (the default) is plaintext.
Cargo features
mock— exposesMockBrokerbeyond#[cfg(test)]for downstream testing.