chash

package
v0.0.0-...-2b4093a Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package chash provides consistent hash balancing

"Consistent hashing can guarantee that when a cache machine is removed, only the objects cached in it will be rehashed; when a new cache machine is added, only a fairly few objects will be rehashed." https://www.codeproject.com/Articles/56138/Consistent-hashing

consistent hashing with bounded loads https://research.googleblog.com/2017/04/consistent-hashing-with-bounded-loads.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Peer

type Peer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Peer defines a single server.

type Pool

type Pool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Pool is a set of Peers.

func CreatePool

func CreatePool(addrs []string) *Pool

CreatePool returns a Pool object.

func New

func New() *Pool

New returns a Pool object.

func (*Pool) Add

func (p *Pool) Add(addr string, args ...interface{})

Add adds a peer by address.

func (*Pool) DownPeer

func (p *Pool) DownPeer(addr string)

DownPeer mark the peer down.

func (*Pool) Get

func (p *Pool) Get(args ...interface{}) string

Get use a key to map the backend server key may be a cookie or request_uri

func (*Pool) Remove

func (p *Pool) Remove(peerAddr string)

Remove deletes a peer by address.

func (*Pool) Size

func (p *Pool) Size() int

Size return the number of peers.

func (*Pool) String

func (p *Pool) String() string

func (*Pool) UpPeer

func (p *Pool) UpPeer(addr string)

UpPeer mark the peer up.

Jump to

Keyboard shortcuts

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