func (lb *rlsBalancer) updateControlChannel(newCfg *lbConfig) {
	oldCfg := lb.lbCfg
	if newCfg.lookupService == oldCfg.lookupService && newCfg.lookupServiceTimeout == oldCfg.lookupServiceTimeout {
		return
	}

	// Use RPC timeout from new config, if different from existing one.
	timeout := oldCfg.lookupServiceTimeout
	if timeout != newCfg.lookupServiceTimeout {
		timeout = newCfg.lookupServiceTimeout
	}

	if newCfg.lookupService == oldCfg.lookupService {
		// This is the case where only the timeout has changed. We will continue
		// to use the existing clientConn. but will create a new rlsClient with
		// the new timeout.
		lb.rlsC = newRLSClientFunc(lb.rlsCC, lb.opts.Target.Endpoint, timeout)
		return
	}

	// This is the case where the RLS server name has changed. We need to create
	// a new clientConn and close the old one.
	var dopts []grpc.DialOption
	if dialer := lb.opts.Dialer; dialer != nil {
		dopts = append(dopts, grpc.WithContextDialer(dialer))
	}
	dopts = append(dopts, dialCreds(lb.opts))

	cc, err := grpc.Dial(newCfg.lookupService, dopts...)
	if err != nil {
		logger.Errorf("rls: dialRLS(%s, %v): %v", newCfg.lookupService, lb.opts, err)
		// An error from a non-blocking dial indicates something serious. We
		// should continue to use the old control channel if one exists, and
		// return so that the rest of the config updates can be processes.
		return
	}
	if lb.rlsCC != nil {
		lb.rlsCC.Close()
	}
	lb.rlsCC = cc
	lb.rlsC = newRLSClientFunc(cc, lb.opts.Target.Endpoint, timeout)
}
// updateControlChannel updates the RLS client if required.
// Caller must hold lb.mu.
updateControlChannel updates the RLS client if required.
Caller must hold lb.mu.
// updateControlChannel updates the RLS client if required . // Caller must hold lb . mu .
func (lb *rlsBalancer) updateControlChannel(newCfg *lbConfig) {
	oldCfg := lb.lbCfg
	if newCfg.lookupService == oldCfg.lookupService && newCfg.lookupServiceTimeout == oldCfg.lookupServiceTimeout {
		return
	}
	timeout := oldCfg.lookupServiceTimeout
	if timeout != newCfg.lookupServiceTimeout {
		timeout = newCfg.lookupServiceTimeout
	}
	if newCfg.lookupService == oldCfg.lookupService {
		lb.rlsC = newRLSClientFunc(lb.rlsCC, lb.opts.Target.Endpoint, timeout)
		return
	}
	var dopts []grpc.DialOption
	if dialer := lb.opts.Dialer; dialer != nil {
		dopts = append(dopts, grpc.WithContextDialer(dialer))
	}
	dopts = append(dopts, dialCreds(lb.opts))
	cc, err := grpc.Dial(newCfg.lookupService, dopts...)
	if err != nil {
		logger.Errorf("rls: dialRLS(%s, %v): %v", newCfg.lookupService, lb.opts, err)
		return
	}
	if lb.rlsCC != nil {
		lb.rlsCC.Close()
	}
	lb.rlsCC = cc
	lb.rlsC = newRLSClientFunc(cc, lb.opts.Target.Endpoint, timeout)
}
func ( lb * rlsBalancer ) updateControlChannel ( newCfg * lbConfig ) { oldCfg := lb . lbCfg if newCfg . lookupService == oldCfg . lookupService && newCfg . lookupServiceTimeout == oldCfg . lookupServiceTimeout { return } timeout := oldCfg . lookupServiceTimeout if timeout != newCfg . lookupServiceTimeout { timeout = newCfg . lookupServiceTimeout } if newCfg . lookupService == oldCfg . lookupService { lb . rlsC = newRLSClientFunc ( lb . rlsCC , lb . opts . Target . Endpoint , timeout ) return } var dopts [ ] grpc . DialOption if dialer := lb . opts . Dialer ; dialer != nil { dopts = append ( dopts , grpc . WithContextDialer ( dialer ) ) } dopts = append ( dopts , dialCreds ( lb . opts ) ) cc , err := grpc . Dial ( newCfg . lookupService , dopts ... ) if err != nil { logger . Errorf ( " " , newCfg . lookupService , lb . opts , err ) return } if lb . rlsCC != nil { lb . rlsCC . Close ( ) } lb . rlsCC = cc lb . rlsC = newRLSClientFunc ( cc , lb . opts . Target . Endpoint , timeout ) }
updateControlChannel updates the RLS client if required.
updateControlChannel updates the RLS client if required .
// Use RPC timeout from new config, if different from existing one. // This is the case where only the timeout has changed. We will continue // to use the existing clientConn. but will create a new rlsClient with // the new timeout. // This is the case where the RLS server name has changed. We need to create // a new clientConn and close the old one. // An error from a non-blocking dial indicates something serious. We // should continue to use the old control channel if one exists, and // return so that the rest of the config updates can be processes.