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 ¶
const ( KindTraffic = "traffic" KindLogs = "logs" )
Batch kinds.
const MaxBatchIDLength = 128
MaxBatchIDLength bounds a batch id, as the subscriber request ledger bounds its request ids.
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 ¶
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 ValidateBatchID ¶
ValidateBatchID checks a batch id's bounds.
Types ¶
This section is empty.