cluster

package
v0.0.0-...-626be4e Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package cluster represents the nodes within a Veracity cluster.

Index

Constants

View Source
const (
	// DefaultRenewInterval is the default interval at which a [Registrar]
	// renews a node's registration.
	//
	// The registration period is always set to 2 * DefaultRenewInterval.
	DefaultRenewInterval = 10 * time.Second

	// DefaultRegistryPollInterval is the default interval at which the registry
	// polls the underlying key-value store for changes.
	DefaultRegistryPollInterval = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MembershipChanged

type MembershipChanged struct {
	Registered, Deregistered []Node
}

MembershipChanged is an engine event that indicates a change in membership to the cluster.

type Node

type Node struct {
	// ID is a unique identifier for the node.
	//
	// It may be generated when the node starts up, or it may be static on a
	// given machine or container.
	ID *uuidpb.UUID

	// Addresses is a list of network addresses for the node's gRPC server, in
	// order of preference.
	Addresses []string
}

A Node is a member of the cluster.

type Partitioner

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

Partitioner determines which node is responsible for handling a specific workload.

func (*Partitioner) AddNode

func (p *Partitioner) AddNode(id *uuidpb.UUID)

AddNode adds a node to the partitioner.

func (*Partitioner) RemoveNode

func (p *Partitioner) RemoveNode(id *uuidpb.UUID)

RemoveNode removes a node from the partitioner.

func (*Partitioner) Route

func (p *Partitioner) Route(workload *uuidpb.UUID) *uuidpb.UUID

Route returns the ID of the node that should handle the given workload.

type Registrar

type Registrar struct {
	Keyspaces     kv.BinaryStore
	Node          Node
	RenewInterval time.Duration
	Shutdown      signaling.Latch
	Logger        *slog.Logger
	// contains filtered or unexported fields
}

Registrar registers and periodically renews a node's registration with the registry.

func (*Registrar) Run

func (r *Registrar) Run(ctx context.Context) error

Run starts the registrar.

type RegistryObserver

type RegistryObserver struct {
	Keyspaces         kv.BinaryStore
	MembershipChanged chan<- MembershipChanged
	Shutdown          signaling.Latch
	PollInterval      time.Duration
	// contains filtered or unexported fields
}

RegistryObserver emits events about changes to the nodes in the registry.

func (*RegistryObserver) Run

func (o *RegistryObserver) Run(ctx context.Context) error

Run starts the observer.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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