kafka-python icon indicating copy to clipboard operation
kafka-python copied to clipboard

How to dynamically adjust the number of partitions?

Open huangpeng0817 opened this issue 4 years ago • 1 comments

如何动态调整partition数量,是使用KafkaAdminClient.create_partitions方法么,有没有示例如何传值啊。。。一直没有成功


How to dynamically adjust the number of partitions? Do you use the KafkaAdminClient.create_partitions method? Are there any examples of how to pass values? . . Has never been successful

huangpeng0817 avatar Apr 06 '21 09:04 huangpeng0817

Currently requires a NewPartitions object instance. This should work:

from kafka.admin.new_partitions import NewPartitions

# Increase the partition count for 'foo_topic' to 6.
admin_client.create_partitions({'foo_topic': NewPartitions(total_count=6)})

dpkp avatar Jun 20 '25 00:06 dpkp