summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Arthur <mumrah@gmail.com>2013-09-24 16:44:28 -0700
committerDavid Arthur <mumrah@gmail.com>2013-09-24 16:44:28 -0700
commit9af7b817c17a8d8c08e60607f117c8ac46668eda (patch)
tree26c58861d3c452c1d85e7b40a266cfa899bab3b3
parent0c732ca68ae94a797fed170b847cbb78885060e9 (diff)
parentcaf7c6860c4554b026728bf6307e20927f682338 (diff)
downloadkafka-python-9af7b817c17a8d8c08e60607f117c8ac46668eda.tar.gz
Merge pull request #45 from quixey/allow-client-id
Allow a client id to be passed to the client +1 thanks, @jimjh
-rw-r--r--kafka/client.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/kafka/client.py b/kafka/client.py
index 2ec1f1f..be61e91 100644
--- a/kafka/client.py
+++ b/kafka/client.py
@@ -20,9 +20,10 @@ class KafkaClient(object):
CLIENT_ID = "kafka-python"
ID_GEN = count()
- def __init__(self, host, port, bufsize=4096):
+ def __init__(self, host, port, bufsize=4096, client_id=CLIENT_ID):
# We need one connection to bootstrap
- self.bufsize = bufsize
+ self.bufsize = bufsize
+ self.client_id = client_id
self.conns = { # (host, port) -> KafkaConnection
(host, port): KafkaConnection(host, port, bufsize)
}
@@ -59,7 +60,7 @@ class KafkaClient(object):
recurse in the event of a retry.
"""
requestId = self._next_id()
- request = KafkaProtocol.encode_metadata_request(KafkaClient.CLIENT_ID,
+ request = KafkaProtocol.encode_metadata_request(self.client_id,
requestId, topics)
response = self._send_broker_unaware_request(requestId, request)
@@ -156,7 +157,7 @@ class KafkaClient(object):
for broker, payloads in payloads_by_broker.items():
conn = self._get_conn_for_broker(broker)
requestId = self._next_id()
- request = encoder_fn(client_id=KafkaClient.CLIENT_ID,
+ request = encoder_fn(client_id=self.client_id,
correlation_id=requestId, payloads=payloads)
# Send the request, recv the response