rust_with_kafka_tls/
custom_context.rs1use log::trace;
2use rdkafka::client::ClientContext;
3use rdkafka::consumer::stream_consumer::StreamConsumer;
4use rdkafka::consumer::ConsumerContext;
5use rdkafka::consumer::Rebalance;
6use rdkafka::error::KafkaResult;
7use rdkafka::topic_partition_list::TopicPartitionList;
8
9pub struct CustomContext;
13
14impl ClientContext for CustomContext {}
15
16impl ConsumerContext for CustomContext {
17 fn pre_rebalance(&self, rebalance: &Rebalance) {
18 trace!("Pre rebalance {:?}", rebalance);
19 }
20
21 fn post_rebalance(&self, rebalance: &Rebalance) {
22 trace!("Post rebalance {:?}", rebalance);
23 }
24
25 fn commit_callback(
26 &self,
27 result: KafkaResult<()>,
28 _offsets: &TopicPartitionList,
29 ) {
30 trace!("Committing offsets: {:?}", result);
31 }
32}
33
34pub type LoggingConsumer = StreamConsumer<CustomContext>;