mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 00:38:33 +02:00
refactor: fix lint errors; improve error handling
This commit is contained in:
@@ -51,19 +51,6 @@ const (
|
||||
SystemInfoAggregateModeSensorTemperature SystemInfoAggregateMode = "sensor_temperature" // @name SystemInfoAggregateModeSensorTemperature
|
||||
)
|
||||
|
||||
var allQueries = []SystemInfoAggregateMode{
|
||||
SystemInfoAggregateModeCPUAverage,
|
||||
SystemInfoAggregateModeMemoryUsage,
|
||||
SystemInfoAggregateModeMemoryUsagePercent,
|
||||
SystemInfoAggregateModeDisksReadSpeed,
|
||||
SystemInfoAggregateModeDisksWriteSpeed,
|
||||
SystemInfoAggregateModeDisksIOPS,
|
||||
SystemInfoAggregateModeDiskUsage,
|
||||
SystemInfoAggregateModeNetworkSpeed,
|
||||
SystemInfoAggregateModeNetworkTransfer,
|
||||
SystemInfoAggregateModeSensorTemperature,
|
||||
}
|
||||
|
||||
var Poller = period.NewPoller("system_info", getSystemInfo, aggregate)
|
||||
|
||||
func isNoDataAvailable(err error) bool {
|
||||
|
||||
@@ -123,6 +123,18 @@ func TestSerialize(t *testing.T) {
|
||||
for i := range 5 {
|
||||
entries[i] = testInfo
|
||||
}
|
||||
var allQueries = []SystemInfoAggregateMode{
|
||||
SystemInfoAggregateModeCPUAverage,
|
||||
SystemInfoAggregateModeMemoryUsage,
|
||||
SystemInfoAggregateModeMemoryUsagePercent,
|
||||
SystemInfoAggregateModeDisksReadSpeed,
|
||||
SystemInfoAggregateModeDisksWriteSpeed,
|
||||
SystemInfoAggregateModeDisksIOPS,
|
||||
SystemInfoAggregateModeDiskUsage,
|
||||
SystemInfoAggregateModeNetworkSpeed,
|
||||
SystemInfoAggregateModeNetworkTransfer,
|
||||
SystemInfoAggregateModeSensorTemperature,
|
||||
}
|
||||
for _, query := range allQueries {
|
||||
t.Run(string(query), func(t *testing.T) {
|
||||
_, result := aggregate(entries, url.Values{"aggregate": []string{string(query)}})
|
||||
|
||||
@@ -3,6 +3,7 @@ package uptime
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"math"
|
||||
"net/url"
|
||||
"slices"
|
||||
"time"
|
||||
@@ -70,7 +71,7 @@ func aggregateStatuses(entries []StatusByAlias, query url.Values) (int, Aggregat
|
||||
for alias, status := range entry.Map {
|
||||
statuses[alias] = append(statuses[alias], Status{
|
||||
Status: status.Status,
|
||||
Latency: int32(status.Latency.Milliseconds()),
|
||||
Latency: int32(min(math.MaxInt32, status.Latency.Milliseconds())), //nolint:gosec
|
||||
Timestamp: entry.Timestamp,
|
||||
})
|
||||
}
|
||||
@@ -134,7 +135,6 @@ func (rs RouteStatuses) aggregate(limit int, offset int) Aggregated {
|
||||
|
||||
status := types.StatusUnknown
|
||||
if state := config.ActiveState.Load(); state != nil {
|
||||
// FIXME: pass ctx to getRoute
|
||||
r, ok := entrypoint.FromCtx(state.Context()).GetRoute(alias)
|
||||
if ok {
|
||||
mon := r.HealthMonitor()
|
||||
|
||||
Reference in New Issue
Block a user