agentreports

package
v4.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package agentreports keeps the record of report batches the Agent Control stream applied (reports.v1, node-ops-service.md section 5.5), so that a batch an agent resends is applied at most once per node.

Index

Constants

View Source
const (
	KindTraffic = "traffic"
	KindLogs    = "logs"
	// KindMaintenance records maintenance events (maintenance.v1), one
	// record per event: MaintenanceBatchID.
	KindMaintenance = "maintenance"
)

Batch kinds.

View Source
const MaxBatchIDLength = 128

MaxBatchIDLength bounds a batch id, as the subscriber request ledger bounds its request ids.

View Source
const Retention = 7 * 24 * time.Hour

Retention is how long a batch id is remembered. Batch ids carry the agent's boot id and a sequence, so one never repeats; the record only has to outlive the agent's spool, which resends on the stream as soon as it reconnects.

Variables

View Source
var ErrInvalidBatchID = errors.New("batch_id is required and at most 128 bytes")

ErrInvalidBatchID means a batch id is empty or longer than MaxBatchIDLength; the batch is refused for good.

Functions

func ClaimTx

func ClaimTx(tx *gorm.DB, nodeKind string, nodeID uint, batchID, kind string, now time.Time) (seen bool, err error)

ClaimTx records that this transaction applies batchID for the node and reports whether a committed transaction recorded it before (seen). The caller applies the batch only when seen is false, in the same tx, so a failure rolls the claim back with the batch and a retry applies it. Two concurrent deliveries of one batch serialize on the row: the second sees the first's claim once it commits.

func MaintenanceBatchID added in v4.2.0

func MaintenanceBatchID(eventID string) string

MaintenanceBatchID is the batch id that records a maintenance event, from its event id: the prefix and the event id's hex SHA-256, within MaxBatchIDLength whatever the event id's length.

func Prune

func Prune(db *gorm.DB, now time.Time) (int64, error)

Prune deletes batch records older than Retention.

func ValidateBatchID

func ValidateBatchID(batchID string) error

ValidateBatchID checks a batch id's bounds.

Types

This section is empty.

Jump to

Keyboard shortcuts

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