pub struct ReplicationConnectionRetry { /* private fields */ }Expand description
Retry wrapper for PostgreSQL replication connection operations
Implementations§
Source§impl ReplicationConnectionRetry
impl ReplicationConnectionRetry
Sourcepub fn new(config: RetryConfig, connection_string: String) -> Self
pub fn new(config: RetryConfig, connection_string: String) -> Self
Create a new retry wrapper
Sourcepub async fn connect_with_retry(&self) -> Result<PgReplicationConnection>
pub async fn connect_with_retry(&self) -> Result<PgReplicationConnection>
Retry connection establishment with exponential backoff
Attempts to establish a PostgreSQL replication connection with automatic retry logic. Uses exponential backoff with optional jitter to handle transient connection failures gracefully.
§Returns
Returns a connected PgReplicationConnection on success.
§Errors
Returns an error if:
- All retry attempts are exhausted
- Maximum duration is exceeded
- The connection string is invalid — returned immediately on the first attempt, without consuming the remaining attempts or the backoff. Other permanent errors (authentication, missing database) are still retried: the server reports a transient directory outage with the same SQLSTATE as a wrong password, so failing fast on those would turn a recoverable blip into an outage.
§Example
use pg_walstream::{ReplicationConnectionRetry, RetryConfig};
let retry_handler = ReplicationConnectionRetry::new(
RetryConfig::default(),
"postgresql://postgres:password@localhost/mydb?replication=database".to_string(),
);
let connection = retry_handler.connect_with_retry().await?;Auto Trait Implementations§
impl Freeze for ReplicationConnectionRetry
impl RefUnwindSafe for ReplicationConnectionRetry
impl Send for ReplicationConnectionRetry
impl Sync for ReplicationConnectionRetry
impl Unpin for ReplicationConnectionRetry
impl UnsafeUnpin for ReplicationConnectionRetry
impl UnwindSafe for ReplicationConnectionRetry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more