Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsistentHashing ¶
type ConsistentHashing struct {
NumOfVirtualNode int // 虚拟节点个数,这个有啥用?
// contains filtered or unexported fields
}
ConsistentHashing 一致性哈希数据结构
func NewConsistentHashing ¶
func NewConsistentHashing() *ConsistentHashing
NewConsistentHashing 新建一个一致性Hash数据结构
func (*ConsistentHashing) Add ¶
func (c *ConsistentHashing) Add(node string)
Add add a node to this consistent hash ring,往哈希环中加新的服务器
func (*ConsistentHashing) Get ¶
func (c *ConsistentHashing) Get(obj string) (string, error)
Get 入参:客户端名称,出参:服务器名
func (*ConsistentHashing) ListNodes ¶
func (c *ConsistentHashing) ListNodes() []string
ListNodes list whole nodes in consistent hashing ring 列出环中所有的服务器
func (*ConsistentHashing) Remove ¶
func (c *ConsistentHashing) Remove(node string)
Remove remove a node form this consistent hashing ring 后端移除一台服务器
type SortedKeys ¶
type SortedKeys []uint32
SortedKeys 排序后的key
func (SortedKeys) Less ¶
func (x SortedKeys) Less(i, j int) bool
func (SortedKeys) Swap ¶
func (x SortedKeys) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.