pub struct Retriever<T> { /* private fields */ }Expand description
Allows asynchronously retrieving the resource T from the owner of the
linked Conduit.
These retrievers are light-weight and may be freely cloned and passed between asynchronous tasks.
Implementations§
Source§impl<T> Retriever<T>
impl<T> Retriever<T>
Sourcepub async fn anticipate(&self) -> T
pub async fn anticipate(&self) -> T
Requests and retrieves the resource T from the owner of the linked
Conduit. Waits for the response potentially indefinitely. For example,
if the linked conduit no longer exists, this method will never return.
§Use cases
This method is useful when the requester of T is logically unable to proceed
without it, and when it can be expected that the owner of the linked conduit
has a good reason to not return a result.
Examples may include the owner of the database connection struggling to establish a connection because the remote server has gone away. Another example would be the application entering the spindown phase before exiting, prompting the conduit’s owner to stop listening for requests.
In such cases, this method exerts useful backpressure that prevents unwanted processing.
Sourcepub async fn request(&self) -> Option<T>
pub async fn request(&self) -> Option<T>
Requests and retrieves the resource T from the owner of the linked
Conduit. If any communication failure occurs (such as the linked
conduit no longer exists, or the request is dropped without responding),
this method returns None.
Note that if the linked conduit still hangs on to incoming requests without ever responding to them, this method may still wait indefinitely. Request with a timeout if necessary.
Sourcepub async fn request_with_timeout(&self, timeout: Duration) -> Option<T>
pub async fn request_with_timeout(&self, timeout: Duration) -> Option<T>
Performs a normal request, but within the given
timeout. If the request is not served in time, None is returned, and
the request is dropped.