Documentation
¶
Overview ¶
Package ring is a Fast Consistent Hashing module It is based on a paper by John Lamping and Eric Veach called "A Fast, Minimal Memory, Consistent Hash Algorithm" The paper can be found here: http://arxiv.org/pdf/1406.2294v1.pdf
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateBucketGivenSize ¶
CalculateBucketGivenSize calculates a Jump hash for the key provided
Types ¶
type Node ¶
type Node interface { // Returns the host for the node. GetHost() string // Returns the capacity of the node. This number determines how many virtual nodes belong to the host. GetSize() int // Returns the hash of the node. This 64-bit number symbolizes where a node falls on the ring. GetHash() uint64 }
Node is an interface representing a physical host. Each node has a host, a capacity and a hash.
type Ring ¶
type Ring interface { // Add adds a host to the ring. Add(host string, size int) // Remove removes a host from the ring. Remove(host string) // Size returns the size of the ring. Virtual nodes are included. Size() int // GetNode returns a node for the given input. GetNode(data []byte) Node }
Ring is the main interface for this package. It comprises of methods used to hash keys into buckets which will be evenly divided among all virtual nodes in the ring. All values are hashed using the FNV algorithm into an unsigned 64-bit integer. The Jump Hash algorithm then determines which bucket a hash falls into.