consistenthash

package
v0.0.0-...-e858c94 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2022 License: GPL-3.0 Imports: 2 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 NodeMap

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

NodeMap stores nodes and you can pick node from NodeMap

func NewNodeMap

func NewNodeMap(fn HashFunc) *NodeMap

NewNodeMap creates a new NodeMap

func (*NodeMap) AddNode

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

AddNode add the given nodes into consistent hash circle

func (*NodeMap) IsEmpty

func (m *NodeMap) IsEmpty() bool

IsEmpty returns if there is no node in NodeMap

func (*NodeMap) PickNode

func (m *NodeMap) 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