pgwire-replication is a high-performance client for PostgreSQL logical replication, leveraging the wire protocol for minimal overhead. Ideal for CDC, change streaming, and WAL replay systems, it offers explicit control over replication state and deterministic behavior, making it a robust choice for developers seeking efficiency.
This low-level, high-performance PostgreSQL logical replication client is built directly on top of the PostgreSQL wire protocol (pgwire). It is specifically designed for Change Data Capture (CDC), change streaming, and WAL replay systems, providing developers with explicit control over replication state, deterministic restart behavior, and minimal runtime overhead.
libpq or tokio-postgres.Here is a simple example of how to integrate pgwire-replication into an application:
use pgwire_replication::{ReplicationClient, ReplicationEvent};
let mut repl = ReplicationClient::connect(config).await?;
while let Some(event) = repl.recv().await? {
match event {
ReplicationEvent::XLogData { wal_end, data, .. } => {
process(data);
repl.update_applied_lsn(wal_end);
}
ReplicationEvent::KeepAlive { .. } => {}
ReplicationEvent::StoppedAt { reached } => break,
}
}
// Clean end-of-stream
The pgwire-replication crate allows for controlled replay of WAL using explicit LSNs, providing a way to pause and resume replication based on specified positions. This is particularly useful for ensuring data consistency during recovery or backfill operations.
As a focused library for PostgreSQL logical replication, pgwire-replication stands out by providing specialized functions necessary for performance-sensitive applications. Its direct interaction with the PostgreSQL wire protocol makes it an optimal choice for systems that rely on efficient change data capture with minimal latency and overhead.
No comments yet.
Sign in to be the first to comment.