dht

package
v0.0.0-...-37eefcc Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDHTNotInitialised     = errors.New("dht is not initialised")
	ErrReplicasLessThanNodes = errors.New("replicas are lesser than physical nodes")
)

Functions

func Create

func Create() *dht

Create initializes an empty distributed hash table.

func InitialiseDHT

func InitialiseDHT(shardCount int, seedNodes []string, replication int) (map[ShardID]ShardLocation, error)

Initialise creates a new distributed hash table from the inputs. Should be called only from bootstrap mode or while creating a new cluster.

Types

type DHT

type DHT interface {
	// GetLocation returns the location of the leader and follower slot and corresponding node
	GetShard(key string) (ShardLocation, error)

	GetLeaderShardsForNode(nodeID NodeID) []ShardID

	GetAllShardsForNode(nodeID NodeID) []ShardID

	// Load loads data from an already existing configuration.
	// This must be taken called after confirmation from the master
	Load(shards map[ShardID]ShardLocation)

	// Snapshot returns the current node vs slot ids map
	Snapshot() map[ShardID]ShardLocation
}

DHT contains the location of a given key in a distributed data system.

type NodeID

type NodeID string

type ShardID

type ShardID int

type ShardLocation

type ShardLocation struct {
	ID        ShardID
	Leader    NodeID
	Followers []NodeID
}

Jump to

Keyboard shortcuts

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