rendezvous

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 3 Imported by: 2

README

Rendezvous

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

This implementation is not currently Go-routine safe at all.

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 creates a new Hash with the given keys (optional).

func (*Hash) Add

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

Add takes any number of nodes and adds them to this Hash.

func (*Hash) Contains

func (h *Hash) Contains(node string) bool

Contains takes a node and returns true or false whether the node is registered in this hash or not.

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 n nodes for the given key, ordered by descending score.

func (*Hash) List

func (h *Hash) List() []string

List returns the list of nodes registered in this Hash.

func (*Hash) Remove

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

Remove takes any number of nodes and removes them from this Hash.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳