/
germanubis
/
rust-postgres
Обзор
Документация
Войти
/
germanubis
/
rust-postgres
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
tokio-postgres/src/keepalive.rs
38 строк
1 KB
Qiu Chaofan
Support AIX keepalive
23 июл 2024, 08:36
23 июл 2024, 08:36
aa10f0d
Код
Авторство
О чём код?
use socket2::TcpKeepalive; use std::time::Duration; #[derive(Clone, PartialEq, Eq)] pub(crate) struct KeepaliveConfig { pub idle: Duration, pub interval: Option<Duration>, pub retries: Option<u32>, } impl From<&KeepaliveConfig> for TcpKeepalive { fn from(keepalive_config: &KeepaliveConfig) -> Self { let mut tcp_keepalive = Self::new().with_time(keepalive_config.idle); #[cfg(not(any( target_os = "aix", target_os = "redox", target_os = "solaris", target_os = "openbsd" )))] if let Some(interval) = keepalive_config.interval { tcp_keepalive = tcp_keepalive.with_interval(interval); } #[cfg(not(any( target_os = "aix", target_os = "redox", target_os = "solaris", target_os = "windows", target_os = "openbsd" )))] if let Some(retries) = keepalive_config.retries { tcp_keepalive = tcp_keepalive.with_retries(retries); } tcp_keepalive } }