Expand description
Service that applies a timeout to request execution.
If a service call does not complete within the configured timeout, its
future is dropped and TimeoutError::Timeout is returned.
If both complete during the same poll, the service result wins.
The timeout covers execution only. The clock starts when the wrapped service is called, after the pipeline has waited for readiness. Waiting for a busy or never-ready service is not bounded by this timeout, because readiness is a gate shared by all callers rather than part of one request. To bound the whole operation, including the readiness wait, wrap the pipeline call:
use ntex_service::Pipeline;
use ntex_util::time::{Millis, timeout};
async fn call_with_deadline(
pl: &Pipeline<u32, u32, std::io::Error>,
) -> Option<Result<u32, std::io::Error>> {
// `Err(())` from `timeout` means the deadline elapsed
timeout(Millis(500), pl.call(1)).await.ok()
}Structs§
- Timeout
- Applies a timeout to the execution of each request.
- Timeout
Service - A service that applies a timeout to the execution of each request.
Enums§
- Timeout
Error - Error returned by a timed service call.