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