rendezvous

package
v0.1.23-oss Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0, MIT Imports: 3 Imported by: 0

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 Hasher

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

func New

func New(nodes ...string) *Hasher

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

func (*Hasher) Add

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

Add adds additional nodes to the Hash.

func (*Hasher) Get

func (h *Hasher) 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 (*Hasher) GetN

func (h *Hasher) 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.

type Key

type Key []byte

type Node

type Node []byte

type Score

type Score []byte

Jump to

Keyboard shortcuts

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