From e74a34be8dc44e5041d12f65b4568fd6ad627b98 Mon Sep 17 00:00:00 2001 From: Michail Safronov Date: Mon, 18 Dec 2023 21:09:41 +0500 Subject: [PATCH] expr: clean from direct use config zipper/limiter --- cmd/carbonapi/config/config.go | 10 ++++-- cmd/carbonapi/http/main_test.go | 2 +- cmd/carbonapi/main.go | 2 +- expr/expr.go | 31 ++++++++++++++----- expr/functions/absolute/function.go | 2 +- expr/functions/absolute/function_test.go | 2 -- expr/functions/aggregate/function.go | 4 +-- expr/functions/aggregate/function_test.go | 2 -- expr/functions/aggregateLine/function.go | 2 +- expr/functions/aggregateLine/function_test.go | 2 -- .../aggregateSeriesLists/function.go | 4 +-- .../aggregateSeriesLists/function_test.go | 9 +++--- .../aggregateWithWildcards/function.go | 2 +- .../aggregateWithWildcards/function_test.go | 2 -- expr/functions/alias/function.go | 2 +- expr/functions/alias/function_test.go | 2 -- expr/functions/aliasByBase64/function.go | 2 +- expr/functions/aliasByBase64/function_test.go | 2 -- expr/functions/aliasByMetric/function.go | 2 +- expr/functions/aliasByMetric/function_test.go | 2 -- expr/functions/aliasByNode/function.go | 2 +- expr/functions/aliasByNode/function_test.go | 2 -- expr/functions/aliasByPostgres/function.go | 2 +- expr/functions/aliasByRedis/function.go | 2 +- expr/functions/aliasByRedis/function_test.go | 2 -- expr/functions/aliasQuery/function.go | 4 +-- expr/functions/aliasQuery/function_test.go | 2 -- expr/functions/aliasSub/function.go | 2 +- expr/functions/aliasSub/function_test.go | 2 -- expr/functions/asPercent/function.go | 6 ++-- expr/functions/asPercent/function_test.go | 2 -- .../averageOutsidePercentile/function.go | 2 +- .../averageOutsidePercentile/function_test.go | 2 -- expr/functions/baselines/function.go | 4 +-- expr/functions/below/function.go | 2 +- expr/functions/below/function_test.go | 2 -- expr/functions/cactiStyle/function.go | 2 +- expr/functions/cactiStyle/function_test.go | 2 -- expr/functions/cairo/function.go | 2 +- expr/functions/cairo/png/cairo.go | 17 +++++----- expr/functions/cairo/png/png.go | 4 ++- expr/functions/changed/function.go | 2 +- expr/functions/changed/function_test.go | 2 -- .../compressPeriodicGaps/function.go | 5 +-- .../compressPeriodicGaps/function_test.go | 7 ++--- expr/functions/consolidateBy/function.go | 2 +- expr/functions/consolidateBy/function_test.go | 7 ++--- expr/functions/constantLine/function_test.go | 2 -- expr/functions/cumulative/function.go | 2 +- expr/functions/cumulative/function_test.go | 2 -- expr/functions/delay/function.go | 2 +- expr/functions/delay/function_test.go | 2 -- expr/functions/derivative/function.go | 2 +- expr/functions/derivative/function_test.go | 2 -- expr/functions/divideSeries/function.go | 4 +-- expr/functions/divideSeries/function_test.go | 2 -- expr/functions/ewma/function.go | 2 +- expr/functions/ewma/function_test.go | 2 -- expr/functions/exclude/function.go | 2 +- expr/functions/exclude/function_test.go | 2 -- expr/functions/exp/function.go | 2 +- expr/functions/exp/function_test.go | 2 -- .../exponentialMovingAverage/function.go | 4 +-- .../exponentialMovingAverage/function_test.go | 2 -- expr/functions/fallbackSeries/function.go | 4 +-- .../functions/fallbackSeries/function_test.go | 2 -- expr/functions/fft/function.go | 2 +- expr/functions/filter/function.go | 2 +- expr/functions/filter/function_test.go | 2 -- expr/functions/grep/function.go | 2 +- expr/functions/grep/function_test.go | 2 -- expr/functions/group/function.go | 2 +- expr/functions/groupByNode/function.go | 2 +- expr/functions/groupByNode/function_test.go | 2 -- expr/functions/groupByTags/function.go | 2 +- expr/functions/groupByTags/function_test.go | 2 -- expr/functions/heatMap/function.go | 2 +- expr/functions/heatMap/function_test.go | 2 -- expr/functions/highestLowest/function.go | 2 +- expr/functions/highestLowest/function_test.go | 2 -- expr/functions/hitcount/function.go | 9 +++--- expr/functions/hitcount/function_test.go | 2 -- .../holtWintersAberration/function.go | 4 +-- .../holtWintersAberration/function_test.go | 5 ++- .../function_cairo.go | 2 +- .../function_test.go | 5 ++- .../holtWintersConfidenceBands/function.go | 3 +- .../function_test.go | 5 ++- .../functions/holtWintersForecast/function.go | 2 +- .../holtWintersForecast/function_test.go | 2 -- expr/functions/identity/function_test.go | 2 -- expr/functions/ifft/function.go | 4 +-- expr/functions/integral/function.go | 2 +- expr/functions/integral/function_test.go | 2 -- expr/functions/integralByInterval/function.go | 2 +- .../integralByInterval/function_test.go | 2 -- expr/functions/integralWithReset/function.go | 4 +-- .../integralWithReset/function_test.go | 5 ++- expr/functions/interpolate/function.go | 2 +- expr/functions/interpolate/function_test.go | 2 -- expr/functions/invert/function.go | 2 +- expr/functions/invert/function_test.go | 2 -- expr/functions/isNotNull/function.go | 2 +- expr/functions/isNotNull/function_test.go | 2 -- expr/functions/join/function.go | 8 ++--- expr/functions/join/function_test.go | 2 -- expr/functions/keepLastValue/function.go | 2 +- expr/functions/keepLastValue/function_test.go | 2 -- .../kolmogorovSmirnovTest2/function.go | 4 +-- expr/functions/legendValue/function.go | 2 +- expr/functions/legendValue/function_test.go | 2 -- expr/functions/limit/function.go | 2 +- expr/functions/limit/function_test.go | 2 -- expr/functions/linearRegression/function.go | 2 +- .../linearRegression/function_test.go | 2 -- expr/functions/logarithm/function.go | 2 +- expr/functions/logarithm/function_test.go | 2 -- expr/functions/logit/function.go | 2 +- expr/functions/logit/function_test.go | 2 -- expr/functions/lowPass/function.go | 2 +- expr/functions/lowPass/function_test.go | 2 -- expr/functions/mapSeries/function.go | 2 +- expr/functions/mapSeries/function_test.go | 2 -- expr/functions/minMax/function.go | 2 +- expr/functions/minMax/function_test.go | 2 -- expr/functions/mostDeviant/function.go | 2 +- expr/functions/mostDeviant/function_test.go | 2 -- expr/functions/moving/function.go | 4 +-- expr/functions/moving/function_test.go | 2 -- expr/functions/movingMedian/function.go | 2 +- expr/functions/movingMedian/function_test.go | 2 -- expr/functions/nPercentile/function.go | 2 +- expr/functions/nPercentile/function_test.go | 2 -- .../nonNegativeDerivative/function.go | 2 +- .../nonNegativeDerivative/function_test.go | 2 -- expr/functions/offset/function.go | 2 +- expr/functions/offset/function_test.go | 2 -- expr/functions/offsetToZero/function.go | 2 +- expr/functions/offsetToZero/function_test.go | 2 -- expr/functions/pearson/function.go | 4 +-- expr/functions/pearson/function_test.go | 2 -- expr/functions/pearsonClosest/function.go | 4 +-- .../functions/pearsonClosest/function_test.go | 2 -- expr/functions/perSecond/function.go | 2 +- expr/functions/perSecond/function_test.go | 2 -- expr/functions/percentileOfSeries/function.go | 2 +- .../percentileOfSeries/function_test.go | 2 -- expr/functions/polyfit/function.go | 2 +- expr/functions/polyfit/function_test.go | 2 -- expr/functions/pow/function.go | 4 +-- expr/functions/pow/function_test.go | 2 -- expr/functions/powSeries/function.go | 2 +- expr/functions/powSeries/function_test.go | 2 -- expr/functions/randomWalk/function_test.go | 2 -- expr/functions/rangeOfSeries/function.go | 2 +- expr/functions/rangeOfSeries/function_test.go | 2 -- expr/functions/reduce/function.go | 2 +- expr/functions/removeBelowSeries/function.go | 2 +- .../removeBelowSeries/function_test.go | 2 -- .../removeBetweenPercentile/function.go | 2 +- .../removeBetweenPercentile/function_test.go | 2 -- expr/functions/removeEmptySeries/function.go | 2 +- .../removeEmptySeries/function_test.go | 2 -- expr/functions/round/function.go | 2 +- expr/functions/round/function_test.go | 2 -- expr/functions/scale/function.go | 2 +- expr/functions/scale/function_test.go | 2 -- expr/functions/scaleToSeconds/function.go | 2 +- .../functions/scaleToSeconds/function_test.go | 2 -- expr/functions/seriesList/function.go | 4 +-- expr/functions/seriesList/function_test.go | 2 -- expr/functions/setXFilesFactor/function.go | 2 +- .../setXFilesFactor/function_test.go | 2 -- expr/functions/sigmoid/function.go | 2 +- expr/functions/sigmoid/function_test.go | 2 -- expr/functions/sinFunction/function_test.go | 2 -- expr/functions/slo/function.go | 4 +-- expr/functions/slo/function_test.go | 2 -- expr/functions/smartSummarize/function.go | 2 +- .../functions/smartSummarize/function_test.go | 2 -- expr/functions/sortBy/function.go | 2 +- expr/functions/sortBy/function_test.go | 5 ++- expr/functions/sortByName/function.go | 2 +- expr/functions/sortByName/function_test.go | 2 -- expr/functions/squareRoot/function.go | 2 +- expr/functions/squareRoot/function_test.go | 2 -- expr/functions/stdev/function.go | 2 +- expr/functions/stdev/function_test.go | 9 +++--- expr/functions/substr/function.go | 2 +- expr/functions/substr/function_test.go | 2 -- expr/functions/summarize/function.go | 5 +-- expr/functions/summarize/function_test.go | 2 -- expr/functions/timeFunction/function_test.go | 2 -- expr/functions/timeShift/function.go | 2 +- expr/functions/timeShift/function_test.go | 2 -- expr/functions/timeShiftByMetric/function.go | 4 +-- .../timeShiftByMetric/function_test.go | 2 -- expr/functions/timeSlice/function.go | 2 +- expr/functions/timeSlice/function_test.go | 2 -- expr/functions/timeStack/function.go | 2 +- expr/functions/timeStack/function_test.go | 2 -- expr/functions/toLowerCase/function.go | 3 +- expr/functions/toLowerCase/function_test.go | 2 -- expr/functions/toUpperCase/function.go | 3 +- expr/functions/toUpperCase/function_test.go | 2 -- expr/functions/transformNull/function.go | 4 +-- expr/functions/transformNull/function_test.go | 2 -- expr/functions/tukey/function.go | 2 +- expr/functions/tukey/function_test.go | 2 -- expr/functions/unique/function.go | 2 +- expr/functions/unique/function_test.go | 2 -- expr/functions/verticalLine/function_test.go | 2 -- expr/functions/weightedAverage/function.go | 4 +-- .../weightedAverage/function_test.go | 2 -- expr/helper/helper.go | 27 ++++++---------- expr/rewrite/aboveSeries/function.go | 2 +- expr/rewrite/aboveSeries/function_test.go | 3 -- expr/rewrite/applyByNode/function.go | 2 +- expr/rewrite/applyByNode/function_test.go | 3 -- .../carbonapi => zipper}/interfaces/zipper.go | 0 220 files changed, 220 insertions(+), 404 deletions(-) rename {cmd/carbonapi => zipper}/interfaces/zipper.go (100%) diff --git a/cmd/carbonapi/config/config.go b/cmd/carbonapi/config/config.go index 122665b46..d3fc8e888 100644 --- a/cmd/carbonapi/config/config.go +++ b/cmd/carbonapi/config/config.go @@ -5,10 +5,11 @@ import ( "time" "github.com/go-graphite/carbonapi/cache" - "github.com/go-graphite/carbonapi/cmd/carbonapi/interfaces" + "github.com/go-graphite/carbonapi/expr" "github.com/go-graphite/carbonapi/limiter" "github.com/go-graphite/carbonapi/pkg/tlsconfig" zipperCfg "github.com/go-graphite/carbonapi/zipper/config" + zipper "github.com/go-graphite/carbonapi/zipper/interfaces" zipperTypes "github.com/go-graphite/carbonapi/zipper/types" "github.com/lomik/zapwriter" @@ -115,7 +116,7 @@ type ConfigType struct { DefaultTimeZone *time.Location `mapstructure:"-" json:"-"` // ZipperInstance is API entry to carbonzipper - ZipperInstance interfaces.CarbonZipper `mapstructure:"-" json:"-"` + ZipperInstance zipper.CarbonZipper `mapstructure:"-" json:"-"` // Limiter limits concurrent zipper requests Limiter limiter.SimpleLimiter `mapstructure:"-" json:"-"` @@ -131,6 +132,11 @@ func (c ConfigType) String() string { } } +func (c *ConfigType) SetZipper(zipper zipper.CarbonZipper) { + c.ZipperInstance = zipper + expr.Init(c.Limiter, c.ZipperInstance) +} + var Config = ConfigType{ ExtrapolateExperiment: false, Buckets: 10, diff --git a/cmd/carbonapi/http/main_test.go b/cmd/carbonapi/http/main_test.go index c14458238..5373b851e 100644 --- a/cmd/carbonapi/http/main_test.go +++ b/cmd/carbonapi/http/main_test.go @@ -118,7 +118,7 @@ func init() { config.Config.Upstreams.Backends = []string{"dummy"} config.SetUpConfigUpstreams(logger) config.SetUpConfig(logger, "(test)") - config.Config.ZipperInstance = newMockCarbonZipper() + config.Config.SetZipper(newMockCarbonZipper()) emptyStringList := make([]string, 0) InitHandlers(emptyStringList, emptyStringList) } diff --git a/cmd/carbonapi/main.go b/cmd/carbonapi/main.go index cb2712f8a..1cb8e857e 100644 --- a/cmd/carbonapi/main.go +++ b/cmd/carbonapi/main.go @@ -57,7 +57,7 @@ func main() { dns.UseDNSCache(config.Config.CachingDNSRefreshTime) } - config.Config.ZipperInstance = newZipper(carbonapiHttp.ZipperStats, &config.Config.Upstreams, config.Config.IgnoreClientTimeout, zapwriter.Logger("zipper")) + config.Config.SetZipper(newZipper(carbonapiHttp.ZipperStats, &config.Config.Upstreams, config.Config.IgnoreClientTimeout, zapwriter.Logger("zipper"))) wg := sync.WaitGroup{} serve := func(listen config.Listener, handler http.Handler) { diff --git a/expr/expr.go b/expr/expr.go index aaf8d284f..84cf643ee 100644 --- a/expr/expr.go +++ b/expr/expr.go @@ -6,22 +6,31 @@ import ( "github.com/ansel1/merry" pb "github.com/go-graphite/protocol/carbonapi_v3_pb" - "github.com/go-graphite/carbonapi/cmd/carbonapi/config" _ "github.com/go-graphite/carbonapi/expr/functions" "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" + "github.com/go-graphite/carbonapi/limiter" "github.com/go-graphite/carbonapi/pkg/parser" utilctx "github.com/go-graphite/carbonapi/util/ctx" + zipper "github.com/go-graphite/carbonapi/zipper/interfaces" ) -type evaluator struct{} +type evaluator struct { + limiter limiter.SimpleLimiter + zipper zipper.CarbonZipper +} func (eval evaluator) Fetch(ctx context.Context, exprs []parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) (map[parser.MetricRequest][]*types.MetricData, error) { - if err := config.Config.Limiter.Enter(ctx); err != nil { + if eval.zipper == nil { + // TODO: may be return error or not check. But for use expr in external applications without CarbonZipper implementation + return values, nil + } + + if err := eval.limiter.Enter(ctx); err != nil { return nil, err } - defer config.Config.Limiter.Leave() + defer eval.limiter.Leave() multiFetchRequest := pb.MultiFetchRequest{} metricRequestCache := make(map[string]parser.MetricRequest) @@ -74,7 +83,7 @@ func (eval evaluator) Fetch(ctx context.Context, exprs []parser.Expr, from, unti } if len(multiFetchRequest.Metrics) > 0 { - metrics, _, err := config.Config.ZipperInstance.Render(ctx, multiFetchRequest) + metrics, _, err := eval.zipper.Render(ctx, multiFetchRequest) // If we had only partial result, we want to do our best to actually do our job if err != nil && merry.HTTPCode(err) >= 400 && !haveFallbackSeries { return nil, err @@ -97,7 +106,7 @@ func (eval evaluator) Fetch(ctx context.Context, exprs []parser.Expr, from, unti targetValues[m] = values[m] } - if config.Config.ZipperInstance.ScaleToCommonStep() { + if eval.zipper.ScaleToCommonStep() { targetValues = helper.ScaleValuesToCommonStep(targetValues) } @@ -131,10 +140,16 @@ func (eval evaluator) Eval(ctx context.Context, exp parser.Expr, from, until int return EvalExpr(ctx, exp, from, until, values) } -var _evaluator = evaluator{} +var _evaluator = &evaluator{} + +// Init call on configure phase, if need limiter or/and custom zipper (for refetch/etc) +func Init(limiter limiter.SimpleLimiter, zipper zipper.CarbonZipper) { + _evaluator.limiter = limiter + _evaluator.zipper = zipper +} func init() { - helper.SetEvaluator(_evaluator) + // helper.SetEvaluator(_evaluator) metadata.SetEvaluator(_evaluator) } diff --git a/expr/functions/absolute/function.go b/expr/functions/absolute/function.go index f2e501624..277f92227 100644 --- a/expr/functions/absolute/function.go +++ b/expr/functions/absolute/function.go @@ -28,7 +28,7 @@ func New(configFile string) []interfaces.FunctionMetadata { } func (f *absolute) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - return helper.ForEachSeriesDo(ctx, e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { + return helper.ForEachSeriesDo(ctx, f.GetEvaluator(), e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { for i, v := range a.Values { if math.IsNaN(a.Values[i]) { r.Values[i] = math.NaN() diff --git a/expr/functions/absolute/function_test.go b/expr/functions/absolute/function_test.go index 73961d78e..06f4826c0 100644 --- a/expr/functions/absolute/function_test.go +++ b/expr/functions/absolute/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aggregate/function.go b/expr/functions/aggregate/function.go index e2e76354b..06ba4c6af 100644 --- a/expr/functions/aggregate/function.go +++ b/expr/functions/aggregate/function.go @@ -49,7 +49,7 @@ func (f *aggregate) Do(ctx context.Context, e parser.Expr, from, until int64, va if e.Target() == "aggregate" { return nil, err } else { - args, err = helper.GetSeriesArgsAndRemoveNonExisting(ctx, e, from, until, values) + args, err = helper.GetSeriesArgsAndRemoveNonExisting(ctx, f.GetEvaluator(), e, from, until, values) if err != nil { return nil, err } @@ -61,7 +61,7 @@ func (f *aggregate) Do(ctx context.Context, e parser.Expr, from, until int64, va xFilesFactor = -1 // xFilesFactor is not used by the ...Series functions } } else { - args, err = helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err = helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aggregate/function_test.go b/expr/functions/aggregate/function_test.go index fa6b0940d..2f3b5e2c5 100644 --- a/expr/functions/aggregate/function_test.go +++ b/expr/functions/aggregate/function_test.go @@ -7,7 +7,6 @@ import ( "time" fconfig "github.com/go-graphite/carbonapi/expr/functions/config" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -19,7 +18,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aggregateLine/function.go b/expr/functions/aggregateLine/function.go index a5c0f85a5..c2bbeed78 100644 --- a/expr/functions/aggregateLine/function.go +++ b/expr/functions/aggregateLine/function.go @@ -32,7 +32,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // aggregateLine(*seriesLists) func (f *aggregateLine) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aggregateLine/function_test.go b/expr/functions/aggregateLine/function_test.go index 9b78c92b8..432f9850a 100644 --- a/expr/functions/aggregateLine/function_test.go +++ b/expr/functions/aggregateLine/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -17,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aggregateSeriesLists/function.go b/expr/functions/aggregateSeriesLists/function.go index f9e4649bc..c412af8b7 100644 --- a/expr/functions/aggregateSeriesLists/function.go +++ b/expr/functions/aggregateSeriesLists/function.go @@ -33,11 +33,11 @@ func (f *aggregateSeriesLists) Do(ctx context.Context, e parser.Expr, from, unti return nil, parser.ErrMissingArgument } - seriesList1, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + seriesList1, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } - seriesList2, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + seriesList2, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aggregateSeriesLists/function_test.go b/expr/functions/aggregateSeriesLists/function_test.go index 2d24cb52b..7a1ac1944 100644 --- a/expr/functions/aggregateSeriesLists/function_test.go +++ b/expr/functions/aggregateSeriesLists/function_test.go @@ -1,21 +1,20 @@ package aggregateSeriesLists import ( - "github.com/go-graphite/carbonapi/expr/helper" + "math" + "testing" + "time" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" th "github.com/go-graphite/carbonapi/tests" - "math" - "testing" - "time" ) func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aggregateWithWildcards/function.go b/expr/functions/aggregateWithWildcards/function.go index d3bef0be2..a6a2cd644 100644 --- a/expr/functions/aggregateWithWildcards/function.go +++ b/expr/functions/aggregateWithWildcards/function.go @@ -34,7 +34,7 @@ func (f *aggregateWithWildcards) Do(ctx context.Context, e parser.Expr, from, un return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aggregateWithWildcards/function_test.go b/expr/functions/aggregateWithWildcards/function_test.go index 1423f6905..baf7696b3 100644 --- a/expr/functions/aggregateWithWildcards/function_test.go +++ b/expr/functions/aggregateWithWildcards/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -17,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/alias/function.go b/expr/functions/alias/function.go index 2ccce6395..28523e76d 100644 --- a/expr/functions/alias/function.go +++ b/expr/functions/alias/function.go @@ -32,7 +32,7 @@ func (f *alias) Do(ctx context.Context, e parser.Expr, from, until int64, values return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/alias/function_test.go b/expr/functions/alias/function_test.go index c8f0c392f..be9966401 100644 --- a/expr/functions/alias/function_test.go +++ b/expr/functions/alias/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aliasByBase64/function.go b/expr/functions/aliasByBase64/function.go index 08e581af7..8e7c1529d 100644 --- a/expr/functions/aliasByBase64/function.go +++ b/expr/functions/aliasByBase64/function.go @@ -30,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { } func (f *aliasByBase64) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aliasByBase64/function_test.go b/expr/functions/aliasByBase64/function_test.go index 6f2503b6c..bfd715229 100644 --- a/expr/functions/aliasByBase64/function_test.go +++ b/expr/functions/aliasByBase64/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aliasByMetric/function.go b/expr/functions/aliasByMetric/function.go index a38ada22c..633d18a93 100644 --- a/expr/functions/aliasByMetric/function.go +++ b/expr/functions/aliasByMetric/function.go @@ -29,7 +29,7 @@ func New(configFile string) []interfaces.FunctionMetadata { } func (f *aliasByMetric) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - return helper.ForEachSeriesDo1(ctx, e, from, until, values, func(a *types.MetricData) *types.MetricData { + return helper.ForEachSeriesDo1(ctx, f.GetEvaluator(), e, from, until, values, func(a *types.MetricData) *types.MetricData { metric := types.ExtractNameTag(a.Name) part := strings.Split(metric, ".") name := part[len(part)-1] diff --git a/expr/functions/aliasByMetric/function_test.go b/expr/functions/aliasByMetric/function_test.go index 2eaa00f5f..67b2df43b 100644 --- a/expr/functions/aliasByMetric/function_test.go +++ b/expr/functions/aliasByMetric/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aliasByNode/function.go b/expr/functions/aliasByNode/function.go index 57a5a1bfb..e10e14e66 100644 --- a/expr/functions/aliasByNode/function.go +++ b/expr/functions/aliasByNode/function.go @@ -31,7 +31,7 @@ func (f *aliasByNode) Do(ctx context.Context, e parser.Expr, from, until int64, return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aliasByNode/function_test.go b/expr/functions/aliasByNode/function_test.go index 24d5b1e17..a2357b188 100644 --- a/expr/functions/aliasByNode/function_test.go +++ b/expr/functions/aliasByNode/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -42,7 +41,6 @@ func init() { evaluator := th.EvaluatorFromFuncWithMetadata(metadata.FunctionMD.Functions) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) } func TestAliasByNode(t *testing.T) { diff --git a/expr/functions/aliasByPostgres/function.go b/expr/functions/aliasByPostgres/function.go index 3846d9194..fab25eebf 100644 --- a/expr/functions/aliasByPostgres/function.go +++ b/expr/functions/aliasByPostgres/function.go @@ -155,7 +155,7 @@ func (f *aliasByPostgres) Do(ctx context.Context, e parser.Expr, from, until int } logger := zapwriter.Logger("functionInit").With(zap.String("function", "aliasByPostgres")) - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aliasByRedis/function.go b/expr/functions/aliasByRedis/function.go index d57f76f9f..ba75656f0 100644 --- a/expr/functions/aliasByRedis/function.go +++ b/expr/functions/aliasByRedis/function.go @@ -167,7 +167,7 @@ func New(configFile string) []interfaces.FunctionMetadata { } func (f *aliasByRedis) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aliasByRedis/function_test.go b/expr/functions/aliasByRedis/function_test.go index 200959bb6..531010d2d 100644 --- a/expr/functions/aliasByRedis/function_test.go +++ b/expr/functions/aliasByRedis/function_test.go @@ -9,7 +9,6 @@ import ( "github.com/alicebob/miniredis/v2" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -46,7 +45,6 @@ enabled: true md := New(config.Name()) evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aliasQuery/function.go b/expr/functions/aliasQuery/function.go index 1e43d6e39..1ab9aa53b 100644 --- a/expr/functions/aliasQuery/function.go +++ b/expr/functions/aliasQuery/function.go @@ -26,7 +26,7 @@ func New(_ string) []interfaces.FunctionMetadata { } func (f *aliasQuery) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - seriesList, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + seriesList, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -88,7 +88,7 @@ func (f *aliasQuery) Do(ctx context.Context, e parser.Expr, from, until int64, v } func (f *aliasQuery) getLastValueOfSeries(ctx context.Context, e parser.Expr, from, until int64, targetValues map[parser.MetricRequest][]*types.MetricData) (float64, error) { - res, err := helper.GetSeriesArg(ctx, e, from, until, targetValues) + res, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e, from, until, targetValues) if err != nil { return 0, err } diff --git a/expr/functions/aliasQuery/function_test.go b/expr/functions/aliasQuery/function_test.go index e7d4322cc..11eb26556 100644 --- a/expr/functions/aliasQuery/function_test.go +++ b/expr/functions/aliasQuery/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/aliasSub/function.go b/expr/functions/aliasSub/function.go index fe40d392d..0ee0ae88c 100644 --- a/expr/functions/aliasSub/function.go +++ b/expr/functions/aliasSub/function.go @@ -32,7 +32,7 @@ func (f *aliasSub) Do(ctx context.Context, e parser.Expr, from, until int64, val return nil, parser.ErrMissingTimeseries } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/aliasSub/function_test.go b/expr/functions/aliasSub/function_test.go index 1a9bdc6d8..26107ee31 100644 --- a/expr/functions/aliasSub/function_test.go +++ b/expr/functions/aliasSub/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/asPercent/function.go b/expr/functions/asPercent/function.go index b1ecc7dfd..48302aa53 100644 --- a/expr/functions/asPercent/function.go +++ b/expr/functions/asPercent/function.go @@ -335,7 +335,7 @@ func seriesGroup2AsPercent(arg, total []*types.MetricData, nodesOrTags []parser. // asPercent(seriesList, total=None, *nodes) func (f *asPercent) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -389,7 +389,7 @@ func (f *asPercent) Do(ctx context.Context, e parser.Expr, from, until int64, va return arg, nil } else if e.ArgsLen() == 2 && (e.Arg(1).IsName() || e.Arg(1).IsFunc()) { // asPercent(seriesList, totalList) - total, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + total, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } @@ -414,7 +414,7 @@ func (f *asPercent) Do(ctx context.Context, e parser.Expr, from, until int64, va return seriesGroupAsPercent(arg, nodesOrTags), nil } else { // asPercent(seriesList, totalSeriesList, *nodes) - total, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + total, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/asPercent/function_test.go b/expr/functions/asPercent/function_test.go index 5547c509f..7923a2250 100644 --- a/expr/functions/asPercent/function_test.go +++ b/expr/functions/asPercent/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -17,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/averageOutsidePercentile/function.go b/expr/functions/averageOutsidePercentile/function.go index 92fab7359..05708f78b 100644 --- a/expr/functions/averageOutsidePercentile/function.go +++ b/expr/functions/averageOutsidePercentile/function.go @@ -33,7 +33,7 @@ func (f *averageOutsidePercentile) Do(ctx context.Context, e parser.Expr, from, return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/averageOutsidePercentile/function_test.go b/expr/functions/averageOutsidePercentile/function_test.go index 0202d55d3..db5d7b908 100644 --- a/expr/functions/averageOutsidePercentile/function_test.go +++ b/expr/functions/averageOutsidePercentile/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/baselines/function.go b/expr/functions/baselines/function.go index 2b560a720..a73c3b8cb 100644 --- a/expr/functions/baselines/function.go +++ b/expr/functions/baselines/function.go @@ -57,7 +57,7 @@ func (f *baselines) Do(ctx context.Context, e parser.Expr, from, until int64, va } current := make(map[string]*types.MetricData) - arg, _ := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, _ := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) for _, a := range arg { current[a.Name] = a } @@ -68,7 +68,7 @@ func (f *baselines) Do(ctx context.Context, e parser.Expr, from, until int64, va continue } offs := int64(i * unit) - arg, _ := helper.GetSeriesArg(ctx, e.Arg(0), from+offs, until+offs, values) + arg, _ := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from+offs, until+offs, values) for _, a := range arg { r := a.CopyLinkTags() if _, ok := current[r.Name]; ok || !isAberration { diff --git a/expr/functions/below/function.go b/expr/functions/below/function.go index dfd0a13bf..d581dcab9 100644 --- a/expr/functions/below/function.go +++ b/expr/functions/below/function.go @@ -35,7 +35,7 @@ func (f *below) Do(ctx context.Context, e parser.Expr, from, until int64, values return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/below/function_test.go b/expr/functions/below/function_test.go index ca919dad8..e13746b10 100644 --- a/expr/functions/below/function_test.go +++ b/expr/functions/below/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/cactiStyle/function.go b/expr/functions/cactiStyle/function.go index 49d487042..cf406d685 100644 --- a/expr/functions/cactiStyle/function.go +++ b/expr/functions/cactiStyle/function.go @@ -34,7 +34,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // cactiStyle(seriesList, system=None, units=None) func (f *cactiStyle) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { // Get the series data - original, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + original, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/cactiStyle/function_test.go b/expr/functions/cactiStyle/function_test.go index e76687f90..f1e6e081a 100644 --- a/expr/functions/cactiStyle/function_test.go +++ b/expr/functions/cactiStyle/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/cairo/function.go b/expr/functions/cairo/function.go index c3a2abc9b..d9f56a1a2 100644 --- a/expr/functions/cairo/function.go +++ b/expr/functions/cairo/function.go @@ -28,7 +28,7 @@ func New(configFile string) []interfaces.FunctionMetadata { } func (f *cairo) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - return png.EvalExprGraph(ctx, e, from, until, values) + return png.EvalExprGraph(ctx, f.GetEvaluator(), e, from, until, values) } func (f *cairo) Description() map[string]types.FunctionDescription { diff --git a/expr/functions/cairo/png/cairo.go b/expr/functions/cairo/png/cairo.go index 8512c845d..32b595f3f 100644 --- a/expr/functions/cairo/png/cairo.go +++ b/expr/functions/cairo/png/cairo.go @@ -19,11 +19,12 @@ import ( pb "github.com/go-graphite/protocol/carbonapi_v3_pb" "github.com/go-graphite/carbonapi/expr/helper" + "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" - "github.com/tebeka/strftime" "github.com/evmar/gocairo/cairo" + "github.com/tebeka/strftime" ) const HaveGraphSupport = true @@ -671,12 +672,12 @@ func Description() map[string]types.FunctionDescription { } // TODO(civil): Split this into several separate functions. -func EvalExprGraph(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { +func EvalExprGraph(ctx context.Context, eval interfaces.Evaluator, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { switch e.Target() { case "color": // color(seriesList, theColor) - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, eval, e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -697,7 +698,7 @@ func EvalExprGraph(ctx context.Context, e parser.Expr, from, until int64, values return results, nil case "stacked": // stacked(seriesList, stackname="__DEFAULT__") - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, eval, e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -720,7 +721,7 @@ func EvalExprGraph(ctx context.Context, e parser.Expr, from, until int64, values return results, nil case "areaBetween": - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, eval, e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -751,7 +752,7 @@ func EvalExprGraph(ctx context.Context, e parser.Expr, from, until int64, values return []*types.MetricData{lower, upper}, nil case "alpha": // alpha(seriesList, theAlpha) - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, eval, e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -773,7 +774,7 @@ func EvalExprGraph(ctx context.Context, e parser.Expr, from, until int64, values return results, nil case "dashed", "drawAsInfinite", "secondYAxis": - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, eval, e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -811,7 +812,7 @@ func EvalExprGraph(ctx context.Context, e parser.Expr, from, until int64, values return results, nil case "lineWidth": // lineWidth(seriesList, width) - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, eval, e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/cairo/png/png.go b/expr/functions/cairo/png/png.go index a4a0e77e7..a0f77cd48 100644 --- a/expr/functions/cairo/png/png.go +++ b/expr/functions/cairo/png/png.go @@ -1,3 +1,4 @@ +//go:build !cairo // +build !cairo package png @@ -6,13 +7,14 @@ import ( "context" "net/http" + "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" ) const HaveGraphSupport = false -func EvalExprGraph(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { +func EvalExprGraph(ctx context.Context, eval interfaces.Evaluator, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { return nil, nil } diff --git a/expr/functions/changed/function.go b/expr/functions/changed/function.go index b6d24f733..0bc47203f 100644 --- a/expr/functions/changed/function.go +++ b/expr/functions/changed/function.go @@ -30,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // changed(SeriesList) func (f *changed) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/changed/function_test.go b/expr/functions/changed/function_test.go index 54792463d..5b62903bd 100644 --- a/expr/functions/changed/function_test.go +++ b/expr/functions/changed/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/compressPeriodicGaps/function.go b/expr/functions/compressPeriodicGaps/function.go index 7e0856b31..5a84eb387 100644 --- a/expr/functions/compressPeriodicGaps/function.go +++ b/expr/functions/compressPeriodicGaps/function.go @@ -2,12 +2,13 @@ package compressPeriodicGaps import ( "context" + "math" + "github.com/go-graphite/carbonapi/expr/consolidations" "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" - "math" ) type compressPeriodicGaps struct { @@ -30,7 +31,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // compressPeriodicGaps(seriesList) func (f *compressPeriodicGaps) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/compressPeriodicGaps/function_test.go b/expr/functions/compressPeriodicGaps/function_test.go index 65cd2af34..83d225820 100644 --- a/expr/functions/compressPeriodicGaps/function_test.go +++ b/expr/functions/compressPeriodicGaps/function_test.go @@ -1,20 +1,19 @@ package compressPeriodicGaps import ( - "github.com/go-graphite/carbonapi/expr/helper" + "math" + "testing" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" th "github.com/go-graphite/carbonapi/tests" - "math" - "testing" ) func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/consolidateBy/function.go b/expr/functions/consolidateBy/function.go index a44361e6d..88a7de7f0 100644 --- a/expr/functions/consolidateBy/function.go +++ b/expr/functions/consolidateBy/function.go @@ -34,7 +34,7 @@ func (f *consolidateBy) Do(ctx context.Context, e parser.Expr, from, until int64 return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/consolidateBy/function_test.go b/expr/functions/consolidateBy/function_test.go index c023dd599..97f457c4f 100644 --- a/expr/functions/consolidateBy/function_test.go +++ b/expr/functions/consolidateBy/function_test.go @@ -1,20 +1,19 @@ package consolidateBy import ( - "github.com/go-graphite/carbonapi/expr/helper" + "testing" + "time" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" th "github.com/go-graphite/carbonapi/tests" - "testing" - "time" ) func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/constantLine/function_test.go b/expr/functions/constantLine/function_test.go index 6bd5bd244..202b12a22 100644 --- a/expr/functions/constantLine/function_test.go +++ b/expr/functions/constantLine/function_test.go @@ -3,7 +3,6 @@ package constantLine import ( "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +13,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/cumulative/function.go b/expr/functions/cumulative/function.go index 0e258402e..622fb2cd6 100644 --- a/expr/functions/cumulative/function.go +++ b/expr/functions/cumulative/function.go @@ -29,7 +29,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // cumulative(seriesList) func (f *cumulative) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/cumulative/function_test.go b/expr/functions/cumulative/function_test.go index 2415feaf9..4ee26bd21 100644 --- a/expr/functions/cumulative/function_test.go +++ b/expr/functions/cumulative/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/delay/function.go b/expr/functions/delay/function.go index 9ea7120b7..e11a01c9b 100644 --- a/expr/functions/delay/function.go +++ b/expr/functions/delay/function.go @@ -34,7 +34,7 @@ func (f *delay) Do(ctx context.Context, e parser.Expr, from, until int64, values return nil, parser.ErrMissingArgument } - seriesList, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + seriesList, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/delay/function_test.go b/expr/functions/delay/function_test.go index 584014414..fb85844f8 100644 --- a/expr/functions/delay/function_test.go +++ b/expr/functions/delay/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -18,7 +17,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/derivative/function.go b/expr/functions/derivative/function.go index 89078ac76..358bc8fde 100644 --- a/expr/functions/derivative/function.go +++ b/expr/functions/derivative/function.go @@ -30,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // derivative(seriesList) func (f *derivative) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - return helper.ForEachSeriesDo(ctx, e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { + return helper.ForEachSeriesDo(ctx, f.GetEvaluator(), e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { prev := math.NaN() for i, v := range a.Values { // We don't need to check for special case here. value-NaN == NaN diff --git a/expr/functions/derivative/function_test.go b/expr/functions/derivative/function_test.go index 11ca3e8b2..c9b93d775 100644 --- a/expr/functions/derivative/function_test.go +++ b/expr/functions/derivative/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/divideSeries/function.go b/expr/functions/divideSeries/function.go index 0c483c08a..92310c2fa 100644 --- a/expr/functions/divideSeries/function.go +++ b/expr/functions/divideSeries/function.go @@ -36,7 +36,7 @@ func (f *divideSeries) Do(ctx context.Context, e parser.Expr, from, until int64, return nil, parser.ErrMissingTimeseries } - firstArg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + firstArg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -50,7 +50,7 @@ func (f *divideSeries) Do(ctx context.Context, e parser.Expr, from, until int64, if e.ArgsLen() == 2 { useMetricNames = true numerators = firstArg - denominators, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + denominators, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/divideSeries/function_test.go b/expr/functions/divideSeries/function_test.go index 9caa103a4..dcd1a2338 100644 --- a/expr/functions/divideSeries/function_test.go +++ b/expr/functions/divideSeries/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/ewma/function.go b/expr/functions/ewma/function.go index 17f9f6ccc..c4de7f739 100644 --- a/expr/functions/ewma/function.go +++ b/expr/functions/ewma/function.go @@ -35,7 +35,7 @@ func (f *ewma) Do(ctx context.Context, e parser.Expr, from, until int64, values return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/ewma/function_test.go b/expr/functions/ewma/function_test.go index c84c39d53..a5958f70c 100644 --- a/expr/functions/ewma/function_test.go +++ b/expr/functions/ewma/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/exclude/function.go b/expr/functions/exclude/function.go index e21e262db..1b43968fc 100644 --- a/expr/functions/exclude/function.go +++ b/expr/functions/exclude/function.go @@ -34,7 +34,7 @@ func (f *exclude) Do(ctx context.Context, e parser.Expr, from, until int64, valu return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/exclude/function_test.go b/expr/functions/exclude/function_test.go index ac6a5d93d..8ea83fca3 100644 --- a/expr/functions/exclude/function_test.go +++ b/expr/functions/exclude/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/exp/function.go b/expr/functions/exp/function.go index c0603d33b..66e4603f7 100644 --- a/expr/functions/exp/function.go +++ b/expr/functions/exp/function.go @@ -29,7 +29,7 @@ func New(configFile string) []interfaces.FunctionMetadata { } func (f *exp) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/exp/function_test.go b/expr/functions/exp/function_test.go index 5e37e33cb..cb8ce5dae 100644 --- a/expr/functions/exp/function_test.go +++ b/expr/functions/exp/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/exponentialMovingAverage/function.go b/expr/functions/exponentialMovingAverage/function.go index 7a43e1108..8d7584f97 100644 --- a/expr/functions/exponentialMovingAverage/function.go +++ b/expr/functions/exponentialMovingAverage/function.go @@ -59,7 +59,7 @@ func (f *exponentialMovingAverage) Do(ctx context.Context, e parser.Expr, from, // data. The already fetched values are discarded. refetch = true var maxStep int64 - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil || len(arg) == 0 { return arg, err } @@ -97,7 +97,7 @@ func (f *exponentialMovingAverage) Do(ctx context.Context, e parser.Expr, from, if refetch { f.GetEvaluator().Fetch(ctx, []parser.Expr{e.Arg(0)}, from, until, values) } - previewList, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + previewList, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/exponentialMovingAverage/function_test.go b/expr/functions/exponentialMovingAverage/function_test.go index 6b5452c0f..99da3e372 100644 --- a/expr/functions/exponentialMovingAverage/function_test.go +++ b/expr/functions/exponentialMovingAverage/function_test.go @@ -5,7 +5,6 @@ import ( "math" "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/fallbackSeries/function.go b/expr/functions/fallbackSeries/function.go index 2a33bccec..9c8be7c32 100644 --- a/expr/functions/fallbackSeries/function.go +++ b/expr/functions/fallbackSeries/function.go @@ -37,8 +37,8 @@ func (f *fallbackSeries) Do(ctx context.Context, e parser.Expr, from, until int6 return nil, parser.ErrMissingTimeseries } - seriesList, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) - fallback, errFallback := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + seriesList, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) + fallback, errFallback := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if errFallback != nil && err != nil { return nil, errFallback } diff --git a/expr/functions/fallbackSeries/function_test.go b/expr/functions/fallbackSeries/function_test.go index fcd9c3ba2..7fe729185 100644 --- a/expr/functions/fallbackSeries/function_test.go +++ b/expr/functions/fallbackSeries/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/fft/function.go b/expr/functions/fft/function.go index 6fddfaac4..6ae996939 100644 --- a/expr/functions/fft/function.go +++ b/expr/functions/fft/function.go @@ -41,7 +41,7 @@ func extractComponent(m *types.MetricData, values []complex128, t string, f func // fft(seriesList, mode) // mode: "", abs, phase. Empty string means "both" func (f *fft) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/filter/function.go b/expr/functions/filter/function.go index 8ab422197..92672a11c 100644 --- a/expr/functions/filter/function.go +++ b/expr/functions/filter/function.go @@ -43,7 +43,7 @@ func (f *filterSeries) Do(ctx context.Context, e parser.Expr, from, until int64, return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/filter/function_test.go b/expr/functions/filter/function_test.go index 372a8da32..f30dfc90d 100644 --- a/expr/functions/filter/function_test.go +++ b/expr/functions/filter/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/grep/function.go b/expr/functions/grep/function.go index 99935ec6d..ccfe1e6f4 100644 --- a/expr/functions/grep/function.go +++ b/expr/functions/grep/function.go @@ -34,7 +34,7 @@ func (f *grep) Do(ctx context.Context, e parser.Expr, from, until int64, values return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/grep/function_test.go b/expr/functions/grep/function_test.go index 4ec6c4679..756ce7dbc 100644 --- a/expr/functions/grep/function_test.go +++ b/expr/functions/grep/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/group/function.go b/expr/functions/group/function.go index 748e508af..3fb18a86f 100644 --- a/expr/functions/group/function.go +++ b/expr/functions/group/function.go @@ -29,7 +29,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // group(*seriesLists) func (f *group) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArgsAndRemoveNonExisting(ctx, e, from, until, values) + args, err := helper.GetSeriesArgsAndRemoveNonExisting(ctx, f.GetEvaluator(), e, from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/groupByNode/function.go b/expr/functions/groupByNode/function.go index a92adf312..ebdb67f1a 100644 --- a/expr/functions/groupByNode/function.go +++ b/expr/functions/groupByNode/function.go @@ -37,7 +37,7 @@ func (f *groupByNode) Do(ctx context.Context, e parser.Expr, from, until int64, return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/groupByNode/function_test.go b/expr/functions/groupByNode/function_test.go index b4e1144db..1f7336879 100644 --- a/expr/functions/groupByNode/function_test.go +++ b/expr/functions/groupByNode/function_test.go @@ -6,7 +6,6 @@ import ( "time" "github.com/go-graphite/carbonapi/expr/functions/aggregate" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -25,7 +24,6 @@ func init() { evaluator := th.EvaluatorFromFuncWithMetadata(metadata.FunctionMD.Functions) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) } // Note: some of these tests are influenced by the testcases for groupByNode and groupByNodes functions diff --git a/expr/functions/groupByTags/function.go b/expr/functions/groupByTags/function.go index 208073f48..b5af8b514 100644 --- a/expr/functions/groupByTags/function.go +++ b/expr/functions/groupByTags/function.go @@ -36,7 +36,7 @@ func (f *groupByTags) Do(ctx context.Context, e parser.Expr, from, until int64, return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/groupByTags/function_test.go b/expr/functions/groupByTags/function_test.go index 785947748..def4b29bd 100644 --- a/expr/functions/groupByTags/function_test.go +++ b/expr/functions/groupByTags/function_test.go @@ -6,7 +6,6 @@ import ( "time" "github.com/go-graphite/carbonapi/expr/functions/aggregate" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -25,7 +24,6 @@ func init() { evaluator := th.EvaluatorFromFuncWithMetadata(metadata.FunctionMD.Functions) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) } func TestGroupByTags(t *testing.T) { diff --git a/expr/functions/heatMap/function.go b/expr/functions/heatMap/function.go index 159db7510..04d583670 100644 --- a/expr/functions/heatMap/function.go +++ b/expr/functions/heatMap/function.go @@ -28,7 +28,7 @@ func New(_ string) []interfaces.FunctionMetadata { } func (f *heatMap) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - series, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + series, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/heatMap/function_test.go b/expr/functions/heatMap/function_test.go index bee2a363a..8c4b119fa 100644 --- a/expr/functions/heatMap/function_test.go +++ b/expr/functions/heatMap/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/highestLowest/function.go b/expr/functions/highestLowest/function.go index fb0a1f755..7467fc9b5 100644 --- a/expr/functions/highestLowest/function.go +++ b/expr/functions/highestLowest/function.go @@ -34,7 +34,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // highestAverage(seriesList, n) , highestCurrent(seriesList, n), highestMax(seriesList, n) func (f *highest) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/highestLowest/function_test.go b/expr/functions/highestLowest/function_test.go index b0bfeda55..ed53c7c95 100644 --- a/expr/functions/highestLowest/function_test.go +++ b/expr/functions/highestLowest/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/hitcount/function.go b/expr/functions/hitcount/function.go index 6a87740ba..ac20bbb88 100644 --- a/expr/functions/hitcount/function.go +++ b/expr/functions/hitcount/function.go @@ -2,14 +2,15 @@ package hitcount import ( "context" + "math" + "strconv" + "strings" + "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" pb "github.com/go-graphite/protocol/carbonapi_v3_pb" - "math" - "strconv" - "strings" ) type hitcount struct { @@ -53,7 +54,7 @@ func (f *hitcount) Do(ctx context.Context, e parser.Expr, from, until int64, val from = helper.AlignStartToInterval(from, until, interval) } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/hitcount/function_test.go b/expr/functions/hitcount/function_test.go index 2c6e6cc72..6e82d32b9 100644 --- a/expr/functions/hitcount/function_test.go +++ b/expr/functions/hitcount/function_test.go @@ -4,7 +4,6 @@ import ( "math" "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/holtWintersAberration/function.go b/expr/functions/holtWintersAberration/function.go index c0082a188..1c1d8ebe0 100644 --- a/expr/functions/holtWintersAberration/function.go +++ b/expr/functions/holtWintersAberration/function.go @@ -36,7 +36,7 @@ func (f *holtWintersAberration) Do(ctx context.Context, e parser.Expr, from, unt return nil, err } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -44,7 +44,7 @@ func (f *holtWintersAberration) Do(ctx context.Context, e parser.Expr, from, unt // Note: additional fetch requests are added with an adjusted start time in expr.Metrics() (in // pkg/parser/parser.go) so that the appropriate data corresponding to the adjusted start time // can be pre-fetched. - adjustedStartArgs, err := helper.GetSeriesArg(ctx, e.Arg(0), from-bootstrapInterval, until, values) + adjustedStartArgs, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from-bootstrapInterval, until, values) if err != nil { return nil, err } diff --git a/expr/functions/holtWintersAberration/function_test.go b/expr/functions/holtWintersAberration/function_test.go index ed4849866..0446b0cee 100644 --- a/expr/functions/holtWintersAberration/function_test.go +++ b/expr/functions/holtWintersAberration/function_test.go @@ -1,10 +1,10 @@ package holtWintersAberration import ( - "github.com/go-graphite/carbonapi/expr/holtwinters" "testing" - "github.com/go-graphite/carbonapi/expr/helper" + "github.com/go-graphite/carbonapi/expr/holtwinters" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/holtWintersConfidenceArea/function_cairo.go b/expr/functions/holtWintersConfidenceArea/function_cairo.go index 95b0fa5f9..b5f5b36b4 100644 --- a/expr/functions/holtWintersConfidenceArea/function_cairo.go +++ b/expr/functions/holtWintersConfidenceArea/function_cairo.go @@ -39,7 +39,7 @@ func (f *holtWintersConfidenceArea) Do(ctx context.Context, e parser.Expr, from, return nil, err } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from-bootstrapInterval, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from-bootstrapInterval, until, values) if err != nil { return nil, err } diff --git a/expr/functions/holtWintersConfidenceArea/function_test.go b/expr/functions/holtWintersConfidenceArea/function_test.go index 90a4c896b..6a0468532 100644 --- a/expr/functions/holtWintersConfidenceArea/function_test.go +++ b/expr/functions/holtWintersConfidenceArea/function_test.go @@ -4,10 +4,10 @@ package holtWintersConfidenceArea import ( - "github.com/go-graphite/carbonapi/expr/holtwinters" "testing" - "github.com/go-graphite/carbonapi/expr/helper" + "github.com/go-graphite/carbonapi/expr/holtwinters" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -18,7 +18,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/holtWintersConfidenceBands/function.go b/expr/functions/holtWintersConfidenceBands/function.go index efc7fc22d..bb3b6be72 100644 --- a/expr/functions/holtWintersConfidenceBands/function.go +++ b/expr/functions/holtWintersConfidenceBands/function.go @@ -2,6 +2,7 @@ package holtWintersConfidenceBands import ( "context" + "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/holtwinters" "github.com/go-graphite/carbonapi/expr/interfaces" @@ -34,7 +35,7 @@ func (f *holtWintersConfidenceBands) Do(ctx context.Context, e parser.Expr, from return nil, err } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from-bootstrapInterval, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from-bootstrapInterval, until, values) if err != nil { return nil, err } diff --git a/expr/functions/holtWintersConfidenceBands/function_test.go b/expr/functions/holtWintersConfidenceBands/function_test.go index c48d7c60c..d49fc732b 100644 --- a/expr/functions/holtWintersConfidenceBands/function_test.go +++ b/expr/functions/holtWintersConfidenceBands/function_test.go @@ -1,10 +1,10 @@ package holtWintersConfidenceBands import ( - "github.com/go-graphite/carbonapi/expr/holtwinters" "testing" - "github.com/go-graphite/carbonapi/expr/helper" + "github.com/go-graphite/carbonapi/expr/holtwinters" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/holtWintersForecast/function.go b/expr/functions/holtWintersForecast/function.go index 2195fc953..6dde77d4b 100644 --- a/expr/functions/holtWintersForecast/function.go +++ b/expr/functions/holtWintersForecast/function.go @@ -35,7 +35,7 @@ func (f *holtWintersForecast) Do(ctx context.Context, e parser.Expr, from, until return nil, err } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from-bootstrapInterval, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from-bootstrapInterval, until, values) if err != nil { return nil, err } diff --git a/expr/functions/holtWintersForecast/function_test.go b/expr/functions/holtWintersForecast/function_test.go index 6283df4c3..2f897adbe 100644 --- a/expr/functions/holtWintersForecast/function_test.go +++ b/expr/functions/holtWintersForecast/function_test.go @@ -3,7 +3,6 @@ package holtWintersForecast import ( "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +13,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/identity/function_test.go b/expr/functions/identity/function_test.go index 7311e0aea..e5acced8f 100644 --- a/expr/functions/identity/function_test.go +++ b/expr/functions/identity/function_test.go @@ -3,7 +3,6 @@ package identity import ( "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +13,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/ifft/function.go b/expr/functions/ifft/function.go index bb8fe54ff..c52d1769c 100644 --- a/expr/functions/ifft/function.go +++ b/expr/functions/ifft/function.go @@ -32,14 +32,14 @@ func New(configFile string) []interfaces.FunctionMetadata { // ifft(absSeriesList, phaseSeriesList) func (f *ifft) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - absSeriesList, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + absSeriesList, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } var phaseSeriesList []*types.MetricData if e.ArgsLen() > 1 { - phaseSeriesList, err = helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + phaseSeriesList, err = helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/integral/function.go b/expr/functions/integral/function.go index 25caf5727..182555484 100644 --- a/expr/functions/integral/function.go +++ b/expr/functions/integral/function.go @@ -30,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // integral(seriesList) func (f *integral) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - return helper.ForEachSeriesDo(ctx, e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { + return helper.ForEachSeriesDo(ctx, f.GetEvaluator(), e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { current := 0.0 for i, v := range a.Values { if math.IsNaN(v) { diff --git a/expr/functions/integral/function_test.go b/expr/functions/integral/function_test.go index be9e3c01b..519dded8f 100644 --- a/expr/functions/integral/function_test.go +++ b/expr/functions/integral/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/integralByInterval/function.go b/expr/functions/integralByInterval/function.go index 718cf6ec6..a95971263 100644 --- a/expr/functions/integralByInterval/function.go +++ b/expr/functions/integralByInterval/function.go @@ -34,7 +34,7 @@ func (f *integralByInterval) Do(ctx context.Context, e parser.Expr, from, until return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/integralByInterval/function_test.go b/expr/functions/integralByInterval/function_test.go index 8a7f4dc11..4d4626abb 100644 --- a/expr/functions/integralByInterval/function_test.go +++ b/expr/functions/integralByInterval/function_test.go @@ -3,7 +3,6 @@ package integralByInterval import ( "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +13,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/integralWithReset/function.go b/expr/functions/integralWithReset/function.go index b3d01544d..51415a37a 100644 --- a/expr/functions/integralWithReset/function.go +++ b/expr/functions/integralWithReset/function.go @@ -32,11 +32,11 @@ func New(configFile string) []interfaces.FunctionMetadata { // integralWithReset(seriesList, resettingSeries) func (f *integralWithReset) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } - resettingSeriesList, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + resettingSeriesList, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/integralWithReset/function_test.go b/expr/functions/integralWithReset/function_test.go index 0cca883f0..e69e9dfbb 100644 --- a/expr/functions/integralWithReset/function_test.go +++ b/expr/functions/integralWithReset/function_test.go @@ -4,19 +4,18 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" + "math" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" th "github.com/go-graphite/carbonapi/tests" - "math" ) func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/interpolate/function.go b/expr/functions/interpolate/function.go index 0b71de30f..8c001879a 100644 --- a/expr/functions/interpolate/function.go +++ b/expr/functions/interpolate/function.go @@ -26,7 +26,7 @@ func New(configFile string) []interfaces.FunctionMetadata { } func (f *interpolate) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) (resultData []*types.MetricData, resultError error) { - seriesList, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + seriesList, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/interpolate/function_test.go b/expr/functions/interpolate/function_test.go index 7a714107f..2a1594c35 100644 --- a/expr/functions/interpolate/function_test.go +++ b/expr/functions/interpolate/function_test.go @@ -7,7 +7,6 @@ import ( th "github.com/go-graphite/carbonapi/tests" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -17,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/invert/function.go b/expr/functions/invert/function.go index 350b9dbc0..4544beb5c 100644 --- a/expr/functions/invert/function.go +++ b/expr/functions/invert/function.go @@ -30,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // invert(seriesList) func (f *invert) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - return helper.ForEachSeriesDo(ctx, e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { + return helper.ForEachSeriesDo(ctx, f.GetEvaluator(), e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { for i, v := range a.Values { if v == 0 { r.Values[i] = math.NaN() diff --git a/expr/functions/invert/function_test.go b/expr/functions/invert/function_test.go index 0a582a7f1..f471624cb 100644 --- a/expr/functions/invert/function_test.go +++ b/expr/functions/invert/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/isNotNull/function.go b/expr/functions/isNotNull/function.go index d71c1f42a..73699e90c 100644 --- a/expr/functions/isNotNull/function.go +++ b/expr/functions/isNotNull/function.go @@ -33,7 +33,7 @@ func New(configFile string) []interfaces.FunctionMetadata { func (f *isNotNull) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { e.SetTarget("isNonNull") - return helper.ForEachSeriesDo(ctx, e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { + return helper.ForEachSeriesDo(ctx, f.GetEvaluator(), e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { for i, v := range a.Values { if math.IsNaN(v) { r.Values[i] = 0 diff --git a/expr/functions/isNotNull/function_test.go b/expr/functions/isNotNull/function_test.go index 4828d8f74..f4f246930 100644 --- a/expr/functions/isNotNull/function_test.go +++ b/expr/functions/isNotNull/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/join/function.go b/expr/functions/join/function.go index fef291e17..e3468f3f0 100644 --- a/expr/functions/join/function.go +++ b/expr/functions/join/function.go @@ -32,7 +32,7 @@ func New(_ string) []interfaces.FunctionMetadata { } } -func (_ *join) Description() map[string]types.FunctionDescription { +func (f *join) Description() map[string]types.FunctionDescription { return map[string]types.FunctionDescription{ "join": { Description: `Performs set operations on 'seriesA' and 'seriesB'. Following options are available: @@ -77,12 +77,12 @@ Example: } } -func (_ *join) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) (results []*types.MetricData, err error) { - seriesA, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) +func (f *join) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) (results []*types.MetricData, err error) { + seriesA, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } - seriesB, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + seriesB, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/join/function_test.go b/expr/functions/join/function_test.go index 7e341aac1..f60fc601a 100644 --- a/expr/functions/join/function_test.go +++ b/expr/functions/join/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/keepLastValue/function.go b/expr/functions/keepLastValue/function.go index 5772033cf..b9fb8791e 100644 --- a/expr/functions/keepLastValue/function.go +++ b/expr/functions/keepLastValue/function.go @@ -32,7 +32,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // keepLastValue(seriesList, limit=inf) func (f *keepLastValue) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/keepLastValue/function_test.go b/expr/functions/keepLastValue/function_test.go index 8c80d1f19..ffd1de713 100644 --- a/expr/functions/keepLastValue/function_test.go +++ b/expr/functions/keepLastValue/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/kolmogorovSmirnovTest2/function.go b/expr/functions/kolmogorovSmirnovTest2/function.go index 1588713cc..2b9c980f2 100644 --- a/expr/functions/kolmogorovSmirnovTest2/function.go +++ b/expr/functions/kolmogorovSmirnovTest2/function.go @@ -32,12 +32,12 @@ func New(configFile string) []interfaces.FunctionMetadata { // ksTest2(series, series, points|"interval") // https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test func (f *kolmogorovSmirnovTest2) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg1, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg1, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } - arg2, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + arg2, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/legendValue/function.go b/expr/functions/legendValue/function.go index 2670979bf..fa607ecb6 100644 --- a/expr/functions/legendValue/function.go +++ b/expr/functions/legendValue/function.go @@ -37,7 +37,7 @@ func (f *legendValue) Do(ctx context.Context, e parser.Expr, from, until int64, return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/legendValue/function_test.go b/expr/functions/legendValue/function_test.go index 19373d66a..d5a4ed451 100644 --- a/expr/functions/legendValue/function_test.go +++ b/expr/functions/legendValue/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/limit/function.go b/expr/functions/limit/function.go index 153ebcfee..b8a577f62 100644 --- a/expr/functions/limit/function.go +++ b/expr/functions/limit/function.go @@ -33,7 +33,7 @@ func (f *limit) Do(ctx context.Context, e parser.Expr, from, until int64, values return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/limit/function_test.go b/expr/functions/limit/function_test.go index 7926c2b4e..b5dfc8da8 100644 --- a/expr/functions/limit/function_test.go +++ b/expr/functions/limit/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/linearRegression/function.go b/expr/functions/linearRegression/function.go index c6b7433c0..d1fee8358 100644 --- a/expr/functions/linearRegression/function.go +++ b/expr/functions/linearRegression/function.go @@ -33,7 +33,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // linearRegression(seriesList, startSourceAt=None, endSourceAt=None) func (f *linearRegression) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/linearRegression/function_test.go b/expr/functions/linearRegression/function_test.go index 670d50850..6f8b07ed8 100644 --- a/expr/functions/linearRegression/function_test.go +++ b/expr/functions/linearRegression/function_test.go @@ -5,7 +5,6 @@ import ( "math" "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/logarithm/function.go b/expr/functions/logarithm/function.go index 31b2fe131..ca554a86f 100644 --- a/expr/functions/logarithm/function.go +++ b/expr/functions/logarithm/function.go @@ -32,7 +32,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // logarithm(seriesList, base=10) // Alias: log func (f *logarithm) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/logarithm/function_test.go b/expr/functions/logarithm/function_test.go index 31b65dad6..a13bfc212 100644 --- a/expr/functions/logarithm/function_test.go +++ b/expr/functions/logarithm/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/logit/function.go b/expr/functions/logit/function.go index e55ec6e03..e681c11ba 100644 --- a/expr/functions/logit/function.go +++ b/expr/functions/logit/function.go @@ -32,7 +32,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // logarithm(seriesList, base=10) // Alias: log func (f *logit) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/logit/function_test.go b/expr/functions/logit/function_test.go index 86451255b..95f37ec02 100644 --- a/expr/functions/logit/function_test.go +++ b/expr/functions/logit/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/lowPass/function.go b/expr/functions/lowPass/function.go index 4945b2921..02eb9fda0 100644 --- a/expr/functions/lowPass/function.go +++ b/expr/functions/lowPass/function.go @@ -31,7 +31,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // lowPass(seriesList, cutPercent) func (f *lowPass) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/lowPass/function_test.go b/expr/functions/lowPass/function_test.go index c39ae7f62..325d4474a 100644 --- a/expr/functions/lowPass/function_test.go +++ b/expr/functions/lowPass/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/mapSeries/function.go b/expr/functions/mapSeries/function.go index 86faad471..282af5957 100644 --- a/expr/functions/mapSeries/function.go +++ b/expr/functions/mapSeries/function.go @@ -34,7 +34,7 @@ func (f *mapSeries) Do(ctx context.Context, e parser.Expr, from, until int64, va return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/mapSeries/function_test.go b/expr/functions/mapSeries/function_test.go index 995263622..3dd93fbd9 100644 --- a/expr/functions/mapSeries/function_test.go +++ b/expr/functions/mapSeries/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/minMax/function.go b/expr/functions/minMax/function.go index c2a278c4d..5e8c68a83 100644 --- a/expr/functions/minMax/function.go +++ b/expr/functions/minMax/function.go @@ -32,7 +32,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // highestAverage(seriesList, n) , highestCurrent(seriesList, n), highestMax(seriesList, n) func (f *minMax) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/minMax/function_test.go b/expr/functions/minMax/function_test.go index d934e694d..f64fe93f0 100644 --- a/expr/functions/minMax/function_test.go +++ b/expr/functions/minMax/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/mostDeviant/function.go b/expr/functions/mostDeviant/function.go index f244c1dfb..061f9688f 100644 --- a/expr/functions/mostDeviant/function.go +++ b/expr/functions/mostDeviant/function.go @@ -48,7 +48,7 @@ func (f *mostDeviant) Do(ctx context.Context, e parser.Expr, from, until int64, return nil, err } - args, err := helper.GetSeriesArg(ctx, e.Arg(seriesArg), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(seriesArg), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/mostDeviant/function_test.go b/expr/functions/mostDeviant/function_test.go index 09f33c782..2c1cd59c6 100644 --- a/expr/functions/mostDeviant/function_test.go +++ b/expr/functions/mostDeviant/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/moving/function.go b/expr/functions/moving/function.go index 562be68b0..865d2ba0f 100644 --- a/expr/functions/moving/function.go +++ b/expr/functions/moving/function.go @@ -88,7 +88,7 @@ func (f *moving) Do(ctx context.Context, e parser.Expr, from, until int64, value n, err = e.GetIntArg(1) argstr = strconv.Itoa(n) - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -130,7 +130,7 @@ func (f *moving) Do(ctx context.Context, e parser.Expr, from, until int64, value targetValues = values } - adjustedArgs, err := helper.GetSeriesArg(ctx, e.Arg(0), adjustedStart, until, targetValues) + adjustedArgs, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), adjustedStart, until, targetValues) if err != nil { return nil, err } diff --git a/expr/functions/moving/function_test.go b/expr/functions/moving/function_test.go index b096af734..633e7aa5a 100644 --- a/expr/functions/moving/function_test.go +++ b/expr/functions/moving/function_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -19,7 +18,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/movingMedian/function.go b/expr/functions/movingMedian/function.go index 9423fde93..ee32f6e45 100644 --- a/expr/functions/movingMedian/function.go +++ b/expr/functions/movingMedian/function.go @@ -102,7 +102,7 @@ func (f *movingMedian) Do(ctx context.Context, e parser.Expr, from, until int64, start -= int64(n) } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), start, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), start, until, values) if err != nil { return nil, err } diff --git a/expr/functions/movingMedian/function_test.go b/expr/functions/movingMedian/function_test.go index 67de1ccdc..b1e1e782f 100644 --- a/expr/functions/movingMedian/function_test.go +++ b/expr/functions/movingMedian/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -18,7 +17,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/nPercentile/function.go b/expr/functions/nPercentile/function.go index 729ab63c2..569dc7170 100644 --- a/expr/functions/nPercentile/function.go +++ b/expr/functions/nPercentile/function.go @@ -36,7 +36,7 @@ func (f *nPercentile) Do(ctx context.Context, e parser.Expr, from, until int64, return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/nPercentile/function_test.go b/expr/functions/nPercentile/function_test.go index 695e5e798..1b04e4c3b 100644 --- a/expr/functions/nPercentile/function_test.go +++ b/expr/functions/nPercentile/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/nonNegativeDerivative/function.go b/expr/functions/nonNegativeDerivative/function.go index 288dbab18..fa974a81e 100644 --- a/expr/functions/nonNegativeDerivative/function.go +++ b/expr/functions/nonNegativeDerivative/function.go @@ -31,7 +31,7 @@ func New(configFile string) []interfaces.FunctionMetadata { } func (f *nonNegativeDerivative) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/nonNegativeDerivative/function_test.go b/expr/functions/nonNegativeDerivative/function_test.go index e5efd3015..25fa6cf79 100644 --- a/expr/functions/nonNegativeDerivative/function_test.go +++ b/expr/functions/nonNegativeDerivative/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/offset/function.go b/expr/functions/offset/function.go index a4c14f764..ecb61c89f 100644 --- a/expr/functions/offset/function.go +++ b/expr/functions/offset/function.go @@ -34,7 +34,7 @@ func (f *offset) Do(ctx context.Context, e parser.Expr, from, until int64, value return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/offset/function_test.go b/expr/functions/offset/function_test.go index 4a209ac7b..bc6e18f4d 100644 --- a/expr/functions/offset/function_test.go +++ b/expr/functions/offset/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/offsetToZero/function.go b/expr/functions/offsetToZero/function.go index 4484406a9..024ce0529 100644 --- a/expr/functions/offsetToZero/function.go +++ b/expr/functions/offsetToZero/function.go @@ -31,7 +31,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // offsetToZero(seriesList) func (f *offsetToZero) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - return helper.ForEachSeriesDo(ctx, e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { + return helper.ForEachSeriesDo(ctx, f.GetEvaluator(), e, from, until, values, func(a *types.MetricData, r *types.MetricData) *types.MetricData { minimum := math.Inf(1) for _, v := range a.Values { // NaN < val is always false diff --git a/expr/functions/offsetToZero/function_test.go b/expr/functions/offsetToZero/function_test.go index 1f92f9da8..ea856d8a9 100644 --- a/expr/functions/offsetToZero/function_test.go +++ b/expr/functions/offsetToZero/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/pearson/function.go b/expr/functions/pearson/function.go index 395f76021..449cff7fe 100644 --- a/expr/functions/pearson/function.go +++ b/expr/functions/pearson/function.go @@ -31,12 +31,12 @@ func New(configFile string) []interfaces.FunctionMetadata { // pearson(series, series, windowSize) func (f *pearson) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg1, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg1, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } - arg2, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + arg2, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/pearson/function_test.go b/expr/functions/pearson/function_test.go index c805ab474..fef423ac7 100644 --- a/expr/functions/pearson/function_test.go +++ b/expr/functions/pearson/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/pearsonClosest/function.go b/expr/functions/pearsonClosest/function.go index 614eefcaf..05224f3fc 100644 --- a/expr/functions/pearsonClosest/function.go +++ b/expr/functions/pearsonClosest/function.go @@ -37,7 +37,7 @@ func (f *pearsonClosest) Do(ctx context.Context, e parser.Expr, from, until int6 return nil, types.ErrTooManyArguments } - ref, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + ref, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -46,7 +46,7 @@ func (f *pearsonClosest) Do(ctx context.Context, e parser.Expr, from, until int6 return nil, types.ErrWildcardNotAllowed } - compare, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + compare, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/pearsonClosest/function_test.go b/expr/functions/pearsonClosest/function_test.go index 8558b9d79..ede2b3a43 100644 --- a/expr/functions/pearsonClosest/function_test.go +++ b/expr/functions/pearsonClosest/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/perSecond/function.go b/expr/functions/perSecond/function.go index fa50da970..4967482cf 100644 --- a/expr/functions/perSecond/function.go +++ b/expr/functions/perSecond/function.go @@ -33,7 +33,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // perSecond(seriesList, maxValue=None) func (f *perSecond) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/perSecond/function_test.go b/expr/functions/perSecond/function_test.go index b1272d652..719329549 100644 --- a/expr/functions/perSecond/function_test.go +++ b/expr/functions/perSecond/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/percentileOfSeries/function.go b/expr/functions/percentileOfSeries/function.go index 7010c329b..8267f7031 100644 --- a/expr/functions/percentileOfSeries/function.go +++ b/expr/functions/percentileOfSeries/function.go @@ -42,7 +42,7 @@ func (f *percentileOfSeries) Do(ctx context.Context, e parser.Expr, from, until return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/percentileOfSeries/function_test.go b/expr/functions/percentileOfSeries/function_test.go index 8e6958c29..a3f1b80bf 100644 --- a/expr/functions/percentileOfSeries/function_test.go +++ b/expr/functions/percentileOfSeries/function_test.go @@ -6,7 +6,6 @@ import ( "time" fconfig "github.com/go-graphite/carbonapi/expr/functions/config" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -17,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/polyfit/function.go b/expr/functions/polyfit/function.go index 8ec678ddd..610b64213 100644 --- a/expr/functions/polyfit/function.go +++ b/expr/functions/polyfit/function.go @@ -36,7 +36,7 @@ func New(configFile string) []interfaces.FunctionMetadata { func (f *polyfit) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { // Fitting Nth degree polynom to the dataset // https://en.wikipedia.org/wiki/Polynomial_regression#Matrix_form_and_calculation_of_estimates - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/polyfit/function_test.go b/expr/functions/polyfit/function_test.go index e423f5d1b..f1e8c085b 100644 --- a/expr/functions/polyfit/function_test.go +++ b/expr/functions/polyfit/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/pow/function.go b/expr/functions/pow/function.go index c4ac5e114..4d23d35c8 100644 --- a/expr/functions/pow/function.go +++ b/expr/functions/pow/function.go @@ -34,8 +34,8 @@ func (f *pow) Do(ctx context.Context, e parser.Expr, from, until int64, values m if e.ArgsLen() < 2 { return nil, parser.ErrMissingArgument } - - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/pow/function_test.go b/expr/functions/pow/function_test.go index 98bf41010..af58bace3 100644 --- a/expr/functions/pow/function_test.go +++ b/expr/functions/pow/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/powSeries/function.go b/expr/functions/powSeries/function.go index 5db4cb7ce..41bdfba9d 100644 --- a/expr/functions/powSeries/function.go +++ b/expr/functions/powSeries/function.go @@ -31,7 +31,7 @@ func New(_ string) []interfaces.FunctionMetadata { } func (f *powSeries) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - series, err := helper.GetSeriesArgs(ctx, e.Args(), from, until, values) + series, err := helper.GetSeriesArgs(ctx, f.GetEvaluator(), e.Args(), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/powSeries/function_test.go b/expr/functions/powSeries/function_test.go index d7947006b..26cb2e4e6 100644 --- a/expr/functions/powSeries/function_test.go +++ b/expr/functions/powSeries/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -17,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/randomWalk/function_test.go b/expr/functions/randomWalk/function_test.go index 4de779661..6dc5d47ea 100644 --- a/expr/functions/randomWalk/function_test.go +++ b/expr/functions/randomWalk/function_test.go @@ -3,7 +3,6 @@ package randomWalk import ( "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/rangeOfSeries/function.go b/expr/functions/rangeOfSeries/function.go index ded6ea926..360208c45 100644 --- a/expr/functions/rangeOfSeries/function.go +++ b/expr/functions/rangeOfSeries/function.go @@ -30,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // rangeOfSeries(*seriesLists) func (f *rangeOfSeries) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - series, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + series, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/rangeOfSeries/function_test.go b/expr/functions/rangeOfSeries/function_test.go index 5251034ee..5e4983838 100644 --- a/expr/functions/rangeOfSeries/function_test.go +++ b/expr/functions/rangeOfSeries/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/reduce/function.go b/expr/functions/reduce/function.go index 7f71175a3..76bc0a9e6 100644 --- a/expr/functions/reduce/function.go +++ b/expr/functions/reduce/function.go @@ -36,7 +36,7 @@ func (f *reduce) Do(ctx context.Context, e parser.Expr, from, until int64, value return nil, parser.ErrMissingArgument } - seriesList, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + seriesList, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/removeBelowSeries/function.go b/expr/functions/removeBelowSeries/function.go index 20f8d7927..d361c94bb 100644 --- a/expr/functions/removeBelowSeries/function.go +++ b/expr/functions/removeBelowSeries/function.go @@ -33,7 +33,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // removeBelowValue(seriesLists, n), removeAboveValue(seriesLists, n), removeBelowPercentile(seriesLists, percent), removeAbovePercentile(seriesLists, percent) func (f *removeBelowSeries) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/removeBelowSeries/function_test.go b/expr/functions/removeBelowSeries/function_test.go index 546dbff4a..8e4545c9b 100644 --- a/expr/functions/removeBelowSeries/function_test.go +++ b/expr/functions/removeBelowSeries/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/removeBetweenPercentile/function.go b/expr/functions/removeBetweenPercentile/function.go index 698557fe4..14384f7ac 100644 --- a/expr/functions/removeBetweenPercentile/function.go +++ b/expr/functions/removeBetweenPercentile/function.go @@ -36,7 +36,7 @@ func (f *removeBetweenPercentile) Do(ctx context.Context, e parser.Expr, from, u return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/removeBetweenPercentile/function_test.go b/expr/functions/removeBetweenPercentile/function_test.go index b2570b7d9..dd1450b50 100644 --- a/expr/functions/removeBetweenPercentile/function_test.go +++ b/expr/functions/removeBetweenPercentile/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/removeEmptySeries/function.go b/expr/functions/removeEmptySeries/function.go index 611fded1f..8367b9711 100644 --- a/expr/functions/removeEmptySeries/function.go +++ b/expr/functions/removeEmptySeries/function.go @@ -33,7 +33,7 @@ func New(configFile string) []interfaces.FunctionMetadata { func (f *removeEmptySeries) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { var xFilesFactor float64 - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/removeEmptySeries/function_test.go b/expr/functions/removeEmptySeries/function_test.go index ef1150d3f..d9f99bd31 100644 --- a/expr/functions/removeEmptySeries/function_test.go +++ b/expr/functions/removeEmptySeries/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/round/function.go b/expr/functions/round/function.go index 1dae20c0b..6e4f3e9de 100644 --- a/expr/functions/round/function.go +++ b/expr/functions/round/function.go @@ -30,7 +30,7 @@ func New(_ string) []interfaces.FunctionMetadata { // round(seriesList,precision) func (f *round) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/round/function_test.go b/expr/functions/round/function_test.go index e541b8f08..2b534b0b0 100644 --- a/expr/functions/round/function_test.go +++ b/expr/functions/round/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/scale/function.go b/expr/functions/scale/function.go index 6e0888be0..873e309a7 100644 --- a/expr/functions/scale/function.go +++ b/expr/functions/scale/function.go @@ -34,7 +34,7 @@ func (f *scale) Do(ctx context.Context, e parser.Expr, from, until int64, values return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/scale/function_test.go b/expr/functions/scale/function_test.go index ea6986b2b..098e7d2d5 100644 --- a/expr/functions/scale/function_test.go +++ b/expr/functions/scale/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -17,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/scaleToSeconds/function.go b/expr/functions/scaleToSeconds/function.go index 3da706902..1bc4e5012 100644 --- a/expr/functions/scaleToSeconds/function.go +++ b/expr/functions/scaleToSeconds/function.go @@ -34,7 +34,7 @@ func (f *scaleToSeconds) Do(ctx context.Context, e parser.Expr, from, until int6 return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/scaleToSeconds/function_test.go b/expr/functions/scaleToSeconds/function_test.go index 752fecd44..2b2f92b14 100644 --- a/expr/functions/scaleToSeconds/function_test.go +++ b/expr/functions/scaleToSeconds/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/seriesList/function.go b/expr/functions/seriesList/function.go index 7af9e7630..0e4fca694 100644 --- a/expr/functions/seriesList/function.go +++ b/expr/functions/seriesList/function.go @@ -43,7 +43,7 @@ func (f *seriesList) Do(ctx context.Context, e parser.Expr, from, until int64, v return nil, err } - numerators, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + numerators, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -56,7 +56,7 @@ func (f *seriesList) Do(ctx context.Context, e parser.Expr, from, until int64, v } } - denominators, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + denominators, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/seriesList/function_test.go b/expr/functions/seriesList/function_test.go index 0e8b4082a..343436a9e 100644 --- a/expr/functions/seriesList/function_test.go +++ b/expr/functions/seriesList/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/setXFilesFactor/function.go b/expr/functions/setXFilesFactor/function.go index e95148a94..bcab868e7 100644 --- a/expr/functions/setXFilesFactor/function.go +++ b/expr/functions/setXFilesFactor/function.go @@ -34,7 +34,7 @@ func (f *setXFilesFactor) Do(ctx context.Context, e parser.Expr, from, until int return nil, parser.ErrMissingArgument } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/setXFilesFactor/function_test.go b/expr/functions/setXFilesFactor/function_test.go index 45152fb86..3a6298f8b 100644 --- a/expr/functions/setXFilesFactor/function_test.go +++ b/expr/functions/setXFilesFactor/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/sigmoid/function.go b/expr/functions/sigmoid/function.go index 950d7679b..eea00d0b7 100644 --- a/expr/functions/sigmoid/function.go +++ b/expr/functions/sigmoid/function.go @@ -30,7 +30,7 @@ func New(_ string) []interfaces.FunctionMetadata { // sigmoid(seriesList) func (f *sigmoid) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/sigmoid/function_test.go b/expr/functions/sigmoid/function_test.go index 1ca0c0187..f6a7a709b 100644 --- a/expr/functions/sigmoid/function_test.go +++ b/expr/functions/sigmoid/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/sinFunction/function_test.go b/expr/functions/sinFunction/function_test.go index 8c7b4dfc8..6c64db8d7 100644 --- a/expr/functions/sinFunction/function_test.go +++ b/expr/functions/sinFunction/function_test.go @@ -3,7 +3,6 @@ package sinFunction import ( "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +13,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/slo/function.go b/expr/functions/slo/function.go index 729b9b818..cec6b53a3 100644 --- a/expr/functions/slo/function.go +++ b/expr/functions/slo/function.go @@ -38,7 +38,7 @@ func (f *slo) Do(ctx context.Context, e parser.Expr, from, until int64, values m ) // requested data points' window - argsWindowed, err = helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + argsWindowed, err = helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if len(argsWindowed) == 0 || err != nil { return nil, err } @@ -59,7 +59,7 @@ func (f *slo) Do(ctx context.Context, e parser.Expr, from, until int64, values m windowSize = until - from if bucketSize > windowSize && !(from == 0 && until == 1) { delta = bucketSize - windowSize - argsExtended, err = helper.GetSeriesArg(ctx, e.Arg(0), from-delta, until, values) + argsExtended, err = helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from-delta, until, values) if err != nil { return nil, err diff --git a/expr/functions/slo/function_test.go b/expr/functions/slo/function_test.go index b297cb15c..30fb14cdf 100644 --- a/expr/functions/slo/function_test.go +++ b/expr/functions/slo/function_test.go @@ -6,7 +6,6 @@ import ( th "github.com/go-graphite/carbonapi/tests" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/smartSummarize/function.go b/expr/functions/smartSummarize/function.go index 53cf5d8a9..f4d5efa58 100644 --- a/expr/functions/smartSummarize/function.go +++ b/expr/functions/smartSummarize/function.go @@ -51,7 +51,7 @@ func (f *smartSummarize) Do(ctx context.Context, e parser.Expr, from, until int6 } from = newStart } - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/smartSummarize/function_test.go b/expr/functions/smartSummarize/function_test.go index d04b848a2..3964a092f 100644 --- a/expr/functions/smartSummarize/function_test.go +++ b/expr/functions/smartSummarize/function_test.go @@ -5,7 +5,6 @@ import ( "strconv" "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/sortBy/function.go b/expr/functions/sortBy/function.go index a4808ef40..fb6a78e0d 100644 --- a/expr/functions/sortBy/function.go +++ b/expr/functions/sortBy/function.go @@ -32,7 +32,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // sortByMaxima(seriesList), sortByMinima(seriesList), sortByTotal(seriesList) func (f *sortBy) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - original, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + original, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/sortBy/function_test.go b/expr/functions/sortBy/function_test.go index d846b9d4e..91c72e7bb 100644 --- a/expr/functions/sortBy/function_test.go +++ b/expr/functions/sortBy/function_test.go @@ -1,11 +1,11 @@ package sortBy import ( - "github.com/go-graphite/carbonapi/expr/consolidations" "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" + "github.com/go-graphite/carbonapi/expr/consolidations" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/sortByName/function.go b/expr/functions/sortByName/function.go index 39f0f4f88..e63e69157 100644 --- a/expr/functions/sortByName/function.go +++ b/expr/functions/sortByName/function.go @@ -30,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // sortByName(seriesList, natural=false) func (f *sortByName) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - original, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + original, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/sortByName/function_test.go b/expr/functions/sortByName/function_test.go index 98e3a4db3..b0881049c 100644 --- a/expr/functions/sortByName/function_test.go +++ b/expr/functions/sortByName/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/squareRoot/function.go b/expr/functions/squareRoot/function.go index 90211683a..5432b60b7 100644 --- a/expr/functions/squareRoot/function.go +++ b/expr/functions/squareRoot/function.go @@ -30,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // squareRoot(seriesList) func (f *squareRoot) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/squareRoot/function_test.go b/expr/functions/squareRoot/function_test.go index 955d6f528..0876f380f 100644 --- a/expr/functions/squareRoot/function_test.go +++ b/expr/functions/squareRoot/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/stdev/function.go b/expr/functions/stdev/function.go index d0672436d..b2d31be71 100644 --- a/expr/functions/stdev/function.go +++ b/expr/functions/stdev/function.go @@ -33,7 +33,7 @@ func (f *stdev) Do(ctx context.Context, e parser.Expr, from, until int64, values return nil, parser.ErrMissingArgument } - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/stdev/function_test.go b/expr/functions/stdev/function_test.go index 4ffcadc34..7110898a2 100644 --- a/expr/functions/stdev/function_test.go +++ b/expr/functions/stdev/function_test.go @@ -1,21 +1,20 @@ package stdev import ( - "github.com/go-graphite/carbonapi/expr/helper" + "math" + "testing" + "time" + "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" th "github.com/go-graphite/carbonapi/tests" - "math" - "testing" - "time" ) func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/substr/function.go b/expr/functions/substr/function.go index b87f7bcf8..1d714c32e 100644 --- a/expr/functions/substr/function.go +++ b/expr/functions/substr/function.go @@ -32,7 +32,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // aliasSub(seriesList, start, stop) func (f *substr) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { // BUG: affected by the same positional arg issue as 'threshold'. - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/substr/function_test.go b/expr/functions/substr/function_test.go index d24edb056..bfbd0d03f 100644 --- a/expr/functions/substr/function_test.go +++ b/expr/functions/substr/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/summarize/function.go b/expr/functions/summarize/function.go index 02f9fa28d..27f95cddb 100644 --- a/expr/functions/summarize/function.go +++ b/expr/functions/summarize/function.go @@ -3,13 +3,14 @@ package summarize import ( "context" "fmt" + "math" + "github.com/go-graphite/carbonapi/expr/consolidations" "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" pb "github.com/go-graphite/protocol/carbonapi_v3_pb" - "math" ) type summarize struct { @@ -33,7 +34,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // summarize(seriesList, intervalString, func='sum', alignToFrom=False) func (f *summarize) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { // TODO(dgryski): make sure the arrays are all the same 'size' - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/summarize/function_test.go b/expr/functions/summarize/function_test.go index f0a126e2c..7bac877d4 100644 --- a/expr/functions/summarize/function_test.go +++ b/expr/functions/summarize/function_test.go @@ -4,7 +4,6 @@ import ( "math" "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/timeFunction/function_test.go b/expr/functions/timeFunction/function_test.go index fce86b07f..19ccad417 100644 --- a/expr/functions/timeFunction/function_test.go +++ b/expr/functions/timeFunction/function_test.go @@ -3,7 +3,6 @@ package timeFunction import ( "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +13,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/timeShift/function.go b/expr/functions/timeShift/function.go index bbe715279..f1d10e2a8 100644 --- a/expr/functions/timeShift/function.go +++ b/expr/functions/timeShift/function.go @@ -91,7 +91,7 @@ func (f *timeShift) Do(ctx context.Context, e parser.Expr, from, until int64, va } resetEndStr := strconv.FormatBool(resetEnd) - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from+int64(offs), until+int64(offs), values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from+int64(offs), until+int64(offs), values) if err != nil { return nil, err } diff --git a/expr/functions/timeShift/function_test.go b/expr/functions/timeShift/function_test.go index d864ad957..d2d50bbb2 100644 --- a/expr/functions/timeShift/function_test.go +++ b/expr/functions/timeShift/function_test.go @@ -3,7 +3,6 @@ package timeShift import ( "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +13,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/timeShiftByMetric/function.go b/expr/functions/timeShiftByMetric/function.go index 21b23e120..dcf44f73f 100644 --- a/expr/functions/timeShiftByMetric/function.go +++ b/expr/functions/timeShiftByMetric/function.go @@ -107,12 +107,12 @@ func (f *timeShiftByMetric) calculateOffsets(params *callParams, versions versio // extractCallParams (preliminarily) validates and extracts parameters of timeShiftByMetric's call as structure func (f *timeShiftByMetric) extractCallParams(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) (*callParams, error) { - metrics, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + metrics, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } - marks, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + marks, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/timeShiftByMetric/function_test.go b/expr/functions/timeShiftByMetric/function_test.go index 6f876e0c6..7ca6b2eba 100644 --- a/expr/functions/timeShiftByMetric/function_test.go +++ b/expr/functions/timeShiftByMetric/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -17,7 +16,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/timeSlice/function.go b/expr/functions/timeSlice/function.go index 504e6c4dc..a6a043151 100644 --- a/expr/functions/timeSlice/function.go +++ b/expr/functions/timeSlice/function.go @@ -48,7 +48,7 @@ func (f *timeSlice) Do(ctx context.Context, e parser.Expr, from, until int64, va startStr := strconv.FormatInt(start, 10) endStr := strconv.FormatInt(end, 10) - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/timeSlice/function_test.go b/expr/functions/timeSlice/function_test.go index 003dae45e..d9d00c2ad 100644 --- a/expr/functions/timeSlice/function_test.go +++ b/expr/functions/timeSlice/function_test.go @@ -4,7 +4,6 @@ import ( "math" "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/timeStack/function.go b/expr/functions/timeStack/function.go index 4f0111a91..73eb59528 100644 --- a/expr/functions/timeStack/function.go +++ b/expr/functions/timeStack/function.go @@ -52,7 +52,7 @@ func (f *timeStack) Do(ctx context.Context, e parser.Expr, from, until int64, va offs := i * int64(unit) fromNew := from + offs untilNew := until + offs - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), fromNew, untilNew, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), fromNew, untilNew, values) if err != nil { return nil, err } diff --git a/expr/functions/timeStack/function_test.go b/expr/functions/timeStack/function_test.go index e6eee06d4..27d364f9d 100644 --- a/expr/functions/timeStack/function_test.go +++ b/expr/functions/timeStack/function_test.go @@ -4,7 +4,6 @@ import ( "math" "testing" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/toLowerCase/function.go b/expr/functions/toLowerCase/function.go index 6298ed030..6362ec7fa 100644 --- a/expr/functions/toLowerCase/function.go +++ b/expr/functions/toLowerCase/function.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/go-graphite/carbonapi/expr/helper" - "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -31,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // toLowerCase(seriesList, *pos) func (f *toLowerCase) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/toLowerCase/function_test.go b/expr/functions/toLowerCase/function_test.go index 2e7d8c0a9..80d5e1a7b 100644 --- a/expr/functions/toLowerCase/function_test.go +++ b/expr/functions/toLowerCase/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/toUpperCase/function.go b/expr/functions/toUpperCase/function.go index fb39e401a..f6bc3b783 100644 --- a/expr/functions/toUpperCase/function.go +++ b/expr/functions/toUpperCase/function.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/go-graphite/carbonapi/expr/helper" - "github.com/go-graphite/carbonapi/expr/interfaces" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -31,7 +30,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // toUpperCase(seriesList, *pos) func (f *toUpperCase) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/toUpperCase/function_test.go b/expr/functions/toUpperCase/function_test.go index efdcf43c4..2af29d17f 100644 --- a/expr/functions/toUpperCase/function_test.go +++ b/expr/functions/toUpperCase/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/transformNull/function.go b/expr/functions/transformNull/function.go index 678151d98..e22d6d39d 100644 --- a/expr/functions/transformNull/function.go +++ b/expr/functions/transformNull/function.go @@ -35,7 +35,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // transformNull(seriesList, default=0) func (f *transformNull) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -57,7 +57,7 @@ func (f *transformNull) Do(ctx context.Context, e parser.Expr, from, until int64 var valMap []bool referenceSeriesExpr := e.GetNamedArg("referenceSeries") if !referenceSeriesExpr.IsInterfaceNil() { - referenceSeries, err := helper.GetSeriesArg(ctx, referenceSeriesExpr, from, until, values) + referenceSeries, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), referenceSeriesExpr, from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/transformNull/function_test.go b/expr/functions/transformNull/function_test.go index d548b5a7f..27cf636a1 100644 --- a/expr/functions/transformNull/function_test.go +++ b/expr/functions/transformNull/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/tukey/function.go b/expr/functions/tukey/function.go index 11041476a..62ea8b6dc 100644 --- a/expr/functions/tukey/function.go +++ b/expr/functions/tukey/function.go @@ -34,7 +34,7 @@ func New(configFile string) []interfaces.FunctionMetadata { // tukeyAbove(seriesList,basis,n,interval=0) , tukeyBelow(seriesList,basis,n,interval=0) func (f *tukey) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/tukey/function_test.go b/expr/functions/tukey/function_test.go index 4690880c5..414f92e7b 100644 --- a/expr/functions/tukey/function_test.go +++ b/expr/functions/tukey/function_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -15,7 +14,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/unique/function.go b/expr/functions/unique/function.go index d0418868d..694efc192 100644 --- a/expr/functions/unique/function.go +++ b/expr/functions/unique/function.go @@ -29,7 +29,7 @@ func New(_ string) []interfaces.FunctionMetadata { // unique(seriesList) func (f *unique) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - arg, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + arg, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/unique/function_test.go b/expr/functions/unique/function_test.go index fff4087fe..6d675181a 100644 --- a/expr/functions/unique/function_test.go +++ b/expr/functions/unique/function_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -16,7 +15,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/verticalLine/function_test.go b/expr/functions/verticalLine/function_test.go index 0fb31101f..a8cb6481c 100644 --- a/expr/functions/verticalLine/function_test.go +++ b/expr/functions/verticalLine/function_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/tags" "github.com/go-graphite/carbonapi/expr/types" @@ -21,7 +20,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/functions/weightedAverage/function.go b/expr/functions/weightedAverage/function.go index 6d55a728e..002084e95 100644 --- a/expr/functions/weightedAverage/function.go +++ b/expr/functions/weightedAverage/function.go @@ -38,12 +38,12 @@ func (f *weightedAverage) Do(ctx context.Context, e parser.Expr, from, until int aggKeyPairs := make(map[string]map[string]*types.MetricData) var productList []*types.MetricData - avgs, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + avgs, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return nil, err } - weights, err := helper.GetSeriesArg(ctx, e.Arg(1), from, until, values) + weights, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(1), from, until, values) if err != nil { return nil, err } diff --git a/expr/functions/weightedAverage/function_test.go b/expr/functions/weightedAverage/function_test.go index 6f5bbde6e..e7cd4fc8e 100644 --- a/expr/functions/weightedAverage/function_test.go +++ b/expr/functions/weightedAverage/function_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -19,7 +18,6 @@ func init() { md := New("") evaluator := th.EvaluatorFromFunc(md[0].F) metadata.SetEvaluator(evaluator) - helper.SetEvaluator(evaluator) for _, m := range md { metadata.RegisterFunction(m.Name, m.F) } diff --git a/expr/helper/helper.go b/expr/helper/helper.go index 925c9f2c9..af7444425 100644 --- a/expr/helper/helper.go +++ b/expr/helper/helper.go @@ -12,8 +12,6 @@ import ( "github.com/go-graphite/carbonapi/pkg/parser" ) -var evaluator interfaces.Evaluator - // Backref is a pre-compiled expression for backref var Backref = regexp.MustCompile(`\\(\d+)`) @@ -24,18 +22,13 @@ func (e ErrUnknownFunction) Error() string { return fmt.Sprintf("unknown function in evalExpr: %q", string(e)) } -// SetEvaluator sets evaluator for all helper functions -func SetEvaluator(e interfaces.Evaluator) { - evaluator = e -} - // GetSeriesArg returns argument from series. -func GetSeriesArg(ctx context.Context, arg parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { +func GetSeriesArg(ctx context.Context, eval interfaces.Evaluator, arg parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { if !arg.IsName() && !arg.IsFunc() { return nil, parser.ErrMissingTimeseries } - a, err := evaluator.Eval(ctx, arg, from, until, values) + a, err := eval.Eval(ctx, arg, from, until, values) if err != nil { return nil, err } @@ -54,11 +47,11 @@ func RemoveEmptySeriesFromName(args []*types.MetricData) string { } // GetSeriesArgs returns arguments of series -func GetSeriesArgs(ctx context.Context, e []parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { +func GetSeriesArgs(ctx context.Context, eval interfaces.Evaluator, e []parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { var args []*types.MetricData for _, arg := range e { - a, err := GetSeriesArg(ctx, arg, from, until, values) + a, err := GetSeriesArg(ctx, eval, arg, from, until, values) if err != nil { return nil, err } @@ -74,8 +67,8 @@ func GetSeriesArgs(ctx context.Context, e []parser.Expr, from, until int64, valu // GetSeriesArgsAndRemoveNonExisting will fetch all required arguments, but will also filter out non existing Series // This is needed to be graphite-web compatible in cases when you pass non-existing Series to, for example, sumSeries -func GetSeriesArgsAndRemoveNonExisting(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { - args, err := GetSeriesArgs(ctx, e.Args(), from, until, values) +func GetSeriesArgsAndRemoveNonExisting(ctx context.Context, eval interfaces.Evaluator, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) { + args, err := GetSeriesArgs(ctx, eval, e.Args(), from, until, values) if err != nil { return nil, err } @@ -118,8 +111,8 @@ func AggKey(arg *types.MetricData, nodesOrTags []parser.NodeOrTag) string { type seriesFunc1 func(*types.MetricData) *types.MetricData // ForEachSeriesDo do action for each serie in list. -func ForEachSeriesDo1(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData, function seriesFunc1) ([]*types.MetricData, error) { - arg, err := GetSeriesArg(ctx, e.Arg(0), from, until, values) +func ForEachSeriesDo1(ctx context.Context, eval interfaces.Evaluator, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData, function seriesFunc1) ([]*types.MetricData, error) { + arg, err := GetSeriesArg(ctx, eval, e.Arg(0), from, until, values) if err != nil { return nil, err } @@ -135,8 +128,8 @@ func ForEachSeriesDo1(ctx context.Context, e parser.Expr, from, until int64, val type seriesFunc func(*types.MetricData, *types.MetricData) *types.MetricData // ForEachSeriesDo do action for each serie in list. -func ForEachSeriesDo(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData, function seriesFunc) ([]*types.MetricData, error) { - arg, err := GetSeriesArg(ctx, e.Arg(0), from, until, values) +func ForEachSeriesDo(ctx context.Context, eval interfaces.Evaluator, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData, function seriesFunc) ([]*types.MetricData, error) { + arg, err := GetSeriesArg(ctx, eval, e.Arg(0), from, until, values) if err != nil { return nil, err } diff --git a/expr/rewrite/aboveSeries/function.go b/expr/rewrite/aboveSeries/function.go index c197656ab..fa2b97be8 100644 --- a/expr/rewrite/aboveSeries/function.go +++ b/expr/rewrite/aboveSeries/function.go @@ -31,7 +31,7 @@ func New(configFile string) []interfaces.RewriteFunctionMetadata { } func (f *aboveSeries) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) (bool, []string, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return false, nil, err } diff --git a/expr/rewrite/aboveSeries/function_test.go b/expr/rewrite/aboveSeries/function_test.go index d61f105d7..9614df411 100644 --- a/expr/rewrite/aboveSeries/function_test.go +++ b/expr/rewrite/aboveSeries/function_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" - "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +12,6 @@ import ( func init() { evaluator := th.DummyEvaluator() - helper.SetEvaluator(evaluator) metadata.SetEvaluator(evaluator) md := New("") diff --git a/expr/rewrite/applyByNode/function.go b/expr/rewrite/applyByNode/function.go index 73c0acc04..a2a7d34dc 100644 --- a/expr/rewrite/applyByNode/function.go +++ b/expr/rewrite/applyByNode/function.go @@ -29,7 +29,7 @@ func New(configFile string) []interfaces.RewriteFunctionMetadata { } func (f *applyByNode) Do(ctx context.Context, e parser.Expr, from, until int64, values map[parser.MetricRequest][]*types.MetricData) (bool, []string, error) { - args, err := helper.GetSeriesArg(ctx, e.Arg(0), from, until, values) + args, err := helper.GetSeriesArg(ctx, f.GetEvaluator(), e.Arg(0), from, until, values) if err != nil { return false, nil, err } diff --git a/expr/rewrite/applyByNode/function_test.go b/expr/rewrite/applyByNode/function_test.go index f60ee5819..2b6352ef8 100644 --- a/expr/rewrite/applyByNode/function_test.go +++ b/expr/rewrite/applyByNode/function_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "github.com/go-graphite/carbonapi/expr/helper" - "github.com/go-graphite/carbonapi/expr/metadata" "github.com/go-graphite/carbonapi/expr/types" "github.com/go-graphite/carbonapi/pkg/parser" @@ -14,7 +12,6 @@ import ( func init() { evaluator := th.DummyEvaluator() - helper.SetEvaluator(evaluator) metadata.SetEvaluator(evaluator) md := New("") diff --git a/cmd/carbonapi/interfaces/zipper.go b/zipper/interfaces/zipper.go similarity index 100% rename from cmd/carbonapi/interfaces/zipper.go rename to zipper/interfaces/zipper.go