1- use super :: { Concrete , Endpoint , Logical } ;
1+ use super :: { Concrete , Logical } ;
22use crate :: { resolve, stack_labels, Outbound } ;
33use linkerd_app_core:: {
44 classify, config, profiles,
5- proxy:: { api_resolve :: Metadata , core:: Resolve , http} ,
6- retry, svc, tls, Error , CANONICAL_DST_HEADER , DST_OVERRIDE_HEADER ,
5+ proxy:: { core:: Resolve , http} ,
6+ retry, svc, tls, Error , Never , CANONICAL_DST_HEADER , DST_OVERRIDE_HEADER ,
77} ;
88use tracing:: debug_span;
99
@@ -25,13 +25,14 @@ impl<E> Outbound<E> {
2525 where
2626 B : http:: HttpBody < Error = Error > + std:: fmt:: Debug + Default + Send + ' static ,
2727 B :: Data : Send + ' static ,
28- E : svc:: NewService < Endpoint , Service = ESvc > + Clone + Send + ' static ,
28+ E : svc:: NewService < R :: Endpoint , Service = ESvc > + Clone + Send + ' static ,
2929 ESvc : svc:: Service < http:: Request < http:: BoxBody > , Response = http:: Response < http:: BoxBody > >
3030 + Send
3131 + ' static ,
3232 ESvc :: Error : Into < Error > ,
3333 ESvc :: Future : Send ,
34- R : Resolve < Concrete , Endpoint = Metadata , Error = Error > + Clone + Send + ' static ,
34+ R : Resolve < Concrete , Error = Error > + Clone + Send + ' static ,
35+ R :: Endpoint : From < ( tls:: NoClientTls , Logical ) > + Clone + Send ,
3536 R :: Resolution : Send ,
3637 R :: Future : Send + Unpin ,
3738 {
@@ -50,6 +51,7 @@ impl<E> Outbound<E> {
5051
5152 let stack = endpoint
5253 . clone ( )
54+ . check_new_service :: < R :: Endpoint , http:: Request < http:: BoxBody > > ( )
5355 . push_on_response (
5456 svc:: layers ( )
5557 . push ( http:: BoxRequest :: layer ( ) )
@@ -62,6 +64,7 @@ impl<E> Outbound<E> {
6264 // the balancer need not drive them all directly.
6365 . push ( svc:: layer:: mk ( svc:: SpawnReady :: new) ) ,
6466 )
67+ . check_new_service :: < R :: Endpoint , http:: Request < _ > > ( )
6568 // Resolve the service to its endpoints and balance requests over them.
6669 //
6770 // If the balancer has been empty/unavailable, eagerly fail requests.
@@ -79,6 +82,7 @@ impl<E> Outbound<E> {
7982 . push ( svc:: FailFast :: layer ( "HTTP Balancer" , dispatch_timeout) )
8083 . push ( http:: BoxResponse :: layer ( ) ) ,
8184 )
85+ . check_make_service :: < Concrete , http:: Request < _ > > ( )
8286 . push ( svc:: MapErrLayer :: new ( Into :: into) )
8387 // Drives the initial resolution via the service's readiness.
8488 . into_new_service ( )
@@ -96,9 +100,12 @@ impl<E> Outbound<E> {
96100 . push ( http:: BoxRequest :: layer ( ) )
97101 . push ( http:: BoxResponse :: layer ( ) ) ,
98102 )
99- . push_map_target ( Endpoint :: from_logical (
100- tls:: NoClientTls :: NotProvidedByServiceDiscovery ,
101- ) )
103+ . push_map_target ( |logical : Logical | {
104+ R :: Endpoint :: from ( (
105+ tls:: NoClientTls :: NotProvidedByServiceDiscovery ,
106+ logical,
107+ ) )
108+ } )
102109 . into_inner ( ) ,
103110 ) )
104111 // Distribute requests over a distribution of balancers via a
@@ -147,7 +154,24 @@ impl<E> Outbound<E> {
147154 )
148155 . instrument ( |l : & Logical | debug_span ! ( "logical" , dst = %l. addr( ) ) )
149156 . push_switch (
150- Logical :: or_endpoint ( tls:: NoClientTls :: NotProvidedByServiceDiscovery ) ,
157+ |logical : Logical | {
158+ let should_resolve = match logical. profile . as_ref ( ) {
159+ Some ( p) => {
160+ let p = p. borrow ( ) ;
161+ p. endpoint . is_none ( ) && ( p. name . is_some ( ) || !p. targets . is_empty ( ) )
162+ }
163+ None => false ,
164+ } ;
165+
166+ if should_resolve {
167+ Ok :: < _ , Never > ( svc:: Either :: A ( logical) )
168+ } else {
169+ Ok ( svc:: Either :: B ( R :: Endpoint :: from ( (
170+ tls:: NoClientTls :: NotProvidedByServiceDiscovery ,
171+ logical,
172+ ) ) ) )
173+ }
174+ } ,
151175 svc:: stack ( endpoint)
152176 . push_on_response ( http:: BoxRequest :: layer ( ) )
153177 . into_inner ( ) ,
0 commit comments