Support keepalive interval and retries.
This commit is contained in:
@@ -48,6 +48,10 @@ use tokio_postgres::{Error, Socket};
|
||||
/// This option is ignored when connecting with Unix sockets. Defaults to on.
|
||||
/// * `keepalives_idle` - The number of seconds of inactivity after which a keepalive message is sent to the server.
|
||||
/// This option is ignored when connecting with Unix sockets. Defaults to 2 hours.
|
||||
/// * `keepalives_interval` - The time interval between TCP keepalive probes.
|
||||
/// This option is ignored when connecting with Unix sockets. Available on neither Redox nor Solaris.
|
||||
/// * `keepalives_retries` - The maximum number of TCP keepalive probes that will be sent before dropping a connection.
|
||||
/// This option is ignored when connecting with Unix sockets. Available on neither Redox, Solaris nor Windows.
|
||||
/// * `target_session_attrs` - Specifies requirements of the session. If set to `read-write`, the client will check that
|
||||
/// the `transaction_read_write` session parameter is set to `on`. This can be used to connect to the primary server
|
||||
/// in a database cluster as opposed to the secondary read-only mirrors. Defaults to `all`.
|
||||
@@ -279,6 +283,45 @@ impl Config {
|
||||
self.config.get_keepalives_idle()
|
||||
}
|
||||
|
||||
/// Sets the time interval between TCP keepalive probes.
|
||||
/// On Windows, this sets the value of the tcp_keepalive struct’s keepaliveinterval field.
|
||||
///
|
||||
/// This is ignored for Unix domain sockets, or if the `keepalives` option is disabled.
|
||||
///
|
||||
/// Available on neither Redox nor Solaris.
|
||||
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
|
||||
pub fn keepalives_interval(&mut self, keepalives_interval: Duration) -> &mut Config {
|
||||
self.config.keepalives_interval(keepalives_interval);
|
||||
self
|
||||
}
|
||||
|
||||
/// Gets the time interval between TCP keepalive probes.
|
||||
///
|
||||
/// Available on neither Redox nor Solaris.
|
||||
#[cfg(not(any(target_os = "redox", target_os = "solaris")))]
|
||||
pub fn get_keepalives_interval(&self) -> Option<&Duration> {
|
||||
self.config.get_keepalives_interval()
|
||||
}
|
||||
|
||||
/// Sets the maximum number of TCP keepalive probes that will be sent before dropping a connection.
|
||||
///
|
||||
/// This is ignored for Unix domain sockets, or if the `keepalives` option is disabled.
|
||||
///
|
||||
/// Available on neither Redox, Solaris nor Windows.
|
||||
#[cfg(not(any(target_os = "redox", target_os = "solaris", target_os = "windows")))]
|
||||
pub fn keepalives_retries(&mut self, keepalives_retries: u32) -> &mut Config {
|
||||
self.config.keepalives_retries(keepalives_retries);
|
||||
self
|
||||
}
|
||||
|
||||
/// Gets the maximum number of TCP keepalive probes that will be sent before dropping a connection.
|
||||
///
|
||||
/// Available on neither Redox, Solaris nor Windows.
|
||||
#[cfg(not(any(target_os = "redox", target_os = "solaris", target_os = "windows")))]
|
||||
pub fn get_keepalives_retries(&self) -> Option<&u32> {
|
||||
self.config.get_keepalives_retries()
|
||||
}
|
||||
|
||||
/// Sets the requirements of the session.
|
||||
///
|
||||
/// This can be used to connect to the primary server in a clustered database rather than one of the read-only
|
||||
|
||||
Reference in New Issue
Block a user