consistenthash

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsistentHash

type ConsistentHash struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ConsistentHash consistent hash map

func New

func New(enableWeight bool, hashType HashAlgorithmType) *ConsistentHash

New create a ConsistentHash which has replicates of virtual endpoint.Endpoint.

func (*ConsistentHash) Add

Add the ep to the hash ring

func (*ConsistentHash) Find

func (c *ConsistentHash) Find(key string) (endpoint.Endpoint, bool)

Find finds a endpoint.Endpoint to put the string key

func (*ConsistentHash) FindInt32

func (c *ConsistentHash) FindInt32(key uint32) (endpoint.Endpoint, bool)

FindInt32 finds a endpoint.Endpoint to put the uint32 key

func (*ConsistentHash) Refresh

func (c *ConsistentHash) Refresh(eps []endpoint.Endpoint)

func (*ConsistentHash) Remove

func (c *ConsistentHash) Remove(ep endpoint.Endpoint) error

Remove the ep and all the virtual eps from the key

func (*ConsistentHash) Select

func (c *ConsistentHash) Select(msg selector.Message) (ep endpoint.Endpoint, err error)

type DefaultHashAlg

type DefaultHashAlg struct {
}

func (DefaultHashAlg) GetHashType

func (k DefaultHashAlg) GetHashType() HashAlgorithmType

func (DefaultHashAlg) Hash

func (k DefaultHashAlg) Hash(key string) uint32

type HashAlgorithmType

type HashAlgorithmType int
const (
	KetamaHash  HashAlgorithmType = 0
	DefaultHash HashAlgorithmType = 1
)

type KetamaHashAlg

type KetamaHashAlg struct {
}

func (KetamaHashAlg) GetHashType

func (k KetamaHashAlg) GetHashType() HashAlgorithmType

func (KetamaHashAlg) Hash

func (k KetamaHashAlg) Hash(key string) uint32

Jump to

Keyboard shortcuts

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