Skip to content

Commit 2adadbf

Browse files
committed
balancer: add support for http2
1 parent 830d3d2 commit 2adadbf

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

crates/ott-balancer/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ use balancer::{start_dispatcher, Balancer, BalancerContext};
66
use clap::Parser;
77
use futures_util::stream::FuturesUnordered;
88
use futures_util::{FutureExt, StreamExt};
9-
use hyper::server::conn::http1;
9+
use hyper_util::rt::TokioExecutor;
10+
use hyper_util::server::conn::auto;
1011
use tokio::net::TcpListener;
1112
use tokio::sync::RwLock;
1213
use tracing::{error, info};
@@ -185,9 +186,8 @@ pub async fn run() -> anyhow::Result<()> {
185186
let task = tokio::task::Builder::new()
186187
.name("serve http")
187188
.spawn(async move {
188-
let conn = http1::Builder::new()
189-
.serve_connection(io, service)
190-
.with_upgrades();
189+
let serve = auto::Builder::new(TokioExecutor::new());
190+
let conn = serve.serve_connection_with_upgrades(io, service);
191191
if let Err(err) = conn.await {
192192
error!("Error serving connection: {:?}", err);
193193
}

crates/ott-balancer/src/service.rs

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ impl Service<Request<IncomingBody>> for BalancerService {
6262
Level::INFO,
6363
"http_request",
6464
request_id = request_id,
65+
version = ?req.version(),
6566
method = %req.method(),
6667
path = %req.uri().path(),
6768
handler = field::Empty,

deploy/fly.prod.balancer.toml

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ force_https = true
1717
# auto_start_machines = true
1818
min_machines_running = 1
1919

20+
[http_service.http_options]
21+
h2_backend = true
22+
2023
[[http_service.checks]]
2124
grace_period = "10s"
2225
interval = "30s"

deploy/fly.staging.balancer.toml

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ force_https = true
1717
# auto_start_machines = true
1818
min_machines_running = 1
1919

20+
[http_service.http_options]
21+
h2_backend = true
22+
2023
[[http_service.checks]]
2124
grace_period = "10s"
2225
interval = "30s"

0 commit comments

Comments
 (0)