feat: publish CDC stream via logical replication - #592
Merged
thlpkee20-wq merged 3 commits intoJul 29, 2026
Merged
Conversation
Add CDC consumer, pgoutput decoder, and pluggable sink interface (Kafka, stdout, in-memory) for streaming row-level changes from PostgreSQL logical replication to downstream consumers. - Add migration 0014 to create "stellabill_cdc" publication with column allowlists that exclude PII columns (PII-safe by design) - Implement pgoutput binary protocol decoder supporting INSERT, UPDATE, DELETE, BEGIN, COMMIT, RELATION, ORIGIN, and TYPE messages - Implement Consumer with reconnection loop, standby status updates, and graceful shutdown via context cancellation - Implement pluggable Sink interface with MemorySink (testing), KafkaSink (production), and StdoutSink (debugging) - LSN advancement gated on successful sink writes to prevent data loss - Build helper functions for crafting pgoutput binary messages in tests - 77.5% test coverage with 60+ test cases covering decoder edge cases, consumer lifecycle, reconnect logic, and sink implementations closes Stellabill#417
|
@believetimothy Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
believetimothy
had a problem deploying
to
preview-592
July 29, 2026 14:51 — with
GitHub Actions
Failure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Change Data Capture consumer that streams row-level changes from PostgreSQL logical replication to pluggable sinks (Kafka, stdout, in-memory), enabling downstream analytics and search indexers without polling.
closes #417
Changes
Migration (
migrations/0014_create_cdc_publication)stellabill_cdcpublication using pgoutput pluginsubscriptions.customer,statements.customer_idoutbox_events.event_data,outbox_attempts.response_body,contract_events.payloadidempotency_keys.response_body,subscriber_keys.jwkexport_operations.caller_id,notification_preferences.*,saga_instances.contextoutbox_attempts.error_message,saga_step_results.error_messageCDC Package (
internal/cdc/)consumer.gopgoutput.gosink.goSinkinterface +MemorySinkfor testing +ConsumerConfigkafka_sink.goMessageWriterinterface abstractionstdout_sink.goKey Design Decisions
Sinkinterface allows adding any downstream (S3, BigQuery, Elasticsearch, etc.)MessageWriterinterface decouples from specific Kafka clientTest Coverage
runReplication(5.8%),execSimple(0%),sendStandbyStatusUpdate(0%) require real PG withwal_level=logicalfor full coverage-raceenabledSecurity