connect_with_retry

Function connect_with_retry 

Source
pub async fn connect_with_retry(connection_string: &str) -> Result<Client>
Expand description

Connect to PostgreSQL with automatic retry for transient failures

Attempts to connect up to 3 times with exponential backoff (1s, 2s, 4s). Useful for handling temporary network issues or server restarts.

§Arguments

  • connection_string - PostgreSQL URL

§Returns

Returns a Client after successful connection, or error after all retries exhausted.

§Errors

Returns the last connection error if all retry attempts fail.

§Examples

let client = connect_with_retry("postgresql://user:pass@localhost:5432/mydb").await?;