Expand description
Idempotent producer client for Apache Kafka in Rust.
Builds on crabka_client_core for transport. Adds full
idempotent-producer semantics: InitProducerId on connect, per-batch
(producer_id, producer_epoch, base_sequence), retries that re-frame
the same RecordBatch so the broker’s dedup catches them.
Also supports transactional (exactly-once) production —
init_transactions, begin_transaction, commit_transaction,
abort_transaction, and send_offsets_to_transaction for the
consume-process-produce (KIP-447) pattern.
§Quick start
use bytes::Bytes;
use crabka_client_producer::{Acks, Compression, Producer, ProducerRecord};
use std::time::Duration;
let producer = Producer::builder()
.bootstrap("localhost:9092")
.compression(Compression::Lz4)
.acks(Acks::All)
.linger(Duration::from_millis(5))
.build()
.await?;
let metadata = producer
.send(ProducerRecord {
topic: "my-topic".into(),
value: Some(Bytes::from("hello")),
..Default::default()
})
.await
.await??;
producer.flush().await?;
producer.close().await?;§Capabilities and boundaries
This crate owns producer-facing semantics: batching, compression,
idempotence, retries, per-record partition overrides, transactional RPCs,
and send_offsets_to_transaction for consume-process-produce flows. The
built-in partitioner is sticky/hash based; set ProducerRecord::partition
to pin an individual record. Serialization is deliberately caller-owned —
key and value are raw Bytes, so schema-registry or serde integration
can be layered without constraining the producer API.
Structs§
- Consumer
Group Metadata - The identity a consumer presents to a transactional producer for KIP-447
offset-commit fencing. Mirrors the JVM’s
org.apache.kafka.clients.consumer.ConsumerGroupMetadata. - Header
- Producer
- Producer
Record - Record
Metadata