@@ -14,12 +14,18 @@ use tracing::debug;
1414
1515#[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
1616pub struct Target {
17- pub logical : Addr ,
17+ pub dst : Addr ,
1818 pub socket_addr : SocketAddr ,
1919 pub http_settings : http:: Settings ,
2020 pub tls_client_id : tls:: PeerIdentity ,
2121}
2222
23+ #[ derive( Clone , Debug ) ]
24+ pub struct Logical {
25+ target : Target ,
26+ profiles : profiles:: Receiver ,
27+ }
28+
2329#[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
2430pub struct HttpEndpoint {
2531 pub port : u16 ,
@@ -100,10 +106,10 @@ impl tls::HasPeerIdentity for TcpEndpoint {
100106
101107// === impl Profile ===
102108
103- pub ( super ) fn route ( route : profiles:: http:: Route , target : Target ) -> dst:: Route {
109+ pub ( super ) fn route ( ( route, logical ) : ( profiles:: http:: Route , Logical ) ) -> dst:: Route {
104110 dst:: Route {
105111 route,
106- target : target. logical ,
112+ target : logical . target . dst ,
107113 direction : metric_labels:: Direction :: In ,
108114 }
109115}
@@ -112,7 +118,7 @@ pub(super) fn route(route: profiles::http::Route, target: Target) -> dst::Route
112118
113119impl AsRef < Addr > for Target {
114120 fn as_ref ( & self ) -> & Addr {
115- & self . logical
121+ & self . dst
116122 }
117123}
118124
@@ -123,7 +129,7 @@ impl http::normalize_uri::ShouldNormalizeUri for Target {
123129 ..
124130 } = self . http_settings
125131 {
126- return Some ( self . logical . to_http_authority ( ) ) ;
132+ return Some ( self . dst . to_http_authority ( ) ) ;
127133 }
128134 None
129135 }
@@ -144,7 +150,7 @@ impl tls::HasPeerIdentity for Target {
144150impl Into < metric_labels:: EndpointLabels > for Target {
145151 fn into ( self ) -> metric_labels:: EndpointLabels {
146152 metric_labels:: EndpointLabels {
147- authority : self . logical . name_addr ( ) . map ( |d| d. as_http_authority ( ) ) ,
153+ authority : self . dst . name_addr ( ) . map ( |d| d. as_http_authority ( ) ) ,
148154 direction : metric_labels:: Direction :: In ,
149155 tls_id : self . tls_client_id . map ( metric_labels:: TlsId :: ClientId ) ,
150156 labels : None ,
@@ -205,7 +211,7 @@ impl tap::Inspect for Target {
205211
206212impl fmt:: Display for Target {
207213 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
208- self . logical . fmt ( f)
214+ self . dst . fmt ( f)
209215 }
210216}
211217
@@ -214,7 +220,7 @@ impl stack_tracing::GetSpan<()> for Target {
214220 use tracing:: info_span;
215221
216222 match self . http_settings {
217- http:: Settings :: Http2 => match self . logical . name_addr ( ) {
223+ http:: Settings :: Http2 => match self . dst . name_addr ( ) {
218224 None => info_span ! (
219225 "http2" ,
220226 port = %self . socket_addr. port( ) ,
@@ -229,7 +235,7 @@ impl stack_tracing::GetSpan<()> for Target {
229235 keep_alive,
230236 wants_h1_upgrade,
231237 was_absolute_form,
232- } => match self . logical . name_addr ( ) {
238+ } => match self . dst . name_addr ( ) {
233239 None => info_span ! (
234240 "http1" ,
235241 port = %self . socket_addr. port( ) ,
@@ -262,7 +268,7 @@ impl<A> router::Recognize<http::Request<A>> for RequestTarget {
262268 type Key = Target ;
263269
264270 fn recognize ( & self , req : & http:: Request < A > ) -> Self :: Key {
265- let logical = req
271+ let dst = req
266272 . headers ( )
267273 . get ( CANONICAL_DST_HEADER )
268274 . and_then ( |dst| {
@@ -286,10 +292,30 @@ impl<A> router::Recognize<http::Request<A>> for RequestTarget {
286292 . unwrap_or_else ( || self . accept . addrs . target_addr ( ) . into ( ) ) ;
287293
288294 Target {
289- logical ,
295+ dst ,
290296 socket_addr : self . accept . addrs . target_addr ( ) ,
291297 tls_client_id : self . accept . peer_identity . clone ( ) ,
292298 http_settings : http:: Settings :: from_request ( req) ,
293299 }
294300 }
295301}
302+
303+ impl From < Logical > for Target {
304+ fn from ( Logical { target, .. } : Logical ) -> Self {
305+ target
306+ }
307+ }
308+
309+ // === impl Logical ===
310+
311+ impl From < ( profiles:: Receiver , Target ) > for Logical {
312+ fn from ( ( profiles, target) : ( profiles:: Receiver , Target ) ) -> Self {
313+ Self { profiles, target }
314+ }
315+ }
316+
317+ impl AsRef < profiles:: Receiver > for Logical {
318+ fn as_ref ( & self ) -> & profiles:: Receiver {
319+ & self . profiles
320+ }
321+ }
0 commit comments