@@ -94,6 +94,8 @@ final class XdsNameResolver extends NameResolver {
94
94
95
95
static final CallOptions .Key <String > CLUSTER_SELECTION_KEY =
96
96
CallOptions .Key .create ("io.grpc.xds.CLUSTER_SELECTION_KEY" );
97
+ static final CallOptions .Key <XdsConfig > XDS_CONFIG_CALL_OPTION_KEY =
98
+ CallOptions .Key .create ("io.grpc.xds.XDS_CONFIG_CALL_OPTION_KEY" );
97
99
static final CallOptions .Key <Long > RPC_HASH_KEY =
98
100
CallOptions .Key .create ("io.grpc.xds.RPC_HASH_KEY" );
99
101
static final CallOptions .Key <Boolean > AUTO_HOST_REWRITE_KEY =
@@ -467,6 +469,7 @@ public Result selectConfig(PickSubchannelArgs args) {
467
469
"Failed to parse service config (method config)" ));
468
470
}
469
471
final String finalCluster = cluster ;
472
+ final XdsConfig xdsConfig = routingCfg .xdsConfig ;
470
473
final long hash = generateHash (routeAction .hashPolicies (), headers );
471
474
class ClusterSelectionInterceptor implements ClientInterceptor {
472
475
@ Override
@@ -475,6 +478,7 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
475
478
final Channel next ) {
476
479
CallOptions callOptionsForCluster =
477
480
callOptions .withOption (CLUSTER_SELECTION_KEY , finalCluster )
481
+ .withOption (XDS_CONFIG_CALL_OPTION_KEY , xdsConfig )
478
482
.withOption (RPC_HASH_KEY , hash );
479
483
if (routeAction .autoHostRewrite ()) {
480
484
callOptionsForCluster = callOptionsForCluster .withOption (AUTO_HOST_REWRITE_KEY , true );
@@ -801,7 +805,7 @@ private void updateRoutes(
801
805
}
802
806
// Make newly added clusters selectable by config selector and deleted clusters no longer
803
807
// selectable.
804
- routingConfig = new RoutingConfig (httpMaxStreamDurationNano , routesData .build ());
808
+ routingConfig = new RoutingConfig (xdsConfig , httpMaxStreamDurationNano , routesData .build ());
805
809
for (String cluster : deletedClusters ) {
806
810
int count = clusterRefs .get (cluster ).refCount .decrementAndGet ();
807
811
if (count == 0 ) {
@@ -879,17 +883,21 @@ private void cleanUpRoutes(Status error) {
879
883
* VirtualHost-level configuration for request routing.
880
884
*/
881
885
private static class RoutingConfig {
882
- private final long fallbackTimeoutNano ;
886
+ final XdsConfig xdsConfig ;
887
+ final long fallbackTimeoutNano ;
883
888
final ImmutableList <RouteData > routes ;
884
889
final Status errorStatus ;
885
890
886
- private RoutingConfig (long fallbackTimeoutNano , ImmutableList <RouteData > routes ) {
891
+ private RoutingConfig (
892
+ XdsConfig xdsConfig , long fallbackTimeoutNano , ImmutableList <RouteData > routes ) {
893
+ this .xdsConfig = checkNotNull (xdsConfig , "xdsConfig" );
887
894
this .fallbackTimeoutNano = fallbackTimeoutNano ;
888
895
this .routes = checkNotNull (routes , "routes" );
889
896
this .errorStatus = null ;
890
897
}
891
898
892
899
private RoutingConfig (Status errorStatus ) {
900
+ this .xdsConfig = null ;
893
901
this .fallbackTimeoutNano = 0 ;
894
902
this .routes = null ;
895
903
this .errorStatus = checkNotNull (errorStatus , "errorStatus" );
0 commit comments