@@ -56,13 +56,15 @@ def __init__(
56
56
executor : Executor ,
57
57
name : str ,
58
58
config : dict [str , Any ] | None = None ,
59
+ config_change_callback : Callable [[dict [str , Any ], int ], None ] | None = None ,
59
60
* ,
60
61
validate : bool = False ,
61
62
) -> None :
62
63
"""Initialize the source.
63
64
64
65
If config is provided, it will be validated against the spec if validate is True.
65
66
"""
67
+ self .config_change_callback = config_change_callback
66
68
self .executor = executor
67
69
self ._name = name
68
70
self ._config_dict : dict [str , Any ] | None = None
@@ -361,7 +363,8 @@ def _peek_airbyte_message(
361
363
362
364
This method handles reading Airbyte messages and taking action, if needed, based on the
363
365
message type. For instance, log messages are logged, records are tallied, and errors are
364
- raised as exceptions if `raise_on_error` is True.
366
+ raised as exceptions if `raise_on_error` is True. If a config change message is received,
367
+ the config change callback is called.
365
368
366
369
Raises:
367
370
AirbyteConnectorFailedError: If a TRACE message of type ERROR is emitted.
@@ -380,6 +383,16 @@ def _peek_airbyte_message(
380
383
)
381
384
return
382
385
386
+ if (
387
+ message .type == "CONTROL"
388
+ and message .control .type == "CONNECTOR_CONFIG"
389
+ and self .config_change_callback is not None
390
+ ):
391
+ self .config_change_callback (
392
+ message .control .config , message .control .emitted_at
393
+ )
394
+ return
395
+
383
396
def _execute (
384
397
self ,
385
398
args : list [str ],
0 commit comments