Documentation
¶
Index ¶
- Constants
- type Bucket
- type Config
- type HashFn
- type HashRing
- func (hr *HashRing) Add(bucket Bucket)
- func (hr *HashRing) AvgLoad() float64
- func (hr *HashRing) Buckets() []Bucket
- func (hr *HashRing) Get(key string) Bucket
- func (hr *HashRing) GetLoads() map[string]float64
- func (hr *HashRing) GetPartitionBucket(id int) Bucket
- func (hr *HashRing) GetPartitionID(key string) int
- func (hr *HashRing) Remove(key string)
Constants ¶
View Source
const ( DefaultPartitionCount = 71 DefaultReplicationFactor = 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Hasher is the hash function that we use to disribute the keys // in the hash ring. Hasher HashFn // ReplicationFactor determines the number of virtual nodes we // put into the hash ring (replication of a real node on the ring). ReplicationFactor int // PartitionCount determines how many time we want to partition the space // to make for more uniform distribution of keys. Select a prime number for // this. PartitionCount int }
type HashRing ¶
type HashRing struct {
// contains filtered or unexported fields
}
func (*HashRing) AvgLoad ¶
AvgLoad computes the average load. For more information, please see: https://blog.research.google/2017/04/consistent-hashing-with-bounded-loads.html
func (*HashRing) GetPartitionBucket ¶
GetPartitionBucket gets a bucket for a given partition id.
func (*HashRing) GetPartitionID ¶
GetPartitionID gets a partition id for a given key in the ring.
Click to show internal directories.
Click to hide internal directories.