@@ -40,6 +40,9 @@ class KafkaConsumer(six.Iterator):
40
40
It just needs to have at least one broker that will respond to a
41
41
Metadata API Request. Default port is 9092. If no servers are
42
42
specified, will default to localhost:9092.
43
+ client (kafka.client_async.KafkaClient): a kafka client to
44
+ use, or if unprovided, one is constructed from the provided
45
+ configuration.
43
46
client_id (str): a name for this client. This string is passed in
44
47
each request to servers and can be used to identify specific
45
48
server-side log entries that correspond to this client. Also
@@ -201,6 +204,8 @@ class KafkaConsumer(six.Iterator):
201
204
}
202
205
203
206
def __init__ (self , * topics , ** configs ):
207
+ client = configs .pop ("client" , None )
208
+
204
209
self .config = copy .copy (self .DEFAULT_CONFIG )
205
210
for key in self .config :
206
211
if key in configs :
@@ -226,7 +231,9 @@ def __init__(self, *topics, **configs):
226
231
metric_group_prefix = 'consumer'
227
232
# TODO _metrics likely needs to be passed to KafkaClient, etc.
228
233
229
- self ._client = KafkaClient (** self .config )
234
+ if client is None :
235
+ client = KafkaClient (** self .config )
236
+ self ._client = client
230
237
231
238
# Check Broker Version if not set explicitly
232
239
if self .config ['api_version' ] == 'auto' :
0 commit comments