Documentation ¶
Overview ¶
Package mobius provides a consistent-hashing algorithm designed to allocate work across a set of members of a cluster.
Index ¶
Constants ¶
const DefaultWeightMultiplier uint32 = 100
DefaultWeightMultiplier is default value to use for Ring.WeightMultiplier if it is zero.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ring ¶
type Ring struct { // WeightMultiplier is the number that each member's weight is multiplied by // to produce the number of vnodes to add for each member. If it zero // DefaultWeightMultiplier is used. WeightMultiplier uint32 // contains filtered or unexported fields }
Ring is a consistent-hashing ring.
It is a set-like collection that allows efficient, consisting mapping of arbitrary keys to the members of the set with minimum redistribution of these mappings when set membership is changed.
func (*Ring) Add ¶
Add adds a member to the ring.
m uniquely identifies the member.
k is the value that is hashed to determine where the member is placed within the ring.
w is the member's relative weight, which controls the proportion of the ring that is assigned to this member. A member with a weight of 2 occupies twice the space on the ring as a member with a weight of 1.
It returns false is m is already a member of the ring.
func (*Ring) Ordered ¶
Ordered returns all members on the ring, ordered according to their distance from k.
The first element is the same as the value returned by Get(). Each subsequent element is the member that would have been returned by Get() had the element before it had not been a member of the ring.