var errBalancerClosed … var _ … // NewBalancer returns a graceful switch Balancer. func NewBalancer(cc balancer.ClientConn, opts balancer.BuildOptions) *Balancer { … } type Balancer … // swap swaps out the current lb with the pending lb and updates the ClientConn. // The caller must hold gsb.mu. func (gsb *Balancer) swap() { … } // Helper function that checks if the balancer passed in is current or pending. // The caller must hold gsb.mu. func (gsb *Balancer) balancerCurrentOrPending(bw *balancerWrapper) bool { … } // SwitchTo initializes the graceful switch process, which completes based on // connectivity state changes on the current/pending balancer. Thus, the switch // process is not complete when this method returns. This method must be called // synchronously alongside the rest of the balancer.Balancer methods this // Graceful Switch Balancer implements. // // Deprecated: use ParseConfig and pass a parsed config to UpdateClientConnState // to cause the Balancer to automatically change to the new child when necessary. func (gsb *Balancer) SwitchTo(builder balancer.Builder) error { … } func (gsb *Balancer) switchTo(builder balancer.Builder) (*balancerWrapper, error) { … } // Returns nil if the graceful switch balancer is closed. func (gsb *Balancer) latestBalancer() *balancerWrapper { … } // UpdateClientConnState forwards the update to the latest balancer created. // // If the state's BalancerConfig is the config returned by a call to // gracefulswitch.ParseConfig, then this function will automatically SwitchTo // the balancer indicated by the config before forwarding its config to it, if // necessary. func (gsb *Balancer) UpdateClientConnState(state balancer.ClientConnState) error { … } // ResolverError forwards the error to the latest balancer created. func (gsb *Balancer) ResolverError(err error) { … } // ExitIdle forwards the call to the latest balancer created. // // If the latest balancer does not support ExitIdle, the subConns are // re-connected to manually. func (gsb *Balancer) ExitIdle() { … } // updateSubConnState forwards the update to the appropriate child. func (gsb *Balancer) updateSubConnState(sc balancer.SubConn, state balancer.SubConnState, cb func(balancer.SubConnState)) { … } // UpdateSubConnState forwards the update to the appropriate child. func (gsb *Balancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState) { … } // Close closes any active child balancers. func (gsb *Balancer) Close() { … } type balancerWrapper … // Close closes the underlying LB policy and shuts down the subconns it // created. bw must not be referenced via balancerCurrent or balancerPending in // gsb when called. gsb.mu must not be held. Does not panic with a nil // receiver. func (bw *balancerWrapper) Close() { … } func (bw *balancerWrapper) UpdateState(state balancer.State) { … } func (bw *balancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer.NewSubConnOptions) (balancer.SubConn, error) { … } func (bw *balancerWrapper) ResolveNow(opts resolver.ResolveNowOptions) { … } func (bw *balancerWrapper) RemoveSubConn(sc balancer.SubConn) { … } func (bw *balancerWrapper) UpdateAddresses(sc balancer.SubConn, addrs []resolver.Address) { … } func (bw *balancerWrapper) Target() string { … }