@@ -549,7 +549,8 @@ def _send_list_offsets_requests(self, timestamps):
549
549
return Future ().failure (
550
550
Errors .LeaderNotAvailableError (partition ))
551
551
else :
552
- timestamps_by_node [node_id ][partition ] = timestamp
552
+ leader_epoch = self ._client .cluster .leader_epoch_for_partition (partition )
553
+ timestamps_by_node [node_id ][partition ] = (timestamp , leader_epoch )
553
554
554
555
# Aggregate results until we have all
555
556
list_offsets_future = Future ()
@@ -574,13 +575,12 @@ def on_fail(err):
574
575
_f .add_errback (on_fail )
575
576
return list_offsets_future
576
577
577
- def _send_list_offsets_request (self , node_id , timestamps ):
578
+ def _send_list_offsets_request (self , node_id , timestamps_and_epochs ):
578
579
version = self ._client .api_version (ListOffsetsRequest , max_version = 3 )
579
580
by_topic = collections .defaultdict (list )
580
- for tp , timestamp in six .iteritems (timestamps ):
581
+ for tp , ( timestamp , leader_epoch ) in six .iteritems (timestamps_and_epochs ):
581
582
if version >= 4 :
582
- # TODO: leader_epoch
583
- data = (tp .partition , - 1 , timestamp )
583
+ data = (tp .partition , leader_epoch , timestamp )
584
584
elif version >= 1 :
585
585
data = (tp .partition , timestamp )
586
586
else :
0 commit comments