minor cleanup
This commit is contained in:
parent
6ed729845f
commit
2ab708c4bc
@ -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(|_| ())
|
||||
})
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ impl Error {
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub fn timeout() -> Error {
|
||||
pub fn __private_api_timeout() -> Error {
|
||||
Error::new(Kind::Timeout, None)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user