RequestPromise
pub struct RequestPromise { /* private fields */ }A promise of a future Request from a customer.
When .wait() is called, this will resolve to either:
- a
Request, if an additional user request has been assigned to this instance - an
Error, if:- The current
Requesthas not been completed - A limit has been reached (number of requests per instance, timeout waiting for the next request)
- The current
Methods
new
View sourceCreate a new promise for receiving a subsequent downstream request.
Parameters
- reuse_settings: &NextRequestOptions
Returns
wait
View sourceWait for the next request.
This returns if a next request is available; if an error occurs; or if the RequestPromise exceeds its deadline.
Parameters
- self: Self
Returns
wait_timeout
View sourceWait for the next request, up to the timeout provided here.
The timeout here represents how long this method waits, and not whether the handle has become invalid. If a timeout of zero is provided, this acts as a poll-once, and returns immediately with NextRequestError::Timeout if there is not a request ready.
Note that if the timeout is reached, this instance is still registered to receive a future
request; the RequestPromise can be recovered from the NextRequestError::Timeout
and another wait_timeout or wait call may be attempted on it.
If this instance needs to shut down, dropping the RequestPromise or NextRequestError will abandon the promise and avoid queueing future requests for the session.
Note that the timeout has an unspecified minimum resolution. If a nonzero timeout smaller than the minimum resolution is provided, the time will be rounded up to this resolution.
Parameters
- self: Self
- timeout: Duration
Returns