consistenthash

package
v1.0.1-0...-3c4f842 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2017 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package consistenthash is a Go port of the Graphite project's consistent-hashing algorithm. Givn the same settings (e.g. vnodes), consistenthash will yield the same node by name for a given key as you'd observe in carbon-relay.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashRing

type HashRing struct {
	sync.RWMutex
	Vnodes int
	// contains filtered or unexported fields
}

HashRing implmenents a consistent-hash ring with a configurable number of vnodes that are mapped to a list of real nodes.

func (*HashRing) AddNode

func (h *HashRing) AddNode(keyname, name string)

AddNode takes a node keyname and name. The name will populate the node.nodeName field, but we pass an explicit keyname value so that the hashing function is using the same naming convention as the consistent hashing implementation in Graphite. The Graphite project hashes nodes using the following format: "('127.0.0.1', 'a'):0".

func (*HashRing) GetNode

func (h *HashRing) GetNode(k string) (string, error)

GetNode takes a key and returns the destination nodeName from the ring.

func (*HashRing) RemoveNode

func (h *HashRing) RemoveNode(name string)

RemoveNode drops a node from the hash ring.

Jump to

Keyboard shortcuts

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