utils

package
v0.0.0-...-aced109 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_HASH_RING_REPLICAS = 100

Variables

This section is empty.

Functions

func Swap

func Swap(this HashRing, i, j int)

Types

type ConsistentHashing

type ConsistentHashing struct {
	Nodes map[uint32]HashRingNode

	sync.RWMutex
	// contains filtered or unexported fields
}

func NewConsistentHashing

func NewConsistentHashing() *ConsistentHashing

func (*ConsistentHashing) AddNode

func (c *ConsistentHashing) AddNode(node *HashRingNode) bool

func (*ConsistentHashing) GetNode

func (c *ConsistentHashing) GetNode(key string) HashRingNode

func (*ConsistentHashing) GetNodeById

func (c *ConsistentHashing) GetNodeById(id int) HashRingNode

func (*ConsistentHashing) RemoveNode

func (c *ConsistentHashing) RemoveNode(node *HashRingNode)

type HashRing

type HashRing []uint32

func NewHashRing

func NewHashRing() HashRing

func (HashRing) Len

func (this HashRing) Len() int

func (HashRing) Less

func (this HashRing) Less(i, j int) bool

func (HashRing) Sort

func (this HashRing) Sort()

type HashRingNode

type HashRingNode struct {
	Id     int
	IP     string
	Port   int
	Weight int
}

func NewHashRingNode

func NewHashRingNode(id int, ip string, port int, weight int) *HashRingNode

Jump to

Keyboard shortcuts

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