pgwire_replication/lib.rs
1//! # pgwire-replication
2//!
3//! A Tokio-based PostgreSQL logical replication client implementing the pgoutput protocol.
4//!
5//! ## Features
6//!
7//! - **Async/await** - Built on Tokio for high-performance async I/O
8//! - **TLS support** - Optional rustls-based encryption with verify modes
9//! - **SCRAM-SHA-256** - Secure password authentication
10//! - **pgoutput protocol** - Native logical replication decoding
11//!
12//! ## Quick Start
13//!
14//! ```rust,no_run
15//! use pgwire_replication::{ReplicationClient, ReplicationConfig, ReplicationEvent, Lsn};
16//! use std::time::Duration;
17//!
18//! # async fn example() -> anyhow::Result<()> {
19//! let config = ReplicationConfig {
20//! host: "localhost".into(),
21//! port: 5432,
22//! user: "postgres".into(),
23//! password: "secret".into(),
24//! database: "mydb".into(),
25//! slot: "my_slot".into(),
26//! publication: "my_publication".into(),
27//! start_lsn: Lsn::ZERO,
28//! ..Default::default()
29//! };
30//!
31//! let mut client = ReplicationClient::connect(config).await?;
32//!
33//! while let Some(ev) = client.recv().await? {
34//! match ev {
35//! ReplicationEvent::XLogData { wal_end, data, .. } => {
36//! println!("Got data at {}: {} bytes", wal_end, data.len());
37//! }
38//! ReplicationEvent::KeepAlive { wal_end, .. } => {
39//! println!("Keepalive at {}", wal_end);
40//! }
41//! ReplicationEvent::Message { prefix, content, .. } => println!(
42//! "Logical message: prefix={}, {} bytes", prefix, content.len()
43//! ),
44//! ReplicationEvent::StoppedAt {reached: _} => break,
45//! ReplicationEvent::Begin { .. } => println!(
46//! "Transaction start, probably want to flush in-flight events to the sinks."
47//! ),
48//! ReplicationEvent::Commit { .. } => println!(
49//! "Transanction finished, good time to store a checkpoint at the higher level."
50//! ),
51//! }
52//! }
53//! # Ok(())
54//! # }
55//! ```
56//!
57//! ## Feature Flags
58//!
59//! - `tls-rustls` (default) - TLS support via rustls
60//! - `scram` (default) - SCRAM-SHA-256 authentication
61//! - `md5` - MD5 authentication (legacy)
62
63#![warn(
64 clippy::all,
65 clippy::cargo,
66 clippy::perf,
67 clippy::style,
68 clippy::correctness,
69 clippy::suspicious
70)]
71#![allow(
72 clippy::module_name_repetitions,
73 clippy::missing_errors_doc,
74 clippy::missing_panics_doc,
75 clippy::must_use_candidate,
76 clippy::multiple_crate_versions
77)]
78
79pub mod auth;
80pub mod client;
81pub mod config;
82pub mod error;
83pub mod lsn;
84pub mod protocol;
85pub mod tls;
86
87pub use client::{ReplicationClient, ReplicationEvent, ReplicationEventReceiver};
88pub use config::{ReplicationConfig, SslMode, TlsConfig};
89pub use error::{PgWireError, Result};
90pub use lsn::Lsn;