LoadBalance

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoundRobinByWeight = 1
	SelectByIPHash     = 2
	SelectByRand       = 3
	RoundRobin         = 4
	SelectByWeightRand = 5
	Ready              = "ok"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultBalance

type DefaultBalance struct {
	CWeight int
	Status  string
	Weight  int
	Id      string
}

func (*DefaultBalance) GetCWeight

func (this *DefaultBalance) GetCWeight() int

func (*DefaultBalance) GetId

func (this *DefaultBalance) GetId() string

func (*DefaultBalance) GetStatus

func (this *DefaultBalance) GetStatus() string

func (*DefaultBalance) GetWeight

func (this *DefaultBalance) GetWeight() int

func (*DefaultBalance) SetCWeight

func (this *DefaultBalance) SetCWeight(val int)

func (*DefaultBalance) SetWeight

func (this *DefaultBalance) SetWeight(Weight int)

type LoadBalance

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

func New

func New() *LoadBalance

func (*LoadBalance) AddNode

func (this *LoadBalance) AddNode(nodeSlice ...NodeBalance)

func (*LoadBalance) Clear

func (this *LoadBalance) Clear()

func (*LoadBalance) NeedReLoad

func (this *LoadBalance) NeedReLoad(service NodeBalanceSlice) bool

func (*LoadBalance) RoundRobin

func (this *LoadBalance) RoundRobin() (NodeBalance, error)

func (*LoadBalance) RoundRobinByWeight

func (this *LoadBalance) RoundRobinByWeight() (NodeBalance, error)

平滑加权轮询

func (*LoadBalance) SelectByIPHash

func (this *LoadBalance) SelectByIPHash(ip string) (NodeBalance, error)

func (*LoadBalance) SelectByRand

func (this *LoadBalance) SelectByRand() (NodeBalance, error)

func (*LoadBalance) SelectByWeightRand

func (this *LoadBalance) SelectByWeightRand() (NodeBalance, error)

type NodeBalance

type NodeBalance interface {
	GetNode() interface{}
	GetCWeight() int
	GetWeight() int
	GetStatus() string
	SetCWeight(val int)
	SetWeight(Weight int)
	GetId() string
}

type NodeBalanceSlice

type NodeBalanceSlice []NodeBalance

func (NodeBalanceSlice) Len

func (p NodeBalanceSlice) Len() int

func (NodeBalanceSlice) Less

func (p NodeBalanceSlice) Less(i, j int) bool

func (NodeBalanceSlice) Swap

func (p NodeBalanceSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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