Documentation
¶
Index ¶
- type HashRing
- func (r *HashRing) AddNode(node *Node)
- func (r *HashRing) CalcIndex(key string) uint32
- func (r *HashRing) GetNode(key string) (uint32, string)
- func (r *HashRing) GetNodeByIndex(keyIndex uint32) (uint32, string)
- func (r *HashRing) GetNodeExcludedNodeIDs(key string, NodeIDs []string) (uint32, string)
- func (r *HashRing) GetNodeUpDownNodes(NodeID string) (string, string)
- func (r *HashRing) IsOnline(ID string) bool
- func (r *HashRing) Node(ID string) *Node
- func (r *HashRing) PrintNodes()
- func (r *HashRing) RandomGetNodes(num int) []*Node
- func (r *HashRing) RemoveNode(nodeID string) bool
- func (r *HashRing) SetOffline(ID string)
- func (r *HashRing) SetOnline(ID string)
- func (r *HashRing) TraversalNRing()
- func (r *HashRing) TraversalVRing()
- type Node
- type VNode
- type VWeightedNode
- type WeightedHashRing
- func (r *WeightedHashRing) AddNode(node *WeightedNode)
- func (r *WeightedHashRing) CalcIndex(key string) uint32
- func (r *WeightedHashRing) GetNode(key string) (uint32, string)
- func (r *WeightedHashRing) GetNodeByIndex(keyIndex uint32) (uint32, string)
- func (r *WeightedHashRing) GetNodeExcludedNodeIDs(key string, NodeIDs []string) (uint32, string)
- func (r *WeightedHashRing) GetNodeUpDownNodes(NodeID string) (string, string)
- func (r *WeightedHashRing) IsOnline(ID string) bool
- func (r *WeightedHashRing) Node(ID string) *WeightedNode
- func (r *WeightedHashRing) PrintNodes()
- func (r *WeightedHashRing) RandomGetNodes(num int) []*WeightedNode
- func (r *WeightedHashRing) RemoveNode(nodeID string) bool
- func (r *WeightedHashRing) SetOffline(ID string)
- func (r *WeightedHashRing) SetOnline(ID string)
- func (r *WeightedHashRing) TraversalNRing()
- func (r *WeightedHashRing) TraversalVRing()
- type WeightedNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashRing ¶
type HashRing struct { VRing *rbtree.Rbtree NRing *rbtree.Rbtree Nodes *sync.Map // map(NodeID => *Node) NodeStatus *sync.Map // map(NodeID => status) NodeCount uint32 NodeOkCount uint32 NumberOfVirtual uint32 sync.Mutex }
HashRing
func (*HashRing) GetNodeByIndex ¶
GetNodeByIndex @params keyIndex
func (*HashRing) GetNodeExcludedNodeIDs ¶
GetNodeMissNodeID get node excluded given NodeIDs @params key
func (*HashRing) GetNodeUpDownNodes ¶
GetNodeUpDownNodes get upstream of downstream of node @params
func (*HashRing) PrintNodes ¶
func (r *HashRing) PrintNodes()
PrintNodes print all non-virtual nodes
func (*HashRing) RandomGetNodes ¶
func (*HashRing) SetOffline ¶
func (*HashRing) TraversalNRing ¶
func (r *HashRing) TraversalNRing()
TraversalNRing traverse non-virtual rbtree
func (*HashRing) TraversalVRing ¶
func (r *HashRing) TraversalVRing()
TraversalVRing traverse virtual rbtree
type VWeightedNode ¶ added in v0.5.0
VWeightedNode virtual node
type WeightedHashRing ¶ added in v0.5.0
type WeightedHashRing struct { VRing *rbtree.Rbtree NRing *rbtree.Rbtree Nodes *sync.Map // map(NodeID => *WeightedNode) NodeStatus *sync.Map // map(NodeID => status) NodeCount uint32 NodeOkCount uint32 NumberOfVirtual uint32 sync.Mutex }
HashRing
func (*WeightedHashRing) AddNode ¶ added in v0.5.0
func (r *WeightedHashRing) AddNode(node *WeightedNode)
AddNode
func (*WeightedHashRing) CalcIndex ¶ added in v0.5.0
func (r *WeightedHashRing) CalcIndex(key string) uint32
CalcIndex
func (*WeightedHashRing) GetNode ¶ added in v0.5.0
func (r *WeightedHashRing) GetNode(key string) (uint32, string)
GetNode @params key
func (*WeightedHashRing) GetNodeByIndex ¶ added in v0.5.0
func (r *WeightedHashRing) GetNodeByIndex(keyIndex uint32) (uint32, string)
GetNodeByIndex @params keyIndex
func (*WeightedHashRing) GetNodeExcludedNodeIDs ¶ added in v0.5.0
func (r *WeightedHashRing) GetNodeExcludedNodeIDs(key string, NodeIDs []string) (uint32, string)
GetNodeMissNodeID get node excluded given NodeIDs @params key
func (*WeightedHashRing) GetNodeUpDownNodes ¶ added in v0.5.0
func (r *WeightedHashRing) GetNodeUpDownNodes(NodeID string) (string, string)
GetNodeUpDownNodes get upstream of downstream of node @params
func (*WeightedHashRing) IsOnline ¶ added in v0.5.0
func (r *WeightedHashRing) IsOnline(ID string) bool
func (*WeightedHashRing) Node ¶ added in v0.5.0
func (r *WeightedHashRing) Node(ID string) *WeightedNode
func (*WeightedHashRing) PrintNodes ¶ added in v0.5.0
func (r *WeightedHashRing) PrintNodes()
PrintNodes print all non-virtual nodes
func (*WeightedHashRing) RandomGetNodes ¶ added in v0.5.0
func (r *WeightedHashRing) RandomGetNodes(num int) []*WeightedNode
func (*WeightedHashRing) RemoveNode ¶ added in v0.5.0
func (r *WeightedHashRing) RemoveNode(nodeID string) bool
RemoveNode
func (*WeightedHashRing) SetOffline ¶ added in v0.5.0
func (r *WeightedHashRing) SetOffline(ID string)
func (*WeightedHashRing) SetOnline ¶ added in v0.5.0
func (r *WeightedHashRing) SetOnline(ID string)
func (*WeightedHashRing) TraversalNRing ¶ added in v0.5.0
func (r *WeightedHashRing) TraversalNRing()
TraversalNRing traverse non-virtual rbtree
func (*WeightedHashRing) TraversalVRing ¶ added in v0.5.0
func (r *WeightedHashRing) TraversalVRing()
TraversalVRing traverse virtual rbtree