etcd: go.etcd.io/etcd/clientv3/balancer Index | Files | Directories

package balancer

import "go.etcd.io/etcd/clientv3/balancer"

Package balancer implements client balancer.

Index

Package Files

balancer.go config.go connectivity.go doc.go grpc1.7-health.go utils.go

Variables

var ErrNoAddrAvilable = status.Error(codes.Unavailable, "there is no address available")

ErrNoAddrAvilable is returned by Get() when the balancer does not have any active connection to endpoints at the time. This error is returned only when opts.BlockingWait is true.

func RegisterBuilder Uses

func RegisterBuilder(cfg Config)

RegisterBuilder creates and registers a builder. Since this function calls balancer.Register, it must be invoked at initialization time.

type Balancer Uses

type Balancer interface {
    // Balancer is called on specified client connection. Client initiates gRPC
    // connection with "grpc.Dial(addr, grpc.WithBalancerName)", and then those resolved
    // addresses are passed to "grpc/balancer.Balancer.HandleResolvedAddrs".
    // For each resolved address, balancer calls "balancer.ClientConn.NewSubConn".
    // "grpc/balancer.Balancer.HandleSubConnStateChange" is called when connectivity state
    // changes, thus requires failover logic in this method.
    balancer.Balancer

    // Picker calls "Pick" for every client request.
    picker.Picker
}

Balancer defines client balancer interface.

type Config Uses

type Config struct {
    // Policy configures balancer policy.
    Policy picker.Policy

    // Name defines an additional name for balancer.
    // Useful for balancer testing to avoid register conflicts.
    // If empty, defaults to policy name.
    Name string

    // Logger configures balancer logging.
    // If nil, logs are discarded.
    Logger *zap.Logger
}

Config defines balancer configurations.

type DialFunc Uses

type DialFunc func(ep string, dopts ...grpc.DialOption) (*grpc.ClientConn, error)

DialFunc defines gRPC dial function.

type GRPC17Health Uses

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

GRPC17Health does the bare minimum to expose multiple eps to the grpc reconnection code path

func NewGRPC17Health Uses

func NewGRPC17Health(
    eps []string,
    timeout time.Duration,
    dialFunc DialFunc,
) *GRPC17Health

NewGRPC17Health returns a new health balancer with gRPC v1.7.

func (*GRPC17Health) Close Uses

func (b *GRPC17Health) Close() error

func (*GRPC17Health) ConnectNotify Uses

func (b *GRPC17Health) ConnectNotify() <-chan struct{}

func (*GRPC17Health) Endpoint Uses

func (b *GRPC17Health) Endpoint(hostPort string) string

func (*GRPC17Health) Get Uses

func (b *GRPC17Health) Get(ctx context.Context, opts grpc.BalancerGetOptions) (grpc.Address, func(), error)

func (*GRPC17Health) HostPortError Uses

func (b *GRPC17Health) HostPortError(hostPort string, err error)

func (*GRPC17Health) NeedUpdate Uses

func (b *GRPC17Health) NeedUpdate() bool

NeedUpdate returns true if all connections are down or addresses do not include current pinned address.

func (*GRPC17Health) Next Uses

func (b *GRPC17Health) Next()

func (*GRPC17Health) Notify Uses

func (b *GRPC17Health) Notify() <-chan []grpc.Address

func (*GRPC17Health) Pinned Uses

func (b *GRPC17Health) Pinned() string

func (*GRPC17Health) Ready Uses

func (b *GRPC17Health) Ready() <-chan struct{}

func (*GRPC17Health) Start Uses

func (b *GRPC17Health) Start(target string, config grpc.BalancerConfig) error

func (*GRPC17Health) StopC Uses

func (b *GRPC17Health) StopC() chan struct{}

func (*GRPC17Health) Up Uses

func (b *GRPC17Health) Up(addr grpc.Address) func(error)

func (*GRPC17Health) UpdateAddrs Uses

func (b *GRPC17Health) UpdateAddrs(eps ...string)

func (*GRPC17Health) UpdateAddrsC Uses

func (b *GRPC17Health) UpdateAddrsC() chan NotifyMsg

type NotifyMsg Uses

type NotifyMsg int
const (
    NotifyReset NotifyMsg = iota
    NotifyNext
)

Directories

PathSynopsis
pickerPackage picker defines/implements client balancer picker policy.
resolver/endpointPackage endpoint resolves etcd entpoints using grpc targets of the form 'endpoint://<id>/<endpoint>'.

Package balancer imports 23 packages (graph) and is imported by 8 packages. Updated 2018-11-11. Refresh now. Tools for package owners.