Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions tonic-xds/src/client/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,18 @@ impl XdsChannelBuilder {
resource_manager: XdsResourceManager,
) -> XdsChannelGrpc {
let router: Arc<dyn Router> = Arc::new(XdsRouter::new(&cache));

// Retry config is control-plane-driven from RDS, per route. It is parsed
// and validated once, when the `RouteConfiguration` is validated. The
// routing layer (outer) stamps the matched route's shared retry config
// into the request's `RouteDecision`; the retry layer reads the shared
// config `Arc` and instantiates a per-request policy from it, so the
// request hot path does no parsing or allocation. The default below is
// the fallback used when a request carries no route retry config (non-xDS
// callers, or a route with no retry policy). See
// [`RetryLayer`](crate::client::retry::RetryLayer).
let retry_layer = RetryLayer::new(GrpcRetryPolicy::default());

#[cfg(feature = "_tls-any")]
let discovery: Arc<
dyn ClusterDiscovery<EndpointAddress, EndpointChannel<Channel>>,
Expand All @@ -378,15 +390,13 @@ impl XdsChannelBuilder {
let discovery: Arc<
dyn ClusterDiscovery<EndpointAddress, EndpointChannel<Channel>>,
> = Arc::new(XdsClusterDiscovery::new(cache, GrpcMakeConnector::new()));
let retry_policy = GrpcRetryPolicy::default();

let resources = Arc::new(XdsChannelResources {
_resource_manager: resource_manager,
_xds_client: xds_client,
});

let routing_layer = XdsRoutingLayer::new(router, self.pre_route.clone(), self.authority());
let retry_layer = RetryLayer::new(retry_policy);
let cluster_registry = Arc::new(ClusterClientRegistryGrpc::new());
let lb_service = XdsLbService::new(cluster_registry, discovery);
let inner = ServiceBuilder::new()
Expand Down Expand Up @@ -527,6 +537,7 @@ mod tests {
Ok(RouteDecision {
cluster: "test-cluster".to_string(),
request_hash: None,
retry_config: None,
})
}
}
Expand Down Expand Up @@ -680,9 +691,7 @@ mod tests {

let retry_policy = GrpcRetryPolicy::new(
RetryConfig::new().num_retries(1),
GrpcRetryClassifier {
retry_on: vec![tonic::Code::Unavailable],
},
GrpcRetryClassifier::new(vec![tonic::Code::Unavailable]),
);

let xds_channel = XdsChannelBuilder::new(test_config()).build_grpc_channel_from_parts(
Expand Down Expand Up @@ -734,6 +743,7 @@ mod tests {
match_fraction: None,
},
action: RouteConfigAction::Cluster(cluster_name.to_string()),
retry_config: None,
}],
}],
metadata: Default::default(),
Expand Down
5 changes: 2 additions & 3 deletions tonic-xds/src/client/circuit_breaking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ mod tests {
request.extensions_mut().insert(RouteDecision {
cluster: CLUSTER.to_string(),
request_hash: None,
retry_config: None,
});
request
}
Expand Down Expand Up @@ -984,9 +985,7 @@ mod tests {
RetryBackoffConfig::new(Duration::from_millis(1))
.max_interval(Duration::from_millis(1)),
),
GrpcRetryClassifier {
retry_on: vec![Code::Unavailable],
},
GrpcRetryClassifier::new(vec![Code::Unavailable]),
);
let calls = Arc::new(AtomicU32::new(0));
let call_counter = calls.clone();
Expand Down
1 change: 1 addition & 0 deletions tonic-xds/src/client/loadbalance/pickers/ring_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ mod tests {
r.extensions_mut().insert(RouteDecision {
cluster: "c".to_string(),
request_hash: hash,
retry_config: None,
});
r
}
Expand Down
Loading
Loading