clusterresources

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package clusterresources samples whole-host CPU, memory, and storage for cloud's ephemeral cache, over the negotiated uplink session.

This is measured state with no entity behind it, so it rides a purpose-built capability rather than entity sync, at the cadence cloud asks for. It is the resource half of the legacy status report; when cloud selects this capability the poll has nothing left to say about resources.

Index

Constants

View Source
const (
	Version1 uint = 1

	TypeSample = "cluster.resources.sample"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IntervalSeconds int `json:"interval_seconds"`
}

Config is how often cloud wants a sample once the session opens.

type Link interface {
	OfferCapability(uplink.CapabilityOffer)
	OnSession(func(context.Context, uplink.Session))
	SendMessageBlocking(context.Context, string, any) error
}

Link is the slice of the uplink client the reporter uses.

type Reporter

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

func NewReporter

func NewReporter(log *slog.Logger, source Source) *Reporter

func (*Reporter) Register

func (r *Reporter) Register(_ context.Context, link Link) error

Register offers the capability and, on each session that selects it, samples at the interval cloud configured until the session ends.

type Sample

type Sample struct {
	ObservedAt     time.Time `json:"observed_at"`
	CPUCores       float64   `json:"cpu_cores,omitempty"`
	CPUPercent     float64   `json:"cpu_percent"`
	MemoryBytes    int64     `json:"memory_bytes,omitempty"`
	MemoryPercent  float64   `json:"memory_percent"`
	StorageBytes   int64     `json:"storage_bytes,omitempty"`
	StoragePercent float64   `json:"storage_percent"`
}

Sample is one reading of what this host is spending. It is the resource half of the legacy status report, field for field. Percentages are whole-host utilization; the byte and core totals are capacity.

type Source

type Source interface {
	ResourceSample() Sample
}

Source takes one reading, stamped with when it was taken. CloudControl implements it over sysstats.

Jump to

Keyboard shortcuts

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