consistenthash

package
v0.0.0-...-0212348 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashFunc

type HashFunc func(data []byte) uint32

HashFunc defines function to generate hash code

type Map

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

Map stores nodes and you can pick node from Map

func New

func New(replicas int, fn HashFunc) *Map

New creates a new Map

func (*Map) AddNode

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

AddNode add the given nodes into consistent hash circle

func (*Map) IsEmpty

func (m *Map) IsEmpty() bool

IsEmpty returns if there is no node in Map

func (*Map) PickNode

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

PickNode gets the closest item in the hash to the provided key.

Jump to

Keyboard shortcuts

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