common

package
v0.0.0-...-c4b640e Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consistent

type Consistent struct {

	//虚拟节点个数,用来增加hash的平衡性
	VirtualNode int
	//map 读写锁
	sync.RWMutex
	// contains filtered or unexported fields
}

创建结构体保存一致性hash信息

func NewConsistent

func NewConsistent() *Consistent

创建一致性hash算法结构体,设置默认节点数量

func (*Consistent) Add

func (c *Consistent) Add(element string)

向hash环中添加节点

func (*Consistent) Get

func (c *Consistent) Get(name string) (string, error)

根据数据标示获取最近的服务器节点信息

func (*Consistent) Remove

func (c *Consistent) Remove(element string)

删除一个节点

Jump to

Keyboard shortcuts

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