VEEH77WELUZIS2L32UGTKYHJTUOZ42RY7EIPTKR46NJJF6M2YPHQC
let mut lock = client.campaign("postrep", host.as_str(), id).await?;
let candidate = {
let l = leader.borrow().as_str().to_string();
if l.is_empty() {
host.clone()
} else {
use std::net::ToSocketAddrs;
let s = (l.as_str(), 5432)
.to_socket_addrs()
.unwrap()
.next()
.unwrap();
if tokio::time::timeout(
std::time::Duration::from_secs(120),
tokio::net::TcpStream::connect(&s),
)
.await
.is_ok()
{
l
} else {
host.clone()
}
}
};
let mut lock = client.campaign("postrep", candidate, id).await?;