Skip to main content

execute_with_timeout

Function execute_with_timeout 

Source
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