distribute

package module
v0.0.0-...-75d6a94 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 4 Imported by: 2

README

go-distribute

A distribution ring similar to ketama based on reading https://medium.com/@dgryski/consistent-hashing-algorithmic-tradeoffs-ef6b8e2fcae8

Documentation

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
}

Bucket is a label and a weight

type Continuum

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

Continuum is a consistent hash ring

func New

func New(buckets []Bucket, replicas int) (*Continuum, error)

New returns a new hash ring with the number of replicas for each bucket given

func (*Continuum) Add

func (c *Continuum) Add(label string, weight int) error

Add a node to the ring

func (*Continuum) Hash

func (c *Continuum) Hash(thing string) (string, error)

Hash returns you the bucket label for this thing

func (*Continuum) Remove

func (c *Continuum) Remove(b string) error

Remove a node from the ring

func (*Continuum) Size

func (c *Continuum) Size() int

Size gets you the size of the ring

Jump to

Keyboard shortcuts

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