RequestPromise

Structin servefastly 0.13.1View source
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 Request has not been completed
    • A limit has been reached (number of requests per instance, timeout waiting for the next request)

Methods

fn new(reuse_settings: &NextRequestOptions) -> Result<RequestPromise, NextRequestError>

Create a new promise for receiving a subsequent downstream request.

Parameters

reuse_settings: &NextRequestOptions

Returns

fn wait(self) -> Result<Request, NextRequestError>

Wait 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 source
fn wait_timeout(self, timeout: Duration) -> Result<Request, NextRequestError>

Wait 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

Trait implementations

impl Debug for RequestPromise

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Parameters

self: &Self
f: &mut $crate::fmt::Formatter

Returns

$crate::fmt::Result

Auto trait implementations

Blanket implementations