ringhash

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2017 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Implementation of a consistent ring hash: https://en.wikipedia.org/wiki/Consistent_hashing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash func(data []byte) uint32

type Ring

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

func New

func New(replicas int, fn Hash) *Ring

func (*Ring) Add

func (ring *Ring) Add(keys ...string)

Adds keys to the ring.

func (*Ring) Get

func (ring *Ring) Get(key string) string

Get returns the closest item in the ring to the provided key.

func (*Ring) Len

func (ring *Ring) Len() int

Returns the number of keys in the ring.

func (*Ring) Signature

func (ring *Ring) Signature() string

Get a ring hash signature. Two identical ring hashes will have the same signature. Two hashes with different number of keys or replicas or hash functions will have different signatures.

Jump to

Keyboard shortcuts

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