Migrate from github.com/jackc/pgx to github.com/jackc/pglogrepl#12
Merged
Migrate from github.com/jackc/pgx to github.com/jackc/pglogrepl#12
Conversation
08c18f2 to
b9da36e
Compare
8f32d26 to
5d80af4
Compare
d108b21 to
cc35c68
Compare
This commit migrates the PostgreSQL logical replication implementation from the legacy pgx v3 API to the modern pglogrepl library with pgx/v5. ## Changes ### Dependencies (go.mod) - Replaced github.com/jackc/pgx v3.6.2+incompatible with: - github.com/jackc/pglogrepl v0.0.0-20251213150135-2e8d0df862c1 - github.com/jackc/pgx/v5 v5.7.4 - Removed obsolete indirect dependencies (cockroachdb/apd, jackc/fake, etc.) ### Main Application (cmd/pgoutbox/init.go) - Created replicationConn wrapper struct that adapts *pgconn.PgConn to the replication interface expected by the listener - Wrapper implements: CreateReplicationSlot, DropReplicationSlot, StartReplication, ReceiveMessage, SendStandbyStatusUpdate, IsAlive, Close - Updated imports to use pgx/v5 and pglogrepl packages ### Listener (internal/listener/listener.go) - Changed lsn field type from uint64 to pglogrepl.LSN - Updated replication interface to use pglogrepl types: - CreateReplicationSlot returns pglogrepl.CreateReplicationSlotResult - StartReplication uses pglogrepl.LSN and pglogrepl.StartReplicationOptions - SendStandbyStatusUpdate uses pglogrepl.StandbyStatusUpdate - ReceiveMessage returns raw []byte instead of structured messages - Rewrote processRawMessage to handle raw byte messages using pglogrepl.ParseXLogData and pglogrepl.ParsePrimaryKeepaliveMessage - Updated SendStandbyStatus and AckWalMessage to take context parameter ### Repository (internal/listener/repository.go) - Updated to pgx/v5 API (QueryRow instead of QueryRowEx) - Close now takes context parameter - IsAlive uses IsClosed() method ### Tests - Updated all mock implementations for new interface signatures - Rewrote test helper functions to use pglogrepl types - Simplified test cases by removing obsolete NewStandbyStatus calls All listener tests pass. Signed-off-by: Tamal Saha <tamal@appscode.com>
Signed-off-by: Tamal Saha <tamal@appscode.com>
Signed-off-by: Tamal Saha <tamal@appscode.com>
cc35c68 to
d593e92
Compare
Signed-off-by: Imtiaz Uddin <imtiaz@appscode.com>
Imtiaz246
approved these changes
Jan 6, 2026
tamalsaha
added a commit
that referenced
this pull request
Jan 6, 2026
* Migrate from github.com/jackc/pgx to github.com/jackc/pglogrepl This commit migrates the PostgreSQL logical replication implementation from the legacy pgx v3 API to the modern pglogrepl library with pgx/v5. ## Changes ### Dependencies (go.mod) - Replaced github.com/jackc/pgx v3.6.2+incompatible with: - github.com/jackc/pglogrepl v0.0.0-20251213150135-2e8d0df862c1 - github.com/jackc/pgx/v5 v5.7.4 - Removed obsolete indirect dependencies (cockroachdb/apd, jackc/fake, etc.) ### Main Application (cmd/pgoutbox/init.go) - Created replicationConn wrapper struct that adapts *pgconn.PgConn to the replication interface expected by the listener - Wrapper implements: CreateReplicationSlot, DropReplicationSlot, StartReplication, ReceiveMessage, SendStandbyStatusUpdate, IsAlive, Close - Updated imports to use pgx/v5 and pglogrepl packages ### Listener (internal/listener/listener.go) - Changed lsn field type from uint64 to pglogrepl.LSN - Updated replication interface to use pglogrepl types: - CreateReplicationSlot returns pglogrepl.CreateReplicationSlotResult - StartReplication uses pglogrepl.LSN and pglogrepl.StartReplicationOptions - SendStandbyStatusUpdate uses pglogrepl.StandbyStatusUpdate - ReceiveMessage returns raw []byte instead of structured messages - Rewrote processRawMessage to handle raw byte messages using pglogrepl.ParseXLogData and pglogrepl.ParsePrimaryKeepaliveMessage - Updated SendStandbyStatus and AckWalMessage to take context parameter ### Repository (internal/listener/repository.go) - Updated to pgx/v5 API (QueryRow instead of QueryRowEx) - Close now takes context parameter - IsAlive uses IsClosed() method ### Tests - Updated all mock implementations for new interface signatures - Rewrote test helper functions to use pglogrepl types - Simplified test cases by removing obsolete NewStandbyStatus calls All listener tests pass. --------- Signed-off-by: Tamal Saha <tamal@appscode.com> Signed-off-by: Imtiaz Uddin <imtiaz@appscode.com> Co-authored-by: Imtiaz Uddin <imtiaz@appscode.com>
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
This PR migrates the PostgreSQL logical replication implementation from the legacy pgx v3 API to the modern pglogrepl library with pgx/v5.
Changes
Dependencies (go.mod)
github.com/jackc/pgx v3.6.2+incompatiblewith:github.com/jackc/pglogrepl v0.0.0-20251213150135-2e8d0df862c1github.com/jackc/pgx/v5 v5.8.0Main Application (cmd/pgoutbox/init.go)
replicationConnwrapper struct that adapts*pgconn.PgConnto the replication interface expected by the listenerCreateReplicationSlot,DropReplicationSlot,StartReplication,ReceiveMessage,SendStandbyStatusUpdate,IsAlive,CloseListener (internal/listener/listener.go)
lsnfield type fromuint64topglogrepl.LSNreplicationinterface to use pglogrepl types:CreateReplicationSlotreturnspglogrepl.CreateReplicationSlotResultStartReplicationusespglogrepl.LSNandpglogrepl.StartReplicationOptionsSendStandbyStatusUpdateusespglogrepl.StandbyStatusUpdateReceiveMessagereturns raw[]byteinstead of structured messagesprocessRawMessageto handle raw byte messages usingpglogrepl.ParseXLogDataandpglogrepl.ParsePrimaryKeepaliveMessageSendStandbyStatusandAckWalMessageto take context parameterRepository (internal/listener/repository.go)
QueryRowinstead ofQueryRowEx)Closenow takes context parameterIsAliveusesIsClosed()methodTests
NewStandbyStatuscallsTesting
TestListener_Streamremains skipped (pre-existing, requires further work)