minor cleanup

This commit is contained in:
Steven Fackler 2020-12-17 20:36:15 -05:00
parent 6ed729845f
commit 2ab708c4bc
2 changed files with 5 additions and 3 deletions

View File

@ -414,14 +414,16 @@ impl Client {
self.connection.block_on(self.client.simple_query(query))
}
/// Validates connection, timing out after specified duration.
/// Validates the connection by performing a simple no-op query.
///
/// If the specified timeout is reached before the backend responds, an error will be returned.
pub fn is_valid(&mut self, timeout: Duration) -> Result<(), Error> {
let inner_client = &self.client;
self.connection.block_on(async {
let trivial_query = inner_client.simple_query("");
tokio::time::timeout(timeout, trivial_query)
.await
.map_err(|_| Error::timeout())?
.map_err(|_| Error::__private_api_timeout())?
.map(|_| ())
})
}

View File

@ -495,7 +495,7 @@ impl Error {
}
#[doc(hidden)]
pub fn timeout() -> Error {
pub fn __private_api_timeout() -> Error {
Error::new(Kind::Timeout, None)
}
}