ReplicationConfig

Struct ReplicationConfig 

Source
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: String

PostgreSQL server hostname or IP address.

§port: u16

PostgreSQL server port (default: 5432).

§user: String

PostgreSQL username with replication privileges.

The user must have the REPLICATION attribute or be a superuser.

§password: String

Password for authentication.

§database: String

Database name to connect to.

§tls: TlsConfig

TLS/SSL configuration.

§slot: String

Name of the replication slot to use.

The slot must already exist and be a logical replication slot using the pgoutput plugin.

§publication: String

Name of the publication to subscribe to.

The publication must exist and include the tables you want to replicate.

§start_lsn: Lsn

LSN position to start replication from.

  • Lsn(0): Start from slot’s confirmed_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: Duration

Interval 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: Duration

Maximum 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: usize

Size 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

Source

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",
);
Source

pub fn with_port(self, port: u16) -> Self

Set the server port.

Source

pub fn with_tls(self, tls: TlsConfig) -> Self

Set TLS configuration.

Source

pub fn with_start_lsn(self, lsn: Lsn) -> Self

Set the starting LSN.

Source

pub fn with_stop_lsn(self, lsn: Lsn) -> Self

Set an optional stop LSN for bounded replay.

Source

pub fn with_status_interval(self, interval: Duration) -> Self

Set the status update interval.

Source

pub fn with_wakeup_interval(self, timeout: Duration) -> Self

Set the idle wakeup interval.

Source

pub fn with_buffer_size(self, size: usize) -> Self

Set the event buffer size.

Source

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

Source§

fn clone(&self) -> ReplicationConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ReplicationConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ReplicationConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ReplicationConfig

Source§

fn eq(&self, other: &ReplicationConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ReplicationConfig

Source§

impl StructuralPartialEq for ReplicationConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more