consistenthash

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChMap

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

ChMap consistent hash map

func NewChMap

func NewChMap(replicates int) *ChMap

NewChMap create a ChMap which has replicates of virtual nodes.

func (*ChMap) Add

func (c *ChMap) Add(node KV) error

Add add the node to the hash ring

func (*ChMap) Find

func (c *ChMap) Find(key string) (KV, bool)

Find finds a nodes to put the string key

func (*ChMap) FindUint32

func (c *ChMap) FindUint32(key uint32) (KV, bool)

FindUint32 finds a nodes to put the uint32 key

func (*ChMap) Remove

func (c *ChMap) Remove(node string) error

Remove remove the node and all the vatual nodes from the key

type KV

type KV interface {
	String() string
}

KV is the key value type.

Jump to

Keyboard shortcuts

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