consistenthashing

package
v0.0.0-...-233725d Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

Executor implements consistent-hashing algorithm inspired by "Consistent Hashing and Random Trees: Distributed Caching Protocols for Relieving Hot Spots on the World Wide Web".

func NewExecutor

func NewExecutor(workerID string, cfg *conf.ConsistentHashing) *Executor

NewExecutor returns a new Executor instance.

func (*Executor) IsReady

func (ch *Executor) IsReady() bool

IsReady indicates that the current worker is leader.

func (*Executor) Join

func (ch *Executor) Join(uuid string, record, replay bool) error

Join adds one physical shard into hash space.

func (*Executor) JoinN

func (ch *Executor) JoinN(uuids []string, record bool) error

JoinN adds N physical shards into hash space.

func (*Executor) Leave

func (ch *Executor) Leave(uuid string, record, replay bool) error

Leave removes one physical shard from hash space.

func (*Executor) List

func (ch *Executor) List() ([]string, error)

List lists all physical shards existed in hash space.

func (*Executor) Map

func (ch *Executor) Map(key string, record, replay bool) (string, error)

Map maps the key to the closest shard.

func (*Executor) PromoteToLeader

func (ch *Executor) PromoteToLeader(leader string)

PromoteToLeader marks the current worker as leader.

func (*Executor) ReplayOpLogs

func (ch *Executor) ReplayOpLogs()

ReplayOpLogs calls oplogger's ReplayOpLogs method.

func (*Executor) Start

func (ch *Executor) Start()

Start runs the consistent hashing service.

func (*Executor) Stop

func (ch *Executor) Stop()

Stop stops the consistent hashing service.

func (*Executor) TellLeader

func (ch *Executor) TellLeader(leader string)

TellLeader tell who is the current leader.

Jump to

Keyboard shortcuts

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