pykafka
pykafka copied to clipboard
PyKafka doesn't currently support creating a new topic
Is there any way that more support for creating/deleting topics can be added to PyKafka?
I am aware that calling KafkaClient.topics['a new topic name'] will create a new topic but this feels wrong.
Hi @jmwri, thanks for being in touch. Since the Kafka API currently doesn't support creating topics via the binary protocol, the only way that pykafka could support it is by wrapping the CLI tools with python calls. We've considered this and have decided that it's not a high priority because of the simplicity with which python allows one to shell out (subprocess.popen("kafka-topics.sh --create --zookeeper localhost:2181 --topic testtopic2 --replication-factor 1 --partitions 1".split())). If we wrapped the CLI, we'd effectively be doing just that. That said, if you feel it's useful enough, I'd support a pull request that added topic creation and deletion via the CLI to the pykafka/cli module.
I understand that the issue is closed, but I still think creating a topic from the API is such an important feature for a publisher/subscriber wrapper and would massively enhance user experience, in particular if you are creating an application that is suppose to run on different environments that might not have the same kafka-topics.sh path. To note that other wrappers (such as the java client and kafka-python client) have it.