We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Client#partitions_for
1 parent 6579253 commit 0dbcb6eCopy full SHA for 0dbcb6e
lib/kafka/client.rb
@@ -700,7 +700,22 @@ def has_topic?(topic)
700
# @param topic [String]
701
# @return [Integer] the number of partitions in the topic.
702
def partitions_for(topic)
703
- @cluster.partitions_for(topic).count
+ attempt = 1
704
+
705
+ begin
706
+ @cluster.partitions_for(topic).count
707
+ rescue LeaderNotAvailable
708
+ if attempt >= 3
709
+ raise
710
+ else
711
+ attempt += 1
712
+ @logger.warn "Leader not available, retrying in 1s..."
713
714
+ sleep 1
715
716
+ retry
717
+ end
718
719
end
720
721
# Counts the number of replicas for a topic's partition
0 commit comments