mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
all: consistently use 'any' instead of 'interface{}'
'any' type is supported starting from Go1.18. Let's consistently use it instead of 'interface{}' type across the code base, since `any` is easier to read than 'interface{}'.
This commit is contained in:
parent
08c32232a6
commit
3c02937a34
97 changed files with 281 additions and 288 deletions
|
@ -117,7 +117,7 @@ func (q *Query) metrics() ([]Metric, error) {
|
|||
type QueryInstant struct {
|
||||
Result []struct {
|
||||
Labels map[string]string `json:"metric"`
|
||||
TV [2]interface{} `json:"value"`
|
||||
TV [2]any `json:"value"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ func (q QueryInstant) metrics() ([]Metric, error) {
|
|||
type QueryRange struct {
|
||||
Result []struct {
|
||||
Metric map[string]string `json:"metric"`
|
||||
Values [][]interface{} `json:"values"`
|
||||
Values [][]any `json:"values"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
|
@ -432,7 +432,7 @@ func httpReadMetrics(t *testing.T, address, query string) []Metric {
|
|||
return rows
|
||||
}
|
||||
|
||||
func httpReadStruct(t *testing.T, address, query string, dst interface{}) {
|
||||
func httpReadStruct(t *testing.T, address, query string, dst any) {
|
||||
t.Helper()
|
||||
s := newSuite(t)
|
||||
resp, err := http.Get(address + query)
|
||||
|
|
|
@ -181,7 +181,7 @@ func (rctx *relabelCtx) reset() {
|
|||
}
|
||||
|
||||
var relabelCtxPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &relabelCtx{}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1000,7 +1000,7 @@ func (rwctx *remoteWriteCtx) tryPushInternal(tss []prompbmarshal.TimeSeries) boo
|
|||
}
|
||||
|
||||
var tssPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
a := []prompbmarshal.TimeSeries{}
|
||||
return &a
|
||||
},
|
||||
|
|
|
@ -45,11 +45,11 @@ type Group struct {
|
|||
// EvalAlignment will make the timestamp of group query requests be aligned with interval
|
||||
EvalAlignment *bool `yaml:"eval_alignment,omitempty"`
|
||||
// Catches all undefined fields and must be empty after parsing.
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
XXX map[string]any `yaml:",inline"`
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||
func (g *Group) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (g *Group) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
type group Group
|
||||
if err := unmarshal((*group)(g)); err != nil {
|
||||
return err
|
||||
|
@ -142,11 +142,11 @@ type Rule struct {
|
|||
UpdateEntriesLimit *int `yaml:"update_entries_limit,omitempty"`
|
||||
|
||||
// Catches all undefined fields and must be empty after parsing.
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
XXX map[string]any `yaml:",inline"`
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||
func (r *Rule) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (r *Rule) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
type rule Rule
|
||||
if err := unmarshal((*rule)(r)); err != nil {
|
||||
return err
|
||||
|
@ -301,7 +301,7 @@ func parseConfig(data []byte) ([]Group, error) {
|
|||
g := struct {
|
||||
Groups []Group `yaml:"groups"`
|
||||
// Catches all undefined fields and must be empty after parsing.
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
XXX map[string]any `yaml:",inline"`
|
||||
}{}
|
||||
err = yaml.Unmarshal(data, &g)
|
||||
if err != nil {
|
||||
|
@ -310,7 +310,7 @@ func parseConfig(data []byte) ([]Group, error) {
|
|||
return g.Groups, checkOverflow(g.XXX, "config")
|
||||
}
|
||||
|
||||
func checkOverflow(m map[string]interface{}, ctx string) error {
|
||||
func checkOverflow(m map[string]any, ctx string) error {
|
||||
if len(m) > 0 {
|
||||
var keys []string
|
||||
for k := range m {
|
||||
|
|
|
@ -29,7 +29,7 @@ func (l *Logger) isDisabled() bool {
|
|||
}
|
||||
|
||||
// Errorf logs error message.
|
||||
func (l *Logger) Errorf(format string, args ...interface{}) {
|
||||
func (l *Logger) Errorf(format string, args ...any) {
|
||||
if l.isDisabled() {
|
||||
return
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ func (l *Logger) Errorf(format string, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Warnf logs warning message.
|
||||
func (l *Logger) Warnf(format string, args ...interface{}) {
|
||||
func (l *Logger) Warnf(format string, args ...any) {
|
||||
if l.isDisabled() {
|
||||
return
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ func (l *Logger) Warnf(format string, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Infof logs info message.
|
||||
func (l *Logger) Infof(format string, args ...interface{}) {
|
||||
func (l *Logger) Infof(format string, args ...any) {
|
||||
if l.isDisabled() {
|
||||
return
|
||||
}
|
||||
|
@ -54,6 +54,6 @@ func (l *Logger) Infof(format string, args ...interface{}) {
|
|||
|
||||
// Panicf logs panic message and panics.
|
||||
// Panicf can't be suppressed
|
||||
func (l *Logger) Panicf(format string, args ...interface{}) {
|
||||
func (l *Logger) Panicf(format string, args ...any) {
|
||||
logger.Panicf(format, args...)
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ func (t *Type) ValidateExpr(expr string) error {
|
|||
}
|
||||
|
||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||
func (t *Type) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (t *Type) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var s string
|
||||
if err := unmarshal(&s); err != nil {
|
||||
return err
|
||||
|
@ -87,7 +87,7 @@ func (t *Type) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
}
|
||||
|
||||
// MarshalYAML implements the yaml.Unmarshaler interface.
|
||||
func (t Type) MarshalYAML() (interface{}, error) {
|
||||
func (t Type) MarshalYAML() (any, error) {
|
||||
return t.Name, nil
|
||||
}
|
||||
|
||||
|
@ -98,7 +98,7 @@ type Header struct {
|
|||
}
|
||||
|
||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||
func (h *Header) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (h *Header) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var s string
|
||||
if err := unmarshal(&s); err != nil {
|
||||
return err
|
||||
|
|
|
@ -119,7 +119,7 @@ func (pi *promInstant) Unmarshal(b []byte) error {
|
|||
type promRange struct {
|
||||
Result []struct {
|
||||
Labels map[string]string `json:"metric"`
|
||||
TVs [][2]interface{} `json:"values"`
|
||||
TVs [][2]any `json:"values"`
|
||||
} `json:"result"`
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ func (r promRange) metrics() ([]Metric, error) {
|
|||
return result, nil
|
||||
}
|
||||
|
||||
type promScalar [2]interface{}
|
||||
type promScalar [2]any
|
||||
|
||||
func (r promScalar) metrics() ([]Metric, error) {
|
||||
var m Metric
|
||||
|
|
|
@ -51,7 +51,7 @@ type Config struct {
|
|||
Checksum string
|
||||
|
||||
// Catches all undefined fields and must be empty after parsing.
|
||||
XXX map[string]interface{} `yaml:",inline"`
|
||||
XXX map[string]any `yaml:",inline"`
|
||||
|
||||
// This is set to the directory from where the config has been loaded.
|
||||
baseDir string
|
||||
|
@ -73,7 +73,7 @@ type StaticConfig struct {
|
|||
}
|
||||
|
||||
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
||||
func (cfg *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (cfg *Config) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
type config Config
|
||||
if err := unmarshal((*config)(cfg)); err != nil {
|
||||
return err
|
||||
|
|
|
@ -183,7 +183,7 @@ func (ar *AlertingRule) GetAlert(id uint64) *notifier.Alert {
|
|||
return ar.alerts[id]
|
||||
}
|
||||
|
||||
func (ar *AlertingRule) logDebugf(at time.Time, a *notifier.Alert, format string, args ...interface{}) {
|
||||
func (ar *AlertingRule) logDebugf(at time.Time, a *notifier.Alert, format string, args ...any) {
|
||||
if !ar.Debug {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -475,7 +475,7 @@ func delayBeforeStart(ts time.Time, key uint64, interval time.Duration, offset *
|
|||
return randSleep
|
||||
}
|
||||
|
||||
func (g *Group) infof(format string, args ...interface{}) {
|
||||
func (g *Group) infof(format string, args ...any) {
|
||||
msg := fmt.Sprintf(format, args...)
|
||||
logger.Infof("group %q %s; interval=%v; eval_offset=%v; concurrency=%d",
|
||||
g.Name, msg, g.Interval, g.EvalOffset, g.Concurrency)
|
||||
|
|
|
@ -316,7 +316,7 @@ func templateFuncs() textTpl.FuncMap {
|
|||
|
||||
// humanize converts given number to a human readable format
|
||||
// by adding metric prefixes https://en.wikipedia.org/wiki/Metric_prefix
|
||||
"humanize": func(i interface{}) (string, error) {
|
||||
"humanize": func(i any) (string, error) {
|
||||
v, err := toFloat64(i)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -347,7 +347,7 @@ func templateFuncs() textTpl.FuncMap {
|
|||
},
|
||||
|
||||
// humanize1024 converts given number to a human readable format with 1024 as base
|
||||
"humanize1024": func(i interface{}) (string, error) {
|
||||
"humanize1024": func(i any) (string, error) {
|
||||
v, err := toFloat64(i)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -359,7 +359,7 @@ func templateFuncs() textTpl.FuncMap {
|
|||
},
|
||||
|
||||
// humanizeDuration converts given seconds to a human-readable duration
|
||||
"humanizeDuration": func(i interface{}) (string, error) {
|
||||
"humanizeDuration": func(i any) (string, error) {
|
||||
v, err := toFloat64(i)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -405,7 +405,7 @@ func templateFuncs() textTpl.FuncMap {
|
|||
},
|
||||
|
||||
// humanizePercentage converts given ratio value to a fraction of 100
|
||||
"humanizePercentage": func(i interface{}) (string, error) {
|
||||
"humanizePercentage": func(i any) (string, error) {
|
||||
v, err := toFloat64(i)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -414,7 +414,7 @@ func templateFuncs() textTpl.FuncMap {
|
|||
},
|
||||
|
||||
// humanizeTimestamp converts given timestamp to a human readable time equivalent
|
||||
"humanizeTimestamp": func(i interface{}) (string, error) {
|
||||
"humanizeTimestamp": func(i any) (string, error) {
|
||||
v, err := toFloat64(i)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
@ -427,7 +427,7 @@ func templateFuncs() textTpl.FuncMap {
|
|||
},
|
||||
|
||||
// toTime converts given timestamp to a time.Time.
|
||||
"toTime": func(i interface{}) (time.Time, error) {
|
||||
"toTime": func(i any) (time.Time, error) {
|
||||
v, err := toFloat64(i)
|
||||
if err != nil {
|
||||
return time.Time{}, err
|
||||
|
@ -524,8 +524,8 @@ func templateFuncs() textTpl.FuncMap {
|
|||
|
||||
// Converts a list of objects to a map with keys arg0, arg1 etc.
|
||||
// This is intended to allow multiple arguments to be passed to templates.
|
||||
"args": func(args ...interface{}) map[string]interface{} {
|
||||
result := make(map[string]interface{})
|
||||
"args": func(args ...any) map[string]any {
|
||||
result := make(map[string]any)
|
||||
for i, a := range args {
|
||||
result[fmt.Sprintf("arg%d", i)] = a
|
||||
}
|
||||
|
@ -565,7 +565,7 @@ func (t Time) Time() time.Time {
|
|||
return time.Unix(int64(t)/second, (int64(t)%second)*nanosPerTick)
|
||||
}
|
||||
|
||||
func toFloat64(v interface{}) (float64, error) {
|
||||
func toFloat64(v any) (float64, error) {
|
||||
switch i := v.(type) {
|
||||
case float64:
|
||||
return i, nil
|
||||
|
|
|
@ -52,10 +52,10 @@ func TestTemplateFuncs(t *testing.T) {
|
|||
t.Fatalf("unexpected mismatch")
|
||||
}
|
||||
|
||||
formatting := func(funcName string, p interface{}, resultExpected string) {
|
||||
formatting := func(funcName string, p any, resultExpected string) {
|
||||
t.Helper()
|
||||
v := funcs[funcName]
|
||||
fLocal := v.(func(s interface{}) (string, error))
|
||||
fLocal := v.(func(s any) (string, error))
|
||||
result, err := fLocal(p)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error for %s(%f): %s", funcName, p, err)
|
||||
|
@ -92,7 +92,7 @@ func TestTemplateFuncs(t *testing.T) {
|
|||
formatting("humanizeTimestamp", 1679055557, "2023-03-17 12:19:17 +0000 UTC")
|
||||
}
|
||||
|
||||
func mkTemplate(current, replacement interface{}) textTemplate {
|
||||
func mkTemplate(current, replacement any) textTemplate {
|
||||
tmpl := textTemplate{}
|
||||
if current != nil {
|
||||
switch val := current.(type) {
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestHandler(t *testing.T) {
|
|||
}}
|
||||
rh := &requestHandler{m: m}
|
||||
|
||||
getResp := func(t *testing.T, url string, to interface{}, code int) {
|
||||
getResp := func(t *testing.T, url string, to any, code int) {
|
||||
t.Helper()
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
|
@ -241,7 +241,7 @@ func TestEmptyResponse(t *testing.T) {
|
|||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { rhWithNoGroups.handler(w, r) }))
|
||||
defer ts.Close()
|
||||
|
||||
getResp := func(t *testing.T, url string, to interface{}, code int) {
|
||||
getResp := func(t *testing.T, url string, to any, code int) {
|
||||
t.Helper()
|
||||
resp, err := http.Get(url)
|
||||
if err != nil {
|
||||
|
|
|
@ -183,7 +183,7 @@ func (ar apiRule) WebLink() string {
|
|||
paramGroupID, ar.GroupID, paramRuleID, ar.ID)
|
||||
}
|
||||
|
||||
func ruleToAPI(r interface{}) apiRule {
|
||||
func ruleToAPI(r any) apiRule {
|
||||
if ar, ok := r.(*rule.AlertingRule); ok {
|
||||
return alertingToAPI(ar)
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ type Header struct {
|
|||
}
|
||||
|
||||
// UnmarshalYAML unmarshals h from f.
|
||||
func (h *Header) UnmarshalYAML(f func(interface{}) error) error {
|
||||
func (h *Header) UnmarshalYAML(f func(any) error) error {
|
||||
var s string
|
||||
if err := f(&s); err != nil {
|
||||
return err
|
||||
|
@ -146,7 +146,7 @@ func (h *Header) UnmarshalYAML(f func(interface{}) error) error {
|
|||
}
|
||||
|
||||
// MarshalYAML marshals h to yaml.
|
||||
func (h *Header) MarshalYAML() (interface{}, error) {
|
||||
func (h *Header) MarshalYAML() (any, error) {
|
||||
return h.sOriginal, nil
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ type QueryArg struct {
|
|||
}
|
||||
|
||||
// UnmarshalYAML unmarshals qa from yaml.
|
||||
func (qa *QueryArg) UnmarshalYAML(f func(interface{}) error) error {
|
||||
func (qa *QueryArg) UnmarshalYAML(f func(any) error) error {
|
||||
var s string
|
||||
if err := f(&s); err != nil {
|
||||
return err
|
||||
|
@ -230,7 +230,7 @@ func (qa *QueryArg) UnmarshalYAML(f func(interface{}) error) error {
|
|||
}
|
||||
|
||||
// MarshalYAML marshals qa to yaml.
|
||||
func (qa *QueryArg) MarshalYAML() (interface{}, error) {
|
||||
func (qa *QueryArg) MarshalYAML() (any, error) {
|
||||
return qa.sOriginal, nil
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ type URLPrefix struct {
|
|||
nextDiscoveryDeadline atomic.Uint64
|
||||
|
||||
// vOriginal contains the original yaml value for URLPrefix.
|
||||
vOriginal interface{}
|
||||
vOriginal any
|
||||
}
|
||||
|
||||
func (up *URLPrefix) setLoadBalancingPolicy(loadBalancingPolicy string) error {
|
||||
|
@ -497,8 +497,8 @@ func getLeastLoadedBackendURL(bus []*backendURL, atomicCounter *atomic.Uint32) *
|
|||
}
|
||||
|
||||
// UnmarshalYAML unmarshals up from yaml.
|
||||
func (up *URLPrefix) UnmarshalYAML(f func(interface{}) error) error {
|
||||
var v interface{}
|
||||
func (up *URLPrefix) UnmarshalYAML(f func(any) error) error {
|
||||
var v any
|
||||
if err := f(&v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ func (up *URLPrefix) UnmarshalYAML(f func(interface{}) error) error {
|
|||
switch x := v.(type) {
|
||||
case string:
|
||||
urls = []string{x}
|
||||
case []interface{}:
|
||||
case []any:
|
||||
if len(x) == 0 {
|
||||
return fmt.Errorf("`url_prefix` must contain at least a single url")
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ func (up *URLPrefix) UnmarshalYAML(f func(interface{}) error) error {
|
|||
}
|
||||
|
||||
// MarshalYAML marshals up to yaml.
|
||||
func (up *URLPrefix) MarshalYAML() (interface{}, error) {
|
||||
func (up *URLPrefix) MarshalYAML() (any, error) {
|
||||
return up.vOriginal, nil
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ func (r *Regex) match(s string) bool {
|
|||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler
|
||||
func (r *Regex) UnmarshalYAML(f func(interface{}) error) error {
|
||||
func (r *Regex) UnmarshalYAML(f func(any) error) error {
|
||||
var s string
|
||||
if err := f(&s); err != nil {
|
||||
return err
|
||||
|
@ -579,7 +579,7 @@ func (r *Regex) UnmarshalYAML(f func(interface{}) error) error {
|
|||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaler.
|
||||
func (r *Regex) MarshalYAML() (interface{}, error) {
|
||||
func (r *Regex) MarshalYAML() (any, error) {
|
||||
return r.sOriginal, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
|
||||
type queryValues struct {
|
||||
name string
|
||||
values map[string][]interface{}
|
||||
values map[string][]any
|
||||
}
|
||||
|
||||
func parseResult(r influx.Result) ([]queryValues, error) {
|
||||
|
@ -21,7 +21,7 @@ func parseResult(r influx.Result) ([]queryValues, error) {
|
|||
}
|
||||
qValues := make([]queryValues, len(r.Series))
|
||||
for i, row := range r.Series {
|
||||
values := make(map[string][]interface{}, len(row.Values))
|
||||
values := make(map[string][]any, len(row.Values))
|
||||
for _, value := range row.Values {
|
||||
for idx, v := range value {
|
||||
key := row.Columns[idx]
|
||||
|
@ -36,7 +36,7 @@ func parseResult(r influx.Result) ([]queryValues, error) {
|
|||
return qValues, nil
|
||||
}
|
||||
|
||||
func toFloat64(v interface{}) (float64, error) {
|
||||
func toFloat64(v any) (float64, error) {
|
||||
switch i := v.(type) {
|
||||
case json.Number:
|
||||
return i.Float64()
|
||||
|
|
|
@ -61,7 +61,7 @@ func TestSeries_Unmarshal(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestToFloat64(t *testing.T) {
|
||||
f := func(in interface{}, want float64) {
|
||||
f := func(in any, want float64) {
|
||||
t.Helper()
|
||||
got, err := toFloat64(in)
|
||||
if err != nil {
|
||||
|
|
|
@ -75,12 +75,6 @@ type TimeRange struct {
|
|||
type MetaResults struct {
|
||||
Type string `json:"type"`
|
||||
Results []Meta `json:"results"`
|
||||
//metric string
|
||||
//tags interface{}
|
||||
//limit int
|
||||
//time int
|
||||
//startIndex int
|
||||
//totalResults int
|
||||
}
|
||||
|
||||
// Meta A meta object about a metric
|
||||
|
@ -88,7 +82,6 @@ type MetaResults struct {
|
|||
type Meta struct {
|
||||
Metric string `json:"metric"`
|
||||
Tags map[string]string `json:"tags"`
|
||||
//tsuid string
|
||||
}
|
||||
|
||||
// OtsdbMetric is a single series in OpenTSDB's returned format
|
||||
|
|
|
@ -45,7 +45,7 @@ type cWriter struct {
|
|||
err error
|
||||
}
|
||||
|
||||
func (cw *cWriter) printf(format string, args ...interface{}) {
|
||||
func (cw *cWriter) printf(format string, args ...any) {
|
||||
if cw.err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -176,10 +176,10 @@ func (p *vmNativeProcessor) runBackfilling(ctx context.Context, tenantID string,
|
|||
}
|
||||
|
||||
initMessage := "Initing import process from %q to %q with filter %s"
|
||||
initParams := []interface{}{srcURL, dstURL, p.filter.String()}
|
||||
initParams := []any{srcURL, dstURL, p.filter.String()}
|
||||
if p.interCluster {
|
||||
initMessage = "Initing import process from %q to %q with filter %s for tenant %s"
|
||||
initParams = []interface{}{srcURL, dstURL, p.filter.String(), tenantID}
|
||||
initParams = []any{srcURL, dstURL, p.filter.String(), tenantID}
|
||||
}
|
||||
|
||||
fmt.Println("") // extra line for better output formatting
|
||||
|
|
|
@ -253,7 +253,7 @@ func putHistogram(h *histogram.Fast) {
|
|||
}
|
||||
|
||||
var histogramPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return histogram.NewFast()
|
||||
},
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
func FunctionsHandler(w http.ResponseWriter, r *http.Request) error {
|
||||
grouped := httputils.GetBool(r, "grouped")
|
||||
group := r.FormValue("group")
|
||||
result := make(map[string]interface{})
|
||||
result := make(map[string]any)
|
||||
for funcName, fi := range funcs {
|
||||
if group != "" && fi.Group != group {
|
||||
continue
|
||||
|
@ -47,7 +47,7 @@ func FunctionDetailsHandler(funcName string, w http.ResponseWriter, r *http.Requ
|
|||
return writeJSON(result, w, r)
|
||||
}
|
||||
|
||||
func writeJSON(result interface{}, w http.ResponseWriter, r *http.Request) error {
|
||||
func writeJSON(result any, w http.ResponseWriter, r *http.Request) error {
|
||||
data, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot marshal response to JSON: %w", err)
|
||||
|
|
|
@ -1968,10 +1968,10 @@ func (h *minSeriesHeap) Swap(i, j int) {
|
|||
a := *h
|
||||
a[i], a[j] = a[j], a[i]
|
||||
}
|
||||
func (h *minSeriesHeap) Push(x interface{}) {
|
||||
func (h *minSeriesHeap) Push(x any) {
|
||||
*h = append(*h, x.(*seriesWithWeight))
|
||||
}
|
||||
func (h *minSeriesHeap) Pop() interface{} {
|
||||
func (h *minSeriesHeap) Pop() any {
|
||||
a := *h
|
||||
x := a[len(a)-1]
|
||||
*h = a[:len(a)-1]
|
||||
|
@ -2499,10 +2499,10 @@ func (h *maxSeriesHeap) Swap(i, j int) {
|
|||
a := *h
|
||||
a[i], a[j] = a[j], a[i]
|
||||
}
|
||||
func (h *maxSeriesHeap) Push(x interface{}) {
|
||||
func (h *maxSeriesHeap) Push(x any) {
|
||||
*h = append(*h, x.(*seriesWithWeight))
|
||||
}
|
||||
func (h *maxSeriesHeap) Pop() interface{} {
|
||||
func (h *maxSeriesHeap) Pop() any {
|
||||
a := *h
|
||||
x := a[len(a)-1]
|
||||
*h = a[:len(a)-1]
|
||||
|
|
|
@ -734,11 +734,11 @@ func (sbh *sortBlocksHeap) Swap(i, j int) {
|
|||
sbs[i], sbs[j] = sbs[j], sbs[i]
|
||||
}
|
||||
|
||||
func (sbh *sortBlocksHeap) Push(x interface{}) {
|
||||
func (sbh *sortBlocksHeap) Push(x any) {
|
||||
sbh.sbs = append(sbh.sbs, x.(*sortBlock))
|
||||
}
|
||||
|
||||
func (sbh *sortBlocksHeap) Pop() interface{} {
|
||||
func (sbh *sortBlocksHeap) Pop() any {
|
||||
sbs := sbh.sbs
|
||||
v := sbs[len(sbs)-1]
|
||||
sbs[len(sbs)-1] = nil
|
||||
|
@ -1084,7 +1084,7 @@ func (xw *exportWork) reset() {
|
|||
}
|
||||
|
||||
var exportWorkPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &exportWork{}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -461,7 +461,7 @@ func (xb *exportBlock) reset() {
|
|||
}
|
||||
|
||||
var exportBlockPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &exportBlock{}
|
||||
},
|
||||
}
|
||||
|
@ -1238,7 +1238,7 @@ func (sw *scalableWriter) maybeFlushBuffer(bb *bytesutil.ByteBuffer) error {
|
|||
}
|
||||
|
||||
func (sw *scalableWriter) flush() error {
|
||||
sw.m.Range(func(_, v interface{}) bool {
|
||||
sw.m.Range(func(_, v any) bool {
|
||||
bb := v.(*bytesutil.ByteBuffer)
|
||||
_, err := sw.bw.Write(bb.B)
|
||||
return err == nil
|
||||
|
|
|
@ -742,13 +742,13 @@ func evalExprsInParallel(qt *querytracer.Tracer, ec *EvalConfig, es []metricsql.
|
|||
return rvs, nil
|
||||
}
|
||||
|
||||
func evalRollupFuncArgs(qt *querytracer.Tracer, ec *EvalConfig, fe *metricsql.FuncExpr) ([]interface{}, *metricsql.RollupExpr, error) {
|
||||
func evalRollupFuncArgs(qt *querytracer.Tracer, ec *EvalConfig, fe *metricsql.FuncExpr) ([]any, *metricsql.RollupExpr, error) {
|
||||
var re *metricsql.RollupExpr
|
||||
rollupArgIdx := metricsql.GetRollupArgIdx(fe)
|
||||
if len(fe.Args) <= rollupArgIdx {
|
||||
return nil, nil, fmt.Errorf("expecting at least %d args to %q; got %d args; expr: %q", rollupArgIdx+1, fe.Name, len(fe.Args), fe.AppendString(nil))
|
||||
}
|
||||
args := make([]interface{}, len(fe.Args))
|
||||
args := make([]any, len(fe.Args))
|
||||
for i, arg := range fe.Args {
|
||||
if i == rollupArgIdx {
|
||||
re = getRollupExprArg(arg)
|
||||
|
|
|
@ -956,10 +956,10 @@ func derivValues(values []float64, timestamps []int64) {
|
|||
values[len(values)-1] = prevDeriv
|
||||
}
|
||||
|
||||
type newRollupFunc func(args []interface{}) (rollupFunc, error)
|
||||
type newRollupFunc func(args []any) (rollupFunc, error)
|
||||
|
||||
func newRollupFuncOneArg(rf rollupFunc) newRollupFunc {
|
||||
return func(args []interface{}) (rollupFunc, error) {
|
||||
return func(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 1); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -968,7 +968,7 @@ func newRollupFuncOneArg(rf rollupFunc) newRollupFunc {
|
|||
}
|
||||
|
||||
func newRollupFuncTwoArgs(rf rollupFunc) newRollupFunc {
|
||||
return func(args []interface{}) (rollupFunc, error) {
|
||||
return func(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -977,7 +977,7 @@ func newRollupFuncTwoArgs(rf rollupFunc) newRollupFunc {
|
|||
}
|
||||
|
||||
func newRollupFuncOneOrTwoArgs(rf rollupFunc) newRollupFunc {
|
||||
return func(args []interface{}) (rollupFunc, error) {
|
||||
return func(args []any) (rollupFunc, error) {
|
||||
if len(args) < 1 || len(args) > 2 {
|
||||
return nil, fmt.Errorf("unexpected number of args; got %d; want 1...2", len(args))
|
||||
}
|
||||
|
@ -985,7 +985,7 @@ func newRollupFuncOneOrTwoArgs(rf rollupFunc) newRollupFunc {
|
|||
}
|
||||
}
|
||||
|
||||
func newRollupHoltWinters(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupHoltWinters(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 3); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1035,7 +1035,7 @@ func newRollupHoltWinters(args []interface{}) (rollupFunc, error) {
|
|||
return rf, nil
|
||||
}
|
||||
|
||||
func newRollupPredictLinear(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupPredictLinear(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1106,7 +1106,7 @@ func areConstValues(values []float64) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func newRollupDurationOverTime(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupDurationOverTime(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1136,7 +1136,7 @@ func newRollupDurationOverTime(args []interface{}) (rollupFunc, error) {
|
|||
return rf, nil
|
||||
}
|
||||
|
||||
func newRollupShareLE(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupShareLE(args []any) (rollupFunc, error) {
|
||||
return newRollupAvgFilter(args, countFilterLE)
|
||||
}
|
||||
|
||||
|
@ -1150,7 +1150,7 @@ func countFilterLE(values []float64, le float64) float64 {
|
|||
return float64(n)
|
||||
}
|
||||
|
||||
func newRollupShareGT(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupShareGT(args []any) (rollupFunc, error) {
|
||||
return newRollupAvgFilter(args, countFilterGT)
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1164,7 @@ func countFilterGT(values []float64, gt float64) float64 {
|
|||
return float64(n)
|
||||
}
|
||||
|
||||
func newRollupShareEQ(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupShareEQ(args []any) (rollupFunc, error) {
|
||||
return newRollupAvgFilter(args, countFilterEQ)
|
||||
}
|
||||
|
||||
|
@ -1218,7 +1218,7 @@ func countFilterNE(values []float64, ne float64) float64 {
|
|||
return float64(n)
|
||||
}
|
||||
|
||||
func newRollupAvgFilter(args []interface{}, f func(values []float64, limit float64) float64) (rollupFunc, error) {
|
||||
func newRollupAvgFilter(args []any, f func(values []float64, limit float64) float64) (rollupFunc, error) {
|
||||
rf, err := newRollupFilter(args, f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1229,35 +1229,35 @@ func newRollupAvgFilter(args []interface{}, f func(values []float64, limit float
|
|||
}, nil
|
||||
}
|
||||
|
||||
func newRollupCountEQ(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupCountEQ(args []any) (rollupFunc, error) {
|
||||
return newRollupFilter(args, countFilterEQ)
|
||||
}
|
||||
|
||||
func newRollupCountLE(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupCountLE(args []any) (rollupFunc, error) {
|
||||
return newRollupFilter(args, countFilterLE)
|
||||
}
|
||||
|
||||
func newRollupCountGT(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupCountGT(args []any) (rollupFunc, error) {
|
||||
return newRollupFilter(args, countFilterGT)
|
||||
}
|
||||
|
||||
func newRollupCountNE(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupCountNE(args []any) (rollupFunc, error) {
|
||||
return newRollupFilter(args, countFilterNE)
|
||||
}
|
||||
|
||||
func newRollupSumEQ(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupSumEQ(args []any) (rollupFunc, error) {
|
||||
return newRollupFilter(args, sumFilterEQ)
|
||||
}
|
||||
|
||||
func newRollupSumLE(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupSumLE(args []any) (rollupFunc, error) {
|
||||
return newRollupFilter(args, sumFilterLE)
|
||||
}
|
||||
|
||||
func newRollupSumGT(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupSumGT(args []any) (rollupFunc, error) {
|
||||
return newRollupFilter(args, sumFilterGT)
|
||||
}
|
||||
|
||||
func newRollupFilter(args []interface{}, f func(values []float64, limit float64) float64) (rollupFunc, error) {
|
||||
func newRollupFilter(args []any, f func(values []float64, limit float64) float64) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1278,7 +1278,7 @@ func newRollupFilter(args []interface{}, f func(values []float64, limit float64)
|
|||
return rf, nil
|
||||
}
|
||||
|
||||
func newRollupHoeffdingBoundLower(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupHoeffdingBoundLower(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1293,7 +1293,7 @@ func newRollupHoeffdingBoundLower(args []interface{}) (rollupFunc, error) {
|
|||
return rf, nil
|
||||
}
|
||||
|
||||
func newRollupHoeffdingBoundUpper(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupHoeffdingBoundUpper(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1338,7 +1338,7 @@ func rollupHoeffdingBoundInternal(rfa *rollupFuncArg, phis []float64) (float64,
|
|||
return bound, vAvg
|
||||
}
|
||||
|
||||
func newRollupQuantiles(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupQuantiles(args []any) (rollupFunc, error) {
|
||||
if len(args) < 3 {
|
||||
return nil, fmt.Errorf("unexpected number of args: %d; want at least 3 args", len(args))
|
||||
}
|
||||
|
@ -1405,7 +1405,7 @@ func rollupOutlierIQR(rfa *rollupFuncArg) float64 {
|
|||
return nan
|
||||
}
|
||||
|
||||
func newRollupQuantile(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupQuantile(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -1445,7 +1445,7 @@ func mad(values []float64) float64 {
|
|||
return v
|
||||
}
|
||||
|
||||
func newRollupCountValues(args []interface{}) (rollupFunc, error) {
|
||||
func newRollupCountValues(args []any) (rollupFunc, error) {
|
||||
if err := expectRollupArgsNum(args, 2); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -2389,7 +2389,7 @@ func rollupFake(_ *rollupFuncArg) float64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func getScalar(arg interface{}, argNum int) ([]float64, error) {
|
||||
func getScalar(arg any, argNum int) ([]float64, error) {
|
||||
ts, ok := arg.([]*timeseries)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf(`unexpected type for arg #%d; got %T; want %T`, argNum+1, arg, ts)
|
||||
|
@ -2400,7 +2400,7 @@ func getScalar(arg interface{}, argNum int) ([]float64, error) {
|
|||
return ts[0].Values, nil
|
||||
}
|
||||
|
||||
func getIntNumber(arg interface{}, argNum int) (int, error) {
|
||||
func getIntNumber(arg any, argNum int) (int, error) {
|
||||
v, err := getScalar(arg, argNum)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
@ -2425,7 +2425,7 @@ func getString(tss []*timeseries, argNum int) (string, error) {
|
|||
return string(ts.MetricName.MetricGroup), nil
|
||||
}
|
||||
|
||||
func expectRollupArgsNum(args []interface{}, expectedNum int) error {
|
||||
func expectRollupArgsNum(args []any, expectedNum int) error {
|
||||
if len(args) == expectedNum {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ func TestDerivValues(t *testing.T) {
|
|||
testRowsEqual(t, values, timestamps, valuesExpected, timestamps)
|
||||
}
|
||||
|
||||
func testRollupFunc(t *testing.T, funcName string, args []interface{}, vExpected float64) {
|
||||
func testRollupFunc(t *testing.T, funcName string, args []any, vExpected float64) {
|
||||
t.Helper()
|
||||
nrf := getRollupFunc(funcName)
|
||||
if nrf == nil {
|
||||
|
@ -245,7 +245,7 @@ func TestRollupDurationOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, maxIntervals}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, maxIntervals}
|
||||
testRollupFunc(t, "duration_over_time", args, dExpected)
|
||||
}
|
||||
f(-123, 0)
|
||||
|
@ -266,7 +266,7 @@ func TestRollupShareLEOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
testRollupFunc(t, "share_le_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ func TestRollupShareGTOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, gts}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, gts}
|
||||
testRollupFunc(t, "share_gt_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ func TestRollupShareEQOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, eqs}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, eqs}
|
||||
testRollupFunc(t, "share_eq_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ func TestRollupCountLEOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
testRollupFunc(t, "count_le_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ func TestRollupCountGTOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, gts}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, gts}
|
||||
testRollupFunc(t, "count_gt_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -377,7 +377,7 @@ func TestRollupCountEQOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, eqs}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, eqs}
|
||||
testRollupFunc(t, "count_eq_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -396,7 +396,7 @@ func TestRollupCountNEOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, nes}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, nes}
|
||||
testRollupFunc(t, "count_ne_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -415,7 +415,7 @@ func TestRollupSumLEOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
testRollupFunc(t, "sum_le_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -438,7 +438,7 @@ func TestRollupSumGTOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
testRollupFunc(t, "sum_gt_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ func TestRollupSumEQOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, les}
|
||||
testRollupFunc(t, "sum_eq_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ func TestRollupQuantileOverTime(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{phis, &metricsql.RollupExpr{Expr: &me}}
|
||||
args := []any{phis, &metricsql.RollupExpr{Expr: &me}}
|
||||
testRollupFunc(t, "quantile_over_time", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -506,7 +506,7 @@ func TestRollupPredictLinear(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, secs}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, secs}
|
||||
testRollupFunc(t, "predict_linear", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -545,7 +545,7 @@ func TestRollupHoltWinters(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}, sfs, tfs}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}, sfs, tfs}
|
||||
testRollupFunc(t, "holt_winters", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ func TestRollupHoeffdingBoundLower(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{phis, &metricsql.RollupExpr{Expr: &me}}
|
||||
args := []any{phis, &metricsql.RollupExpr{Expr: &me}}
|
||||
testRollupFunc(t, "hoeffding_bound_lower", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -594,7 +594,7 @@ func TestRollupHoeffdingBoundUpper(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{phis, &metricsql.RollupExpr{Expr: &me}}
|
||||
args := []any{phis, &metricsql.RollupExpr{Expr: &me}}
|
||||
testRollupFunc(t, "hoeffding_bound_upper", args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -611,7 +611,7 @@ func TestRollupNewRollupFuncSuccess(t *testing.T) {
|
|||
f := func(funcName string, vExpected float64) {
|
||||
t.Helper()
|
||||
var me metricsql.MetricExpr
|
||||
args := []interface{}{&metricsql.RollupExpr{Expr: &me}}
|
||||
args := []any{&metricsql.RollupExpr{Expr: &me}}
|
||||
testRollupFunc(t, funcName, args, vExpected)
|
||||
}
|
||||
|
||||
|
@ -668,7 +668,7 @@ func TestRollupNewRollupFuncError(t *testing.T) {
|
|||
t.Fatalf("expecting nil func; got %p", nrf)
|
||||
}
|
||||
|
||||
f := func(funcName string, args []interface{}) {
|
||||
f := func(funcName string, args []any) {
|
||||
t.Helper()
|
||||
|
||||
nrf := getRollupFunc(funcName)
|
||||
|
@ -694,13 +694,13 @@ func TestRollupNewRollupFuncError(t *testing.T) {
|
|||
Timestamps: []int64{123},
|
||||
}}
|
||||
me := &metricsql.MetricExpr{}
|
||||
f("holt_winters", []interface{}{123, 123, 321})
|
||||
f("holt_winters", []interface{}{me, 123, 321})
|
||||
f("holt_winters", []interface{}{me, scalarTs, 321})
|
||||
f("predict_linear", []interface{}{123, 123})
|
||||
f("predict_linear", []interface{}{me, 123})
|
||||
f("quantile_over_time", []interface{}{123, 123})
|
||||
f("quantiles_over_time", []interface{}{123, 123})
|
||||
f("holt_winters", []any{123, 123, 321})
|
||||
f("holt_winters", []any{me, 123, 321})
|
||||
f("holt_winters", []any{me, scalarTs, 321})
|
||||
f("predict_linear", []any{123, 123})
|
||||
f("predict_linear", []any{me, 123})
|
||||
f("quantile_over_time", []any{123, 123})
|
||||
f("quantiles_over_time", []any{123, 123})
|
||||
}
|
||||
|
||||
func TestRollupNoWindowNoPoints(t *testing.T) {
|
||||
|
|
|
@ -65,7 +65,7 @@ func (c *Cache) MustStop() {
|
|||
}
|
||||
|
||||
// RemoveBlocksForPart removes all the blocks for the given part from the cache.
|
||||
func (c *Cache) RemoveBlocksForPart(p interface{}) {
|
||||
func (c *Cache) RemoveBlocksForPart(p any) {
|
||||
for _, shard := range c.shards {
|
||||
shard.RemoveBlocksForPart(p)
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ type cache struct {
|
|||
mu sync.Mutex
|
||||
|
||||
// m contains cached blocks keyed by Key.Part and then by Key.Offset
|
||||
m map[interface{}]map[uint64]*cacheEntry
|
||||
m map[any]map[uint64]*cacheEntry
|
||||
|
||||
// perKeyMisses contains per-block cache misses.
|
||||
//
|
||||
|
@ -199,7 +199,7 @@ type cache struct {
|
|||
// Key represents a key, which uniquely identifies the Block.
|
||||
type Key struct {
|
||||
// Part must contain a pointer to part structure where the block belongs to.
|
||||
Part interface{}
|
||||
Part any
|
||||
|
||||
// Offset is the offset of the block in the part.
|
||||
Offset uint64
|
||||
|
@ -233,12 +233,12 @@ type cacheEntry struct {
|
|||
func newCache(getMaxSizeBytes func() int) *cache {
|
||||
var c cache
|
||||
c.getMaxSizeBytes = getMaxSizeBytes
|
||||
c.m = make(map[interface{}]map[uint64]*cacheEntry)
|
||||
c.m = make(map[any]map[uint64]*cacheEntry)
|
||||
c.perKeyMisses = make(map[Key]int)
|
||||
return &c
|
||||
}
|
||||
|
||||
func (c *cache) RemoveBlocksForPart(p interface{}) {
|
||||
func (c *cache) RemoveBlocksForPart(p any) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
|
@ -398,13 +398,13 @@ func (lah *lastAccessHeap) Less(i, j int) bool {
|
|||
h := *lah
|
||||
return h[i].lastAccessTime < h[j].lastAccessTime
|
||||
}
|
||||
func (lah *lastAccessHeap) Push(x interface{}) {
|
||||
func (lah *lastAccessHeap) Push(x any) {
|
||||
e := x.(*cacheEntry)
|
||||
h := *lah
|
||||
e.heapIdx = len(h)
|
||||
*lah = append(h, e)
|
||||
}
|
||||
func (lah *lastAccessHeap) Pop() interface{} {
|
||||
func (lah *lastAccessHeap) Pop() any {
|
||||
h := *lah
|
||||
e := h[len(h)-1]
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestCache(t *testing.T) {
|
|||
t.Fatalf("unexpected SizeMaxBytes(); got %d; want %d", n, sizeMaxBytes)
|
||||
}
|
||||
offset := uint64(1234)
|
||||
part := (interface{})("foobar")
|
||||
part := (any)("foobar")
|
||||
k := Key{
|
||||
Offset: offset,
|
||||
Part: part,
|
||||
|
@ -145,7 +145,7 @@ func TestCacheConcurrentAccess(_ *testing.T) {
|
|||
|
||||
func testCacheSetGet(c *Cache, worker int) {
|
||||
for i := 0; i < 1000; i++ {
|
||||
part := (interface{})(i)
|
||||
part := (any)(i)
|
||||
b := testBlock{}
|
||||
k := Key{
|
||||
Offset: uint64(worker*1000 + i),
|
||||
|
|
|
@ -71,7 +71,7 @@ func (fsm *FastStringMatcher) Match(s string) bool {
|
|||
// Perform a global cleanup for fsm.m by removing items, which weren't accessed during the last 5 minutes.
|
||||
m := &fsm.m
|
||||
deadline := ct - uint64(cacheExpireDuration.Seconds())
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
e := v.(*fsmEntry)
|
||||
if e.lastAccessTime.Load() < deadline {
|
||||
m.Delete(k)
|
||||
|
|
|
@ -82,7 +82,7 @@ func (fst *FastStringTransformer) Transform(s string) string {
|
|||
// Perform a global cleanup for fst.m by removing items, which weren't accessed during the last 5 minutes.
|
||||
m := &fst.m
|
||||
deadline := ct - uint64(cacheExpireDuration.Seconds())
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
e := v.(*fstEntry)
|
||||
if e.lastAccessTime.Load() < deadline {
|
||||
m.Delete(k)
|
||||
|
|
|
@ -186,7 +186,7 @@ func whetherToCloseConn(r *http.Request) bool {
|
|||
return ok && fasttime.UnixTimestamp() > *deadline
|
||||
}
|
||||
|
||||
var connDeadlineTimeKey = interface{}("connDeadlineSecs")
|
||||
var connDeadlineTimeKey = any("connDeadlineSecs")
|
||||
|
||||
// Stop stops the http server on the given addrs, which has been started via Serve func.
|
||||
func Stop(addrs []string) error {
|
||||
|
@ -617,7 +617,7 @@ func (rwa *responseWriterWithAbort) abort() {
|
|||
}
|
||||
|
||||
// Errorf writes formatted error message to w and to logger.
|
||||
func Errorf(w http.ResponseWriter, r *http.Request, format string, args ...interface{}) {
|
||||
func Errorf(w http.ResponseWriter, r *http.Request, format string, args ...any) {
|
||||
errStr := fmt.Sprintf(format, args...)
|
||||
remoteAddr := GetQuotedRemoteAddr(r)
|
||||
requestURI := GetRequestURI(r)
|
||||
|
|
|
@ -95,45 +95,45 @@ func StdErrorLogger() *log.Logger {
|
|||
}
|
||||
|
||||
// Infof logs info message.
|
||||
func Infof(format string, args ...interface{}) {
|
||||
func Infof(format string, args ...any) {
|
||||
logLevel("INFO", format, args)
|
||||
}
|
||||
|
||||
// Warnf logs warn message.
|
||||
func Warnf(format string, args ...interface{}) {
|
||||
func Warnf(format string, args ...any) {
|
||||
logLevel("WARN", format, args)
|
||||
}
|
||||
|
||||
// Errorf logs error message.
|
||||
func Errorf(format string, args ...interface{}) {
|
||||
func Errorf(format string, args ...any) {
|
||||
logLevel("ERROR", format, args)
|
||||
}
|
||||
|
||||
// WarnfSkipframes logs warn message and skips the given number of frames for the caller.
|
||||
func WarnfSkipframes(skipframes int, format string, args ...interface{}) {
|
||||
func WarnfSkipframes(skipframes int, format string, args ...any) {
|
||||
logLevelSkipframes(skipframes, "WARN", format, args)
|
||||
}
|
||||
|
||||
// ErrorfSkipframes logs error message and skips the given number of frames for the caller.
|
||||
func ErrorfSkipframes(skipframes int, format string, args ...interface{}) {
|
||||
func ErrorfSkipframes(skipframes int, format string, args ...any) {
|
||||
logLevelSkipframes(skipframes, "ERROR", format, args)
|
||||
}
|
||||
|
||||
// Fatalf logs fatal message and terminates the app.
|
||||
func Fatalf(format string, args ...interface{}) {
|
||||
func Fatalf(format string, args ...any) {
|
||||
logLevel("FATAL", format, args)
|
||||
}
|
||||
|
||||
// Panicf logs panic message and panics.
|
||||
func Panicf(format string, args ...interface{}) {
|
||||
func Panicf(format string, args ...any) {
|
||||
logLevel("PANIC", format, args)
|
||||
}
|
||||
|
||||
func logLevel(level, format string, args []interface{}) {
|
||||
func logLevel(level, format string, args []any) {
|
||||
logLevelSkipframes(1, level, format, args)
|
||||
}
|
||||
|
||||
func logLevelSkipframes(skipframes int, level, format string, args []interface{}) {
|
||||
func logLevelSkipframes(skipframes int, level, format string, args []any) {
|
||||
if shouldSkipLog(level) {
|
||||
return
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ func logLevelSkipframes(skipframes int, level, format string, args []interface{}
|
|||
logMessage(level, msg, 3+skipframes)
|
||||
}
|
||||
|
||||
func formatLogMessage(maxArgLen int, format string, args []interface{}) string {
|
||||
func formatLogMessage(maxArgLen int, format string, args []any) string {
|
||||
x := format
|
||||
// Limit the length of every string-like arg in order to prevent from too long log messages
|
||||
for i := range args {
|
||||
|
@ -217,7 +217,7 @@ type logWriter struct {
|
|||
}
|
||||
|
||||
func (lw *logWriter) Write(p []byte) (int, error) {
|
||||
logLevelSkipframes(2, "ERROR", "%s", []interface{}{p})
|
||||
logLevelSkipframes(2, "ERROR", "%s", []any{p})
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
)
|
||||
|
||||
func TestFormatLogMessage(t *testing.T) {
|
||||
f := func(format string, args []interface{}, maxArgLen int, expectedResult string) {
|
||||
f := func(format string, args []any, maxArgLen int, expectedResult string) {
|
||||
t.Helper()
|
||||
result := formatLogMessage(maxArgLen, format, args)
|
||||
if result != expectedResult {
|
||||
|
@ -18,8 +18,8 @@ func TestFormatLogMessage(t *testing.T) {
|
|||
f("foobar", nil, 1, "foobar")
|
||||
|
||||
// Format args not exceeding the maxArgLen
|
||||
f("foo: %d, %s, %s, %s", []interface{}{123, "bar", []byte("baz"), fmt.Errorf("abc")}, 3, "foo: 123, bar, baz, abc")
|
||||
f("foo: %d, %s, %s, %s", []any{123, "bar", []byte("baz"), fmt.Errorf("abc")}, 3, "foo: 123, bar, baz, abc")
|
||||
|
||||
// Format args exceeding the maxArgLen
|
||||
f("foo: %s, %q, %s", []interface{}{"abcde", fmt.Errorf("foo bar baz"), "xx"}, 4, `foo: a..e, "f..z", xx`)
|
||||
f("foo: %s, %q, %s", []any{"abcde", fmt.Errorf("foo bar baz"), "xx"}, 4, `foo: a..e, "f..z", xx`)
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ func newLogThrottler(throttle time.Duration) *LogThrottler {
|
|||
}
|
||||
|
||||
// Errorf logs error message.
|
||||
func (lt *LogThrottler) Errorf(format string, args ...interface{}) {
|
||||
func (lt *LogThrottler) Errorf(format string, args ...any) {
|
||||
select {
|
||||
case lt.ch <- struct{}{}:
|
||||
ErrorfSkipframes(1, format, args...)
|
||||
|
@ -58,7 +58,7 @@ func (lt *LogThrottler) Errorf(format string, args ...interface{}) {
|
|||
}
|
||||
|
||||
// Warnf logs warn message.
|
||||
func (lt *LogThrottler) Warnf(format string, args ...interface{}) {
|
||||
func (lt *LogThrottler) Warnf(format string, args ...any) {
|
||||
select {
|
||||
case lt.ch <- struct{}{}:
|
||||
WarnfSkipframes(1, format, args...)
|
||||
|
|
|
@ -302,12 +302,12 @@ func (h *blockStreamReadersHeap) Swap(i, j int) {
|
|||
x[i], x[j] = x[j], x[i]
|
||||
}
|
||||
|
||||
func (h *blockStreamReadersHeap) Push(v interface{}) {
|
||||
func (h *blockStreamReadersHeap) Push(v any) {
|
||||
bsr := v.(*blockStreamReader)
|
||||
*h = append(*h, bsr)
|
||||
}
|
||||
|
||||
func (h *blockStreamReadersHeap) Pop() interface{} {
|
||||
func (h *blockStreamReadersHeap) Pop() any {
|
||||
x := *h
|
||||
bsr := x[len(x)-1]
|
||||
x[len(x)-1] = nil
|
||||
|
|
|
@ -308,13 +308,13 @@ func (lah *lastAccessHeap) Less(i, j int) bool {
|
|||
h := *lah
|
||||
return h[i].lastAccessTime < h[j].lastAccessTime
|
||||
}
|
||||
func (lah *lastAccessHeap) Push(x interface{}) {
|
||||
func (lah *lastAccessHeap) Push(x any) {
|
||||
e := x.(*cacheEntry)
|
||||
h := *lah
|
||||
e.heapIdx = len(h)
|
||||
*lah = append(h, e)
|
||||
}
|
||||
func (lah *lastAccessHeap) Pop() interface{} {
|
||||
func (lah *lastAccessHeap) Pop() any {
|
||||
h := *lah
|
||||
e := h[len(h)-1]
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ func mergeBlockStreams(ph *partHeader, bsw *blockStreamWriter, bsrs []*blockStre
|
|||
}
|
||||
|
||||
var bsmPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &blockStreamMerger{}
|
||||
},
|
||||
}
|
||||
|
@ -238,14 +238,14 @@ func (bh *bsrHeap) Less(i, j int) bool {
|
|||
return x[i].CurrItem() < x[j].CurrItem()
|
||||
}
|
||||
|
||||
func (bh *bsrHeap) Pop() interface{} {
|
||||
func (bh *bsrHeap) Pop() any {
|
||||
a := *bh
|
||||
v := a[len(a)-1]
|
||||
*bh = a[:len(a)-1]
|
||||
return v
|
||||
}
|
||||
|
||||
func (bh *bsrHeap) Push(x interface{}) {
|
||||
func (bh *bsrHeap) Push(x any) {
|
||||
v := x.(*blockStreamReader)
|
||||
*bh = append(*bh, v)
|
||||
}
|
||||
|
|
|
@ -205,11 +205,11 @@ func (psh *partSearchHeap) Swap(i, j int) {
|
|||
x[i], x[j] = x[j], x[i]
|
||||
}
|
||||
|
||||
func (psh *partSearchHeap) Push(x interface{}) {
|
||||
func (psh *partSearchHeap) Push(x any) {
|
||||
*psh = append(*psh, x.(*partSearch))
|
||||
}
|
||||
|
||||
func (psh *partSearchHeap) Pop() interface{} {
|
||||
func (psh *partSearchHeap) Pop() any {
|
||||
a := *psh
|
||||
v := a[len(a)-1]
|
||||
*psh = a[:len(a)-1]
|
||||
|
|
|
@ -43,12 +43,12 @@ func NewSecret(s string) *Secret {
|
|||
// MarshalYAML implements yaml.Marshaler interface.
|
||||
//
|
||||
// It substitutes the secret with "<secret>" string.
|
||||
func (s *Secret) MarshalYAML() (interface{}, error) {
|
||||
func (s *Secret) MarshalYAML() (any, error) {
|
||||
return "<secret>", nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler interface.
|
||||
func (s *Secret) UnmarshalYAML(f func(interface{}) error) error {
|
||||
func (s *Secret) UnmarshalYAML(f func(any) error) error {
|
||||
var secret string
|
||||
if err := f(&secret); err != nil {
|
||||
return fmt.Errorf("cannot parse secret: %w", err)
|
||||
|
|
|
@ -61,8 +61,8 @@ type MultiLineRegex struct {
|
|||
}
|
||||
|
||||
// UnmarshalYAML unmarshals mlr from YAML passed to f.
|
||||
func (mlr *MultiLineRegex) UnmarshalYAML(f func(interface{}) error) error {
|
||||
var v interface{}
|
||||
func (mlr *MultiLineRegex) UnmarshalYAML(f func(any) error) error {
|
||||
var v any
|
||||
if err := f(&v); err != nil {
|
||||
return fmt.Errorf("cannot parse multiline regex: %w", err)
|
||||
}
|
||||
|
@ -74,12 +74,12 @@ func (mlr *MultiLineRegex) UnmarshalYAML(f func(interface{}) error) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func stringValue(v interface{}) (string, error) {
|
||||
func stringValue(v any) (string, error) {
|
||||
if v == nil {
|
||||
return "null", nil
|
||||
}
|
||||
switch x := v.(type) {
|
||||
case []interface{}:
|
||||
case []any:
|
||||
a := make([]string, len(x))
|
||||
for i, xx := range x {
|
||||
s, err := stringValue(xx)
|
||||
|
@ -106,7 +106,7 @@ func stringValue(v interface{}) (string, error) {
|
|||
}
|
||||
|
||||
// MarshalYAML marshals mlr to YAML.
|
||||
func (mlr *MultiLineRegex) MarshalYAML() (interface{}, error) {
|
||||
func (mlr *MultiLineRegex) MarshalYAML() (any, error) {
|
||||
if strings.ContainsAny(mlr.S, "([") {
|
||||
// The mlr.S contains groups. Fall back to returning the regexp as is without splitting it into parts.
|
||||
// This fixes https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2928 .
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
var graphiteMatchesPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &graphiteMatches{}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ func (ie *IfExpression) Parse(s string) error {
|
|||
|
||||
// UnmarshalJSON unmarshals ie from JSON data.
|
||||
func (ie *IfExpression) UnmarshalJSON(data []byte) error {
|
||||
var v interface{}
|
||||
var v any
|
||||
if err := json.Unmarshal(data, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -72,15 +72,15 @@ func (ie *IfExpression) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
// UnmarshalYAML unmarshals ie from YAML passed to f.
|
||||
func (ie *IfExpression) UnmarshalYAML(f func(interface{}) error) error {
|
||||
var v interface{}
|
||||
func (ie *IfExpression) UnmarshalYAML(f func(any) error) error {
|
||||
var v any
|
||||
if err := f(&v); err != nil {
|
||||
return fmt.Errorf("cannot unmarshal `match` option: %w", err)
|
||||
}
|
||||
return ie.unmarshalFromInterface(v)
|
||||
}
|
||||
|
||||
func (ie *IfExpression) unmarshalFromInterface(v interface{}) error {
|
||||
func (ie *IfExpression) unmarshalFromInterface(v any) error {
|
||||
ies := ie.ies[:0]
|
||||
switch t := v.(type) {
|
||||
case string:
|
||||
|
@ -89,7 +89,7 @@ func (ie *IfExpression) unmarshalFromInterface(v interface{}) error {
|
|||
return fmt.Errorf("unexpected `match` option: %w", err)
|
||||
}
|
||||
ies = append(ies, ieLocal)
|
||||
case []interface{}:
|
||||
case []any:
|
||||
for _, x := range t {
|
||||
s, ok := x.(string)
|
||||
if !ok {
|
||||
|
@ -109,7 +109,7 @@ func (ie *IfExpression) unmarshalFromInterface(v interface{}) error {
|
|||
}
|
||||
|
||||
// MarshalYAML marshals ie to YAML
|
||||
func (ie *IfExpression) MarshalYAML() (interface{}, error) {
|
||||
func (ie *IfExpression) MarshalYAML() (any, error) {
|
||||
if ie == nil || len(ie.ies) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ func (ie *ifExpression) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
// UnmarshalYAML unmarshals ie from YAML passed to f.
|
||||
func (ie *ifExpression) UnmarshalYAML(f func(interface{}) error) error {
|
||||
func (ie *ifExpression) UnmarshalYAML(f func(any) error) error {
|
||||
var s string
|
||||
if err := f(&s); err != nil {
|
||||
return fmt.Errorf("cannot unmarshal `if` option: %w", err)
|
||||
|
@ -210,7 +210,7 @@ func (ie *ifExpression) UnmarshalYAML(f func(interface{}) error) error {
|
|||
}
|
||||
|
||||
// MarshalYAML marshals ie to YAML.
|
||||
func (ie *ifExpression) MarshalYAML() (interface{}, error) {
|
||||
func (ie *ifExpression) MarshalYAML() (any, error) {
|
||||
return ie.s, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ type ScrapeConfig struct {
|
|||
}
|
||||
|
||||
func (sc *ScrapeConfig) mustStart(baseDir string) {
|
||||
swosFunc := func(metaLabels *promutils.Labels) interface{} {
|
||||
swosFunc := func(metaLabels *promutils.Labels) any {
|
||||
target := metaLabels.Get("__address__")
|
||||
sw, err := sc.swc.getScrapeWork(target, nil, metaLabels)
|
||||
if err != nil {
|
||||
|
|
|
@ -72,7 +72,7 @@ type apiConfig struct {
|
|||
type refreshTokenFunc func() (string, time.Duration, error)
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ func (ac *apiConfig) mustStop() {
|
|||
var configMap = discoveryutils.NewConfigMap()
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ func (ac *apiConfig) mustStop() {
|
|||
var configMap = discoveryutils.NewConfigMap()
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ func newAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ type apiConfig struct {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ type apiConfig struct {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ type containerSpec struct {
|
|||
}
|
||||
|
||||
type serviceSpecMode struct {
|
||||
Global interface{}
|
||||
Replicated interface{}
|
||||
Global any
|
||||
Replicated any
|
||||
}
|
||||
|
||||
type serviceUpdateStatus struct {
|
||||
|
|
|
@ -102,7 +102,7 @@ func TestParseServicesResponse(t *testing.T) {
|
|||
},
|
||||
},
|
||||
Mode: serviceSpecMode{
|
||||
Replicated: map[string]interface{}{},
|
||||
Replicated: map[string]any{},
|
||||
},
|
||||
},
|
||||
Endpoint: serviceEndpoint{
|
||||
|
@ -147,7 +147,7 @@ func TestAddServicesLabels(t *testing.T) {
|
|||
},
|
||||
},
|
||||
Mode: serviceSpecMode{
|
||||
Replicated: map[string]interface{}{},
|
||||
Replicated: map[string]any{},
|
||||
},
|
||||
},
|
||||
Endpoint: serviceEndpoint{
|
||||
|
|
|
@ -228,7 +228,7 @@ func TestAddTasksLabels(t *testing.T) {
|
|||
},
|
||||
},
|
||||
Mode: serviceSpecMode{
|
||||
Replicated: map[string]interface{}{},
|
||||
Replicated: map[string]any{},
|
||||
},
|
||||
},
|
||||
Endpoint: serviceEndpoint{
|
||||
|
|
|
@ -21,7 +21,7 @@ type apiConfig struct {
|
|||
var configMap = discoveryutils.NewConfigMap()
|
||||
|
||||
func getAPIConfig(sdc *SDConfig) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ func newAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ type apiConfig struct {
|
|||
var configMap = discoveryutils.NewConfigMap()
|
||||
|
||||
func getAPIConfig(sdc *SDConfig) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ type ZoneYAML struct {
|
|||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler
|
||||
func (z *ZoneYAML) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
var v interface{}
|
||||
func (z *ZoneYAML) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var v any
|
||||
if err := unmarshal(&v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ func (z *ZoneYAML) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
switch t := v.(type) {
|
||||
case string:
|
||||
zones = []string{t}
|
||||
case []interface{}:
|
||||
case []any:
|
||||
for _, vv := range t {
|
||||
zone, ok := vv.(string)
|
||||
if !ok {
|
||||
|
@ -57,7 +57,7 @@ func (z *ZoneYAML) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaler
|
||||
func (z ZoneYAML) MarshalYAML() (interface{}, error) {
|
||||
func (z ZoneYAML) MarshalYAML() (any, error) {
|
||||
return z.Zones, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ type apiConfig struct {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ func newAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ type apiWatcher struct {
|
|||
gw *groupWatcher
|
||||
|
||||
// swosByURLWatcher contains per-urlWatcher maps of ScrapeWork objects for the given apiWatcher
|
||||
swosByURLWatcher map[*urlWatcher]map[string][]interface{}
|
||||
swosByURLWatcher map[*urlWatcher]map[string][]any
|
||||
swosByURLWatcherLock sync.Mutex
|
||||
|
||||
swosCount *metrics.Counter
|
||||
|
@ -94,7 +94,7 @@ func newAPIWatcher(apiServer string, ac *promauth.Config, sdc *SDConfig, swcFunc
|
|||
role: role,
|
||||
swcFunc: swcFunc,
|
||||
gw: gw,
|
||||
swosByURLWatcher: make(map[*urlWatcher]map[string][]interface{}),
|
||||
swosByURLWatcher: make(map[*urlWatcher]map[string][]any),
|
||||
swosCount: metrics.GetOrCreateCounter(fmt.Sprintf(`vm_promscrape_discovery_kubernetes_scrape_works{role=%q}`, role)),
|
||||
}
|
||||
return aw, nil
|
||||
|
@ -106,7 +106,7 @@ func (aw *apiWatcher) mustStart() {
|
|||
aw.gw.apiWatcherInflightStartCalls.Add(-1)
|
||||
}
|
||||
|
||||
func (aw *apiWatcher) updateSwosCount(multiplier int, swosByKey map[string][]interface{}) {
|
||||
func (aw *apiWatcher) updateSwosCount(multiplier int, swosByKey map[string][]any) {
|
||||
n := 0
|
||||
for _, swos := range swosByKey {
|
||||
n += len(swos)
|
||||
|
@ -121,11 +121,11 @@ func (aw *apiWatcher) mustStop() {
|
|||
for _, swosByKey := range aw.swosByURLWatcher {
|
||||
aw.updateSwosCount(-1, swosByKey)
|
||||
}
|
||||
aw.swosByURLWatcher = make(map[*urlWatcher]map[string][]interface{})
|
||||
aw.swosByURLWatcher = make(map[*urlWatcher]map[string][]any)
|
||||
aw.swosByURLWatcherLock.Unlock()
|
||||
}
|
||||
|
||||
func (aw *apiWatcher) replaceScrapeWorks(uw *urlWatcher, swosByKey map[string][]interface{}) {
|
||||
func (aw *apiWatcher) replaceScrapeWorks(uw *urlWatcher, swosByKey map[string][]any) {
|
||||
aw.swosByURLWatcherLock.Lock()
|
||||
aw.updateSwosCount(-1, aw.swosByURLWatcher[uw])
|
||||
aw.updateSwosCount(1, swosByKey)
|
||||
|
@ -133,11 +133,11 @@ func (aw *apiWatcher) replaceScrapeWorks(uw *urlWatcher, swosByKey map[string][]
|
|||
aw.swosByURLWatcherLock.Unlock()
|
||||
}
|
||||
|
||||
func (aw *apiWatcher) updateScrapeWorks(uw *urlWatcher, swosByKey map[string][]interface{}) {
|
||||
func (aw *apiWatcher) updateScrapeWorks(uw *urlWatcher, swosByKey map[string][]any) {
|
||||
aw.swosByURLWatcherLock.Lock()
|
||||
dst := aw.swosByURLWatcher[uw]
|
||||
if dst == nil {
|
||||
dst = make(map[string][]interface{})
|
||||
dst = make(map[string][]any)
|
||||
aw.swosByURLWatcher[uw] = dst
|
||||
}
|
||||
for key, swos := range swosByKey {
|
||||
|
@ -156,7 +156,7 @@ func (aw *apiWatcher) setScrapeWorks(uw *urlWatcher, key string, labelss []*prom
|
|||
aw.swosByURLWatcherLock.Lock()
|
||||
swosByKey := aw.swosByURLWatcher[uw]
|
||||
if swosByKey == nil {
|
||||
swosByKey = make(map[string][]interface{})
|
||||
swosByKey = make(map[string][]any)
|
||||
aw.swosByURLWatcher[uw] = swosByKey
|
||||
}
|
||||
aw.swosCount.Add(len(swos) - len(swosByKey[key]))
|
||||
|
@ -178,9 +178,9 @@ func (aw *apiWatcher) removeScrapeWorks(uw *urlWatcher, key string) {
|
|||
aw.swosByURLWatcherLock.Unlock()
|
||||
}
|
||||
|
||||
func getScrapeWorkObjectsForLabels(swcFunc ScrapeWorkConstructorFunc, labelss []*promutils.Labels) []interface{} {
|
||||
func getScrapeWorkObjectsForLabels(swcFunc ScrapeWorkConstructorFunc, labelss []*promutils.Labels) []any {
|
||||
// Do not pre-allocate swos, since it is likely the swos will be empty because of relabeling
|
||||
var swos []interface{}
|
||||
var swos []any
|
||||
for _, labels := range labelss {
|
||||
swo := swcFunc(labels)
|
||||
// The reflect check is needed because of https://mangatmodi.medium.com/go-check-nil-interface-the-right-way-d142776edef1
|
||||
|
@ -192,10 +192,10 @@ func getScrapeWorkObjectsForLabels(swcFunc ScrapeWorkConstructorFunc, labelss []
|
|||
}
|
||||
|
||||
// getScrapeWorkObjects returns all the ScrapeWork objects for the given aw.
|
||||
func (aw *apiWatcher) getScrapeWorkObjects() []interface{} {
|
||||
func (aw *apiWatcher) getScrapeWorkObjects() []any {
|
||||
aw.gw.registerPendingAPIWatchers()
|
||||
|
||||
swos := make([]interface{}, 0, aw.swosCount.Get())
|
||||
swos := make([]any, 0, aw.swosCount.Get())
|
||||
aw.swosByURLWatcherLock.Lock()
|
||||
for _, swosByKey := range aw.swosByURLWatcher {
|
||||
for _, swosLocal := range swosByKey {
|
||||
|
@ -352,7 +352,7 @@ func groupWatchersCleaner() {
|
|||
|
||||
type swosByKeyWithLock struct {
|
||||
mu sync.Mutex
|
||||
swosByKey map[string][]interface{}
|
||||
swosByKey map[string][]any
|
||||
}
|
||||
|
||||
func (gw *groupWatcher) getScrapeWorkObjectsByAPIWatcherLocked(objectsByKey map[string]object, awsMap map[*apiWatcher]struct{}) map[*apiWatcher]*swosByKeyWithLock {
|
||||
|
@ -362,7 +362,7 @@ func (gw *groupWatcher) getScrapeWorkObjectsByAPIWatcherLocked(objectsByKey map[
|
|||
swosByAPIWatcher := make(map[*apiWatcher]*swosByKeyWithLock, len(awsMap))
|
||||
for aw := range awsMap {
|
||||
swosByAPIWatcher[aw] = &swosByKeyWithLock{
|
||||
swosByKey: make(map[string][]interface{}),
|
||||
swosByKey: make(map[string][]any),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -921,8 +921,8 @@ func TestGetScrapeWorkObjects(t *testing.T) {
|
|||
}
|
||||
testAPIServer := httptest.NewServer(mux)
|
||||
tc.sdc.APIServer = testAPIServer.URL
|
||||
ac, err := newAPIConfig(tc.sdc, "", func(metaLabels *promutils.Labels) interface{} {
|
||||
var res []interface{}
|
||||
ac, err := newAPIConfig(tc.sdc, "", func(metaLabels *promutils.Labels) any {
|
||||
var res []any
|
||||
for _, label := range metaLabels.Labels {
|
||||
res = append(res, label.Name)
|
||||
}
|
||||
|
|
|
@ -70,12 +70,12 @@ type Selector struct {
|
|||
}
|
||||
|
||||
// ScrapeWorkConstructorFunc must construct ScrapeWork object for the given metaLabels.
|
||||
type ScrapeWorkConstructorFunc func(metaLabels *promutils.Labels) interface{}
|
||||
type ScrapeWorkConstructorFunc func(metaLabels *promutils.Labels) any
|
||||
|
||||
// GetScrapeWorkObjects returns ScrapeWork objects for the given sdc.
|
||||
//
|
||||
// This function must be called after MustStart call.
|
||||
func (sdc *SDConfig) GetScrapeWorkObjects() ([]interface{}, error) {
|
||||
func (sdc *SDConfig) GetScrapeWorkObjects() ([]any, error) {
|
||||
if sdc.cfg == nil {
|
||||
return nil, sdc.startErr
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ type apiConfig struct {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ func (ac *apiConfig) mustStop() {
|
|||
var configMap = discoveryutils.NewConfigMap()
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ func (cfg *apiConfig) getFreshAPICredentials() (*apiCredentials, error) {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ func buildAuthRequestBody(sdc *SDConfig) ([]byte, error) {
|
|||
ApplicationCredential *applicationCredentialReq `json:"application_credential,omitempty"`
|
||||
}
|
||||
type authReq struct {
|
||||
Identity identityReq `json:"identity"`
|
||||
Scope map[string]interface{} `json:"scope,omitempty"`
|
||||
Identity identityReq `json:"identity"`
|
||||
Scope map[string]any `json:"scope,omitempty"`
|
||||
}
|
||||
type request struct {
|
||||
Auth authReq `json:"auth"`
|
||||
|
@ -233,7 +233,7 @@ func buildAuthRequestBody(sdc *SDConfig) ([]byte, error) {
|
|||
// buildScope adds scope information into auth request
|
||||
//
|
||||
// See https://docs.openstack.org/api-ref/identity/v3/#password-authentication-with-unscoped-authorization
|
||||
func buildScope(sdc *SDConfig) (map[string]interface{}, error) {
|
||||
func buildScope(sdc *SDConfig) (map[string]any, error) {
|
||||
if len(sdc.ProjectName) == 0 && len(sdc.ProjectID) == 0 && len(sdc.DomainID) == 0 && len(sdc.DomainName) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -244,24 +244,24 @@ func buildScope(sdc *SDConfig) (map[string]interface{}, error) {
|
|||
return nil, fmt.Errorf("domain_id or domain_name must present")
|
||||
}
|
||||
if len(sdc.DomainID) > 0 {
|
||||
return map[string]interface{}{
|
||||
"project": map[string]interface{}{
|
||||
return map[string]any{
|
||||
"project": map[string]any{
|
||||
"name": &sdc.ProjectName,
|
||||
"domain": map[string]interface{}{"id": &sdc.DomainID},
|
||||
"domain": map[string]any{"id": &sdc.DomainID},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
if len(sdc.DomainName) > 0 {
|
||||
return map[string]interface{}{
|
||||
"project": map[string]interface{}{
|
||||
return map[string]any{
|
||||
"project": map[string]any{
|
||||
"name": &sdc.ProjectName,
|
||||
"domain": map[string]interface{}{"name": &sdc.DomainName},
|
||||
"domain": map[string]any{"name": &sdc.DomainName},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
} else if len(sdc.ProjectID) > 0 {
|
||||
return map[string]interface{}{
|
||||
"project": map[string]interface{}{
|
||||
return map[string]any{
|
||||
"project": map[string]any{
|
||||
"id": &sdc.ProjectID,
|
||||
},
|
||||
}, nil
|
||||
|
@ -269,14 +269,14 @@ func buildScope(sdc *SDConfig) (map[string]interface{}, error) {
|
|||
if len(sdc.DomainName) > 0 {
|
||||
return nil, fmt.Errorf("both domain_id and domain_name present")
|
||||
}
|
||||
return map[string]interface{}{
|
||||
"domain": map[string]interface{}{
|
||||
return map[string]any{
|
||||
"domain": map[string]any{
|
||||
"id": &sdc.DomainID,
|
||||
},
|
||||
}, nil
|
||||
} else if len(sdc.DomainName) > 0 {
|
||||
return map[string]interface{}{
|
||||
"domain": map[string]interface{}{
|
||||
return map[string]any{
|
||||
"domain": map[string]any{
|
||||
"name": &sdc.DomainName,
|
||||
},
|
||||
}, nil
|
||||
|
|
|
@ -17,7 +17,7 @@ type apiConfig struct {
|
|||
|
||||
// getAPIConfig get or create API config from configMap.
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ type apiConfig struct {
|
|||
}
|
||||
|
||||
func getAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
||||
v, err := configMap.Get(sdc, func() (interface{}, error) { return newAPIConfig(sdc, baseDir) })
|
||||
v, err := configMap.Get(sdc, func() (any, error) { return newAPIConfig(sdc, baseDir) })
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// It automatically removes old configs which weren't accessed recently.
|
||||
type ConfigMap struct {
|
||||
mu sync.Mutex
|
||||
m map[interface{}]interface{}
|
||||
m map[any]any
|
||||
|
||||
entriesCount *metrics.Counter
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ type ConfigMap struct {
|
|||
// NewConfigMap creates ConfigMap
|
||||
func NewConfigMap() *ConfigMap {
|
||||
return &ConfigMap{
|
||||
m: make(map[interface{}]interface{}),
|
||||
m: make(map[any]any),
|
||||
entriesCount: metrics.GetOrCreateCounter(`vm_promscrape_discoveryutils_configmap_entries_count`),
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func NewConfigMap() *ConfigMap {
|
|||
// Key must be a pointer.
|
||||
//
|
||||
// It creates new config map with newConfig() call if cm doesn't contain config under the given key.
|
||||
func (cm *ConfigMap) Get(key interface{}, newConfig func() (interface{}, error)) (interface{}, error) {
|
||||
func (cm *ConfigMap) Get(key any, newConfig func() (any, error)) (any, error) {
|
||||
cm.mu.Lock()
|
||||
defer cm.mu.Unlock()
|
||||
|
||||
|
@ -47,7 +47,7 @@ func (cm *ConfigMap) Get(key interface{}, newConfig func() (interface{}, error))
|
|||
}
|
||||
|
||||
// Delete deletes config for the given key from cm and returns it.
|
||||
func (cm *ConfigMap) Delete(key interface{}) interface{} {
|
||||
func (cm *ConfigMap) Delete(key any) any {
|
||||
cm.mu.Lock()
|
||||
defer cm.mu.Unlock()
|
||||
|
||||
|
|
|
@ -414,7 +414,7 @@ func labelsHash(labels *promutils.Labels) uint64 {
|
|||
}
|
||||
|
||||
var xxhashPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return xxhash.New()
|
||||
},
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ func NewDuration(d time.Duration) *Duration {
|
|||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaler interface.
|
||||
func (pd Duration) MarshalYAML() (interface{}, error) {
|
||||
func (pd Duration) MarshalYAML() (any, error) {
|
||||
return pd.D.String(), nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler interface.
|
||||
func (pd *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (pd *Duration) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var s string
|
||||
if err := unmarshal(&s); err != nil {
|
||||
return err
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestDuration(t *testing.T) {
|
|||
if s := v.(string); s != sExpected {
|
||||
t.Fatalf("unexpected value from MarshalYAML(); got %q; want %q", s, sExpected)
|
||||
}
|
||||
if err := d.UnmarshalYAML(func(v interface{}) error {
|
||||
if err := d.UnmarshalYAML(func(v any) error {
|
||||
sp := v.(*string)
|
||||
s := "1w3d5h"
|
||||
*sp = s
|
||||
|
|
|
@ -34,13 +34,13 @@ func NewLabelsFromMap(m map[string]string) *Labels {
|
|||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaler interface.
|
||||
func (x *Labels) MarshalYAML() (interface{}, error) {
|
||||
func (x *Labels) MarshalYAML() (any, error) {
|
||||
m := x.ToMap()
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler interface.
|
||||
func (x *Labels) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (x *Labels) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var m map[string]string
|
||||
if err := unmarshal(&m); err != nil {
|
||||
return err
|
||||
|
|
|
@ -197,7 +197,7 @@ func (uw *unmarshalWork) unmarshal() error {
|
|||
}
|
||||
|
||||
var blockPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &storage.Block{}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ func (u *URL) getAuthHeader(ac *promauth.Config) (string, error) {
|
|||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaler interface.
|
||||
func (u *URL) MarshalYAML() (interface{}, error) {
|
||||
func (u *URL) MarshalYAML() (any, error) {
|
||||
if u.URL == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func (u *URL) MarshalYAML() (interface{}, error) {
|
|||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler interface.
|
||||
func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (u *URL) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
var s string
|
||||
if err := unmarshal(&s); err != nil {
|
||||
return err
|
||||
|
|
|
@ -49,7 +49,7 @@ type Tracer struct {
|
|||
// If enabled isn't set, then all function calls to the returned object will be no-op.
|
||||
//
|
||||
// Done or Donef must be called when the tracer should be finished.
|
||||
func New(enabled bool, format string, args ...interface{}) *Tracer {
|
||||
func New(enabled bool, format string, args ...any) *Tracer {
|
||||
if *denyQueryTracing || !enabled {
|
||||
return nil
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func (t *Tracer) Enabled() bool {
|
|||
// NewChild cannot be called from concurrent goroutines.
|
||||
// Create children tracers from a single goroutine and then pass them
|
||||
// to concurrent goroutines.
|
||||
func (t *Tracer) NewChild(format string, args ...interface{}) *Tracer {
|
||||
func (t *Tracer) NewChild(format string, args ...any) *Tracer {
|
||||
if t == nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ func (t *Tracer) Done() {
|
|||
//
|
||||
// Donef cannot be called multiple times.
|
||||
// Other Tracer functions cannot be called after Donef call.
|
||||
func (t *Tracer) Donef(format string, args ...interface{}) {
|
||||
func (t *Tracer) Donef(format string, args ...any) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ func (t *Tracer) Donef(format string, args ...interface{}) {
|
|||
// Printf adds new fmt.Sprintf(format, args...) message to t.
|
||||
//
|
||||
// Printf cannot be called from concurrent goroutines.
|
||||
func (t *Tracer) Printf(format string, args ...interface{}) {
|
||||
func (t *Tracer) Printf(format string, args ...any) {
|
||||
if t == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -143,11 +143,11 @@ func (bsrh *blockStreamReaderHeap) Swap(i, j int) {
|
|||
x[i], x[j] = x[j], x[i]
|
||||
}
|
||||
|
||||
func (bsrh *blockStreamReaderHeap) Push(x interface{}) {
|
||||
func (bsrh *blockStreamReaderHeap) Push(x any) {
|
||||
*bsrh = append(*bsrh, x.(*blockStreamReader))
|
||||
}
|
||||
|
||||
func (bsrh *blockStreamReaderHeap) Pop() interface{} {
|
||||
func (bsrh *blockStreamReaderHeap) Pop() any {
|
||||
a := *bsrh
|
||||
v := a[len(a)-1]
|
||||
*bsrh = a[:len(a)-1]
|
||||
|
|
|
@ -1459,11 +1459,11 @@ func (th *topHeap) Swap(i, j int) {
|
|||
a[j], a[i] = a[i], a[j]
|
||||
}
|
||||
|
||||
func (th *topHeap) Push(_ interface{}) {
|
||||
func (th *topHeap) Push(_ any) {
|
||||
panic(fmt.Errorf("BUG: Push shouldn't be called"))
|
||||
}
|
||||
|
||||
func (th *topHeap) Pop() interface{} {
|
||||
func (th *topHeap) Pop() any {
|
||||
panic(fmt.Errorf("BUG: Pop shouldn't be called"))
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ func mergeBlockStreams(ph *partHeader, bsw *blockStreamWriter, bsrs []*blockStre
|
|||
}
|
||||
|
||||
var bsmPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &blockStreamMerger{}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -190,11 +190,11 @@ func (psh *partSearchHeap) Swap(i, j int) {
|
|||
x[i], x[j] = x[j], x[i]
|
||||
}
|
||||
|
||||
func (psh *partSearchHeap) Push(x interface{}) {
|
||||
func (psh *partSearchHeap) Push(x any) {
|
||||
*psh = append(*psh, x.(*partSearch))
|
||||
}
|
||||
|
||||
func (psh *partSearchHeap) Pop() interface{} {
|
||||
func (psh *partSearchHeap) Pop() any {
|
||||
a := *psh
|
||||
v := a[len(a)-1]
|
||||
*psh = a[:len(a)-1]
|
||||
|
|
|
@ -194,11 +194,11 @@ func (ptsh *partitionSearchHeap) Swap(i, j int) {
|
|||
x[i], x[j] = x[j], x[i]
|
||||
}
|
||||
|
||||
func (ptsh *partitionSearchHeap) Push(x interface{}) {
|
||||
func (ptsh *partitionSearchHeap) Push(x any) {
|
||||
*ptsh = append(*ptsh, x.(*partitionSearch))
|
||||
}
|
||||
|
||||
func (ptsh *partitionSearchHeap) Pop() interface{} {
|
||||
func (ptsh *partitionSearchHeap) Pop() any {
|
||||
a := *ptsh
|
||||
v := a[len(a)-1]
|
||||
*ptsh = a[:len(a)-1]
|
||||
|
|
|
@ -64,7 +64,7 @@ func (as *avgAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *avgAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -61,7 +61,7 @@ func (as *countSamplesAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *countSamplesAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -70,7 +70,7 @@ func (as *countSeriesAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *countSeriesAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -69,7 +69,7 @@ func (as *histogramBucketAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *histogramBucketAggrState) removeOldEntries(ctx *flushCtx, currentTime uint64) {
|
||||
m := &as.m
|
||||
var staleOutputSamples int
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
sv := v.(*histogramBucketStateValue)
|
||||
|
||||
sv.mu.Lock()
|
||||
|
@ -96,7 +96,7 @@ func (as *histogramBucketAggrState) flushState(ctx *flushCtx, _ bool) {
|
|||
as.removeOldEntries(ctx, currentTime)
|
||||
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
sv := v.(*histogramBucketStateValue)
|
||||
sv.mu.Lock()
|
||||
if !sv.deleted {
|
||||
|
|
|
@ -66,7 +66,7 @@ func (as *lastAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *lastAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -63,7 +63,7 @@ func (as *maxAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *maxAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -63,7 +63,7 @@ func (as *minAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *minAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -70,7 +70,7 @@ func (as *quantilesAggrState) flushState(ctx *flushCtx, resetState bool) {
|
|||
phis := as.phis
|
||||
var quantiles []float64
|
||||
var b []byte
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -111,7 +111,7 @@ func (as *rateAggrState) flushState(ctx *flushCtx, _ bool) {
|
|||
var staleOutputSamples, staleInputSamples int
|
||||
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
sv := v.(*rateStateValue)
|
||||
sv.mu.Lock()
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ func (as *stddevAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *stddevAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -63,7 +63,7 @@ func (as *stdvarAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *stdvarAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -61,7 +61,7 @@ func (as *sumSamplesAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *sumSamplesAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -127,7 +127,7 @@ func (as *totalAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *totalAggrState) removeOldEntries(ctx *flushCtx, currentTime uint64) {
|
||||
m := &as.m
|
||||
var staleInputSamples, staleOutputSamples int
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
sv := v.(*totalStateValue)
|
||||
|
||||
sv.mu.Lock()
|
||||
|
@ -164,7 +164,7 @@ func (as *totalAggrState) flushState(ctx *flushCtx, resetState bool) {
|
|||
as.removeOldEntries(ctx, currentTime)
|
||||
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
sv := v.(*totalStateValue)
|
||||
sv.mu.Lock()
|
||||
total := sv.total
|
||||
|
|
|
@ -65,7 +65,7 @@ func (as *uniqueSamplesAggrState) pushSamples(samples []pushSample) {
|
|||
func (as *uniqueSamplesAggrState) flushState(ctx *flushCtx, resetState bool) {
|
||||
currentTimeMsec := int64(fasttime.UnixTimestamp()) * 1000
|
||||
m := &as.m
|
||||
m.Range(func(k, v interface{}) bool {
|
||||
m.Range(func(k, v any) bool {
|
||||
if resetState {
|
||||
// Atomically delete the entry from the map, so new entry is created for the next flush.
|
||||
m.Delete(k)
|
||||
|
|
|
@ -535,7 +535,7 @@ func (b *bucket32) forEach(f func(part []uint64) bool) bool {
|
|||
}
|
||||
|
||||
var partBufPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
buf := make([]uint64, 0, bitsPerBucket)
|
||||
return &buf
|
||||
},
|
||||
|
@ -948,7 +948,7 @@ func (b *bucket16) appendTo(dst []uint64, hi uint32, hi16 uint16) []uint64 {
|
|||
}
|
||||
|
||||
var smallPoolSorterPool = &sync.Pool{
|
||||
New: func() interface{} {
|
||||
New: func() any {
|
||||
return &smallPoolSorter{}
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue