pub struct ReplicationConfig {Show 13 fields
pub host: String,
pub port: u16,
pub user: String,
pub password: String,
pub database: String,
pub tls: TlsConfig,
pub slot: String,
pub publication: String,
pub start_lsn: Lsn,
pub stop_at_lsn: Option<Lsn>,
pub status_interval: Duration,
pub idle_wakeup_interval: Duration,
pub buffer_events: usize,
}Expand description
Configuration for PostgreSQL logical replication connections.
§Example
use pgwire_replication::config::{ReplicationConfig, TlsConfig, SslMode};
use pgwire_replication::lsn::Lsn;
use std::time::Duration;
let config = ReplicationConfig {
host: "db.example.com".into(),
port: 5432,
user: "replicator".into(),
password: "secret".into(),
database: "mydb".into(),
slot: "my_slot".into(),
publication: "my_publication".into(),
tls: TlsConfig::verify_full(Some("/path/to/ca.pem".into())),
start_lsn: Lsn(0), // Start from slot's confirmed position
..Default::default()
};Fields§
§host: StringPostgreSQL server hostname or IP address.
port: u16PostgreSQL server port (default: 5432).
user: StringPostgreSQL username with replication privileges.
The user must have the REPLICATION attribute or be a superuser.
password: StringPassword for authentication.
database: StringDatabase name to connect to.
tls: TlsConfigTLS/SSL configuration.
slot: StringName of the replication slot to use.
The slot must already exist and be a logical replication slot
using the pgoutput plugin.
publication: StringName of the publication to subscribe to.
The publication must exist and include the tables you want to replicate.
start_lsn: LsnLSN position to start replication from.
Lsn(0): Start from slot’sconfirmed_flush_lsn- Specific LSN: Resume from that position (must be >= slot’s restart_lsn)
stop_at_lsn: Option<Lsn>Optional LSN to stop replication at.
When set, replication will stop once a commit with end_lsn >= stop_at_lsn
is received. Useful for:
- Bounded replay (e.g., point-in-time recovery)
- Testing with known data ranges
If None, replication continues indefinitely (normal CDC mode).
status_interval: DurationInterval for sending standby status updates to the server.
Status updates inform PostgreSQL of the client’s replay position, allowing the server to release WAL segments. Too infrequent updates may cause WAL accumulation; too frequent updates add overhead.
Default: 1 second (matches pg_recvlogical)
idle_wakeup_interval: DurationMaximum time to wait for server messages before waking up.
Silence is normal during logical replication. When this interval elapses with no incoming messages, the client will send a standby status update (feedback) and continue waiting.
This effectively bounds how long the worker can stay blocked in a read while idle.
Default: 10 seconds
buffer_events: usizeSize of the bounded event buffer between replication worker and consumer.
Larger buffers can smooth out processing latency spikes but use more memory. Each event is typically 100-1000 bytes depending on row size.
Default: 8192 events
Implementations§
Source§impl ReplicationConfig
impl ReplicationConfig
Sourcepub fn new(
host: impl Into<String>,
user: impl Into<String>,
password: impl Into<String>,
database: impl Into<String>,
slot: impl Into<String>,
publication: impl Into<String>,
) -> Self
pub fn new( host: impl Into<String>, user: impl Into<String>, password: impl Into<String>, database: impl Into<String>, slot: impl Into<String>, publication: impl Into<String>, ) -> Self
Create a new configuration with required fields.
Other fields use defaults and can be customized with builder methods.
§Example
use pgwire_replication::config::ReplicationConfig;
let config = ReplicationConfig::new(
"db.example.com",
"replicator",
"secret",
"mydb",
"my_slot",
"my_pub",
);Sourcepub fn with_start_lsn(self, lsn: Lsn) -> Self
pub fn with_start_lsn(self, lsn: Lsn) -> Self
Set the starting LSN.
Sourcepub fn with_stop_lsn(self, lsn: Lsn) -> Self
pub fn with_stop_lsn(self, lsn: Lsn) -> Self
Set an optional stop LSN for bounded replay.
Sourcepub fn with_status_interval(self, interval: Duration) -> Self
pub fn with_status_interval(self, interval: Duration) -> Self
Set the status update interval.
Sourcepub fn with_wakeup_interval(self, timeout: Duration) -> Self
pub fn with_wakeup_interval(self, timeout: Duration) -> Self
Set the idle wakeup interval.
Sourcepub fn with_buffer_size(self, size: usize) -> Self
pub fn with_buffer_size(self, size: usize) -> Self
Set the event buffer size.
Sourcepub fn display_connection(&self) -> String
pub fn display_connection(&self) -> String
Returns the connection string for display (password masked).
Useful for logging without exposing credentials.
Trait Implementations§
Source§impl Clone for ReplicationConfig
impl Clone for ReplicationConfig
Source§fn clone(&self) -> ReplicationConfig
fn clone(&self) -> ReplicationConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more