consistenthashing

package module
v0.0.0-...-949780b Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 2 Imported by: 0

README

Consistent Hashing

Go Go Report Card Read the Docs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsistentHash

type ConsistentHash[T Hash] struct {
	// contains filtered or unexported fields
}

func NewConsistentHash

func NewConsistentHash[T Hash](replicate uint, opts ...ConsistentHashOption[T]) *ConsistentHash[T]

func (*ConsistentHash[T]) Add

func (s *ConsistentHash[T]) Add(node T)

func (*ConsistentHash[T]) Get

func (s *ConsistentHash[T]) Get(key uint) T

func (*ConsistentHash[T]) Remove

func (s *ConsistentHash[T]) Remove(node T)

type ConsistentHashOption

type ConsistentHashOption[T Hash] func(*ConsistentHash[T])

func WithHash

func WithHash[T Hash](hash HashFunction) ConsistentHashOption[T]

type Hash

type Hash interface {
	Sum() uint
}

type HashFunction

type HashFunction func([]byte) uint

type SortedMap

type SortedMap[K Unsigned, T any] struct {
	// contains filtered or unexported fields
}

func NewSortedMap

func NewSortedMap[K Unsigned, T any]() *SortedMap[K, T]

func (*SortedMap[K, T]) Add

func (s *SortedMap[K, T]) Add(key K, item T)

func (*SortedMap[K, T]) Contains

func (s *SortedMap[K, T]) Contains(key K) bool

func (*SortedMap[K, T]) Empty

func (s *SortedMap[K, T]) Empty() bool

func (*SortedMap[K, T]) First

func (s *SortedMap[K, T]) First() T

func (*SortedMap[K, T]) Get

func (s *SortedMap[K, T]) Get(key K) T

func (*SortedMap[K, T]) Keys

func (s *SortedMap[K, T]) Keys() []K

func (*SortedMap[K, T]) Remove

func (s *SortedMap[K, T]) Remove(key K)

func (*SortedMap[K, T]) Tail

func (s *SortedMap[K, T]) Tail(key K) []K

type Unsigned

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Jump to

Keyboard shortcuts

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