jump

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TopWeight is the top weight that one entry might set.
	TopWeight = 100
)

Variables

This section is empty.

Functions

func AddNode added in v0.1.26

func AddNode(t *ConsistentHash, n *node)

AddNode 添加节点

func GetNode added in v0.1.26

func GetNode(t *ConsistentHash, key string) *node

GetNode 获取节点

func Hash

func Hash(key uint64, numBuckets int) int32

Hash consistently chooses a hash bucket number in the range [0, numBuckets) for the given key. numBuckets must be >= 1.

func HashString

func HashString(key string, numBuckets int) int32

HashString works like hash but accept string as an input.

func Sum64

func Sum64(key string) uint64

Sum64 ...

Types

type ConsistentHash added in v0.1.26

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

A ConsistentHash is a ring hash implementation. 一致性哈希

func NewCustomConsistentHash added in v0.1.26

func NewCustomConsistentHash(replicas int, fn Func) *ConsistentHash

NewCustomConsistentHash returns a ConsistentHash with given replicas and hash func. 有参构造器

type Func added in v0.1.26

type Func func(data []byte) uint64

Func defines the hash method. 哈希函数

Jump to

Keyboard shortcuts

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