node

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager handles node management and health checking

func NewManager

func NewManager(logger ...*logrus.Logger) (*Manager, error)

NewManager creates a new node manager

func (*Manager) CheckHealth

func (m *Manager) CheckHealth() (bool, error)

CheckHealth checks the health of the node

func (*Manager) Close

func (m *Manager) Close() error

Close closes the node manager

func (*Manager) CloseManager

func (m *Manager) CloseManager() error

CloseManager closes the node manager and releases any resources

func (*Manager) GetNodeByAddress

func (m *Manager) GetNodeByAddress(ctx context.Context, address string) (*NodeInfo, error)

GetNodeByAddress returns a node by its address

func (*Manager) GetNodeByHostname

func (m *Manager) GetNodeByHostname(ctx context.Context, hostname string) (*NodeInfo, error)

GetNodeByHostname returns a node by its hostname

func (*Manager) GetNodeByID

func (m *Manager) GetNodeByID(ctx context.Context, nodeID string) (*NodeInfo, error)

GetNodeByID returns a node by its ID

func (*Manager) GetNodeDetails

func (m *Manager) GetNodeDetails() ([]NodeInfo, error)

GetNodeDetails returns details about all known nodes

func (*Manager) GetNodeID

func (m *Manager) GetNodeID() string

GetNodeID returns the ID of this node

func (*Manager) GetNodes

func (m *Manager) GetNodes(ctx context.Context) ([]*NodeInfo, error)

GetNodes returns a list of all nodes

func (*Manager) InitMembershipProtocol

func (m *Manager) InitMembershipProtocol() error

InitMembershipProtocol initializes the membership protocol

func (*Manager) JoinCluster

func (m *Manager) JoinCluster(host string) error

JoinCluster joins an existing cluster

func (*Manager) LeaveCluster

func (m *Manager) LeaveCluster() error

LeaveCluster gracefully leaves the cluster

func (*Manager) ListNodes

func (m *Manager) ListNodes(ctx context.Context) ([]interface{}, error)

ListNodes returns a list of all known nodes

func (*Manager) RegisterNode

func (m *Manager) RegisterNode(ctx context.Context, nodeInfo *NodeInfo) error

RegisterNode registers a node with the manager

func (*Manager) RemoveNode

func (m *Manager) RemoveNode(ctx context.Context, nodeID string) error

RemoveNode removes a node from the cluster

func (*Manager) SetNetworkManager

func (m *Manager) SetNetworkManager(networkManager interface{})

SetNetworkManager sets the network manager

func (*Manager) StartDiscovery

func (m *Manager) StartDiscovery() error

StartDiscovery starts the node discovery service

func (*Manager) StartHealthMonitoring

func (m *Manager) StartHealthMonitoring(ctx context.Context, interval time.Duration)

StartHealthMonitoring starts periodic health monitoring

func (*Manager) UpdateNodeResources

func (m *Manager) UpdateNodeResources(ctx context.Context, nodeID string, resources Resources) error

UpdateNodeResources updates the resources of a node

func (*Manager) UpdateNodeStatus

func (m *Manager) UpdateNodeStatus(ctx context.Context, nodeID string, status NodeStatus) error

UpdateNodeStatus updates the status of a node

func (*Manager) WithMembership

func (m *Manager) WithMembership(membership MembershipManagerInterface) *Manager

WithMembership sets the membership manager

func (*Manager) WithMembershipManager

func (m *Manager) WithMembershipManager(membershipManager MembershipManagerInterface) *Manager

WithMembershipManager sets the membership manager and returns the manager for chaining

func (*Manager) WithStorage

func (m *Manager) WithStorage(storage *storage.Manager) *Manager

WithStorage sets the storage manager

type MembershipManagerInterface

type MembershipManagerInterface interface {
	Join(addresses []string) (int, error)
	Leave(timeout time.Duration) error
	GetMembers(ctx context.Context) ([]string, error)
	RemoveMember(ctx context.Context, nodeID string) error
	AddMember(nodeID string, address string)
}

MembershipManagerInterface defines the interface for membership manager

type NodeHealth

type NodeHealth struct {
	IsHealthy           bool
	LastCheck           time.Time
	CheckCount          uint32
	FailureCount        uint32
	MaxFailureThreshold uint32
}

NodeHealth represents the health status of a node

type NodeInfo

type NodeInfo struct {
	ID        string
	Address   string
	LastSeen  time.Time
	Resources NodeResources
	Status    NodeStatus
	Hostname  string
}

NodeInfo represents information about a node

type NodeResources

type NodeResources struct {
	CPUAvailable      float64
	MemoryAvailable   uint64
	ContainersRunning uint32
	IsLeader          bool
	CPU               int
	Memory            int
	Disk              int64
}

NodeResources represents the resources available on a node

type NodeStatus

type NodeStatus string

NodeStatus represents the status of a node

const (
	// NodeStatusReady indicates the node is ready to accept workloads
	NodeStatusReady NodeStatus = "ready"

	// NodeStatusMaintenance indicates the node is in maintenance mode
	NodeStatusMaintenance NodeStatus = "maintenance"

	// NodeStatusOffline indicates the node is offline
	NodeStatusOffline NodeStatus = "offline"

	// NodeStatusError indicates the node is in an error state
	NodeStatusError NodeStatus = "error"
)

type Resources

type Resources struct {
	CPU    int
	Memory int
	Disk   int64
}

Resources represents the resources of a node

Jump to

Keyboard shortcuts

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