consistenthash

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 2 more Imports: 9 Imported by: 2

Documentation

Overview

Package consistenthash provides consistent hash utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsistentHash

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

ConsistentHash defines the consistent hash.

func NewConsistentHash

func NewConsistentHash() *ConsistentHash

NewConsistentHash creates a new ConsistentHash.

func NewCustomConsistentHash

func NewCustomConsistentHash(hashFunc Hash) *ConsistentHash

NewCustomConsistentHash creates a new ConsistentHash with custom hash function.

func (*ConsistentHash) Select

func (ch *ConsistentHash) Select(serviceName string, list []*registry.Node,
	opt ...loadbalance.Option) (*registry.Node, error)

Select implements loadbalance.LoadBalancer.

type Hash

type Hash func(data []byte) uint64

Hash is the hash function type.

type Uint64Slice

type Uint64Slice []uint64

Uint64Slice defines uint64 slice.

func (Uint64Slice) Len

func (s Uint64Slice) Len() int

Len returns the length of the slice.

func (Uint64Slice) Less

func (s Uint64Slice) Less(i, j int) bool

Less returns whether the value at i is less than j.

func (Uint64Slice) Swap

func (s Uint64Slice) Swap(i, j int)

Swap swaps values between i and j.

Jump to

Keyboard shortcuts

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