Skip to main content

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//!
17//! # async fn example() -> anyhow::Result<()> {
18//! let config = ReplicationConfig::new(
19//!     "localhost",
20//!     "postgres",
21//!     "secret",
22//!     "mydb",
23//!     "my_slot",
24//!     "my_publication",
25//! )
26//! .with_start_lsn(Lsn::ZERO);
27//!
28//! let mut client = ReplicationClient::connect(config).await?;
29//!
30//! while let Some(ev) = client.recv().await? {
31//!     match ev {
32//!         ReplicationEvent::XLogData { wal_end, data, .. } => {
33//!             println!("Got data at {}: {} bytes", wal_end, data.len());
34//!         }
35//!         ReplicationEvent::KeepAlive { wal_end, .. } => {
36//!             println!("Keepalive at {}", wal_end);
37//!         }
38//!         ReplicationEvent::Message { prefix, content, .. } => println!(
39//!             "Logical message: prefix={}, {} bytes", prefix, content.len()
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::{
85    ReplicationClient, ReplicationEvent, ReplicationEventReceiver, ReplicationMetrics,
86};
87pub use config::{Publication, ReplicationConfig, SslMode, TlsConfig};
88pub use error::{PgWireError, Result};
89pub use lsn::Lsn;