Created
February 15, 2018 20:16
-
-
Save diasjorge/1eae844c3ebc425309b64c492e8890a8 to your computer and use it in GitHub Desktop.
create_topics.py
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
import kafka.conn | |
from kafka import protocol | |
import collections | |
ip, port, afi = kafka.conn.get_ip_port_afi('localhost:9092') | |
bc = kafka.conn.BrokerConnection(ip, port, afi) | |
bc.check_version() | |
bc.send(protocol.admin.ListGroupsRequest[0]()) | |
bc.recv() | |
Topic = collections.namedtuple('Topic', 'topic num_partitions replication_factor replica_assignment configs') | |
req = protocol.admin.CreateTopicsRequest[0]( | |
create_topic_requests=[Topic(topic='example', num_partitions=12, replication_factor=-1,replica_assignment=[],configs=[])], | |
timeout=1000 | |
) | |
fut = bc.send(req) | |
bc.recv() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment