Documentation
¶
Overview ¶
Package consistenthash provides an implementation of a ring hash.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map tracks segments in a hash-ring, mapped to specific keys.
func (*Map) Add ¶
Add adds some keys to the hashring, establishing ownership of segsPerKey segments.
func (*Map) GetReplicated ¶
GetReplicated gets the closest item in the hash to a deterministic set of keyReplicas variations of the provided key. The returned set of segment-owning keys is dedup'd, and collisions are resolved by traversing backwards in the hash-ring to find an unused owning-key.
func (*Map) OwnerRangeSummary ¶ added in v1.2.0
func (m *Map) OwnerRangeSummary(ownerKey string, skipOverrideKeys int) (RangeSummary, bool)
OwnerRangeSummary provides an object that provides an efficient check as to whether a key is owned by a specific owner-key. (where owner-keys would be provided to [(*Map).Add] and a `key` would be passed to [(*Map).Get]).
skipOverrideKeys allows one to provide a broader bound on ownership that includes the removal of `skipOverrideKeys` owners.
Returns nil if the key is not present in this map.
type RangeSummary ¶ added in v1.2.0
type RangeSummary struct {
// contains filtered or unexported fields
}
func (*RangeSummary) OwnerPossiblyOwns ¶ added in v1.2.0
func (r *RangeSummary) OwnerPossiblyOwns(key string, replicas int) bool