Expand description
Provides utilities for working with records (Kafka messages).
FetchResponse
and associated APIs for interacting with reading and writing
contain records in a raw format, allowing the user to implement their own logic for interacting
with those values.
§Example
Decoding a set of records from a FetchResponse
:
use kafka_protocol::messages::FetchResponse;
use kafka_protocol::protocol::Decodable;
use kafka_protocol::records::RecordBatchDecoder;
use bytes::Bytes;
use kafka_protocol::records::Compression;
let res = FetchResponse::decode(&mut buf, 4).unwrap();
for topic in res.responses {
for partition in topic.partitions {
let mut records = partition.records.unwrap();
let records = RecordBatchDecoder::decode_with_custom_compression(&mut records, Some(decompress_record_batch_data)).unwrap();
}
}
fn decompress_record_batch_data(compressed_buffer: &mut bytes::Bytes, compression: Compression) -> anyhow::Result<Bytes> {
match compression {
Compression::None => Ok(compressed_buffer.to_vec().into()),
_ => { panic!("Compression not implemented") }
}
}
Structs§
- Record
- A Kafka message containing key, payload value, and all associated metadata.
- Record
Batch Decoder - Batch decoder for Kafka records.
- Record
Batch Encoder - Batch encoder for Kafka records.
- Record
Encode Options - Options for encoding and compressing a batch of records. Note, not all compression algorithms are currently implemented by this library.
- Record
Set - Decoded records plus information about compression.
Enums§
- Compression
- The different types of compression supported by Kafka.
- Record
Compression - Record compression for a set of records.
- Timestamp
Type - Indicates the meaning of the timestamp field on a record.
Constants§
- IEEE
- IEEE (checksum) cyclic redundancy check.
- NO_
PARTITION_ LEADER_ EPOCH - Value to indicated missing leader epoch.
- NO_
PRODUCER_ EPOCH - Value to indicate missing producer epoch.
- NO_
PRODUCER_ ID - Value to indicate missing producer id.
- NO_
SEQUENCE - Value to indicate missing sequence id.
- NO_
TIMESTAMP - Value to indicate missing timestamp.