Documentation ¶
Overview ¶
Package consistenthash provides a ring hash implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoNodes is returned when a hash is requested containing no nodes. ErrNoNodes = errors.New( "there must be at least one node, otherwise keys cannot be mapped") )
Functions ¶
This section is empty.
Types ¶
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring is an immutable ring hash.
func NewRing ¶
NewRing creates a new consistent hash ring, initialised with the provided nodes (order does not matter). When the node list changes, a new hash should be created; updating a hash in place is not supported, as it would drastically increase the time complexity of lookups, which are expected to be the vastly more common operation. Replicas must be at least one, and should be greater when there are few nodes in order to reduce the variance in load amongst them. 50 is usually a reasonable choice.
Click to show internal directories.
Click to hide internal directories.