MCPcopy
hub / github.com/grpc/grpc-go / lbBalancer

Struct lbBalancer

balancer/grpclb/grpclb.go:177–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175}
176
177type lbBalancer struct {
178 cc *lbCacheClientConn
179 dialTarget string // user's dial target
180 target string // same as dialTarget unless overridden in service config
181 opt balancer.BuildOptions
182 logger *internalgrpclog.PrefixLogger
183
184 usePickFirst bool
185
186 // grpclbClientConnCreds is the creds bundle to be used to connect to grpclb
187 // servers. If it's nil, use the TransportCredentials from BuildOptions
188 // instead.
189 grpclbClientConnCreds credentials.Bundle
190 // grpclbBackendCreds is the creds bundle to be used for addresses that are
191 // returned by grpclb server. If it's nil, don't set anything when creating
192 // SubConns.
193 grpclbBackendCreds credentials.Bundle
194
195 fallbackTimeout time.Duration
196 doneCh chan struct{}
197
198 // manualResolver is used in the remote LB ClientConn inside grpclb. When
199 // resolved address updates are received by grpclb, filtered updates will be
200 // sent to remote LB ClientConn through this resolver.
201 manualResolver *manual.Resolver
202 // The ClientConn to talk to the remote balancer.
203 ccRemoteLB *remoteBalancerCCWrapper
204 // backoff for calling remote balancer.
205 backoff backoff.Strategy
206
207 // Support client side load reporting. Each picker gets a reference to this,
208 // and will update its content.
209 clientStats *rpcStats
210
211 mu sync.Mutex // guards everything following.
212 // The full server list including drops, used to check if the newly received
213 // serverList contains anything new. Each generate picker will also have
214 // reference to this list to do the first layer pick.
215 fullServerList []*lbpb.Server
216 // Backend addresses. It's kept so the addresses are available when
217 // switching between round_robin and pickfirst.
218 backendAddrs []resolver.Address
219 // All backends addresses, with metadata set to nil. This list contains all
220 // backend addresses in the same order and with the same duplicates as in
221 // serverlist. When generating picker, a SubConn slice with the same order
222 // but with only READY SCs will be generated.
223 backendAddrsWithoutMetadata []resolver.Address
224 // Roundrobin functionalities.
225 state connectivity.State
226 subConns map[resolver.Address]balancer.SubConn // Used to new/shutdown SubConn.
227 scStates map[balancer.SubConn]connectivity.State // Used to filter READY SubConns.
228 picker balancer.Picker
229 // Support fallback to resolved backend addresses if there's no response
230 // from remote balancer within fallbackTimeout.
231 remoteBalancerConnected bool
232 serverListReceived bool
233 inFallback bool
234 // resolvedBackendAddrs is resolvedAddrs minus remote balancers. It's set

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected