balancer

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAbleUsageRpcNodes = errors.New("no able usage rpc node")
)

Functions

func Register

func Register(scheme string, bf Factory)

Types

type Balancer

type Balancer interface {
	// Scheme 负载均衡器的名字
	// 默认实现RoundRobbin和Hash
	Scheme() string
	// IncNotify 用于增量通知, 适合地址列表少量变化的时候
	IncNotify(keys []int, nodes []*loadbalance.RpcNode)
	// FullNotify 全量更新
	FullNotify(nodes []*loadbalance.RpcNode)
	// Target 依赖Key从地址列表中给出一个地址
	// 负载均衡器没有可用节点时则会返回error
	Target(service string) (loadbalance.RpcNode, error)
}

func NewConsistentHash

func NewConsistentHash() Balancer

func NewHash

func NewHash() Balancer

func NewRandom

func NewRandom() Balancer

func NewRoundRobin

func NewRoundRobin() Balancer

type Factory

type Factory func() Balancer

func Get

func Get(scheme string) Factory

Jump to

Keyboard shortcuts

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