Search and commands

↑ ↓ to select · Enter to open · Esc to close

Type to search packages.

gracefulswitch

v1.85.0
google.golang.org/grpc/internal/balancer/gracefulswitch

Documentation

pkg.go.dev ↗

Table of contents

↓ to select · Enter to jump· Shift+Enter for source

12 matches

Top ↑

Package gracefulswitch implements a graceful switch load balancer.

Functions

ChildName

func ChildName(l serviceconfig.LoadBalancingConfig) string

ChildName returns the name of the child balancer of the gracefulswitch Balancer.

ParseConfig

func ParseConfig(cfg json.RawMessage) (serviceconfig.LoadBalancingConfig, error)

ParseConfig parses a child config list and returns a LB config for the gracefulswitch Balancer.

cfg is expected to be a json.RawMessage containing a JSON array of LB policy names + configs as the format of the "loadBalancingConfig" field in ServiceConfig. It returns a type that should be passed to UpdateClientConnState in the BalancerConfig field.

Types

Balancer

type Balancer struct {
	// contains filtered or unexported fields
}

Balancer is a utility to gracefully switch from one balancer to a new balancer. It implements the balancer.Balancer interface.

NewBalancer

func NewBalancer(cc balancer.ClientConn, opts balancer.BuildOptions) *Balancer

NewBalancer returns a graceful switch Balancer.

Balancer.Close

func (gsb *Balancer) Close()

Close closes any active child balancers.

Balancer.ExitIdle

func (gsb *Balancer) ExitIdle()

ExitIdle forwards the call to the latest balancer created.

If the latest balancer does not support ExitIdle, the subConns are re-connected to manually.

Balancer.ResolverError

func (gsb *Balancer) ResolverError(err error)

ResolverError forwards the error to the latest balancer created.

Balancer.SwitchTo

func (gsb *Balancer) SwitchTo(builder balancer.Builder) error

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.

Balancer.UpdateClientConnState

func (gsb *Balancer) UpdateClientConnState(state balancer.ClientConnState) error

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.

Balancer.UpdateSubConnState

func (gsb *Balancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState)

UpdateSubConnState forwards the update to the appropriate child.

Dependency graph