rendezvous

package module
v0.0.0-...-9975fc3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 5 Imported by: 2

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.

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.

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. GetN is not goroutine-safe.

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