@@ -85,21 +85,18 @@ impl Config {
8585 & self ,
8686 connect : C ,
8787 resolve : E ,
88- ) -> impl tower :: Service <
88+ ) -> impl svc :: NewService <
8989 SocketAddr ,
90- Error = impl Into < Error > ,
91- Future = impl Unpin + Send + ' static ,
92- Response = impl tower:: Service <
90+ Service = impl tower:: Service <
9391 I ,
9492 Response = ( ) ,
9593 Future = impl Unpin + Send + ' static ,
9694 Error = impl Into < Error > ,
9795 > + Unpin
98- + Clone
99- + Send
100- + ' static ,
101- > + Unpin
102- + Clone
96+ + Send
97+ + ' static ,
98+ > + Clone
99+ + Unpin
103100 + Send
104101 + ' static
105102 where
@@ -112,10 +109,7 @@ impl Config {
112109 I : tokio:: io:: AsyncRead + tokio:: io:: AsyncWrite + std:: fmt:: Debug + Unpin + Send + ' static ,
113110 {
114111 let ProxyConfig {
115- dispatch_timeout,
116- cache_max_idle_age,
117- buffer_capacity,
118- ..
112+ cache_max_idle_age, ..
119113 } = self . proxy ;
120114
121115 svc:: stack ( connect)
@@ -132,18 +126,6 @@ impl Config {
132126 . push_on_response ( svc:: layer:: mk ( tcp:: Forward :: new) )
133127 . into_new_service ( )
134128 . check_new_service :: < SocketAddr , I > ( )
135- . cache (
136- svc:: layers ( ) . push_on_response (
137- svc:: layers ( )
138- . push_failfast ( dispatch_timeout)
139- . push_spawn_buffer_with_idle_timeout ( buffer_capacity, cache_max_idle_age)
140- ) ,
141- )
142- . into_make_service ( )
143- . spawn_buffer ( buffer_capacity)
144- . push_make_ready ( )
145- . instrument ( |_: & _ | info_span ! ( "tcp" ) )
146- . check_make_service :: < SocketAddr , I > ( )
147129 }
148130
149131 pub fn build_dns_refine (
@@ -327,7 +309,8 @@ impl Config {
327309 . box_http_request ( ) ,
328310 )
329311 . push_spawn_ready ( )
330- . check_make_service :: < HttpEndpoint , http:: Request < _ > > ( )
312+ . into_new_service ( )
313+ . check_new_service :: < HttpEndpoint , http:: Request < _ > > ( )
331314 . push ( discover)
332315 . check_service :: < HttpConcrete > ( )
333316 . push_on_response (
@@ -379,36 +362,13 @@ impl Config {
379362 // it to inner stack to build the router and traffic split.
380363 . push ( profiles:: discover:: layer ( profiles_client) )
381364 . into_new_service ( )
382- . cache (
383- svc:: layers ( ) . push_on_response (
384- svc:: layers ( )
385- . push_failfast ( dispatch_timeout)
386- . push_spawn_buffer_with_idle_timeout ( buffer_capacity, cache_max_idle_age)
387- . push ( metrics. stack . layer ( stack_labels ( "profile" ) ) ) ,
388- ) ,
389- )
390- . into_make_service ( )
391- . spawn_buffer ( buffer_capacity)
392- . push_make_ready ( )
393- . check_make_service :: < HttpLogical , http:: Request < _ > > ( ) ;
365+ . check_new_service :: < HttpLogical , http:: Request < _ > > ( ) ;
394366
395367 // Caches clients that bypass discovery/balancing.
396368 let forward = svc:: stack ( endpoint)
397- . check_make_service :: < HttpEndpoint , http:: Request < http:: boxed:: Payload > > ( )
398369 . into_new_service ( )
399- . cache (
400- svc:: layers ( ) . push_on_response (
401- svc:: layers ( )
402- . push_failfast ( dispatch_timeout)
403- . push_spawn_buffer_with_idle_timeout ( buffer_capacity, cache_max_idle_age)
404- . box_http_request ( )
405- . push ( metrics. stack . layer ( stack_labels ( "forward.endpoint" ) ) ) ,
406- ) ,
407- )
408- . into_make_service ( )
409- . spawn_buffer ( buffer_capacity)
410370 . instrument ( |t : & HttpEndpoint | debug_span ! ( "forward" , peer. id = ?t. identity) )
411- . check_make_service :: < HttpEndpoint , http:: Request < _ > > ( ) ;
371+ . check_new_service :: < HttpEndpoint , http:: Request < _ > > ( ) ;
412372
413373 // Attempts to route route request to a logical services that uses
414374 // control plane for discovery. If the discovery is rejected, the
@@ -422,6 +382,17 @@ impl Config {
422382 . into_inner ( ) ,
423383 is_discovery_rejected,
424384 )
385+ . cache (
386+ svc:: layers ( ) . push_on_response (
387+ svc:: layers ( )
388+ . push_failfast ( dispatch_timeout)
389+ . push_spawn_buffer_with_idle_timeout ( buffer_capacity, cache_max_idle_age)
390+ . push ( metrics. stack . layer ( stack_labels ( "logical" ) ) ) ,
391+ ) ,
392+ )
393+ . into_make_service ( )
394+ . spawn_buffer ( buffer_capacity)
395+ . check_make_service :: < HttpLogical , http:: Request < _ > > ( )
425396 . push ( http:: header_from_target:: layer ( CANONICAL_DST_HEADER ) )
426397 // Strips headers that may be set by this proxy.
427398 . push_on_response ( http:: strip_header:: request:: layer ( DST_OVERRIDE_HEADER ) )
@@ -486,6 +457,8 @@ impl Config {
486457 dispatch_timeout,
487458 max_in_flight_requests,
488459 detect_protocol_timeout,
460+ cache_max_idle_age,
461+ buffer_capacity,
489462 ..
490463 } = self . proxy ;
491464 let canonicalize_timeout = self . canonicalize_timeout ;
@@ -536,9 +509,22 @@ impl Config {
536509 // Load balances TCP streams that cannot be decoded as HTTP.
537510 let tcp_balance = svc:: stack ( self . build_tcp_balance ( tcp_connect, resolve) )
538511 . push_fallback_with_predicate (
539- svc:: stack ( tcp_forward. clone ( ) ) . push_map_target ( TcpEndpoint :: from) ,
512+ svc:: stack ( tcp_forward. clone ( ) )
513+ . check_new :: < TcpEndpoint > ( )
514+ . push_map_target ( TcpEndpoint :: from)
515+ . into_inner ( ) ,
540516 is_discovery_rejected,
541517 )
518+ . cache (
519+ svc:: layers ( ) . push_on_response (
520+ svc:: layers ( )
521+ . push_failfast ( dispatch_timeout)
522+ . push_spawn_buffer_with_idle_timeout ( buffer_capacity, cache_max_idle_age) ,
523+ ) ,
524+ )
525+ . into_make_service ( )
526+ . spawn_buffer ( buffer_capacity)
527+ . instrument ( |_: & _ | info_span ! ( "tcp" ) )
542528 . push_map_target ( |a : listen:: Addrs | a. target_addr ( ) )
543529 . into_inner ( ) ;
544530
0 commit comments