Documentation ¶
Index ¶
- Constants
- func IPToUInt32(ip string) uint32
- type Config
- type ContinuumSelector
- type KetamaLoadBalancer
- func (k *KetamaLoadBalancer) ChooseInstance(criteria *loadbalancer.Criteria, inputInstances model.ServiceInstances) (model.Instance, error)
- func (k *KetamaLoadBalancer) Destroy() error
- func (k *KetamaLoadBalancer) Init(ctx *plugin.InitContext) error
- func (k *KetamaLoadBalancer) Name() string
- func (k *KetamaLoadBalancer) Type() common.Type
- type L5CSTLoadBalancer
- type L5ContinuumSelector
Constants ¶
View Source
const (
// 默认虚拟节点数
DefaultVnodeCount = 10
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { HashFunction string `yaml:"hashFunction" json:"hashFunction"` VnodeCount int `yaml:"vnodeCount" json:"vnodeCount"` }
一致性hash配置对象
type ContinuumSelector ¶
type ContinuumSelector struct { model.SelectorBase // contains filtered or unexported fields }
一致性hash环
func NewContinuum ¶
func NewContinuum( instanceSet *model.InstanceSet, vnodeCount int, hashFunc hash.HashFuncWithSeed, id int32) (*ContinuumSelector, error)
创建hash环
func (*ContinuumSelector) Select ¶
func (c *ContinuumSelector) Select(value interface{}) (int, *model.ReplicateNodes, error)
选择实例下标
type KetamaLoadBalancer ¶
type KetamaLoadBalancer struct { *plugin.PluginBase // contains filtered or unexported fields }
ketama算法的一致性hash负载均衡器
func (*KetamaLoadBalancer) ChooseInstance ¶
func (k *KetamaLoadBalancer) ChooseInstance(criteria *loadbalancer.Criteria, inputInstances model.ServiceInstances) (model.Instance, error)
ChooseInstance 获取单个服务实例
func (*KetamaLoadBalancer) Init ¶
func (k *KetamaLoadBalancer) Init(ctx *plugin.InitContext) error
初始化插件
type L5CSTLoadBalancer ¶
type L5CSTLoadBalancer struct {
*plugin.PluginBase
}
l5一致性算法的hash负载均衡器
func (*L5CSTLoadBalancer) ChooseInstance ¶
func (l *L5CSTLoadBalancer) ChooseInstance(criteria *loadbalancer.Criteria, inputInstances model.ServiceInstances) (model.Instance, error)
ChooseInstance 获取单个服务实例
func (*L5CSTLoadBalancer) Init ¶
func (l *L5CSTLoadBalancer) Init(ctx *plugin.InitContext) error
初始化插件
type L5ContinuumSelector ¶
type L5ContinuumSelector struct { model.SelectorBase // contains filtered or unexported fields }
L5ContinuumSelector 一致性hash环
func NewL5Continuum ¶
func NewL5Continuum( instanceSet *model.InstanceSet, id int32) (*L5ContinuumSelector, error)
NewL5Continuum 创建hash环
func (*L5ContinuumSelector) Select ¶
func (c *L5ContinuumSelector) Select(value interface{}) (int, *model.ReplicateNodes, error)
Select 选择实例下标
Click to show internal directories.
Click to hide internal directories.