mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-08 06:01:12 +02:00
Instead of doing excessive get/list requests, do a watch per node in an infinite retry. Additionally, refactor the dashboard code to make the various data listener namings more consistent and reorganize the packages. Closes siderolabs/talos#6960. Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
39 lines
956 B
Go
39 lines
956 B
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
// Package apidata implements types to handle monitoring data, calculate values from it, etc.
|
|
package apidata
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
const maxPoints = 1000
|
|
|
|
// Data represents the monitoring data retrieved via Talos API.
|
|
//
|
|
// Data structure is sent over the channel each interval.
|
|
type Data struct {
|
|
// Data per each node.
|
|
Nodes map[string]*Node
|
|
|
|
Timestamp time.Time
|
|
Interval time.Duration
|
|
}
|
|
|
|
// CalculateDiff with data from previous iteration.
|
|
func (data *Data) CalculateDiff(oldData *Data) {
|
|
data.Interval = data.Timestamp.Sub(oldData.Timestamp)
|
|
|
|
for node, nodeData := range data.Nodes {
|
|
oldNodeData := oldData.Nodes[node]
|
|
if oldNodeData == nil {
|
|
continue
|
|
}
|
|
|
|
nodeData.UpdateDiff(oldNodeData)
|
|
nodeData.UpdateSeries(oldNodeData)
|
|
}
|
|
}
|