hashring

package
v0.0.0-...-bf71a7b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashRing

type HashRing struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New() *HashRing

func (*HashRing) AddNode

func (r *HashRing) AddNode(id string, node *Node)

func (*HashRing) IsOnline

func (r *HashRing) IsOnline(ID string) bool

func (*HashRing) Node

func (r *HashRing) Node(ID string) *Node

func (*HashRing) NodeCount

func (r *HashRing) NodeCount() uint32

func (*HashRing) NodeOkCount

func (r *HashRing) NodeOkCount() uint32

func (*HashRing) RandomNode

func (r *HashRing) RandomNode(seed string) (string, *Node)

RandomNode uses the given seed to select a random online node If the seed is empty, it will use a cryptographically secure random seed

func (*HashRing) RandomNodeExcludedIDs

func (r *HashRing) RandomNodeExcludedIDs(excludedIDs []string, seed string) (string, *Node)

RandomNodeExcludedIDs uses the given seed to select a random online node, while excluding specified nodes If the seed is empty, it will use a cryptographically secure random seed

func (*HashRing) RandomNodes

func (r *HashRing) RandomNodes(num int, seed string) []*Node

RandomNodes return random nodes from the hashring If the seed is empty, it will use a cryptographically secure random seed

func (*HashRing) RemoveNode

func (r *HashRing) RemoveNode(ID string)

func (*HashRing) SetOffline

func (r *HashRing) SetOffline(ID string)

func (*HashRing) SetOnline

func (r *HashRing) SetOnline(ID string)

func (*HashRing) String

func (r *HashRing) String() string

func (*HashRing) UpdateNodeDiskUsage

func (r *HashRing) UpdateNodeDiskUsage(ID string, diskSize, freeDisk uint64)

type Node

type Node struct {
	Host      string
	Rest      string
	Data      *sync.Map
	DiskUsage float64
	Weight    float64
	// contains filtered or unexported fields
}

func (*Node) GetID

func (n *Node) GetID() string

func (*Node) IsOnline

func (n *Node) IsOnline() bool

func (*Node) SetDiskUsage

func (n *Node) SetDiskUsage(diskSize, freeDisk uint64)

func (*Node) SetID

func (n *Node) SetID(ID string)

SetID will only set the ID if it's missing

func (*Node) String

func (n *Node) String() string

Jump to

Keyboard shortcuts

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