#[non_exhaustive]pub struct ReplicationConfig {Show 14 fields
pub host: String,
pub port: u16,
pub user: String,
pub password: String,
pub database: String,
pub tls: TlsConfig,
pub slot: String,
pub publication: Publication,
pub start_lsn: Lsn,
pub stop_at_lsn: Option<Lsn>,
pub status_interval: Duration,
pub idle_wakeup_interval: Duration,
pub buffer_events: usize,
pub binary: bool,
}Expand description
Configuration for PostgreSQL logical replication connections.
§Example
use pgwire_replication::config::{ReplicationConfig, TlsConfig};
let config = ReplicationConfig::new(
"db.example.com",
"replicator",
"secret",
"mydb",
"my_slot",
"my_publication",
)
.with_tls(TlsConfig::verify_full(Some("/path/to/ca.pem".into())));This struct is #[non_exhaustive]: construct it with ReplicationConfig::new
(or unix) plus the with_* builder methods
rather than a struct literal, so new fields can be added without breaking you.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.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: PublicationPublication(s) to subscribe to.
Each publication must exist and include the tables you want to replicate.
Accepts a single name or a collection — see Publication.
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
binary: boolRequest column values in PostgreSQL binary wire format.
When true, the binary 'true' option is added to START_REPLICATION
and pgoutput encodes column values using each type’s binary send
function instead of text output.
This does not change anything the library parses — the worker decodes
only Begin/Commit/Message boundaries and forwards XLogData tuple bytes
raw — so it is the consumer’s decoder that must handle binary values.
Leave as false (the default) unless you control both ends and have
measured a real win: any column whose type lacks a binary send function
makes the walsender error and close the replication stream.
Requires PostgreSQL 14 or newer.
Default: false
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<Publication>,
) -> 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<Publication>, ) -> 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 is_unix_socket(&self) -> bool
pub fn is_unix_socket(&self) -> bool
Returns true if host refers to a Unix domain socket directory.
Following libpq convention, a host starting with / is treated as
the directory containing the PostgreSQL Unix socket file.
Sourcepub fn unix_socket_path(&self) -> PathBuf
pub fn unix_socket_path(&self) -> PathBuf
Returns the full Unix socket path: {host}/.s.PGSQL.{port}.
§Panics
Panics if host does not start with / (i.e. is_unix_socket() is false).
Sourcepub fn unix(
socket_dir: impl Into<String>,
port: u16,
user: impl Into<String>,
password: impl Into<String>,
database: impl Into<String>,
slot: impl Into<String>,
publication: impl Into<Publication>,
) -> Self
pub fn unix( socket_dir: impl Into<String>, port: u16, user: impl Into<String>, password: impl Into<String>, database: impl Into<String>, slot: impl Into<String>, publication: impl Into<Publication>, ) -> Self
Create a configuration for connecting via Unix domain socket.
socket_dir is the directory containing the PostgreSQL socket file
(e.g. /var/run/postgresql). The actual socket path will be
{socket_dir}/.s.PGSQL.{port}.
TLS is automatically disabled for Unix socket connections.
§Example
use pgwire_replication::config::ReplicationConfig;
let config = ReplicationConfig::unix(
"/var/run/postgresql",
5432,
"replicator",
"secret",
"mydb",
"my_slot",
"my_pub",
);
assert!(config.is_unix_socket());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 with_binary(self, binary: bool) -> Self
pub fn with_binary(self, binary: bool) -> Self
Request binary-format column values from pgoutput (requires PG 14+).
See binary for caveats — off by default.
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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more