@@ -13,7 +13,10 @@ use std::fmt;
1313use  std:: fmt:: { Display ,  Formatter } ; 
1414use  std:: ops:: RangeInclusive ; 
1515
16- use  crate :: deployment:: { DeploymentAddress ,  HttpDeploymentAddress ,  LambdaDeploymentAddress } ; 
16+ use  crate :: config:: Configuration ; 
17+ use  crate :: deployment:: { 
18+     DeploymentAddress ,  Headers ,  HttpDeploymentAddress ,  LambdaDeploymentAddress , 
19+ } ; 
1720use  crate :: identifiers:: { DeploymentId ,  LambdaARN ,  ServiceRevision } ; 
1821use  crate :: schema:: service:: ServiceMetadata ; 
1922use  crate :: time:: MillisSinceEpoch ; 
@@ -141,15 +144,24 @@ impl DeploymentMetadata {
141144        self . created_at 
142145    } 
143146
144-     pub  fn  semantic_eq_with_address_and_headers ( & self ,  other_addess :  & DeploymentAddress )  -> bool  { 
147+     pub  fn  semantic_eq_with_address_and_headers ( 
148+         & self , 
149+         other_addess :  & DeploymentAddress , 
150+         other_additional_headers :  & Headers , 
151+     )  -> bool  { 
145152        match  ( & self . ty ,  other_addess)  { 
146153            ( 
147154                DeploymentType :: Http  { 
148155                    address :  this_address, 
149156                    ..
150157                } , 
151158                DeploymentAddress :: Http ( HttpDeploymentAddress  {  uri :  other_address } ) , 
152-             )  => Self :: semantic_eq_http ( this_address,  other_address) , 
159+             )  => Self :: semantic_eq_http ( 
160+                 this_address, 
161+                 other_address, 
162+                 & self . delivery_options . additional_headers , 
163+                 other_additional_headers, 
164+             ) , 
153165            ( 
154166                DeploymentType :: Lambda  {  arn :  this_arn,  .. } , 
155167                DeploymentAddress :: Lambda ( LambdaDeploymentAddress  {  arn :  other_arn,  .. } ) , 
@@ -162,10 +174,21 @@ impl DeploymentMetadata {
162174        this_arn == other_arn
163175    } 
164176
165-     pub ( crate )  fn  semantic_eq_http ( this_address :  & Uri ,  other_address :  & Uri )  -> bool  { 
177+     pub ( crate )  fn  semantic_eq_http ( 
178+         this_address :  & Uri , 
179+         other_address :  & Uri , 
180+         this_additional_headers :  & Headers , 
181+         other_additional_headers :  & Headers , 
182+     )  -> bool  { 
183+         let  deployment_routing_headers = & Configuration :: pinned ( ) . admin . deployment_routing_headers ; 
184+ 
166185        this_address. authority ( ) . expect ( "Must have authority" ) 
167186            == other_address. authority ( ) . expect ( "Must have authority" ) 
168187            && this_address. path ( )  == other_address. path ( ) 
188+             && deployment_routing_headers. iter ( ) . all ( |routing_header_key| { 
189+                 this_additional_headers. get ( routing_header_key) 
190+                     == other_additional_headers. get ( routing_header_key) 
191+             } ) 
169192    } 
170193} 
171194
@@ -245,6 +268,7 @@ pub trait DeploymentResolver {
245268    fn  find_deployment ( 
246269        & self , 
247270        deployment_address :  & DeploymentAddress , 
271+         additional_headers :  & Headers , 
248272    )  -> Option < ( Deployment ,  Vec < ServiceMetadata > ) > ; 
249273
250274    fn  get_deployment ( & self ,  deployment_id :  & DeploymentId )  -> Option < Deployment > ; 
@@ -445,10 +469,13 @@ pub mod test_util {
445469        fn  find_deployment ( 
446470            & self , 
447471            deployment_address :  & DeploymentAddress , 
472+             additional_headers :  & Headers , 
448473        )  -> Option < ( Deployment ,  Vec < ServiceMetadata > ) >  { 
449474            self . deployments 
450475                . iter ( ) 
451-                 . find ( |( _,  d) | d. semantic_eq_with_address_and_headers ( deployment_address) ) 
476+                 . find ( |( _,  d) | { 
477+                     d. semantic_eq_with_address_and_headers ( deployment_address,  additional_headers) 
478+                 } ) 
452479                . and_then ( |( dp_id,  _) | self . get_deployment_and_services ( dp_id) ) 
453480        } 
454481
@@ -504,6 +531,7 @@ pub mod test_util {
504531        fn  find_deployment ( 
505532            & self , 
506533            _:  & DeploymentAddress , 
534+             _:  & Headers , 
507535        )  -> Option < ( Deployment ,  Vec < ServiceMetadata > ) >  { 
508536            None 
509537        } 
0 commit comments