Documentation ¶
Overview ¶
Package ringhash provides a ring hash implementation.
Index ¶
- Variables
- type Config
- type Hash
- type Node
- type Option
- type Ring
- func (r *Ring) Add(node string) bool
- func (r *Ring) AddNode(keys ...string)
- func (r *Ring) Done(node string) bool
- func (r *Ring) GetLeastNode(key string) (string, error)
- func (r *Ring) GetNode(key string) (string, error)
- func (r *Ring) IsEmpty() bool
- func (r *Ring) Loads() map[string]int64
- func (r *Ring) MaxLoad() int64
- func (r *Ring) Nodes() (nodes []string)
- func (r *Ring) RemoveNode(node string) bool
- func (r *Ring) UpdateLoad(node string, load int64)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoNode when there is no node added into the hash ring. ErrNoNode = errors.New("no node added") // ErrNodeNotFound when no node found in LoadMap. ErrNodeNotFound = errors.New("node not found in LoadMap") // DefaultConfig is the default config for hash ring. DefaultConfig = Config{ HashFn: hash, Replicas: 10, BalancingFactor: 1.25, } )
Functions ¶
This section is empty.
Types ¶
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring is the data store for keys hash map.
func (*Ring) GetLeastNode ¶
GetLeastNode uses consistent hashing with bounded loads to get the least loaded node.
func (*Ring) MaxLoad ¶
MaxLoad returns the maximum load for a single node in the hash ring, which is (totalLoad/numberOfNodes)*balancingFactor.
func (*Ring) RemoveNode ¶
RemoveNode deletes node from the hash ring.
func (*Ring) UpdateLoad ¶
UpdateLoad sets load of the given node to the given load.
Click to show internal directories.
Click to hide internal directories.