load_balance

package
v0.0.0-...-426aaea Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsistentHashBalance

type ConsistentHashBalance struct {
	// contains filtered or unexported fields
}

func NewConsistentHashBalance

func NewConsistentHashBalance(replicas int, fn Hash) *ConsistentHashBalance

func (*ConsistentHashBalance) Add

func (c *ConsistentHashBalance) Add(params ...string) error

func (*ConsistentHashBalance) Get

func (c *ConsistentHashBalance) Get(key string) (string, error)

func (*ConsistentHashBalance) IsEmpty

func (c *ConsistentHashBalance) IsEmpty() bool

func (*ConsistentHashBalance) Update

func (c *ConsistentHashBalance) Update(addrs []string)

type Hash

type Hash func(data []byte) uint32

type IPHashBalance

type IPHashBalance struct {
	// contains filtered or unexported fields
}

func (*IPHashBalance) Add

func (ih *IPHashBalance) Add(params ...string) error

func (*IPHashBalance) Get

func (ih *IPHashBalance) Get(key string) (string, error)

func (*IPHashBalance) Update

func (ih *IPHashBalance) Update(addrs []string)

type LbType

type LbType int
const (
	LbRandom LbType = iota
	LbRoundRobin
	LbWeightRoundRobin
	LbConsistentHash
	LbIPHash
)

type LoadBalance

type LoadBalance interface {
	Add(...string) error
	Get(string) (string, error)
}

func NewLoadBalanceFromFactorWithDiscovery

func NewLoadBalanceFromFactorWithDiscovery(lbType LbType, discovery *etcd.ServiceDiscovery) LoadBalance

func NewLoadBalanceFromFactory

func NewLoadBalanceFromFactory(lbType LbType) LoadBalance

type RandomBalance

type RandomBalance struct {
	// contains filtered or unexported fields
}

func (*RandomBalance) Add

func (r *RandomBalance) Add(params ...string) error

func (*RandomBalance) Get

func (r *RandomBalance) Get(key string) (string, error)

func (*RandomBalance) Next

func (r *RandomBalance) Next() string

func (*RandomBalance) Update

func (r *RandomBalance) Update(addrs []string)

type RoundRobinBalance

type RoundRobinBalance struct {
	// contains filtered or unexported fields
}

func (*RoundRobinBalance) Add

func (r *RoundRobinBalance) Add(params ...string) error

func (*RoundRobinBalance) Get

func (r *RoundRobinBalance) Get(key string) (string, error)

func (*RoundRobinBalance) Next

func (r *RoundRobinBalance) Next() string

func (*RoundRobinBalance) Update

func (r *RoundRobinBalance) Update(addrs []string)

type UInt32Slice

type UInt32Slice []uint32

func (UInt32Slice) Len

func (s UInt32Slice) Len() int

func (UInt32Slice) Less

func (s UInt32Slice) Less(i, j int) bool

func (UInt32Slice) Swap

func (s UInt32Slice) Swap(i, j int)

type WeightNode

type WeightNode struct {
	// contains filtered or unexported fields
}

type WeightRoundRobinBalance

type WeightRoundRobinBalance struct {
	// contains filtered or unexported fields
}

func (*WeightRoundRobinBalance) Add

func (r *WeightRoundRobinBalance) Add(params ...string) error

Add 地址 权重值

func (*WeightRoundRobinBalance) Get

func (r *WeightRoundRobinBalance) Get(key string) (string, error)

func (*WeightRoundRobinBalance) Next

func (r *WeightRoundRobinBalance) Next() string

func (*WeightRoundRobinBalance) Update

func (r *WeightRoundRobinBalance) Update(addrs []string)

Jump to

Keyboard shortcuts

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