Alerting: Add doc comments to classic.go (#56724)

This commit is contained in:
George Robinson
2022-10-12 10:55:48 +01:00
committed by GitHub
parent dd9e1498f9
commit 67d93ceea0
4 changed files with 153 additions and 121 deletions
+7 -5
View File
@@ -7,11 +7,9 @@ import (
"github.com/grafana/grafana/pkg/expr/mathexp"
)
func nilOrNaN(f *float64) bool {
return f == nil || math.IsNaN(*f)
}
type reducer string
func (cr classicReducer) ValidReduceFunc() bool {
func (cr reducer) ValidReduceFunc() bool {
switch cr {
case "avg", "sum", "min", "max", "count", "last", "median":
return true
@@ -22,7 +20,7 @@ func (cr classicReducer) ValidReduceFunc() bool {
}
//nolint:gocyclo
func (cr classicReducer) Reduce(series mathexp.Series) mathexp.Number {
func (cr reducer) Reduce(series mathexp.Series) mathexp.Number {
num := mathexp.NewNumber("", nil)
if series.GetLabels() != nil {
@@ -184,6 +182,10 @@ func calculateDiff(ff mathexp.Float64Field, allNull bool, value float64, fn func
return allNull, value
}
func nilOrNaN(f *float64) bool {
return f == nil || math.IsNaN(*f)
}
var diff = func(newest, oldest float64) float64 {
return newest - oldest
}