consistenthash

package
v2.6.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package consistenthash provides an implementation of a ring hash.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hash

type Hash func(data []byte) uint64

type Hosts added in v2.6.2

type Hosts []string

type KeyOwner added in v2.6.1

type KeyOwner struct {
	Key   int
	Peers []string
}

type Map

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

func New

func New(partitions int, replicaFn func(hostCount int) int, fn Hash) *Map

func (*Map) Add

func (m *Map) Add(hosts ...string)

Adds some keys to the hash.

func (*Map) Get

func (m *Map) Get(key string) Hosts

Gets the set of hosts owning the keyring space closest to the provided key.

func (*Map) IsEmpty

func (m *Map) IsEmpty() bool

Returns true if there are no hosts available.

func (*Map) KeyOwners added in v2.6.1

func (m *Map) KeyOwners() []KeyOwner

Jump to

Keyboard shortcuts

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