/
function.go
56 lines (49 loc) · 1.56 KB
/
function.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package group
import (
"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"
)
type group struct {
interfaces.FunctionBase
}
func GetOrder() interfaces.Order {
return interfaces.Any
}
func New(configFile string) []interfaces.FunctionMetadata {
res := make([]interfaces.FunctionMetadata, 0)
f := &group{}
functions := []string{"group"}
for _, n := range functions {
res = append(res, interfaces.FunctionMetadata{Name: n, F: f})
}
return res
}
// group(*seriesLists)
func (f *group) Do(e parser.Expr, from, until int32, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error) {
args, err := helper.GetSeriesArgsAndRemoveNonExisting(e, from, until, values)
if err != nil {
return nil, err
}
return args, nil
}
// Description is auto-generated description, based on output of https://github.com/graphite-project/graphite-web
func (f *group) Description() map[string]types.FunctionDescription {
return map[string]types.FunctionDescription{
"group": {
Description: "Takes an arbitrary number of seriesLists and adds them to a single seriesList. This is used\nto pass multiple seriesLists to a function which only takes one",
Function: "group(*seriesLists)",
Group: "Combine",
Module: "graphite.render.functions",
Name: "group",
Params: []types.FunctionParam{
{
Multiple: true,
Name: "seriesLists",
Type: types.SeriesList,
},
},
},
}
}