File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
examples/Container/Frontend/Balancer Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 1- #region Copyright notice and license
1+ #region Copyright notice and license
22
33// Copyright 2019 The gRPC Authors
44//
@@ -24,6 +24,8 @@ namespace Frontend.Balancer
2424{
2525 public class ConfigurableResolverFactory : ResolverFactory
2626 {
27+ private static readonly BalancerAttributesKey < string > HostOverrideKey = new BalancerAttributesKey < string > ( "HostOverride" ) ;
28+
2729 private readonly ResolverFactory _innerResolverFactory ;
2830 private readonly BalancerConfiguration _balancerConfiguration ;
2931
@@ -101,6 +103,13 @@ private void RaiseResult(ResolverResult result)
101103 // DNS results change order between refreshes.
102104 // Explicitly order by host to keep result order consistent.
103105 var orderedAddresses = result . Addresses . OrderBy ( a => a . EndPoint . Host ) . ToList ( ) ;
106+ // Remove host override from addresses so the destination IP address is available.
107+ // The sample does this because the server returns the IP address to the client.
108+ // This makes it clear that gRPC calls are balanced between pods.
109+ foreach ( var address in orderedAddresses )
110+ {
111+ ( ( IDictionary < string , object ? > ) address . Attributes ) . Remove ( HostOverrideKey . Key ) ;
112+ }
104113 _listener ( ResolverResult . ForResult ( orderedAddresses , serviceConfig , Status . DefaultSuccess ) ) ;
105114 }
106115 else
You can’t perform that action at this time.
0 commit comments