consistent

package module
v0.0.0-...-53b3303 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2015 License: MIT Imports: 4 Imported by: 0

README

consistenthash

This library implements consistent hash introduced in this paper. This library is for learning purposes only.

Checkout this blog post for more info.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNodeNotFound = errors.New("node not found")

Functions

This section is empty.

Types

type Node

type Node struct {
	Id     string
	HashId uint32
}

func NewNode

func NewNode(id string) *Node

type Nodes

type Nodes []*Node

func (Nodes) Len

func (n Nodes) Len() int

func (Nodes) Less

func (n Nodes) Less(i, j int) bool

func (Nodes) Swap

func (n Nodes) Swap(i, j int)

type Ring

type Ring struct {
	Nodes Nodes
	sync.Mutex
}

func NewRing

func NewRing() *Ring

func (*Ring) AddNode

func (r *Ring) AddNode(id string)

func (*Ring) Get

func (r *Ring) Get(id string) string

func (*Ring) RemoveNode

func (r *Ring) RemoveNode(id string) error

Jump to

Keyboard shortcuts

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