https://github.com/figma/pglogrepl
PostgreSQL logical replication library for Go.
https://github.com/figma/pglogrepl
Last synced: 5 months ago
JSON representation
PostgreSQL logical replication library for Go.
- Host: GitHub
- URL: https://github.com/figma/pglogrepl
- Owner: figma
- License: mit
- Fork: true (jackc/pglogrepl)
- Created: 2019-12-17T00:36:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-21T22:06:32.000Z (over 4 years ago)
- Last Synced: 2025-10-02T22:35:18.229Z (9 months ago)
- Language: Go
- Size: 19.5 KB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://godoc.org/github.com/jackc/pglogrepl)
[](https://travis-ci.org/jackc/pglogrepl)
# 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:secret@127.0.0.1/pglogrepl?replication=database go test
```