maglev

package
v0.0.0-...-2831398 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package maglev implements maglev consistent hashing.

http://research.google.com/pubs/pub44824.html

Index

Constants

View Source
const (
	SmallM = 65537
	BigM   = 655373
)

Prime numbers of varying scale

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config map[*common.Backend]uint

A Config is a mapping from backends to weights.

type Table

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

Table represents a Maglev hashing table.

func New

func New(m uint64) *Table

New returns a new Maglev table with the specified size.

func (*Table) Add

func (t *Table) Add(backend *common.Backend)

Add adds a backend to the table with weight 1.

func (*Table) Lookup

func (t *Table) Lookup(key uint64) (*common.Backend, bool)

Lookup looks up a key in the table and returns the associated backend, or false if there are no backends.

func (*Table) Reconfig

func (t *Table) Reconfig(c Config)

Reconfig reconfigures the table with the given backend weight configuration.

func (*Table) Remove

func (t *Table) Remove(backend *common.Backend)

Remove removes a backend from the table.

func (*Table) SetWeight

func (t *Table) SetWeight(backend *common.Backend, weight uint)

SetWeight sets the weight of the given backend to weight, adding it to the table if necessary.

Jump to

Keyboard shortcuts

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