maglev

package
v1.6.0-beta Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 11 Imported by: 0

Documentation

Index

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配置对象

func (*Config) SetDefault

func (c *Config) SetDefault()

SetDefault 设置一致性hash默认值

func (*Config) Verify

func (c *Config) Verify() error

Verify 检验一致性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

Init 初始化插件

func (*MaglevLoadBalancer) Name

func (m *MaglevLoadBalancer) Name() string

Name 插件名,一个类型下插件名唯一

func (*MaglevLoadBalancer) Type

func (m *MaglevLoadBalancer) Type() common.Type

Type 插件类型

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 选择实例下标

Jump to

Keyboard shortcuts

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