Skip to content

Commit 9f5b854

Browse files
committed
Refactor legacy client to be independent of tokio
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.
1 parent e5f3230 commit 9f5b854

File tree

26 files changed

+4943
-4477
lines changed

26 files changed

+4943
-4477
lines changed

Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ full = [
7171
"http1",
7272
"http2",
7373
"tokio",
74+
"tokio-net",
7475
"tracing",
7576
]
7677

77-
client = ["hyper/client", "tokio/net", "dep:tracing", "dep:futures-channel", "dep:tower-service"]
78-
client-legacy = ["client", "dep:socket2", "tokio/sync", "dep:libc", "dep:futures-util"]
79-
client-pool = ["client", "dep:futures-util", "dep:tower-layer"]
78+
client = ["hyper/client", "dep:futures-channel", "dep:futures-util", "dep:socket2", "dep:tracing", "dep:tower-service"]
79+
client-legacy = ["client", "tokio/sync", "dep:libc", "dep:futures-util"]
80+
client-pool = ["client", "dep:futures-util", "dep:tower-layer", "tokio/sync"]
8081
client-proxy = ["client", "dep:base64", "dep:ipnet", "dep:percent-encoding"]
8182
client-proxy-system = ["dep:system-configuration", "dep:windows-registry"]
8283

@@ -89,7 +90,9 @@ service = ["dep:tower-service"]
8990
http1 = ["hyper/http1"]
9091
http2 = ["hyper/http2"]
9192

92-
tokio = ["dep:tokio", "tokio/rt", "tokio/time"]
93+
tokio = ["dep:tokio", "tokio/time"]
94+
tokio-rt = ["dep:tokio", "tokio/rt"]
95+
tokio-net = ["tokio-rt", "tokio/net"]
9396

9497
tracing = ["dep:tracing"]
9598

0 commit comments

Comments
 (0)