Documentation
¶
Index ¶
- type Hash
- func (ch *Hash[T]) AddNode(node T) error
- func (ch *Hash[T]) Clear()
- func (ch *Hash[T]) GetNode(key string) T
- func (ch *Hash[T]) GetNodeByID(nodeID uint32) T
- func (ch *Hash[T]) GetNodeByUint64(key uint64) T
- func (ch *Hash[T]) GetNodeCount() int
- func (ch *Hash[T]) GetNodes() []T
- func (ch *Hash[T]) GetNodesForKey(key string, count int) []T
- func (ch *Hash[T]) GetVirtualNodeCount() int
- func (ch *Hash[T]) RemoveNode(nodeID uint32) T
- func (ch *Hash[T]) UpdateNode(node T) error
- type INode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hash ¶
type Hash[T INode] struct { // contains filtered or unexported fields }
Hash 一致性哈希实现
func (*Hash[T]) GetNodeByID ¶
GetNodeByID 根据节点ID获取节点
func (*Hash[T]) GetNodeByUint64 ¶
GetNodeByUint64 根据uint64类型的key获取节点
func (*Hash[T]) GetNodesForKey ¶
GetNodesForKey 获取某个key的所有备份节点(用于故障转移)
func (*Hash[T]) GetVirtualNodeCount ¶
GetVirtualNodeCount 获取虚拟节点数量
Click to show internal directories.
Click to hide internal directories.