{"id":50812732,"url":"https://github.com/pgx-contrib/pgxrepl","last_synced_at":"2026-06-13T06:33:39.071Z","repository":{"id":352131996,"uuid":"815188400","full_name":"pgx-contrib/pgxrepl","owner":"pgx-contrib","description":"Change data capture for pgx v5 — typed logical replication events with CollectableRow scanning and at-least-once delivery","archived":false,"fork":false,"pushed_at":"2026-06-07T09:22:45.000Z","size":68,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-06-07T11:14:54.437Z","etag":null,"topics":["cdc","change-data-capture","go","golang","logical-replication","pgoutput","pgx","postgres","postgresql","replication","wal"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/pgx-contrib/pgxrepl","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgx-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-06-14T14:41:44.000Z","updated_at":"2026-06-07T09:22:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pgx-contrib/pgxrepl","commit_stats":null,"previous_names":["pgx-contrib/pgxrepl"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pgx-contrib/pgxrepl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxrepl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxrepl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxrepl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxrepl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgx-contrib","download_url":"https://codeload.github.com/pgx-contrib/pgxrepl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgx-contrib%2Fpgxrepl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34275068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cdc","change-data-capture","go","golang","logical-replication","pgoutput","pgx","postgres","postgresql","replication","wal"],"created_at":"2026-06-13T06:33:38.671Z","updated_at":"2026-06-13T06:33:39.066Z","avatar_url":"https://github.com/pgx-contrib.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgxrepl\n\n[![CI](https://github.com/pgx-contrib/pgxrepl/actions/workflows/ci.yml/badge.svg)](https://github.com/pgx-contrib/pgxrepl/actions/workflows/ci.yml)\n[![Release](https://img.shields.io/github/v/release/pgx-contrib/pgxrepl)](https://github.com/pgx-contrib/pgxrepl/releases)\n[![Go Reference](https://pkg.go.dev/badge/github.com/pgx-contrib/pgxrepl.svg)](https://pkg.go.dev/github.com/pgx-contrib/pgxrepl)\n[![License](https://img.shields.io/github/license/pgx-contrib/pgxrepl)](LICENSE)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/pgx-contrib/pgxrepl)](go.mod)\n[![pgx Version](https://img.shields.io/badge/pgx-v5-blue)](https://github.com/jackc/pgx)\n\nLogical replication consumer for [pgx v5](https://github.com/jackc/pgx).\n\n## Features\n\n- Typed `Insert`, `Update`, `Delete`, and `Truncate` events with `BEGIN` / `COMMIT` framing\n- Replicated rows expose `pgx.CollectableRow` — decode with `pgx.RowTo` / `pgx.RowToStructByName`\n- Slot and publication helpers (`CreateSlot`, `DropSlot`, `CreatePublication`, `DropPublication`)\n- At-least-once delivery — the slot advances only after `HandleCommit` returns nil, so failed transactions replay on restart\n\n## Installation\n\n```bash\ngo get github.com/pgx-contrib/pgxrepl\n```\n\nYour Postgres server must be configured with `wal_level=logical`.\n\n## Usage\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"os\"\n\n    \"github.com/jackc/pgx/v5\"\n    \"github.com/jackc/pgx/v5/pgconn\"\n    \"github.com/pgx-contrib/pgxrepl\"\n)\n\ntype Logger struct{}\n\nfunc (Logger) HandleBegin(op *pgxrepl.BeginOperation) error    { return nil }\nfunc (Logger) HandleCommit(op *pgxrepl.CommitOperation) error  { return nil }\nfunc (Logger) HandleInsert(op *pgxrepl.InsertOperation) error {\n    var id int\n    var name string\n    if err := op.NewRow.Scan(\u0026id, \u0026name); err != nil {\n        return err\n    }\n    // ... forward to your sink\n    return nil\n}\nfunc (Logger) HandleUpdate(op *pgxrepl.UpdateOperation) error     { return nil }\nfunc (Logger) HandleDelete(op *pgxrepl.DeleteOperation) error     { return nil }\nfunc (Logger) HandleTruncate(op *pgxrepl.TruncateOperation) error { return nil }\n\nfunc main() {\n    ctx := context.Background()\n    dsn := os.Getenv(\"PGX_DATABASE_URL\")\n\n    // 1. Create a publication on a normal connection.\n    normal, err := pgconn.Connect(ctx, dsn)\n    must(err)\n    must(pgxrepl.CreatePublication(ctx, normal, \"users_pub\", []pgx.Identifier{{\"public\", \"users\"}}))\n    must(normal.Close(ctx))\n\n    // 2. Create a slot on a replication connection.\n    cfg, err := pgconn.ParseConfig(dsn)\n    must(err)\n    cfg.RuntimeParams[\"replication\"] = \"database\"\n    repl, err := pgconn.ConnectConfig(ctx, cfg)\n    must(err)\n    must(pgxrepl.CreateSlot(ctx, repl, \"users_slot\"))\n\n    // 3. Run the broker.\n    broker := \u0026pgxrepl.Broker{\n        Conn:        repl,\n        Handler:     Logger{},\n        Slot:        \"users_slot\",\n        Publication: \"users_pub\",\n    }\n    must(broker.Run(ctx))\n}\n\nfunc must(err error) { if err != nil { panic(err) } }\n```\n\n## Non-goals\n\npgxrepl deliberately stays narrow. The following pgoutput features are not handled, and there are no plans to add them:\n\n- Streaming in-progress transactions (`StreamStart` / `StreamStop` / `StreamCommit` / `StreamAbort`)\n- `Origin`, `Type`, and `LogicalDecodingMessage` events\n- Physical replication\n\nIf you need any of these, drive [pglogrepl](https://github.com/jackc/pglogrepl) directly.\n\n## Development\n\n### DevContainer\n\nOpen in VS Code with the Dev Containers extension. The environment provides Go,\nNix, and a PostgreSQL 18 instance started with `wal_level=logical`.\n\n```\nPGX_DATABASE_URL=postgres://vscode@postgres:5432/pgxrepl?sslmode=disable\n```\n\n### Nix\n\n```bash\nnix develop          # enter shell with Go\ngo tool ginkgo run -r\n```\n\n### Run tests\n\n```bash\n# Unit tests only (no database required — integration specs skip)\ngo tool ginkgo run -r\n\n# With integration tests\nexport PGX_DATABASE_URL=\"postgres://localhost/pgxrepl?sslmode=disable\"\ngo tool ginkgo run -r\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgx-contrib%2Fpgxrepl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgx-contrib%2Fpgxrepl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgx-contrib%2Fpgxrepl/lists"}