Documentation ¶
Index ¶
- Constants
- type Config
- type MaglevLoadBalancer
- func (m *MaglevLoadBalancer) ChooseInstance(criteria *loadbalancer.Criteria, inputInstances model.ServiceInstances) (model.Instance, error)
- func (m *MaglevLoadBalancer) Destroy() error
- func (m *MaglevLoadBalancer) Init(ctx *plugin.InitContext) error
- func (m *MaglevLoadBalancer) Name() string
- func (m *MaglevLoadBalancer) Type() common.Type
- type TableSelector
Constants ¶
View Source
const (
// DefaultTableSize 默认初始化表向量区间
DefaultTableSize = 65537
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { HashFunction string `yaml:"hashFunction" json:"hashFunction"` TableSize int `yaml:"tableSize" json:"tableSize"` }
Config 一致性hash配置对象
type MaglevLoadBalancer ¶
type MaglevLoadBalancer struct { *plugin.PluginBase // contains filtered or unexported fields }
MaglevLoadBalancer 基于maglev算法的负载均衡器 maglev算法基于论文:https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/44824.pdf
func (*MaglevLoadBalancer) ChooseInstance ¶
func (m *MaglevLoadBalancer) ChooseInstance(criteria *loadbalancer.Criteria, inputInstances model.ServiceInstances) (model.Instance, error)
ChooseInstance 获取单个服务实例
func (*MaglevLoadBalancer) Destroy ¶
func (m *MaglevLoadBalancer) Destroy() error
Destroy 销毁插件,可用于释放资源
func (*MaglevLoadBalancer) Init ¶
func (m *MaglevLoadBalancer) Init(ctx *plugin.InitContext) error
Init 初始化插件
type TableSelector ¶
type TableSelector struct { model.SelectorBase // contains filtered or unexported fields }
TableSelector maglev向量表选择器
func NewTable ¶
func NewTable( instanceSet *model.InstanceSet, tableSize uint64, hashFunc hash.HashFuncWithSeed, id int32) (*TableSelector, error)
NewTable 创建maglev向量选择器
func (*TableSelector) Select ¶
func (t *TableSelector) Select(value interface{}) (int, *model.ReplicateNodes, error)
Select 选择实例下标
Click to show internal directories.
Click to hide internal directories.