Expand description
§pgwire-replication
A Tokio-based PostgreSQL logical replication client implementing the pgoutput protocol.
§Features
- Async/await - Built on Tokio for high-performance async I/O
- TLS support - Optional rustls-based encryption with verify modes
- SCRAM-SHA-256 - Secure password authentication
- pgoutput protocol - Native logical replication decoding
§Quick Start
use pgwire_replication::{ReplicationClient, ReplicationConfig, ReplicationEvent, Lsn};
use std::time::Duration;
let config = ReplicationConfig {
host: "localhost".into(),
port: 5432,
user: "postgres".into(),
password: "secret".into(),
database: "mydb".into(),
slot: "my_slot".into(),
publication: "my_publication".into(),
start_lsn: Lsn::ZERO,
..Default::default()
};
let mut client = ReplicationClient::connect(config).await?;
while let Some(ev) = client.recv().await? {
match ev {
ReplicationEvent::XLogData { wal_end, data, .. } => {
println!("Got data at {}: {} bytes", wal_end, data.len());
}
ReplicationEvent::KeepAlive { wal_end, .. } => {
println!("Keepalive at {}", wal_end);
}
ReplicationEvent::StoppedAt {reached: _} => break,
ReplicationEvent::Begin { .. } => println!(
"Transaction start, probably want to flush in-flight events to the sinks."
),
ReplicationEvent::Commit { .. } => println!(
"Transanction finished, good time to store a checkpoint at the higher level."
),
}
}§Feature Flags
tls-rustls(default) - TLS support via rustlsscram(default) - SCRAM-SHA-256 authenticationmd5- MD5 authentication (legacy)
Re-exports§
pub use client::ReplicationClient;pub use client::ReplicationEvent;pub use client::ReplicationEventReceiver;pub use config::ReplicationConfig;pub use config::SslMode;pub use config::TlsConfig;pub use error::PgWireError;pub use error::Result;pub use lsn::Lsn;
Modules§
- auth
- Authentication mechanisms for PostgreSQL connections.
- client
- PostgreSQL logical replication client.
- config
- Configuration types for PostgreSQL replication connections.
- error
- Error types for pgwire-replication.
- lsn
- PostgreSQL Log Sequence Number (LSN) type.
- protocol
- PostgreSQL wire protocol implementation.
- tls