Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions kafka/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -59,7 +60,7 @@ def _load_metadata_for_topics(self, *topics):
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)
Expand Down Expand Up @@ -156,7 +157,7 @@ def _send_broker_aware_request(self, payloads, encoder_fn, decoder_fn):
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
Expand Down