cluster

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cluster provides cluster state collection functionality for FODC agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateClusterStateAddrs

func GenerateClusterStateAddrs(ports []string) []string

GenerateClusterStateAddrs generates cluster state gRPC addresses from the given ports.

func NodeRoleFromNode

func NodeRoleFromNode(node *databasev1.Node) string

NodeRoleFromNode determines the node role string from the Node's role and labels.

func StopCollector

func StopCollector(collector *Collector)

StopCollector stops the collector if it's not nil.

Types

type Collector

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

Collector collects cluster state from BanyanDB nodes via gRPC and stores the data.

func NewCollector

func NewCollector(log *logger.Logger, addrs []string, interval time.Duration, podName string) *Collector

NewCollector creates a new cluster state collector.

func StartCollector

func StartCollector(ctx context.Context, log *logger.Logger, ports []string, interval time.Duration, podName string) (*Collector, error)

StartCollector creates and starts a cluster state collector.

func (*Collector) GetClusterTopology

func (c *Collector) GetClusterTopology() TopologyMap

GetClusterTopology returns the aggregated cluster topology across all endpoints.

func (*Collector) GetCurrentNodes

func (c *Collector) GetCurrentNodes() map[string]*databasev1.Node

GetCurrentNodes returns all current node info, keyed by endpoint address.

func (*Collector) GetNodeInfo

func (c *Collector) GetNodeInfo() (nodeRole string, nodeLabels map[string]string)

GetNodeInfo returns the processed node role and labels from the first available current node.

func (*Collector) ResolveNodeRole added in v0.10.3

func (c *Collector) ResolveNodeRole(ctx context.Context) (nodeRole string, nodeLabels map[string]string)

ResolveNodeRole polls the current node until a resolved (non-unspecified) role is obtained or resolveBudget elapses, then returns the role string and labels. All per-attempt fetches share a budget-scoped context, so the total runtime is bounded by resolveBudget regardless of the per-attempt gRPC timeouts and backoffs. This guards the startup race where the sibling lifecycle/banyandb gRPC server is not yet listening when the agent first polls, which previously left node_role permanently ROLE_UNSPECIFIED. It does not touch nodeFetchedCh, so the collector's readiness signal stays prompt.

func (*Collector) SetClusterTopology

func (c *Collector) SetClusterTopology(topology TopologyMap)

SetClusterTopology sets the cluster topology data, primarily for tests.

func (*Collector) Start

func (c *Collector) Start(ctx context.Context) error

Start starts the cluster state collector.

func (*Collector) Stop

func (c *Collector) Stop()

Stop stops the cluster state collector.

func (*Collector) WaitForNodeFetched

func (c *Collector) WaitForNodeFetched(ctx context.Context) error

WaitForNodeFetched waits until the current node info has been fetched.

type TopologyMap

type TopologyMap struct {
	Nodes []*databasev1.Node `json:"nodes"`
	Calls []*fodcv1.Call     `json:"calls"`
}

TopologyMap represents processed cluster data for a single endpoint.

Jump to

Keyboard shortcuts

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