pub async fn execute_with_timeout<T>(
timeout_secs: Option<u64>,
sql: &str,
fut: impl Future<Output = Result<T, Error>>,
) -> Result<T, SqlError>Expand description
Executes fut with an optional query timeout.
When timeout_secs is Some(n) where n > 0, the future is wrapped
with tokio::time::timeout. On expiry the future is dropped
(cancelling the in-flight query) and SqlError::QueryTimeout is
returned with the wall-clock elapsed time and the original SQL text.
When timeout_secs is None or Some(0), the future runs without
any timeout.
§Errors
SqlError::QueryTimeout— the query exceeded the configured timeout.SqlError::Query— the underlying query failed for a non-timeout reason (e.g. syntax error, connection loss).