hash

package
v0.0.0-...-91249f1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoElements = errors.New("No elements to hash to")
)

Functions

This section is empty.

Types

type Hash

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

Hash implements simple modulo hashing.

func New

func New(view types.View) *Hash

func (*Hash) Get

func (m *Hash) Get(key string) (string, error)

Get returns the address of the node that should store the given key.

func (*Hash) GetAny

func (m *Hash) GetAny(key string) (string, error)

GetAny returns any node that should be able to service a given key, even if that node is not the primary for a given key.

func (*Hash) GetKeyShardId

func (m *Hash) GetKeyShardId(key string) (int, error)

GetKeyShardId returns the shard that a key belongs to.

func (*Hash) GetReplicas

func (m *Hash) GetReplicas(id int) []string

GetReplicas returns the set of members in the given shard.

func (*Hash) GetReplicationFactor

func (m *Hash) GetReplicationFactor() int

func (*Hash) GetShardId

func (m *Hash) GetShardId(member string) int

GetShardId returns the shard ID of the given member.

func (*Hash) GetView

func (m *Hash) GetView() types.View

Returns view address and replication factor

func (*Hash) Members

func (m *Hash) Members() []string

Members returns the list of nodes in this hash.

func (*Hash) TestAndSet

func (m *Hash) TestAndSet(view types.View) bool

Test and set performs an atomic Set operation iff the new member slice is different than the old. Returns true if the member slice changed.

Jump to

Keyboard shortcuts

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