pub struct Requestor<E, D> { /* private fields */ }Expand description
A Requestor stream that dispatches requests to any Replier streams bound to the specified topic.
Requestor streams are synchronous, meaning that they will block the current task while awaiting a response, as opposed to the asynchronous, non-blocking nature of Publisher streams. This makes them ideal for any use-cases relying on the RPC messaging pattern, when a response is expected before resuming the task.
Once constructed, requests can be dispatched by calling and awaiting the request method.
§Concurrency
The Requestor type derives the Clone trait, so requests can safely be made concurrently, as the Requestor
will implicitly handle routing replies to the correct task.
Implementations§
Source§impl<E, D> Requestor<E, D>
impl<E, D> Requestor<E, D>
Sourcepub async fn request(&mut self, req: E::Item) -> Result<D::Item>
pub async fn request(&mut self, req: E::Item) -> Result<D::Item>
Dispatches a request and blocks the current task while waiting for a response, or a request timeout.
§Errors
Returns Err under the current conditions:
- The request fails to be encoded.
- The encoded request fails to dispatched.
- The request times out.
- The reply fails to be decoded.
Trait Implementations§
Source§impl<E, D> KeepAliveStream for Requestor<E, D>
impl<E, D> KeepAliveStream for Requestor<E, D>
type Headers = RequestorPayload
Source§fn reestablish_connection(
connection: Arc<Mutex<ClientConnection>>,
headers: Self::Headers,
) -> Pin<Box<dyn Future<Output = Result<BiStream>> + Send>>
fn reestablish_connection( connection: Arc<Mutex<ClientConnection>>, headers: Self::Headers, ) -> Pin<Box<dyn Future<Output = Result<BiStream>> + Send>>
Selium server.Source§fn on_reconnect(&mut self, stream: BiStream)
fn on_reconnect(&mut self, stream: BiStream)
Source§fn get_connection(&self) -> Arc<Mutex<ClientConnection>>
fn get_connection(&self) -> Arc<Mutex<ClientConnection>>
Source§fn get_headers(&self) -> Self::Headers
fn get_headers(&self) -> Self::Headers
Selium server.