activity

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package activity keeps the raw activity facts one process of the laboratory hands, through the agent API, to the platform that runs it (the daemon): internet egress, console sessions, devices touched over the VPN. The facts sit in a bounded ring of a LabActivityReport in the group namespace; the agent reads them. The laboratory aggregates nothing and sends nothing anywhere by itself. Everything is off unless the chart value activityReports.enabled is true: a nil *Hub is the disabled state, and every method of it is a no-op.

Index

Constants

View Source
const (
	MaxEvents = 1000
	MaxAge    = time.Hour
)

The bounds of one writer's ring in one namespace.

View Source
const EnvEnabled = "ACTIVITY_REPORTS"

EnvEnabled is the variable every process reads (the chart sets it from activityReports.enabled).

View Source
const FlushEvery = time.Minute

FlushEvery is how often a writer looks for events to write: at most one write per ring per minute, and none when nothing is new.

Variables

This section is empty.

Functions

func Enabled

func Enabled() bool

Enabled reports whether this process was told to keep activity reports (chart value activityReports.enabled).

func ReportName

func ReportName(writer string) string

ReportName is the name of the LabActivityReport of a writer ("vpn", "egress", "proxy-<pod>").

Types

type Hub

type Hub struct {
	Client client.Client
	// Reader reads the report back before it is written (default: Client). Give an uncached reader where the process has no list and watch
	// right on the reports.
	Reader    client.Reader
	Writer    string
	MaxEvents int
	MaxAge    time.Duration
	Now       func() time.Time
	OnError   func(error)
	// contains filtered or unexported fields
}

Hub is the rings of one writer, one per group namespace.

func New

func New(c client.Client, writer string) *Hub

New returns a Hub for a writer.

func (*Hub) Add

func (h *Hub) Add(namespace string, ev laboratoryv1alpha1.ActivityEvent)

Add appends an event to the ring of a namespace. Seq is set here. A nil Hub (reports disabled) does nothing.

func (*Hub) Events

func (h *Hub) Events(namespace string) []laboratoryv1alpha1.ActivityEvent

Events returns a copy of the ring of a namespace (what the next flush writes).

func (*Hub) Flush

func (h *Hub) Flush(ctx context.Context) error

Flush writes every ring that changed (or aged) to its LabActivityReport.

func (*Hub) Run

func (h *Hub) Run(ctx context.Context, every time.Duration)

Run flushes every interval until ctx ends, and once more at the end.

Jump to

Keyboard shortcuts

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