Skip to content
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

fix(http client): set reuseaddr and nodelay. #687

Merged
merged 8 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions client/http-client/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,32 @@ impl HttpTransportClient {
return Err(Error::Url("Port number is missing in the URL".into()));
}

let mut connector = HttpConnector::new();

connector.set_reuse_address(true);
connector.set_nodelay(true);

let client = match target.scheme_str() {
Some("http") => {
let connector = HttpConnector::new();
let client = Client::builder().build::<_, hyper::Body>(connector);
HyperClient::Http(client)
}
#[cfg(feature = "tls")]
Some("https") => {
let connector = match cert_store {
CertificateStore::Native => {
hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1()
}
CertificateStore::WebPki => {
hyper_rustls::HttpsConnectorBuilder::new().with_webpki_roots().https_or_http().enable_http1()
}
CertificateStore::Native => hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_or_http()
.enable_http1()
.wrap_connector(connector),
CertificateStore::WebPki => hyper_rustls::HttpsConnectorBuilder::new()
.with_webpki_roots()
.https_or_http()
.enable_http1()
.wrap_connector(connector),
_ => return Err(Error::InvalidCertficateStore),
};
let client = Client::builder().build::<_, hyper::Body>(connector.build());
let client = Client::builder().build::<_, hyper::Body>(connector);
HyperClient::Https(client)
}
_ => {
Expand Down Expand Up @@ -132,7 +140,7 @@ pub enum Error {
Url(String),

/// Error during the HTTP request, including networking errors and HTTP protocol errors.
#[error("Error while performing the HTTP request")]
#[error("HTTP error: {0}")]
Http(Box<dyn std::error::Error + Send + Sync>),

/// Server returned a non-success status code.
Expand Down
4 changes: 1 addition & 3 deletions proc-macros/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ impl FindSubscriptionParams {

syn::Type::Infer(_) | syn::Type::Never(_) | syn::Type::Verbatim(_) => {}

#[cfg(test)]
syn::Type::__TestExhaustive(_) => unimplemented!(),
#[cfg(not(test))]
#[cfg_attr(all(test, exhaustive), deny(non_exhaustive_omitted_patterns))]
_ => {}
}
}
Expand Down