Skip to content

Comments

Refactor legacy client to be independent of tokio#269

Draft
erickt wants to merge 2 commits intohyperium:masterfrom
erickt:refactor-client
Draft

Refactor legacy client to be independent of tokio#269
erickt wants to merge 2 commits intohyperium:masterfrom
erickt:refactor-client

Conversation

@erickt
Copy link
Contributor

@erickt erickt commented Feb 20, 2026

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.

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-rustls to 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.

@erickt erickt marked this pull request as draft February 20, 2026 04:04
@erickt erickt force-pushed the refactor-client branch 4 times, most recently from 3e14630 to 9f5b854 Compare February 20, 2026 23:46
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant