rendezvous

package module
v0.0.0-...-7d9edf8 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 7 Imported by: 1

README

rendezvous is a Go implementation of rendezvous hashing (also known as highest random weight hashing).

API documentation

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.

Hash is safe for concurrent use: multiple goroutines may call Get, GetN, Add, and Remove on the same instance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

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

func New

func New(nodes ...string) *Hash

New returns a new Hash ready for use with the given nodes.

func (*Hash) Add

func (h *Hash) Add(nodes ...string)

Add adds additional nodes to the Hash. Duplicate node names are ignored.

func (*Hash) Get

func (h *Hash) Get(key string) string

Get returns the node with the highest score for the given key. If this Hash has no nodes, an empty string is returned.

func (*Hash) GetN

func (h *Hash) GetN(n int, key string) []string

GetN returns no more than n nodes for the given key, ordered by descending score. It does not reorder the internal node list.

func (*Hash) Remove

func (h *Hash) Remove(node string)

Remove removes a node from the Hash, if it exists

Jump to

Keyboard shortcuts

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