@@ -46,7 +46,10 @@ class KafkaConsumer(six.Iterator):
46
46
It just needs to have at least one broker that will respond to a
47
47
Metadata API Request. Default port is 9092. If no servers are
48
48
specified, will default to localhost:9092.
49
- client_id (str): A name for this client. This string is passed in
49
+ client (kafka.client_async.KafkaClient): a kafka client to
50
+ use, or if unprovided, one is constructed from the provided
51
+ configuration.
52
+ client_id (str): a name for this client. This string is passed in
50
53
each request to servers and can be used to identify specific
51
54
server-side log entries that correspond to this client. Also
52
55
submitted to GroupCoordinator for logging with respect to
@@ -243,6 +246,7 @@ class KafkaConsumer(six.Iterator):
243
246
"""
244
247
DEFAULT_CONFIG = {
245
248
'bootstrap_servers' : 'localhost' ,
249
+ 'client' : None ,
246
250
'client_id' : 'kafka-python-' + __version__ ,
247
251
'group_id' : None ,
248
252
'key_deserializer' : None ,
@@ -338,7 +342,11 @@ def __init__(self, *topics, **configs):
338
342
log .warning ('use api_version=%s [tuple] -- "%s" as str is deprecated' ,
339
343
str (self .config ['api_version' ]), str_version )
340
344
341
- self ._client = KafkaClient (metrics = self ._metrics , ** self .config )
345
+ client = self .config .pop ('client' , None ) or KafkaClient (
346
+ metrics = self ._metrics ,
347
+ ** self .config
348
+ )
349
+ self ._client = client
342
350
343
351
# Get auto-discovered version from client if necessary
344
352
if self .config ['api_version' ] is None :
0 commit comments