stub

package
v0.0.0-...-552da36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

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)
	// ParseConfig is used for parsing LB configs, if specified.
	ParseConfig func(json.RawMessage) (serviceconfig.LoadBalancingConfig, error)

	UpdateClientConnState func(*BalancerData, balancer.ClientConnState) error
	ResolverError         func(*BalancerData, error)
	UpdateSubConnState    func(*BalancerData, balancer.SubConn, balancer.SubConnState)
	Close                 func(*BalancerData)
	ExitIdle              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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL