@@ -7,7 +7,7 @@ use std::time::Duration;
77use rdkafka_sys as rdsys;
88use rdkafka_sys:: types:: * ;
99
10- use crate :: client:: { Client , ClientContext , NativeClient } ;
10+ use crate :: client:: { Client , ClientContext } ;
1111use crate :: error:: { KafkaError , KafkaResult } ;
1212use crate :: groups:: GroupList ;
1313use crate :: log:: { error, trace} ;
@@ -43,15 +43,15 @@ pub enum Rebalance<'a> {
4343/// be specified.
4444///
4545/// See also the [`ClientContext`] trait.
46- pub trait ConsumerContext : ClientContext {
46+ pub trait ConsumerContext : ClientContext + Sized {
4747 /// Implements the default rebalancing strategy and calls the
4848 /// [`pre_rebalance`](ConsumerContext::pre_rebalance) and
4949 /// [`post_rebalance`](ConsumerContext::post_rebalance) methods. If this
5050 /// method is overridden, it will be responsibility of the user to call them
5151 /// if needed.
5252 fn rebalance (
5353 & self ,
54- native_client : & NativeClient ,
54+ base_consumer : & BaseConsumer < Self > ,
5555 err : RDKafkaRespErr ,
5656 tpl : & mut TopicPartitionList ,
5757 ) {
@@ -66,9 +66,10 @@ pub trait ConsumerContext: ClientContext {
6666 } ;
6767
6868 trace ! ( "Running pre-rebalance with {:?}" , rebalance) ;
69- self . pre_rebalance ( & rebalance) ;
69+ self . pre_rebalance ( base_consumer , & rebalance) ;
7070
7171 trace ! ( "Running rebalance with {:?}" , rebalance) ;
72+ let native_client = base_consumer. native_client ( ) ;
7273 // Execute rebalance
7374 unsafe {
7475 match err {
@@ -93,18 +94,18 @@ pub trait ConsumerContext: ClientContext {
9394 }
9495 }
9596 trace ! ( "Running post-rebalance with {:?}" , rebalance) ;
96- self . post_rebalance ( & rebalance) ;
97+ self . post_rebalance ( base_consumer , & rebalance) ;
9798 }
9899
99100 /// Pre-rebalance callback. This method will run before the rebalance and
100101 /// should terminate its execution quickly.
101102 #[ allow( unused_variables) ]
102- fn pre_rebalance < ' a > ( & self , rebalance : & Rebalance < ' a > ) { }
103+ fn pre_rebalance < ' a > ( & self , base_consumer : & BaseConsumer < Self > , rebalance : & Rebalance < ' a > ) { }
103104
104105 /// Post-rebalance callback. This method will run after the rebalance and
105106 /// should terminate its execution quickly.
106107 #[ allow( unused_variables) ]
107- fn post_rebalance < ' a > ( & self , rebalance : & Rebalance < ' a > ) { }
108+ fn post_rebalance < ' a > ( & self , base_consumer : & BaseConsumer < Self > , rebalance : & Rebalance < ' a > ) { }
108109
109110 // TODO: convert pointer to structure
110111 /// Post commit callback. This method will run after a group of offsets was
0 commit comments