-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upgrade to hyper v1.0 #1368
upgrade to hyper v1.0 #1368
Conversation
@@ -34,8 +37,8 @@ tokio = { version = "1.16", features = ["net", "rt-multi-thread", "macros"] } | |||
|
|||
[features] | |||
default = ["native-tls"] | |||
native-tls = ["hyper-rustls/native-tokio", "__tls"] | |||
webpki-tls = ["hyper-rustls/webpki-tokio", "__tls"] | |||
native-tls = ["hyper-rustls/native-tokio", "hyper-rustls/ring", "__tls"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's discuss whether we should support both crypto backends.
Rustls now supports both ring and aws-lc-rs but migrating to aws-lc-rs requires more dependencies such as cmake, NASM etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with not exposing it initially, and then as a non-breaking change we can always expose it later or whatever if there's demand :)
client/http-client/src/lib.rs
Outdated
@@ -46,3 +46,10 @@ mod tests; | |||
pub use client::{HttpClient, HttpClientBuilder}; | |||
pub use hyper::http::{HeaderMap, HeaderValue}; | |||
pub use jsonrpsee_types as types; | |||
|
|||
/// Default HTTP body for the client. | |||
pub type HttpBody = http_body_util::Full<hyper::body::Bytes>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this also be jsonrpsee_core::http_helpers::ResponseBody
, since the below two things reference that?
(maybe rename RepsonseBody
to HttpBody
though?)
@@ -63,17 +66,17 @@ async fn main() -> anyhow::Result<()> { | |||
println!("[main]: response: {:?}", response); | |||
|
|||
// Use hyper client to manually submit a `GET /health` request. | |||
let http_client = Client::new(); | |||
let http_client = Client::builder(TokioExecutor::new()).build_http(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting way to be agnostic over runtime; I could imagine we might adopt a similar thing in subxt to hide the spawning stuff behind the scenes unless the user wants to override the executor or manually drive stuff
server/src/transport/ws.rs
Outdated
let upgraded = match hyper::upgrade::on(req).await { | ||
Ok(u) => u, | ||
Err(e) => { | ||
tracing::debug!(target: LOG_TARGET, "WS upgrade handshake failed: {}", e); | ||
return Err(HttpResponse::new(HttpResponseBody::from(format!("WS upgrade handshake failed {e}")))); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the thing that moved into that async block below not super long ago for a reason I can't remember (maybe something shutdown related)?
Wondering what the impact of moving it up is!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like, previously it would only be executed when the returned future is polled, but now it's executed in the connect(..).await
and has to finish before the fut is returned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thus, it will be stuck until the response is returned but I can add a comment in the code because it confuses me as well
server/src/server.rs
Outdated
/// fn run_server() -> ServerHandle { | ||
/// let addr = SocketAddr::from(([127, 0, 0, 1], 0)); | ||
/// async fn run_server() -> ServerHandle { | ||
/// let listener = tokio::net::TcpListener::bind(SocketAddr::from(([127, 0, 0, 1], 0))).await.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this could move into the tokio::spawn
and then run_server
could be sync again (iirc this is in an example or two as well)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice one! Just a couple of small comments!
@CodiumAI-Agent /review |
PR Review 🔍
Code feedback:
|
server/src/server.rs
Outdated
@@ -960,32 +995,28 @@ impl<RpcMiddleware, HttpMiddleware> TowerService<RpcMiddleware, HttpMiddleware> | |||
} | |||
} | |||
|
|||
impl<RpcMiddleware, HttpMiddleware> hyper::service::Service<hyper::Request<hyper::Body>> | |||
for TowerService<RpcMiddleware, HttpMiddleware> | |||
impl<B, RpcMiddleware, HttpMiddleware> Service<HttpRequest<B>> for TowerService<RpcMiddleware, HttpMiddleware> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Maybe instead of B
we can call this Body
? To keep consistency with RpcMiddleware
and HttpMiddleware
?
client/ws-client/src/tests.rs
Outdated
@@ -461,6 +461,8 @@ fn assert_error_response(err: Error, exp: ErrorObjectOwned) { | |||
|
|||
#[tokio::test] | |||
async fn redirections() { | |||
init_logger(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is this indended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Close #1257
Things that could be improved in this PR or in follow-up:
aws-lc-rs
TLS crypto backend