Replies: 1 comment
-
Yes, you can |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is your feature request related to a problem? Please describe.
I was going through the hyperium/hyper web_api.rs example https://raw.githubusercontent.com/hyperium/hyper/master/examples/web_api.rs.
Looking specifically at the function below
when I make multiple http requests,
let (mut sender, conn) = hyper::client::conn::http1::handshake(io).await?;
will be triggered on every function meaning establishing a connection every-time an http request is made which may not be very efficient performance wise (apologies if this is a wrong assumption)
Describe the solution you'd like
I want to be able to initialise sender & connection only once, preferably encapsulated in a client
Describe alternatives you've considered
so that i can initialise my client using new()/builder() function as follows:
The new function won't work, unless i add an
async
keyword behind the new function.So my questions is:
Is there a way to establish a connection once, creating single instances of sender, conn as in
(sender, conn) = hyper::client::conn::http1::handshake(io).await?;
without using
async/await
?or would there be no performance bottleneck in running the handshake(io).await for every request ?
Additional context
Cargo.toml
Beta Was this translation helpful? Give feedback.
All reactions