Refactor legacy client to be independent of tokio#269
Draft
erickt wants to merge 2 commits intohyperium:masterfrom
Draft
Refactor legacy client to be independent of tokio#269erickt wants to merge 2 commits intohyperium:masterfrom
erickt wants to merge 2 commits intohyperium:masterfrom
Conversation
3e14630 to
9f5b854
Compare
Now that hyper-util uses `socket2::Socket::set_tcp_nodelay`, which was added in [0.6.0]. It used to be called `socket2::Socket::set_nodelay` in [0.5.10]. It also updates the MSRV to Rust 1.70 since that's the minimum supported version in socket2 0.6.0. [0.5.10]: https://docs.rs/socket2/0.5.10/socket2/struct.Socket.html#method.set_nodelay [0.6.0]: https://docs.rs/socket2/0.6.0/socket2/struct.Socket.html#method.set_tcp_nodelay
This patch decouples the functionality of `client::legacy` from tokio, by lifting up a `Client`, `HttpConnection`, and `Resolver` into the `client` module. For backwards compatibility, it reimplements `client::legacy` to be based off of the new code. As best as I can tell it should be backwards compatible, and passes all the tests. There's a couple of areas where I'm not sure if we got quite the right API: * Capturing connection info - This adds a helper closure you can call to get it, which is then used by he legacy client to send the info to the tokio watch. * This extracts the pool info, but there's been a long standing plan to replace it with something better. I'm not sure what that would look like though. * I set up the legacy Client and HttpConnector to wrap the new generic APIs. That adds a bit of code duplication, but as far as I can tell we can't use a type alias due to the `new` method.
9f5b854 to
22c3809
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch decouples the functionality of
client::legacyfrom tokio, by lifting up aClient,HttpConnection, andResolverinto theclientmodule. For backwards compatibility, it reimplementsclient::legacyto be based off of the new code.As best as I can tell it should be backwards compatible, and passes all the tests.
There's a couple of areas where I'm not sure if we got quite the right API:
newmethod.This is an experiment, so I wouldn't be surprised if it needs changes. To test out the design, I also have a WIP branch to update
hyper-rustlsto use the new interface, found in https://github.com/erickt/hyper-rustls/tree/new-client. I'll not push that up as a PR for now to avoid splitting the conversation, but I did want to cc @djc since you might also have opinions about how this should look.