Skip to content

Commit abe154e

Browse files
committed
Adds config_change_callback to Destinations and Sources
1 parent 7c703ac commit abe154e

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

airbyte/_connector_base.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ def __init__(
5656
executor: Executor,
5757
name: str,
5858
config: dict[str, Any] | None = None,
59+
config_change_callback: Callable[[dict[str, Any], int], None] | None = None,
5960
*,
6061
validate: bool = False,
6162
) -> None:
6263
"""Initialize the source.
6364
6465
If config is provided, it will be validated against the spec if validate is True.
6566
"""
67+
self.config_change_callback = config_change_callback
6668
self.executor = executor
6769
self._name = name
6870
self._config_dict: dict[str, Any] | None = None
@@ -361,7 +363,8 @@ def _peek_airbyte_message(
361363
362364
This method handles reading Airbyte messages and taking action, if needed, based on the
363365
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.
365368
366369
Raises:
367370
AirbyteConnectorFailedError: If a TRACE message of type ERROR is emitted.
@@ -380,6 +383,16 @@ def _peek_airbyte_message(
380383
)
381384
return
382385

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+
383396
def _execute(
384397
self,
385398
args: list[str],

airbyte/destinations/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def __init__(
4848
executor: Executor,
4949
name: str,
5050
config: dict[str, Any] | None = None,
51+
config_change_callback: Callable[[dict[str, Any]], None] | None = None,
5152
*,
5253
validate: bool = False,
5354
) -> None:
@@ -59,6 +60,7 @@ def __init__(
5960
executor=executor,
6061
name=name,
6162
config=config,
63+
config_change_callback=config_change_callback,
6264
validate=validate,
6365
)
6466

airbyte/sources/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
executor: Executor,
5959
name: str,
6060
config: dict[str, Any] | None = None,
61+
config_change_callback: Callable[[dict[str, Any]], None] | None = None,
6162
streams: str | list[str] | None = None,
6263
*,
6364
validate: bool = False,
@@ -73,6 +74,7 @@ def __init__(
7374
executor=executor,
7475
name=name,
7576
config=config,
77+
config_change_callback=config_change_callback,
7678
validate=validate,
7779
)
7880
self._config_dict: dict[str, Any] | None = None

0 commit comments

Comments
 (0)