-
Notifications
You must be signed in to change notification settings - Fork 87
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
Use generic HTTP connector in Client #27
Conversation
@loyd please take a look and leave comments when you have time :) |
Thanks for contributing, too useful feature! However, I don't want to add a generic parameter because, firstly, it pollutes all structs and, secondly, it exposes hyper-specific types and traits. I have plans to support other frameworks (to support different runtimes), so this solution complicates the transition later. Instead, I suggest using dynamic dispatching (some custom So, // http_client.rs
use crate::sealed::Sealed;
trait HttpClient: Sealed {
/// Private API.
#[doc(hidden)]
fn request(&self, req: Request<Body>) -> ResponseFuture;
}
impl<C> Sealed for hyper::Client<C> {}
impl<C> HttpClient for hyper::Client<C> {
...
} What do you think about it? |
Your design looks much cleaner! I'll update the implementation. |
@loyd I've updated the code. Please take a look :) Note: it might not be as extensible as intended:
|
Thanks for the updates!
Exactly what we want, because internally the crate should know about implementation until h2 is used. |
Tests passed, code is fine, LGTM. |
Yeah it's good to merge :) |
Hi @iwinux I'm trying to use this feature. Could you point me to some documentation that walks me through using a https only connection with clickhouse? |
Motivation
Need to connect to ClickHouse via TLS, but the
hyper::Client<HttpConnector>
used inclickhouse::Client::default()
cannot handlehttps://
URLs.Solution
Client
generic over type paramC
, which should implement thehyper::client::connect::Connect
trait.hyper::Client
viawith_hyper_client()
.With these updates, users of
clickhouse::Client
can connect to ClickHouse via TLS with something likehyper::Client<hyper_tls::HttpsConnector<HttpConnector>>
. For example: