consistent

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsistentHashing

type ConsistentHashing struct {
	Nodes    map[uint32]string
	Replicas int
	Keys     []uint32
	Logger   *log.Logger
}

func (*ConsistentHashing) AddNode

func (h *ConsistentHashing) AddNode(node string)

AddNode will add a node or entity in the ring using its hashed value The ring is then ordered by the hashed value and saved in Keys

func (*ConsistentHashing) GetImmediateNode

func (h *ConsistentHashing) GetImmediateNode(key string) string

GetImmediateNode will return the first node following the given node identified with its key. The node is found going counter clock-wise onto the ring In the case of servers, the Immediate node will represent the server to send data to.

func (*ConsistentHashing) Hash

func (h *ConsistentHashing) Hash(uuid string, _ int) (string, error)

Hash hashes the given input using a graph-based data-structure and keeps a sorted list of nodes and Replicas for faster retrieval. It returns the immediate node index to which the uuid will be assigned

func (*ConsistentHashing) RemoveNode

func (h *ConsistentHashing) RemoveNode(node string)

RemoveNode will remove a node or entity from the ring. Then we will also make sure that the Keys are consistent are removal of a node

func (*ConsistentHashing) SetReplicas

func (h *ConsistentHashing) SetReplicas(replicas int)

SetReplicas set the replicas for the entities to be hashed in the ring

Jump to

Keyboard shortcuts

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