File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ class KafkaClient(object):
63
63
'ssl_crlfile' : None ,
64
64
'api_version' : None ,
65
65
'api_version_auto_timeout_ms' : 2000 ,
66
+ 'selector' : selectors .DefaultSelector ,
66
67
}
67
68
API_VERSIONS = [
68
69
(0 , 10 ),
@@ -134,6 +135,9 @@ def __init__(self, **configs):
134
135
api_version_auto_timeout_ms (int): number of milliseconds to throw a
135
136
timeout exception from the constructor when checking the broker
136
137
api version. Only applies if api_version is None
138
+ selector (selectors.BaseSelector): Provide a specific selector
139
+ implementation to use for I/O multiplexing.
140
+ Default: selectors.DefaultSelector
137
141
"""
138
142
self .config = copy .copy (self .DEFAULT_CONFIG )
139
143
for key in self .config :
@@ -149,7 +153,7 @@ def __init__(self, **configs):
149
153
self ._topics = set () # empty set will fetch all topic metadata
150
154
self ._metadata_refresh_in_progress = False
151
155
self ._last_no_node_available_ms = 0
152
- self ._selector = selectors . DefaultSelector ()
156
+ self ._selector = self . config [ 'selector' ] ()
153
157
self ._conns = {}
154
158
self ._connecting = set ()
155
159
self ._refresh_on_disconnects = True
Original file line number Diff line number Diff line change 6
6
7
7
import six
8
8
9
- from kafka .client_async import KafkaClient
9
+ from kafka .client_async import KafkaClient , selectors
10
10
from kafka .consumer .fetcher import Fetcher
11
11
from kafka .consumer .subscription_state import SubscriptionState
12
12
from kafka .coordinator .consumer import ConsumerCoordinator
@@ -173,6 +173,9 @@ class KafkaConsumer(six.Iterator):
173
173
metrics. Default: 2
174
174
metrics_sample_window_ms (int): The number of samples maintained to
175
175
compute metrics. Default: 30000
176
+ selector (selectors.BaseSelector): Provide a specific selector
177
+ implementation to use for I/O multiplexing.
178
+ Default: selectors.DefaultSelector
176
179
177
180
Note:
178
181
Configuration parameters are described in more detail at
@@ -218,6 +221,7 @@ class KafkaConsumer(six.Iterator):
218
221
'metric_reporters' : [],
219
222
'metrics_num_samples' : 2 ,
220
223
'metrics_sample_window_ms' : 30000 ,
224
+ 'selector' : selectors .DefaultSelector ,
221
225
}
222
226
223
227
def __init__ (self , * topics , ** configs ):
Original file line number Diff line number Diff line change 8
8
import weakref
9
9
10
10
from .. import errors as Errors
11
- from ..client_async import KafkaClient
11
+ from ..client_async import KafkaClient , selectors
12
12
from ..partitioner .default import DefaultPartitioner
13
13
from ..protocol .message import Message , MessageSet
14
14
from ..structs import TopicPartition
@@ -220,6 +220,9 @@ class KafkaProducer(object):
220
220
api_version_auto_timeout_ms (int): number of milliseconds to throw a
221
221
timeout exception from the constructor when checking the broker
222
222
api version. Only applies if api_version set to 'auto'
223
+ selector (selectors.BaseSelector): Provide a specific selector
224
+ implementation to use for I/O multiplexing.
225
+ Default: selectors.DefaultSelector
223
226
224
227
Note:
225
228
Configuration parameters are described in more detail at
@@ -255,7 +258,8 @@ class KafkaProducer(object):
255
258
'ssl_keyfile' : None ,
256
259
'ssl_crlfile' : None ,
257
260
'api_version' : None ,
258
- 'api_version_auto_timeout_ms' : 2000
261
+ 'api_version_auto_timeout_ms' : 2000 ,
262
+ 'selector' : selectors .DefaultSelector ,
259
263
}
260
264
261
265
def __init__ (self , ** configs ):
You can’t perform that action at this time.
0 commit comments