consistenthash

package
v0.0.0-...-379d7ff Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash func(data []byte) uint32

定义了函数类型 Hash,采取依赖注入的方式,允许用于替换成自定义的 Hash 函数,也方便测试时替换,

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map 是一致性哈希算法的主数据结构

func New

func New(replicas int, fn Hash) *Map

New :新建创建一个map映射实例

func (*Map) Add

func (m *Map) Add(keys ...string)

Add :允许传入 0 或 多个真实节点的名称。

func (*Map) Get

func (m *Map) Get(key string) string

Get :获取哈希中最接近提供的键的项

Jump to

Keyboard shortcuts

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