AirbyteTriggerSyncOperator¶
使用 AirbyteTriggerSyncOperator
在 Airbyte 中触发现有的 ConnectionId 同步作业。
警告
此操作符在 Airbyte 中触发同步作业。如果再次触发,此操作符不保证幂等性。您必须了解您正在更新/同步的源(数据库、API 等)以及在 Airbyte 中执行操作应用的方法。
使用操作符¶
AirbyteTriggerSyncOperator 需要 connection_id
,这是 Airbyte 中源和目标同步作业之间创建的 uuid 标识符。使用 airbyte_conn_id
参数指定用于连接到您账户的 Airbyte 连接。
Airbyte 为云端和开源用户提供一种单一的认证方法。您需要提供 client_id
和 client_secret
以认证 Airbyte 服务器。
您可以使用此操作符通过两种方式在 Airflow 中触发同步作业。第一种是同步过程。此操作符将启动 Airbyte 作业,并管理作业状态。另一种方式是使用标志 async = True
,这样操作符仅触发作业并返回 job_id
,该 job_id
会传递给 AirbyteSensor。
使用同步方式的示例
tests/system/airbyte/example_airbyte_trigger_job.py
sync_source_destination = AirbyteTriggerSyncOperator(
task_id="airbyte_sync_source_dest_example",
connection_id=CONN_ID,
)
使用异步方式的示例
tests/system/airbyte/example_airbyte_trigger_job.py
async_source_destination = AirbyteTriggerSyncOperator(
task_id="airbyte_async_source_dest_example",
connection_id=CONN_ID,
asynchronous=True,
)
airbyte_sensor = AirbyteJobSensor(
task_id="airbyte_sensor_source_dest_example",
airbyte_job_id=async_source_destination.output,
)