|
56 | 56 | P::Future: Unpin + Send, |
57 | 57 | P::Error: Send, |
58 | 58 | { |
59 | | - let tcp_balance = tcp::balance::stack(&config.proxy, tcp_connect.clone(), resolve); |
| 59 | + let tcp_balance = |
| 60 | + tcp::balance::stack(&config.proxy, tcp_connect.clone(), resolve, drain.clone()); |
60 | 61 | let accept = accept_stack( |
61 | 62 | config, |
62 | 63 | profiles, |
@@ -206,36 +207,30 @@ where |
206 | 207 |
|
207 | 208 | // Load balances TCP streams that cannot be decoded as HTTP. |
208 | 209 | let tcp_balance = svc::stack(tcp_balance) |
209 | | - .push_map_target(tcp::Concrete::from) |
210 | | - .push(profiles::split::layer()) |
211 | | - .check_new_service::<tcp::Logical, transport::io::PrefixedIo<transport::metrics::SensorIo<I>>>() |
212 | | - .push_switch(tcp::Logical::should_resolve, tcp_forward) |
213 | | - .push_on_response( |
214 | | - svc::layers() |
215 | | - .push_failfast(dispatch_timeout) |
216 | | - .push_spawn_buffer(buffer_capacity), |
217 | | - ) |
218 | | - .instrument(|_: &_| debug_span!("tcp")) |
219 | | - .check_new_service::<tcp::Logical, transport::io::PrefixedIo<transport::metrics::SensorIo<I>>>() |
220 | | - .into_inner(); |
| 210 | + .push_map_target(tcp::Concrete::from) |
| 211 | + .push(profiles::split::layer()) |
| 212 | + .check_new_service::<tcp::Logical, transport::io::PrefixedIo<transport::metrics::SensorIo<I>>>() |
| 213 | + .push_switch(tcp::Logical::should_resolve, tcp_forward) |
| 214 | + .push_on_response( |
| 215 | + svc::layers() |
| 216 | + .push_failfast(dispatch_timeout) |
| 217 | + .push_spawn_buffer(buffer_capacity), |
| 218 | + ) |
| 219 | + .instrument(|_: &_| debug_span!("tcp")) |
| 220 | + .check_new_service::<tcp::Logical, transport::io::PrefixedIo<transport::metrics::SensorIo<I>>>() |
| 221 | + .into_inner(); |
221 | 222 |
|
222 | | - let http = svc::stack(http::NewServeHttp::new( |
223 | | - h2_settings, |
224 | | - http_server, |
225 | | - tcp_balance, |
226 | | - drain, |
227 | | - )) |
228 | | - .check_new_clone::<(Option<http::Version>, tcp::Logical)>() |
229 | | - .check_new_service::<(Option<http::Version>, tcp::Logical), transport::io::PrefixedIo<transport::metrics::SensorIo<I>>>() |
230 | | - .push_cache(cache_max_idle_age) |
231 | | - .push(transport::NewDetectService::layer( |
232 | | - transport::detect::DetectTimeout::new( |
233 | | - detect_protocol_timeout, |
234 | | - http::DetectHttp::default(), |
235 | | - ), |
236 | | - )) |
237 | | - .check_new_service::<tcp::Logical, transport::metrics::SensorIo<I>>() |
238 | | - .into_inner(); |
| 223 | + let http = svc::stack(http::NewServeHttp::new(h2_settings, http_server, drain)) |
| 224 | + .push(svc::stack::NewOptional::layer(tcp_balance)) |
| 225 | + .push_cache(cache_max_idle_age) |
| 226 | + .push(transport::NewDetectService::layer( |
| 227 | + transport::detect::DetectTimeout::new( |
| 228 | + detect_protocol_timeout, |
| 229 | + http::DetectHttp::default(), |
| 230 | + ), |
| 231 | + )) |
| 232 | + .check_new_service::<tcp::Logical, transport::metrics::SensorIo<I>>() |
| 233 | + .into_inner(); |
239 | 234 |
|
240 | 235 | let tcp = svc::stack(tcp::connect::forward(tcp_connect)) |
241 | 236 | .push_map_target(tcp::Endpoint::from_logical( |
|
0 commit comments