Documentation
¶
Overview ¶
Package gsel provides selector definition and implements.
Index ¶
Constants ¶
View Source
const SelectorLeastConnection = "BalancerLeastConnection"
View Source
const SelectorRandom = "BalancerRandom"
View Source
const SelectorRoundRobin = "BalancerRoundRobin"
View Source
const SelectorWeight = "BalancerWeight"
Variables ¶
This section is empty.
Functions ¶
func SetBuilder ¶
func SetBuilder(builder Builder)
SetBuilder sets the default builder for globally used purpose.
Types ¶
type Builder ¶
type Builder interface {
Build() Selector
}
Builder creates and returns selector in runtime.
func GetBuilder ¶
func GetBuilder() Builder
GetBuilder returns the default builder for globally used purpose.
func NewBuilderLeastConnection ¶
func NewBuilderLeastConnection() Builder
func NewBuilderRandom ¶
func NewBuilderRandom() Builder
func NewBuilderRoundRobin ¶
func NewBuilderRoundRobin() Builder
func NewBuilderWeight ¶
func NewBuilderWeight() Builder
type DoneInfo ¶
type DoneInfo struct {
// Err is the rpc error the RPC finished with. It could be nil.
Err error
// Trailer contains the metadata from the RPC's trailer, if present.
Trailer DoneInfoMD
// BytesSent indicates if any bytes have been sent to the server.
BytesSent bool
// BytesReceived indicates if any byte has been received from the server.
BytesReceived bool
// ServerLoad is the load received from server. It's usually sent as part of
// trailing metadata.
//
// The only supported type now is *orca_v1.LoadReport.
ServerLoad interface{}
}
DoneInfo contains additional information for done.
type DoneInfoMD ¶
type DoneInfoMD interface {
// Len returns the number of items in md.
Len() int
// Get obtains the values for a given key.
//
// k is converted to lowercase before searching in md.
Get(k string) []string
// Set sets the value of a given key with a slice of values.
//
// k is converted to lowercase before storing in md.
Set(key string, values ...string)
// Append adds the values to key k, not overwriting what was already stored at
// that key.
//
// k is converted to lowercase before storing in md.
Append(k string, values ...string)
// Delete removes the values for a given key k which is converted to lowercase
// before removing it from md.
Delete(k string)
}
DoneInfoMD is a mapping from metadata keys to value array. Users should use the following two convenience functions New and Pairs to generate MD.
type Selector ¶
type Selector interface {
// Pick selects and returns service.
Pick(ctx context.Context) (node Node, done DoneFunc, err error)
// Update updates services into Selector.
Update(ctx context.Context, nodes Nodes) error
}
Selector for service balancer.
func NewSelectorLeastConnection ¶
func NewSelectorLeastConnection() Selector
func NewSelectorRandom ¶
func NewSelectorRandom() Selector
func NewSelectorRoundRobin ¶
func NewSelectorRoundRobin() Selector
func NewSelectorWeight ¶
func NewSelectorWeight() Selector
Click to show internal directories.
Click to hide internal directories.