pgfeed
Version, currently main branch1 version
- main branchlatestMay 18, 2025
github.com/jabr/pgfeed
Consume PostgreSQL logical replication INSERT stream and send to sink
Installation
# Add this to your shard.yml
dependencies:
pgfeed:
github: jabr/pgfeed
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
>= 1.16.2- License
- MIT
- Author
- Justin Bradford
- Target
pgfeedfrom src/main.cr
Dependencies
This version declares no dependencies.
README
pgfeed
This utility reads a standard PostgreSQL pgoutput logical replication slot (in text or binary mode) and sends INSERT records to the configured upstream sink.
Supported sinks
- stdout
- AMQP (todo)
LSN save point
The replicated LSN position is periodically written to file (e.g. replicated.lsn) and used as the starting point sent to Postgres on subsequent starts.
Architecture
- PostgreSQL replication runs in an isolated thread, using the
libpqlibrary with blocking I/O. - Writes to upstream sink use an asynchronous I/O runtime in its own, dedicated thread.
- Logging output and periodic replicated LSN position checkpoint writes occur in a third (parent) thread.
Crystal
This currently requires the -Dpreview_mt -Dexecution_context options to enable execution contexts in Crystal.
Replication setup in Postgres
-- Enable logical replication in postgresql.conf:
-- wal_level = logical
-- max_replication_slots = 10
-- max_wal_senders = 10
-- Create a replication role
CREATE ROLE repuser WITH REPLICATION LOGIN PASSWORD 'reppass';
-- Create a publication
CREATE PUBLICATION my_pub FOR ALL TABLES;
-- Create a logical replication slot
SELECT * FROM pg_create_logical_replication_slot('my_slot', 'pgoutput');
References
License
This project is licensed under the terms of the MIT license.
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- May 18, 2025
- Crystal
>= 1.16.2- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/jabr/pgfeed
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 15, 2026
- Versions
- 1