Documentation ¶
Index ¶
- Constants
- type Content
- func (this *Content) AddNode(nodeSlice ...NodeBalance)
- func (this *Content) Clear()
- func (this *Content) NeedReLoad(service NodeBalanceSlice) bool
- func (this *Content) RoundRobin() (NodeBalance, error)
- func (this *Content) RoundRobinByWeight() (NodeBalance, error)
- func (this *Content) SelectByIPHash(ip string) (NodeBalance, error)
- func (this *Content) SelectByRand() (NodeBalance, error)
- func (this *Content) SelectByWeightRand() (NodeBalance, error)
- type DefaultBalance
- type NodeBalance
- type NodeBalanceSlice
Constants ¶
View Source
const ( RoundRobinByWeight = 1 SelectByIPHash = 2 SelectByRand = 3 RoundRobin = 4 SelectByWeightRand = 5 )
View Source
const Ready = "ok"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
func (*Content) AddNode ¶
func (this *Content) AddNode(nodeSlice ...NodeBalance)
func (*Content) NeedReLoad ¶
func (this *Content) NeedReLoad(service NodeBalanceSlice) bool
判断是否需要重新加载,也就是nodes对象是否变了 2种情况 1种数量变了,一种数量没变,里面的节点变了
func (*Content) RoundRobin ¶
func (this *Content) RoundRobin() (NodeBalance, error)
func (*Content) RoundRobinByWeight ¶
func (this *Content) RoundRobinByWeight() (NodeBalance, error)
平滑加权轮询
func (*Content) SelectByIPHash ¶
func (this *Content) SelectByIPHash(ip string) (NodeBalance, error)
func (*Content) SelectByRand ¶
func (this *Content) SelectByRand() (NodeBalance, error)
func (*Content) SelectByWeightRand ¶
func (this *Content) SelectByWeightRand() (NodeBalance, error)
type DefaultBalance ¶
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 NodeBalance ¶
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)
Click to show internal directories.
Click to hide internal directories.