Skip to content

Split request/response awaitables #190

@Karrq

Description

@Karrq

Currently when issuing a request (using ReqSocket) the future will resolve to the response.

This is most often useful, but it is not an atomic operation:

  1. The request is sent to the underlying driver (which is driven autonomously by the task)
  2. The response is received back in a channel

It would be useful therefore to expose this and allow users to ensure the request has been queued without having to necessarily retrieve a response back in the same future.

This, for example, could allow timing precisely how long a request has taken to process, or would allow the response to be received by another task.

The following pseudocode illustrates the desired behaviour:

let response_fut = req_socket.send_request(request).await?;

// somewhere else
let response = response_fut.await?;
impl ReqSocket {
  async fn send_request(&self, req: Request) -> ResponseFut {
    let (tx, rx) = oneshot::channel();

    self.to_driver.send(req).await?;
    rx  
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions