Documentation ¶
Index ¶
- func DefaultHashFn(data []byte) uint64
- type HashFn
- type HashRing
- func (r *HashRing) AddNode(node string) *HashRing
- func (r *HashRing) AddNodeWeight(node string, weight int) *HashRing
- func (r *HashRing) DelNode(node string) *HashRing
- func (r *HashRing) GetHashRing() map[string][]uint64
- func (r *HashRing) GetNodeWeight() map[string]int
- func (r *HashRing) GetNodes() []string
- func (r *HashRing) LocateKey(data []byte) string
- func (r *HashRing) LocateKeyStr(data string) string
- func (r *HashRing) UpdateNodeWeight(node string, weight int) *HashRing
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHashFn ¶
DefaultHashFn return the fnv hash function hashed twice to make the distribution more uniformly
Types ¶
type HashRing ¶
type HashRing struct {
// contains filtered or unexported fields
}
HashRing represents hash ring
func NewWithWeight ¶
NewWithWeight returns a hash ring with customized weight
func (*HashRing) AddNodeWeight ¶
AddNodeWeight add new node with weight
func (*HashRing) GetHashRing ¶
GetHashRing return hash ring string is node, []uint64 is corresponding key
func (*HashRing) GetNodeWeight ¶
GetNodeWeight returns all node and corresponding weight in hash ring
func (*HashRing) LocateKeyStr ¶
LocateKeyStr locates the position of string data in hash ring
Click to show internal directories.
Click to hide internal directories.