Documentation
¶
Overview ¶
Package consistenthash provides an implementation of a ring hash.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FNVHash ¶ added in v1.4.0
FNVHash is an alternate hash function for Map, and wraps/adapts fnv.New32a. It is generally a better choice of hash function than the default crc32 with the IEEE polynomial (crc32.ChecksumIEEE). (the default cannot be updated without breaking existing systems)
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map tracks segments in a hash-ring, mapped to specific keys.
func New ¶
New constructs a new consistenthash hashring, with segsPerKey segments per added key. It is recommended to use FNVHash as the second (fn) argument for new applications/systems.
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
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chtest provides some helper hash-functions for use with the parent consistenthash package (and galaxycache) to provide particular owners for specific keys.
|
Package chtest provides some helper hash-functions for use with the parent consistenthash package (and galaxycache) to provide particular owners for specific keys. |