hashcircler

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotPresent = errors.New("key is not present")
)

Functions

This section is empty.

Types

type HashCircler

type HashCircler interface {
	// Add adds the target key in hash circle.
	Add(key string)

	// Hash hashes the input and output the target key which hashes.
	Hash(input string) (key string, err error)

	// Delete deletes the target key
	Delete(key string)
}

HashCircler hashes input string to target key, and the key could be enabled or disabled. And the keys array is preset, only the keys could be enable or disable.

func NewConsistentHashCircler

func NewConsistentHashCircler(keys []string, hashFunc func(string) uint64) (HashCircler, error)

NewConsistentHashCircler constructs an instance of HashCircler from keys. And this is thread safety. if hashFunc is nil, it will be set to default hash func.

Jump to

Keyboard shortcuts

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