distribution

package
v0.0.0-...-cacfd1a Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package distribution implements distributions such as consistent hashing compatible with twemproxy (hopefully)

This implementation draws from the Daisuke Maki's Perl module, which itself is based on the original libketama code. That code was licensed under the GPLv2, and thus so is this.

The major API change from libketama is that Algorithm::ConsistentHash::Ketama allows hashing arbitrary strings, instead of just memcached server IP addresses.

Original source: https://github.com/dgryski/go-ketama/blob/master/ketama.go

Modified to store integers directly to avoid a pointer lookup and type coercion

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Label  string
	Weight int
	// Index of the client to use
	Data int
}

type KetamaContinuum

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

func NewKetama

func NewKetama(buckets []Bucket) (*KetamaContinuum, error)

func (KetamaContinuum) Get

func (c KetamaContinuum) Get(h uint32) int

Retrieves the Data for a uint32 value generated by another algorithm.

type ModulaContinuum

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

func NewModula

func NewModula(buckets []Bucket) (*ModulaContinuum, error)

func (ModulaContinuum) Get

func (c ModulaContinuum) Get(h uint32) int

Retrieves the array index for a uint32 value generated by another algorithm.

Jump to

Keyboard shortcuts

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