hashring

package
v0.0.0-...-80248e1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultVirtualNodeCount uint32 = 30 // 默认-虚拟节点基数

Functions

This section is empty.

Types

type HashRing

type HashRing[NODE comparable] struct {
	// contains filtered or unexported fields
}

HashRing 哈希环

func NewHashRing

func NewHashRing[NODE comparable]() *HashRing[NODE]

func (*HashRing[NODE]) AddNode

func (p *HashRing[NODE]) AddNode(node NODE) *HashRing[NODE]

func (*HashRing[NODE]) AddNodeWithWeight

func (p *HashRing[NODE]) AddNodeWithWeight(node NODE, weight uint32) *HashRing[NODE]

func (*HashRing[NODE]) GetNode

func (p *HashRing[NODE]) GetNode(key string) (node NODE, ok bool)

func (*HashRing[NODE]) IsNodeExist

func (p *HashRing[NODE]) IsNodeExist(node NODE) bool

判断物理节点是否存在

func (*HashRing[NODE]) RemoveNode

func (p *HashRing[NODE]) RemoveNode(node NODE) *HashRing[NODE]

type VirtualNodeHashSliceOrder

type VirtualNodeHashSliceOrder []uint32 // 虚拟节点-哈希值切片, 已排序, 便于二分查找

func (*VirtualNodeHashSliceOrder) Len

func (p *VirtualNodeHashSliceOrder) Len() int

func (*VirtualNodeHashSliceOrder) Less

func (p *VirtualNodeHashSliceOrder) Less(i, j int) bool

func (*VirtualNodeHashSliceOrder) Swap

func (p *VirtualNodeHashSliceOrder) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL