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::StoppedAt {reached: _} => break,
42//! ReplicationEvent::Begin { .. } => println!(
43//! "Transaction start, probably want to flush in-flight events to the sinks."
44//! ),
45//! ReplicationEvent::Commit { .. } => println!(
46//! "Transanction finished, good time to store a checkpoint at the higher level."
47//! ),
48//! }
49//! }
50//! # Ok(())
51//! # }
52//! ```
53//!
54//! ## Feature Flags
55//!
56//! - `tls-rustls` (default) - TLS support via rustls
57//! - `scram` (default) - SCRAM-SHA-256 authentication
58//! - `md5` - MD5 authentication (legacy)
59
60#![warn(
61 clippy::all,
62 clippy::cargo,
63 clippy::perf,
64 clippy::style,
65 clippy::correctness,
66 clippy::suspicious
67)]
68#![allow(
69 clippy::module_name_repetitions,
70 clippy::missing_errors_doc,
71 clippy::missing_panics_doc,
72 clippy::must_use_candidate,
73 clippy::multiple_crate_versions
74)]
75
76pub mod auth;
77pub mod client;
78pub mod config;
79pub mod error;
80pub mod lsn;
81pub mod protocol;
82pub mod tls;
83
84pub use client::{ReplicationClient, ReplicationEvent, ReplicationEventReceiver};
85pub use config::{ReplicationConfig, SslMode, TlsConfig};
86pub use error::{PgWireError, Result};
87pub use lsn::Lsn;