Skip to main content
Version: 1.9.1

CdcTrigger

class CdcTrigger(
conn: Conn,
tables: QualifiedTablesSpec,
cdc_format: CdcFormat = CdcFormat(values_format='columns', flatten_values=True),
buffer_max_rows: int = 10000,
buffer_max_bytes: int | None = None,
buffer_max_secs: int = 60,
trigger_max_rows: int | None = None,
trigger_max_bytes: int | None = None,
trigger_max_secs: int = 60,
poll_interval_seconds: int = 1,
start: datetime | None = None,
end: datetime | None = None,
)

Bases: StageTrigger

Categories: trigger

Base StageTrigger for Change Data Capture (CDC) connectors.

This abstract trigger provides the common polling loop, buffering, and staging logic for all CDC connectors. Database-specific subclasses implement the ingestion details for their respective replication protocols.

Initialize a CdcTrigger instance.

Parameters

parameter
conn

The CDC connection configuration.

parameter
tables

Qualified table names to track for changes.

parameter
cdc_format

The output format specification for CDC data.

parameter
buffer_max_rows

Maximum rows in memory before flushing to the working directory.

parameter
buffer_max_bytes

Maximum bytes in memory before flushing to the working directory.

parameter
buffer_max_secs

Maximum seconds before flushing memory data to the working directory.

parameter
trigger_max_rows

Maximum total rows before staging from working directory to the stage location.

parameter
trigger_max_bytes

Maximum total bytes before staging from working directory to the stage location.

parameter
trigger_max_secs

Maximum seconds before staging from working directory to the stage location.

parameter
poll_interval_seconds

Interval in seconds between polling for new changes.

parameter
start

Optional datetime for the trigger to start working.

parameter
end

Optional datetime for the trigger to stop working.

Properties

property
buffer_max_bytesint | None

Maximum bytes in memory before flushing to the working directory.

property
buffer_max_rowsint

Maximum rows in memory before flushing to the working directory.

property
buffer_max_secsint

Maximum seconds before flushing memory data to the working directory.

property
cdc_formatCdcFormat

Output format specification for CDC data.

property
connConn

CDC connection configuration.

property
enddatetime | None

property
outdict[int, str] | None

Mapping of table indices to qualified table names.

property
poll_interval_secondsint

Interval in seconds between polling for new changes.

property
startdatetime | None

property
tableslist[str] | None

Qualified table names being tracked for changes.

property
trigger_max_bytesint | None

Maximum total bytes before staging from working directory to the stage location.

property
trigger_max_rowsint | None

Maximum total rows before staging from working directory to the stage location.

property
trigger_max_secsint

Maximum seconds before staging from working directory to the stage location.

Methods

collect_tables
def collect_tables(
session: Any,
cdc_format: CdcFormat = CdcFormat(values_format='columns', flatten_values=True),
) -> dict[str, TrackedTable]

harvest_tables
def harvest_tables(
session: Any,
cdc_format: CdcFormat = CdcFormat(values_format='columns', flatten_values=True),
) -> dict[str, TrackedTable]

run
def run(context: StageTriggerContext)

Continuously runs the stage trigger logic using the received context to trigger and monitor executions. SUCCESS if the StageTrigger.end datetime is reached. exit with 0. ERROR if any issue stops it from working or recovering. exit with 1. STOPPED upon a signal. exit with 0.