Documentation ¶
Index ¶
- type HashFunc
- type HashKey
- type HashKeyOrder
- type HashRing
- func (h *HashRing) AddNode(node string) *HashRing
- func (h *HashRing) AddWeightedNode(node string, weight int) *HashRing
- func (h *HashRing) GenKey(key string) HashKey
- func (h *HashRing) GetNode(stringKey string) (node string, ok bool)
- func (h *HashRing) GetNodePos(stringKey string) (pos int, ok bool)
- func (h *HashRing) GetNodes(stringKey string, size int) (nodes []string, ok bool)
- func (h *HashRing) RemoveNode(node string) *HashRing
- func (h *HashRing) Size() int
- func (h *HashRing) UpdateWeightedNode(node string, weight int) *HashRing
- func (h *HashRing) UpdateWithWeights(weights map[string]int)
- type HashSum
- type Int64PairHashKey
- type Uint32HashKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashKey ¶
func NewInt64PairHashKey ¶
type HashKeyOrder ¶
type HashKeyOrder []HashKey
func (HashKeyOrder) Len ¶
func (h HashKeyOrder) Len() int
func (HashKeyOrder) Less ¶
func (h HashKeyOrder) Less(i, j int) bool
func (HashKeyOrder) Swap ¶
func (h HashKeyOrder) Swap(i, j int)
type HashRing ¶
type HashRing struct {
// contains filtered or unexported fields
}
func NewWithHash ¶
func NewWithHashAndWeights ¶
func NewWithWeights ¶
func (*HashRing) AddWeightedNode ¶
func (*HashRing) GetNodes ¶
GetNodes iterates over the hash ring and returns the nodes in the order which is determined by the key. GetNodes is thread safe if the hash which was used to configure the hash ring is thread safe.
func (*HashRing) RemoveNode ¶
func (*HashRing) UpdateWeightedNode ¶
func (*HashRing) UpdateWithWeights ¶
type HashSum ¶
type HashSum struct {
// contains filtered or unexported fields
}
HashSum allows to use a builder pattern to create different HashFunc objects. See examples for details.
func NewHash ¶
NewHash creates a new *HashSum object which can be used to create HashFunc. HashFunc object is thread safe if the hasher argument produces a new hash.Hash each time. The produced hash.Hash is allowed to be non thread-safe.
func (*HashSum) FirstBytes ¶
type Int64PairHashKey ¶
func (*Int64PairHashKey) Less ¶
func (k *Int64PairHashKey) Less(other HashKey) bool
type Uint32HashKey ¶
type Uint32HashKey uint32
func (Uint32HashKey) Less ¶
func (k Uint32HashKey) Less(other HashKey) bool
Click to show internal directories.
Click to hide internal directories.