Created
February 8, 2020 13:57
-
-
Save justdoit0823/3d4d2d524ec484dbdf37068d391f04ab to your computer and use it in GitHub Desktop.
Fetch kafka topic offsets at specified timestamp.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kafka import KafkaConsumer, TopicPartition | |
def get_topic_offsets(bootstrap_servers, topic, n_partition, ts): | |
consumer = KafkaConsumer(bootstrap_servers=bootstrap_servers) | |
return consumer.offsets_for_times({TopicPartition(topic, i): ts for i in range(n_partition)}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment