consistenthash

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GlobalReplicas = defaultReplicas
)

Functions

This section is empty.

Types

type ConsOptions added in v0.2.0

type ConsOptions func(*Map)

func HashFunc added in v0.2.0

func HashFunc(hash Hash) ConsOptions

func Replicas added in v0.2.0

func Replicas(replicas int) ConsOptions

type Hash

type Hash func(data []byte) uint32

type Map

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

func New

func New(opts ...ConsOptions) *Map

New with the replicas number and hash function

func (*Map) Add

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

Add adds some keys to the hash. keys is the name of reality node

func (*Map) Get

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

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

func (*Map) Remove

func (m *Map) Remove(key string)

Remove removes some node from the hash.

Jump to

Keyboard shortcuts

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