{"modulePath":"github.com/GoCodeAlone/workflow-plugin-data-engineering","version":"v0.3.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package cdc\n\nPackage cdc implements Change Data Capture modules, steps, and triggers.\n\n## Functions\n\n```go\nfunc NewBackpressureStep(name string, _ map[string]any) (sdk.StepInstance, error)\n```\nNewBackpressureStep creates a new step.cdc\\_backpressure instance.\n\n```go\nfunc NewMonitorStep(name string, _ map[string]any) (sdk.StepInstance, error)\n```\nNewMonitorStep creates a new step.cdc\\_monitor instance.\n\n```go\nfunc NewSchemaHistoryStep(name string, _ map[string]any) (sdk.StepInstance, error)\n```\nNewSchemaHistoryStep creates a new step.cdc\\_schema\\_history instance.\n\n```go\nfunc NewSnapshotStep(name string, _ map[string]any) (sdk.StepInstance, error)\n```\nNewSnapshotStep creates a new step.cdc\\_snapshot instance.\n\n```go\nfunc NewSourceModule(name string, config map[string]any) (sdk.ModuleInstance, error)\n```\nNewSourceModule creates a new CDC source module.\n\n```go\nfunc NewStartStep(name string, _ map[string]any) (sdk.StepInstance, error)\n```\nNewStartStep creates a new step.cdc\\_start instance.\n\n```go\nfunc NewStatusStep(name string, _ map[string]any) (sdk.StepInstance, error)\n```\nNewStatusStep creates a new step.cdc\\_status instance.\n\n```go\nfunc NewStopStep(name string, _ map[string]any) (sdk.StepInstance, error)\n```\nNewStopStep creates a new step.cdc\\_stop instance.\n\n```go\nfunc NewTrigger(config map[string]any, cb sdk.TriggerCallback) (sdk.TriggerInstance, error)\n```\nNewTrigger creates a new CDC trigger instance.\n\n```go\nfunc RegisterSource(sourceID string, p CDCProvider) error\n```\nRegisterSource registers a CDC provider in the global registry.\n\n```go\nfunc UnregisterSource(sourceID string)\n```\nUnregisterSource removes a source from the global registry.\n\n## Types\n\n```go\ntype BackpressureMonitor struct {\n\tThresholdLagBytes   int64\n\tThresholdLagSeconds int64\n\tWarningMultiplier   float64 // warn at this fraction of threshold (e.g. 0.8)\n}\n```\nBackpressureMonitor evaluates CDC lag against configurable thresholds.\n\n```go\nfunc (m *BackpressureMonitor) Evaluate(sourceID string, lagBytes, lagSeconds int64) BackpressureStatus\n```\nEvaluate returns the backpressure status for the given lag values.\n\n```go\ntype BackpressureStatus struct {\n\tSourceID   string\n\tLagBytes   int64\n\tLagSeconds int64\n\tStatus     string // \"healthy\", \"warning\", \"critical\"\n}\n```\nBackpressureStatus holds the lag evaluation result.\n\n```go\ntype BentoProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nBentoProvider implements CDCProvider by generating Bento input YAML configs and delegating actual stream management to the workflow-plugin-bento engine module.\n\nThe data-engineering plugin no longer manages Bento stream lifecycle in-process. Instead, the engine config declares a bento.input module (referenced via options.bento\\_module) alongside the cdc.source module. The Bento module handles stream execution and publishes events to the engine's EventBus, which the cdc trigger consumes.\n\n```go\nfunc (p *BentoProvider) ConfigYAML(sourceID string) (string, error)\n```\nConfigYAML returns the generated Bento input YAML for a configured CDC source. This can be used to inspect what config was generated for the delegated module.\n\n```go\nfunc (p *BentoProvider) Connect(_ context.Context, config SourceConfig) error\n```\nConnect generates the Bento CDC input YAML and stores it for delegation. Actual stream management is handled by the bento.input engine module referenced in config.Options\\[\"bento\\_module\"].\n\n```go\nfunc (p *BentoProvider) Disconnect(_ context.Context, sourceID string) error\n```\nDisconnect removes the CDC source configuration.\n\n```go\nfunc (p *BentoProvider) RegisterEventHandler(sourceID string, h EventHandler) error\n```\nRegisterEventHandler stores the event handler for a CDC source. Events are delivered by the delegated bento.input engine module via the engine's EventBus.\n\n```go\nfunc (p *BentoProvider) SchemaHistory(_ context.Context, sourceID string, _ string) ([]SchemaVersion, error)\n```\nSchemaHistory returns schema change history. Bento streams do not track DDL history natively; this always returns empty.\n\n```go\nfunc (p *BentoProvider) Snapshot(_ context.Context, sourceID string, tables []string) error\n```\nSnapshot regenerates the CDC config for the given source, optionally overriding the table list. The updated YAML is available for the delegated bento.input module.\n\n```go\nfunc (p *BentoProvider) Status(_ context.Context, sourceID string) (*CDCStatus, error)\n```\nStatus returns the current status of a CDC source.\n\n```go\ntype CDCProvider interface {\n\t// Connect establishes a connection and starts the CDC stream.\n\tConnect(ctx context.Context, config SourceConfig) error\n\t// Disconnect stops the CDC stream and releases resources.\n\tDisconnect(ctx context.Context, sourceID string) error\n\t// Status returns the current status of a CDC stream.\n\tStatus(ctx context.Context, sourceID string) (*CDCStatus, error)\n\t// Snapshot triggers a full table snapshot for the given tables.\n\tSnapshot(ctx context.Context, sourceID string, tables []string) error\n\t// SchemaHistory returns the schema change history for a table.\n\tSchemaHistory(ctx context.Context, sourceID string, table string) ([]SchemaVersion, error)\n\t// RegisterEventHandler registers a callback for CDC events from a source stream.\n\tRegisterEventHandler(sourceID string, h EventHandler) error\n}\n```\nCDCProvider defines the interface for Change Data Capture providers. Implementations: BentoProvider, DebeziumProvider, DMSProvider, MemoryProvider.\n\n```go\nfunc LookupSource(sourceID string) (CDCProvider, error)\n```\nLookupSource finds a running CDC source provider by ID.\n\n```go\ntype CDCStatus struct {\n\tSourceID   string `json:\"source_id\"              yaml:\"source_id\"`\n\tState      string `json:\"state\"                  yaml:\"state\"`\n\tProvider   string `json:\"provider\"               yaml:\"provider\"`\n\tLastEvent  string `json:\"last_event\"             yaml:\"last_event\"`\n\tError      string `json:\"error,omitempty\"        yaml:\"error,omitempty\"`\n\tLagBytes   int64  `json:\"lag_bytes,omitempty\"    yaml:\"lag_bytes,omitempty\"`\n\tLagSeconds int64  `json:\"lag_seconds,omitempty\"  yaml:\"lag_seconds,omitempty\"`\n}\n```\nCDCStatus describes the current state of a CDC stream.\n\n```go\ntype DMSClient interface {\n\tCreateReplicationTask(ctx context.Context, params *dms.CreateReplicationTaskInput, optFns ...func(*dms.Options)) (*dms.CreateReplicationTaskOutput, error)\n\tStartReplicationTask(ctx context.Context, params *dms.StartReplicationTaskInput, optFns ...func(*dms.Options)) (*dms.StartReplicationTaskOutput, error)\n\tStopReplicationTask(ctx context.Context, params *dms.StopReplicationTaskInput, optFns ...func(*dms.Options)) (*dms.StopReplicationTaskOutput, error)\n\tDescribeReplicationTasks(ctx context.Context, params *dms.DescribeReplicationTasksInput, optFns ...func(*dms.Options)) (*dms.DescribeReplicationTasksOutput, error)\n\tDeleteReplicationTask(ctx context.Context, params *dms.DeleteReplicationTaskInput, optFns ...func(*dms.Options)) (*dms.DeleteReplicationTaskOutput, error)\n\tDescribeTableStatistics(ctx context.Context, params *dms.DescribeTableStatisticsInput, optFns ...func(*dms.Options)) (*dms.DescribeTableStatisticsOutput, error)\n}\n```\nDMSClient is the interface over AWS DMS SDK calls, enabling mock injection in tests.\n\n```go\ntype DMSConfig struct {\n\tSourceEndpointARN      string `json:\"source_endpoint_arn\"      yaml:\"source_endpoint_arn\"`\n\tTargetEndpointARN      string `json:\"target_endpoint_arn\"      yaml:\"target_endpoint_arn\"`\n\tReplicationInstanceARN string `json:\"replication_instance_arn\" yaml:\"replication_instance_arn\"`\n\tMigrationType          string `json:\"migration_type\"           yaml:\"migration_type\"` // cdc, full-load-and-cdc\n}\n```\nDMSConfig holds DMS-specific configuration for the provider.\n\n```go\ntype DMSProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nDMSProvider implements CDCProvider using AWS Database Migration Service. It creates and manages AWS DMS replication tasks via the AWS SDK. The SourceConfig.Connection field is not used; DMS config comes from DMSConfig.\n\n```go\nfunc (p *DMSProvider) Connect(ctx context.Context, config SourceConfig) error\n```\nConnect creates an AWS DMS replication task and starts it.\n\n```go\nfunc (p *DMSProvider) Disconnect(ctx context.Context, sourceID string) error\n```\nDisconnect stops and deletes the AWS DMS replication task.\n\n```go\nfunc (p *DMSProvider) PauseSource(ctx context.Context, sourceID string) error\n```\nPauseSource stops the DMS replication task (pause = stop for DMS).\n\n```go\nfunc (p *DMSProvider) RegisterEventHandler(sourceID string, h EventHandler) error\n```\nRegisterEventHandler registers a callback for CDC events from an AWS DMS task.\n\n```go\nfunc (p *DMSProvider) ResumeSource(ctx context.Context, sourceID string) error\n```\nResumeSource restarts the DMS replication task from where it stopped.\n\n```go\nfunc (p *DMSProvider) SchemaHistory(ctx context.Context, sourceID string, table string) ([]SchemaVersion, error)\n```\nSchemaHistory returns schema change stats from AWS DMS table statistics. DMS tracks DDL counts per table via DescribeTableStatistics.\n\n```go\nfunc (p *DMSProvider) Snapshot(ctx context.Context, sourceID string, tables []string) error\n```\nSnapshot triggers a full re-snapshot via reload-target: stops the task then restarts with reload-target migration type.\n\n```go\nfunc (p *DMSProvider) Status(ctx context.Context, sourceID string) (*CDCStatus, error)\n```\nStatus returns the current status of an AWS DMS replication task.\n\n```go\ntype DebeziumProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nDebeziumProvider implements CDCProvider via the Kafka Connect REST API. It creates and manages Debezium connectors on an external Kafka Connect cluster. The SourceConfig.Connection field must be the base URL of the Kafka Connect REST API (e.g. \"[http://localhost:8083](http://localhost:8083)\").\n\n```go\nfunc (p *DebeziumProvider) Connect(ctx context.Context, config SourceConfig) error\n```\nConnect creates a Debezium connector via POST /connectors on the Kafka Connect API. config.Connection must be the Kafka Connect base URL.\n\n```go\nfunc (p *DebeziumProvider) Disconnect(ctx context.Context, sourceID string) error\n```\nDisconnect deletes the Debezium connector via DELETE /connectors/{name}.\n\n```go\nfunc (p *DebeziumProvider) PauseSource(ctx context.Context, sourceID string) error\n```\nPauseSource pauses a Debezium connector via PUT /connectors/{name}/pause.\n\n```go\nfunc (p *DebeziumProvider) RegisterEventHandler(sourceID string, h EventHandler) error\n```\nRegisterEventHandler registers a callback for CDC events from a Debezium connector.\n\n```go\nfunc (p *DebeziumProvider) ResumeSource(ctx context.Context, sourceID string) error\n```\nResumeSource resumes a paused Debezium connector via PUT /connectors/{name}/resume.\n\n```go\nfunc (p *DebeziumProvider) SchemaHistory(ctx context.Context, sourceID string, table string) ([]SchemaVersion, error)\n```\nSchemaHistory returns schema change history for a table. NOTE: The Kafka Connect REST API does not expose schema history directly. A full implementation would require consuming the Debezium schema history Kafka topic. This implementation verifies the connector is running and returns an empty history.\n\n```go\nfunc (p *DebeziumProvider) Snapshot(ctx context.Context, sourceID string, tables []string) error\n```\nSnapshot triggers a full re-snapshot by updating the connector's snapshot.mode and restarting it via PUT /connectors/{name}/config + POST /connectors/{name}/restart.\n\n```go\nfunc (p *DebeziumProvider) Status(ctx context.Context, sourceID string) (*CDCStatus, error)\n```\nStatus returns the current connector state from GET /connectors/{name}/status.\n\n```go\ntype EventHandler func(sourceID string, event map[string]any) error\n```\nEventHandler is called for each CDC event received from the provider. Implementations must be goroutine-safe.\n\n```go\ntype MemoryProvider struct {\n\t// contains filtered or unexported fields\n}\n```\nMemoryProvider is an in-memory CDCProvider implementation intended for testing. It allows injecting synthetic CDC events via InjectEvent and verifying provider behavior without real database connections or external services.\n\n```go\nfunc NewMemoryProvider() *MemoryProvider\n```\nNewMemoryProvider creates a new MemoryProvider.\n\n```go\nfunc (p *MemoryProvider) AddSchemaVersion(sourceID string, sv SchemaVersion) error\n```\nAddSchemaVersion records a synthetic DDL change event for testing schema history.\n\n```go\nfunc (p *MemoryProvider) Connect(ctx context.Context, config SourceConfig) error\n```\nConnect registers an in-memory CDC source and starts its event dispatch goroutine.\n\n```go\nfunc (p *MemoryProvider) Disconnect(ctx context.Context, sourceID string) error\n```\nDisconnect stops the event dispatch goroutine and removes the source.\n\n```go\nfunc (p *MemoryProvider) InjectEvent(sourceID string, event map[string]any) error\n```\nInjectEvent injects a synthetic CDC event into the named source's event stream. This is the primary API used by tests to simulate database change events.\n\n```go\nfunc (p *MemoryProvider) RegisterEventHandler(sourceID string, h EventHandler) error\n```\nRegisterEventHandler registers a callback for events from a named source.\n\n```go\nfunc (p *MemoryProvider) SchemaHistory(_ context.Context, sourceID string, table string) ([]SchemaVersion, error)\n```\nSchemaHistory returns the recorded DDL change history for a table.\n\n```go\nfunc (p *MemoryProvider) SetLag(sourceID string, lagBytes, lagSeconds int64) error\n```\nSetLag configures simulated CDC lag on a running memory source (for backpressure tests).\n\n```go\nfunc (p *MemoryProvider) Snapshot(_ context.Context, sourceID string, tables []string) error\n```\nSnapshot triggers a synthetic snapshot by emitting a snapshot\\_started event.\n\n```go\nfunc (p *MemoryProvider) Status(_ context.Context, sourceID string) (*CDCStatus, error)\n```\nStatus returns the current status of a memory CDC source.\n\n```go\ntype SchemaVersion struct {\n\tTable     string `json:\"table\"      yaml:\"table\"`\n\tVersion   int64  `json:\"version\"    yaml:\"version\"`\n\tDDL       string `json:\"ddl\"        yaml:\"ddl\"`\n\tAppliedAt string `json:\"applied_at\" yaml:\"applied_at\"`\n}\n```\nSchemaVersion describes a schema change event for a table.\n\n```go\ntype SourceConfig struct {\n\tProvider   string         `json:\"provider\"    yaml:\"provider\"`\n\tSourceID   string         `json:\"source_id\"   yaml:\"source_id\"`\n\tSourceType string         `json:\"source_type\" yaml:\"source_type\"`\n\tConnection string         `json:\"connection\"  yaml:\"connection\"`\n\tTables     []string       `json:\"tables\"      yaml:\"tables\"`\n\tOptions    map[string]any `json:\"options\"     yaml:\"options\"`\n}\n```\nSourceConfig holds configuration for the cdc.source module.\n\n```go\ntype SourceModule struct {\n\t// contains filtered or unexported fields\n}\n```\nSourceModule is a CDC source module that streams change events from a database.\n\n```go\nfunc (m *SourceModule) Config() SourceConfig\n```\nConfig returns the source configuration.\n\n```go\nfunc (m *SourceModule) Init() error\n```\nInit validates the module configuration.\n\n```go\nfunc (m *SourceModule) Provider() CDCProvider\n```\nProvider returns the underlying CDC provider (used by steps).\n\n```go\nfunc (m *SourceModule) Start(ctx context.Context) error\n```\nStart initializes the CDC provider connection and registers the module in the global registry. The module mutex is NOT held during provider.Connect to avoid blocking Provider() and Config() accessors during potentially long network round-trips. m.provider and m.config are immutable after NewSourceModule, so no lock is needed to read them.\n\n```go\nfunc (m *SourceModule) Stop(ctx context.Context) error\n```\nStop shuts down the CDC provider connection and deregisters from the global registry. m.provider and m.config are immutable after NewSourceModule; no lock needed.\n\n```go\ntype ThrottleableProvider interface {\n\tPauseSource(ctx context.Context, sourceID string) error\n\tResumeSource(ctx context.Context, sourceID string) error\n}\n```\nThrottleableProvider is an optional extension of CDCProvider for providers that support pausing and resuming the CDC stream.\n\n```go\ntype Trigger struct {\n\t// contains filtered or unexported fields\n}\n```\nTrigger implements sdk.TriggerInstance for trigger.cdc. It registers an EventHandler on the named cdc.source provider and fires the workflow callback for each matching CDC change event.\n\nThe trigger filters events by table name and action (INSERT/UPDATE/DELETE) when configured. If tables or actions are empty, all events are forwarded.\n\n```go\nfunc (t *Trigger) Start(ctx context.Context) error\n```\nStart registers an event handler on the running cdc.source module and begins forwarding matching CDC events to the workflow callback.\n\n```go\nfunc (t *Trigger) Stop(ctx context.Context) error\n```\nStop deregisters the event handler and halts event forwarding.\n\n```go\ntype TriggerConfig struct {\n\t// SourceID references a running cdc.source module by source_id.\n\tSourceID string `json:\"source_id\" yaml:\"source_id\"`\n\t// Tables filters events to the given table names. Empty = all tables.\n\tTables []string `json:\"tables\" yaml:\"tables\"`\n\t// Actions filters events by DML operation type (INSERT, UPDATE, DELETE). Empty = all.\n\tActions []string `json:\"actions\" yaml:\"actions\"`\n}\n```\nTriggerConfig holds configuration for the CDC trigger.\n\n","path":"github.com/GoCodeAlone/workflow-plugin-data-engineering/internal/cdc","name":"cdc","synopsis":"Package cdc implements Change Data Capture modules, steps, and triggers.","isRedistributable":true}
