dht

package
v0.0.0-...-4ff85e9 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashKey

func HashKey(key string) int

Types

type HashRing

type HashRing struct {
	// contains filtered or unexported fields
}

func NewHashRing

func NewHashRing() *HashRing

NewHashRing creates empty HashRing

func (*HashRing) AddNode

func (h *HashRing) AddNode(nodes ...*Node)

AddNode adds node to Hash Ring

func (*HashRing) GetNodeForKey

func (h *HashRing) GetNodeForKey(key string) (*Node, error)

GetNodeForKey returns Node corresponding to given key. Error can occur if Node is not found

func (*HashRing) GetNodes

func (h *HashRing) GetNodes() map[int]*Node

func (*HashRing) NodeExists

func (h *HashRing) NodeExists(key string) bool

NodeExists returns true if node exists in hash ring, false otherwise

func (*HashRing) RemoveNode

func (h *HashRing) RemoveNode(nodes ...*Node)

type Node

type Node struct {
	Addr  net.Addr
	Alive bool
}

func NewNode

func NewNode(addr net.Addr) *Node

Jump to

Keyboard shortcuts

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