Documentation

Overview

Package stub implements a balancer for testing purposes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, bf BalancerFuncs)

Register registers a stub balancer builder which will call the provided functions. The name used should be unique.

Types

type BalancerData

type BalancerData struct {
	// ClientConn is set by the builder.
	ClientConn balancer.ClientConn
	// BuildOptions is set by the builder.
	BuildOptions balancer.BuildOptions
	// Data may be used to store arbitrary user data.
	Data interface{}
}

BalancerData contains data relevant to a stub balancer.

type BalancerFuncs

type BalancerFuncs struct {
	// Init is called after ClientConn and BuildOptions are set in
	// BalancerData.  It may be used to initialize BalancerData.Data.
	Init func(*BalancerData)

	UpdateClientConnState func(*BalancerData, balancer.ClientConnState) error
	ResolverError         func(*BalancerData, error)
	UpdateSubConnState    func(*BalancerData, balancer.SubConn, balancer.SubConnState)
	Close                 func(*BalancerData)
}

BalancerFuncs contains all balancer.Balancer functions with a preceding *BalancerData parameter for passing additional instance information. Any nil functions will never be called.

Source Files