consistenthash

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 3 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) uint32

type Map

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

func New

func New(replicas int, fn Hash) *Map

func (*Map) Add

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

Add adds some keys to the hash.

func (*Map) Get

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

Get gets the closest item in the hash to the provided key.

func (*Map) GetWithFilters

func (m *Map) GetWithFilters(key string, filters ...func(string) bool) string

GetWithFilters gets the closest item in the hash to which passes all filters.

func (*Map) IsEmpty

func (m *Map) IsEmpty() bool

IsEmpty returns true if there are no items available.

func (*Map) Remove

func (m *Map) Remove(keys ...string)

Remove removes keys from existing hash ring.

Jump to

Keyboard shortcuts

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