hash

package
v1.10.35 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TopWeight = 100
)

Variables

This section is empty.

Functions

func Hash

func Hash(data []byte) uint64

func Md5

func Md5(data []byte) []byte

func Md5Hex

func Md5Hex(data []byte) string

Types

type ConsistentHash

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

func NewConsistentHash

func NewConsistentHash() *ConsistentHash

func NewCustomConsistentHash

func NewCustomConsistentHash(replicas int, fn HashFunc) *ConsistentHash

func (*ConsistentHash) Add

func (h *ConsistentHash) Add(node interface{})

Add adds the node with the number of h.replicas, the later call will overwrite the replicas of the former calls.

func (*ConsistentHash) AddWithReplicas

func (h *ConsistentHash) AddWithReplicas(node interface{}, replicas int)

AddWithReplicas adds the node with the number of replicas, replicas will be truncated to h.replicas if it's larger than h.replicas, the later call will overwrite the replicas of the former calls.

func (*ConsistentHash) AddWithWeight

func (h *ConsistentHash) AddWithWeight(node interface{}, weight int)

AddWithWeight adds the node with weight, the weight can be 1 to 100, indicates the percent, the later call will overwrite the replicas of the former calls.

func (*ConsistentHash) Get

func (h *ConsistentHash) Get(v interface{}) (interface{}, bool)

func (*ConsistentHash) Remove

func (h *ConsistentHash) Remove(node interface{})

type HashFunc

type HashFunc func(data []byte) uint64

Jump to

Keyboard shortcuts

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