Categorygithub.com/Slava/pglogrepl
modulepackage
1.1.0-fork2
Repository: https://github.com/slava/pglogrepl.git
Documentation: pkg.go.dev

# README

Build Status

pglogrepl

pglogrepl is a Go package for PostgreSQL logical replication.

pglogrepl uses package github.com/jackc/pgconn as its underlying PostgreSQL connection.

Proper use of this package requires understanding the underlying PostgreSQL concepts. See https://www.postgresql.org/docs/current/protocol-replication.html.

Example

In example/pglogrepl_demo, there is an example demo program that connects to a database and logs all messages sent over logical replication.

Testing

Testing requires a user with replication permission, a database to replicate, access allowed in pg_hba.conf, and logical replication enabled in postgresql.conf.

Create a database:

create database pglogrepl;

Create a user:

create user pglogrepl with replication password 'secret';

Add a replication line to your pg_hba.conf:

host replication pglogrepl 127.0.0.1/32 md5

Change the following settings in your postgresql.conf:

wal_level=logical
max_wal_senders=5
max_replication_slots=5

To run the tests set PGLOGREPL_TEST_CONN_STRING environment variable with a replication connection string (URL or DSN).

Example:

PGLOGREPL_TEST_CONN_STRING=postgres://pglogrepl:[email protected]/pglogrepl?replication=database go test

# Packages

No description provided by the author

# Functions

CreateReplicationSlot creates a logical replication slot.
DropReplicationSlot drops a logical replication slot.
IdentifySystem executes the IDENTIFY_SYSTEM command.
ParseCreateReplicationSlot parses the result of the CREATE_REPLICATION_SLOT command.
ParseIdentifySystem parses the result of the IDENTIFY_SYSTEM command.
Parse the given XXX/XXX text format LSN used by PostgreSQL.
ParsePrimaryKeepaliveMessage parses a Primary keepalive message from the server.
ParseXLogData parses a XLogData message from the server.
SendStandbyStatusUpdate sends a StandbyStatusUpdate to the PostgreSQL server.
StartReplication begins the replication process by executing the START_REPLICATION command.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
CreateReplicationSlotResult is the parsed results the CREATE_REPLICATION_SLOT command.
No description provided by the author
IdentifySystemResult is the parsed result of the IDENTIFY_SYSTEM command.
No description provided by the author
StandbyStatusUpdate is a message sent from the client that acknowledges receipt of WAL records.
No description provided by the author
No description provided by the author

# Type aliases

LSN is a PostgreSQL Log Sequence Number.