Skip to content

Commit bf72b8d

Browse files
committed
Add HTTP/2 multiplexed connection with concurrency control
## Summary - Introduce Connection<C>, a Tower Service-based HTTP/2 connection that multiplexes requests over a single H2 session with semaphore-backed concurrency control - Add TcpConnector service and ConnectionInfo/IntoConnectionInfo abstractions for URI-based TCP connection establishment
1 parent 386f4ab commit bf72b8d

File tree

9 files changed

+1426
-6
lines changed

9 files changed

+1426
-6
lines changed

Cargo.lock

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/service-client/Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,29 @@ bytestring = { workspace = true }
2828
futures = { workspace = true }
2929
h2 = "0.4.12"
3030
http = { workspace = true }
31+
http-body = { workspace = true }
3132
http-body-util = { workspace = true }
3233
http-serde = { workspace = true }
3334
hyper = { workspace = true, features = ["http1", "http2", "client"] }
3435
hyper-rustls = { workspace = true }
3536
hyper-util = { workspace = true, features = ["client-legacy"] }
3637
jsonwebtoken = { workspace = true }
3738
pem = { version = "3.0.6" }
39+
pin-project = { workspace = true }
3840
ring = { version = "0.17.14" }
3941
rustls = { workspace = true }
4042
serde = { workspace = true }
4143
serde_json = { workspace = true }
4244
serde_with = { workspace = true }
4345
thiserror = { workspace = true }
44-
tower-service = { version = "0.3" }
46+
tokio = { workspace = true }
47+
tokio-util = { workspace = true }
48+
tokio-rustls = "0.26"
49+
tower = { workspace = true }
4550
tracing = { workspace = true }
4651
zstd = { workspace = true }
4752

4853
[dev-dependencies]
4954
googletest = { workspace = true }
50-
tempfile = { workspace = true }
55+
tempfile = { workspace = true }
56+
tokio-stream = {workspace = true}

crates/service-client/src/http.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use super::proxy::ProxyConnector;
1212

13+
use crate::pool;
1314
use crate::utils::ErrorExt;
1415

1516
use bytes::Bytes;
@@ -30,6 +31,7 @@ use std::fmt::Debug;
3031
use std::future::Future;
3132
use std::sync::{Arc, LazyLock};
3233
use std::{fmt, future};
34+
use tower::Layer;
3335

3436
type ProxiedHttpsConnector = ProxyConnector<HttpsConnector<HttpConnector>>;
3537

@@ -107,6 +109,11 @@ impl HttpClient {
107109
.enable_http2()
108110
.wrap_connector(http_connector.clone());
109111

112+
{
113+
let _connector = pool::tls::TlsConnectorLayer::new(TLS_CLIENT_CONFIG.clone())
114+
.layer(pool::TcpConnector);
115+
}
116+
110117
HttpClient {
111118
alpn_client: builder.clone().build::<_, BoxBody>(ProxyConnector::new(
112119
options.http_proxy.clone(),

crates/service-client/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use std::sync::Arc;
3636

3737
mod http;
3838
mod lambda;
39+
pub mod pool;
3940
mod proxy;
4041
mod request_identity;
4142
mod utils;

0 commit comments

Comments
 (0)