Documentation ¶
Index ¶
- Variables
- func Register(resolver selectorResolver)
- type Balancer
- type BalancerBuilder
- type Builder
- type Default
- type DefaultBuilder
- type DefaultNode
- type DoneFunc
- type DoneInfo
- type Filter
- type Node
- type Rebalancer
- type ReplyMeta
- type SelectOption
- type SelectOptions
- type Selector
- type WeightedNode
- type WeightedNodeBuilder
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoAvailable = errors.InternalServer("no_available_node")
ErrNoAvailable is no available node.
Functions ¶
Types ¶
type Balancer ¶
type Balancer interface {
Pick(ctx context.Context, nodes []WeightedNode) (selected WeightedNode, done DoneFunc, err error)
}
Balancer is balancer interface
type BalancerBuilder ¶
type BalancerBuilder interface {
Build() Balancer
}
BalancerBuilder build balancer
type Default ¶
type Default struct { NodeBuilder WeightedNodeBuilder Balancer Balancer Filters []Filter // contains filtered or unexported fields }
Default is composite selector.
type DefaultBuilder ¶
type DefaultBuilder struct { BuilderName string Node WeightedNodeBuilder Balancer BalancerBuilder Filters []Filter }
DefaultBuilder is de
func (*DefaultBuilder) Name ¶
func (db *DefaultBuilder) Name() string
type DefaultNode ¶
type DefaultNode struct {
// contains filtered or unexported fields
}
DefaultNode is selector node
func (*DefaultNode) InitialWeight ¶
func (n *DefaultNode) InitialWeight() *int64
InitialWeight is node initialWeight
func (*DefaultNode) Metadata ¶
func (n *DefaultNode) Metadata() map[string]string
Metadata is node metadata
func (*DefaultNode) ServiceName ¶
func (n *DefaultNode) ServiceName() string
ServiceName is node serviceName
type Node ¶
type Node interface { // Address is the unique address under the same service Address() string // ServiceName is service name ServiceName() string // InitialWeight is the initial value of scheduling weight // if not set return nil InitialWeight() *int64 // Version is service node version Version() string // Metadata is the kv pair metadata associated with the service instance. // version,namespace,region,protocol etc.. Metadata() map[string]string }
Node is node interface.
type Rebalancer ¶
type Rebalancer interface { // Apply is apply all nodes when any changes happen Apply(nodes []Node) }
Rebalancer is nodes rebalancer.
type SelectOptions ¶
type SelectOptions struct {
Filters []Filter
}
SelectOptions is Select Options.
type Selector ¶
type Selector interface { Rebalancer // Select nodes // if err == nil, selected and done must not be empty. Select(ctx context.Context, opts ...SelectOption) (selected Node, done DoneFunc, err error) }
Selector is node pick balancer.
func GetSelector ¶
type WeightedNode ¶
type WeightedNode interface { Node // Raw returns the original node Raw() Node // Weight is the runtime calculated weight Weight() float64 // Pick the node Pick() DoneFunc // PickElapsed is time elapsed since the latest pick PickElapsed() time.Duration }
WeightedNode calculates scheduling weight in real time
type WeightedNodeBuilder ¶
type WeightedNodeBuilder interface {
Build(Node) WeightedNode
}
WeightedNodeBuilder is WeightedNode Builder
Source Files ¶
Click to show internal directories.
Click to hide internal directories.