endpointSharding is a balancer that wraps child balancers. It creates a child balancer with child config for every unique Endpoint received. It updates the child states on any update from parent or child.
| 91 | // balancer with child config for every unique Endpoint received. It updates the |
| 92 | // child states on any update from parent or child. |
| 93 | type endpointSharding struct { |
| 94 | cc balancer.ClientConn |
| 95 | bOpts balancer.BuildOptions |
| 96 | esOpts Options |
| 97 | childBuilder ChildBuilderFunc |
| 98 | |
| 99 | // childMu synchronizes calls to any single child. It must be held for all |
| 100 | // calls into a child. To avoid deadlocks, do not acquire childMu while |
| 101 | // holding mu. |
| 102 | childMu sync.Mutex |
| 103 | children atomic.Pointer[resolver.EndpointMap[*balancerWrapper]] |
| 104 | |
| 105 | // inhibitChildUpdates is set during UpdateClientConnState/ResolverError |
| 106 | // calls (calls to children will each produce an update, only want one |
| 107 | // update). |
| 108 | inhibitChildUpdates atomic.Bool |
| 109 | |
| 110 | // mu synchronizes access to the state stored in balancerWrappers in the |
| 111 | // children field. mu must not be held during calls into a child since |
| 112 | // synchronous calls back from the child may require taking mu, causing a |
| 113 | // deadlock. To avoid deadlocks, do not acquire childMu while holding mu. |
| 114 | mu sync.Mutex |
| 115 | } |
| 116 | |
| 117 | // rotateEndpoints returns a slice of all the input endpoints rotated a random |
| 118 | // amount. |
nothing calls this directly
no outgoing calls
no test coverage detected