rendezvous

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: BSD-3-Clause-Clear Imports: 6 Imported by: 2

README

Weighted Rendezvous Hashing

An alternative to Consistent Hashing. Evenly distributes load on node removal.

ring := rendezvous.New()
for _, s := range serversAndWeights {
  ring.AddWithWeight(s.Addr, s.Weight)
}

addr := ring.Lookup("some_client_addr")

Documentation

Overview

Package rendezvous implements rendezvous hashing (a.k.a. highest random weight hashing). See http://en.wikipedia.org/wiki/Rendezvous_hashing for more information.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node added in v0.1.4

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

type Ring added in v0.1.4

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

A Ring is a collection of nodes making up a rendezvous group. Nodes have a label and, optionally, a weight. If unspecified, a default weighting is used.

func New

func New() *Ring

func NewWithHash added in v0.1.4

func NewWithHash(hash stdhash.Hash64) *Ring

func (*Ring) Add added in v0.1.4

func (r *Ring) Add(name string)

func (*Ring) AddWithWeight added in v0.1.4

func (r *Ring) AddWithWeight(name string, weight float64)

func (*Ring) Contains added in v0.1.4

func (r *Ring) Contains(name string) bool

func (*Ring) Len added in v0.1.5

func (r *Ring) Len() int

func (*Ring) List added in v0.1.4

func (r *Ring) List() []string

func (*Ring) Lookup added in v0.1.4

func (r *Ring) Lookup(key string) string

func (*Ring) LookupAll added in v0.1.4

func (r *Ring) LookupAll(key string) []string

func (*Ring) LookupTopN added in v0.1.4

func (r *Ring) LookupTopN(key string, n int) []string

func (*Ring) Remove added in v0.1.4

func (r *Ring) Remove(name string)

func (*Ring) Weight added in v0.1.6

func (r *Ring) Weight(name string) float64

type ScoredNode added in v0.1.4

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

Jump to

Keyboard shortcuts

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