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

Method fallbackToBackendsAfter

balancer/grpclb/grpclb.go:404–420  ·  view source on GitHub ↗

fallbackToBackendsAfter blocks for fallbackTimeout and falls back to use resolved backends (backends received from resolver, not from remote balancer) if no connection to remote balancers was successful.

(fallbackTimeout time.Duration)

Source from the content-addressed store, hash-verified

402// resolved backends (backends received from resolver, not from remote balancer)
403// if no connection to remote balancers was successful.
404func (lb *lbBalancer) fallbackToBackendsAfter(fallbackTimeout time.Duration) {
405 timer := time.NewTimer(fallbackTimeout)
406 defer timer.Stop()
407 select {
408 case <-timer.C:
409 case <-lb.doneCh:
410 return
411 }
412 lb.mu.Lock()
413 if lb.inFallback || lb.serverListReceived {
414 lb.mu.Unlock()
415 return
416 }
417 // Enter fallback.
418 lb.refreshSubConns(lb.resolvedBackendAddrs, true, lb.usePickFirst)
419 lb.mu.Unlock()
420}
421
422func (lb *lbBalancer) handleServiceConfig(gc *grpclbServiceConfig) {
423 lb.mu.Lock()

Callers 1

UpdateClientConnStateMethod · 0.95

Calls 5

StopMethod · 0.95
refreshSubConnsMethod · 0.95
NewTimerMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected