ketama

package
v0.0.0-...-ac3ec91 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2018 License: BSD-4-Clause Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoServers       = errors.New("No valid server definitions found")
	ErrMalformedServer = errors.New("One of the servers is in an invalid format")
)

Functions

func ServerAddr

func ServerAddr(addr string) (net.Addr, error)

Types

type Continuum

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

func New

func New(serverList []ServerInfo, newHash func() hash.Hash) *Continuum

Construct a new Continum for the given servers and hashing function

func NewFromFile

func NewFromFile(filename string) (*Continuum, error)

func (*Continuum) Each

func (cont *Continuum) Each(f func(net.Addr) error) error

Each iterates over each server calling the given function

func (*Continuum) GetHash

func (cont *Continuum) GetHash(in string, offset int) uint32

func (*Continuum) PickServer

func (cont *Continuum) PickServer(key string) (net.Addr, error)

type ServerInfo

type ServerInfo struct {
	Addr   net.Addr
	Memory uint64
}

A non-zero value for Memory enables ketama weighted

Jump to

Keyboard shortcuts

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