I feel like we need some crate (in-between tokio and hyper) to provide a layer of connectors.
In hyper everything's about http, but we do need a TcpConnector and a Connector trait to be available for better composability in our networking libraries.
The rationale is the "connecting" isn't just about HTTP, it's about all the connection-based protocols. It abstracts really nicely and allows us to really use the transport protocols interchangeably.
There's an emerging anti-pattern that I observed is a couple of codebases - to use HttpConnector to establish non-http TCP stream. I don't think it's right, and that's why I classify it as an anti-pattern. Unfortunately, even the authors do recommend this: #1445.
I propose we extract TcpConnector from HttpConnector, and keep the HttpConnector as a thin layer atop of TcpConnector, providing functionality like using URI as an argument (and enforce_http and so on). We can put the happy eyeballs and DNS resolution support in a layer between TcpConnector and HttpConnector (HttpConnector<HappyEyeballsConnector<TcpConnector, DomainResolver>>).
What do you think?
P.S. Maybe this is not the right place for this issue, but can start here and move somewhere else if needed.
I feel like we need some crate (in-between
tokioandhyper) to provide a layer of connectors.In
hypereverything's about http, but we do need aTcpConnectorand aConnectortrait to be available for better composability in our networking libraries.The rationale is the "connecting" isn't just about HTTP, it's about all the connection-based protocols. It abstracts really nicely and allows us to really use the transport protocols interchangeably.
There's an emerging anti-pattern that I observed is a couple of codebases - to use
HttpConnectorto establish non-http TCP stream. I don't think it's right, and that's why I classify it as an anti-pattern. Unfortunately, even the authors do recommend this: #1445.I propose we extract
TcpConnectorfromHttpConnector, and keep theHttpConnectoras a thin layer atop ofTcpConnector, providing functionality like using URI as an argument (andenforce_httpand so on). We can put the happy eyeballs and DNS resolution support in a layer betweenTcpConnectorandHttpConnector(HttpConnector<HappyEyeballsConnector<TcpConnector, DomainResolver>>).What do you think?
P.S. Maybe this is not the right place for this issue, but can start here and move somewhere else if needed.