@@ -121,6 +121,7 @@ def __init__(
121
121
Accepts string with Kafka broker host and port formatted as `<host>:<port>`,
122
122
or a ConnectionConfig object if authentication is required.
123
123
Either this OR `quix_sdk_token` must be set to use `Application` (not both).
124
+ Takes priority over quix auto-configuration.
124
125
Linked Environment Variable: `Quix__Broker__Address`.
125
126
Default: `None`
126
127
:param quix_sdk_token: If using the Quix Cloud, the SDK token to connect with.
@@ -198,27 +199,32 @@ def __init__(
198
199
"Quix__Consumer_Group" , "quixstreams-default"
199
200
)
200
201
201
- if quix_config_builder :
202
- quix_app_source = "Quix Config Builder"
203
- if quix_config_builder and quix_sdk_token :
204
- raise warnings .warn (
205
- "'quix_config_builder' is not necessary when an SDK token is defined; "
206
- "we recommend letting the Application generate it automatically"
207
- )
208
-
209
- if quix_sdk_token and not quix_config_builder :
210
- quix_app_source = "Quix SDK Token"
211
- quix_config_builder = QuixKafkaConfigsBuilder (quix_sdk_token = quix_sdk_token )
202
+ if broker_address :
203
+ # If broker_address is passed to the app it takes priority over any quix configuration
204
+ self ._is_quix_app = False
205
+ topic_manager_factory = TopicManager
206
+ if isinstance (broker_address , str ):
207
+ broker_address = ConnectionConfig (bootstrap_servers = broker_address )
208
+ else :
209
+ self ._is_quix_app = True
210
+
211
+ if quix_config_builder :
212
+ quix_app_source = "Quix Config Builder"
213
+ if quix_sdk_token :
214
+ warnings .warn (
215
+ "'quix_config_builder' is not necessary when an SDK token is defined; "
216
+ "we recommend letting the Application generate it automatically"
217
+ )
218
+ elif quix_sdk_token :
219
+ quix_app_source = "Quix SDK Token"
220
+ quix_config_builder = QuixKafkaConfigsBuilder (
221
+ quix_sdk_token = quix_sdk_token
222
+ )
223
+ else :
224
+ raise ValueError (
225
+ 'Either "broker_address" or "quix_sdk_token" must be provided'
226
+ )
212
227
213
- if broker_address and quix_config_builder :
214
- raise ValueError (
215
- 'Cannot provide both "broker_address" and "quix_sdk_token"'
216
- )
217
- elif not (broker_address or quix_config_builder ):
218
- raise ValueError (
219
- 'Either "broker_address" or "quix_sdk_token" must be provided'
220
- )
221
- elif quix_config_builder :
222
228
# SDK Token or QuixKafkaConfigsBuilder were provided
223
229
logger .info (
224
230
f"{ quix_app_source } detected; "
@@ -235,13 +241,6 @@ def __init__(
235
241
consumer_group = quix_app_config .consumer_group
236
242
consumer_extra_config .update (quix_app_config .librdkafka_extra_config )
237
243
producer_extra_config .update (quix_app_config .librdkafka_extra_config )
238
- else :
239
- # Only broker address is provided
240
- topic_manager_factory = TopicManager
241
- if isinstance (broker_address , str ):
242
- broker_address = ConnectionConfig (bootstrap_servers = broker_address )
243
-
244
- self ._is_quix_app = bool (quix_config_builder )
245
244
246
245
self ._broker_address = broker_address
247
246
self ._consumer_group = consumer_group
@@ -306,6 +305,10 @@ def __init__(
306
305
state_manager = self ._state_manager ,
307
306
)
308
307
308
+ @property
309
+ def is_quix_app (self ):
310
+ return self ._is_quix_app
311
+
309
312
@classmethod
310
313
def Quix (
311
314
cls ,
@@ -704,7 +707,7 @@ def run(
704
707
f'auto_offset_reset="{ self ._auto_offset_reset } " '
705
708
f"commit_interval={ self ._commit_interval } s"
706
709
)
707
- if self ._is_quix_app :
710
+ if self .is_quix_app :
708
711
self ._quix_runtime_init ()
709
712
710
713
self ._setup_topics ()
0 commit comments