forked from bookingcom/carbonapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inteface.go
61 lines (50 loc) · 1.58 KB
/
inteface.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
57
58
59
60
61
package interfaces
import (
"github.com/bookingcom/carbonapi/expr/types"
"github.com/bookingcom/carbonapi/pkg/parser"
)
// FunctionBase is a set of base methods that partly satisfy Function interface and most probably nobody will modify
type FunctionBase struct {
Evaluator Evaluator
}
// SetEvaluator sets evaluator
func (b *FunctionBase) SetEvaluator(evaluator Evaluator) {
b.Evaluator = evaluator
}
// GetEvaluator returns evaluator
func (b *FunctionBase) GetEvaluator() Evaluator {
return b.Evaluator
}
// Evaluator is a interface for any existing expression parser
type Evaluator interface {
EvalExpr(e parser.Expr, from, until int32, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error)
}
type Order int
const (
Any Order = iota
Last
)
type RewriteFunctionMetadata struct {
Name string
Order Order
F RewriteFunction
}
type FunctionMetadata struct {
Name string
Order Order
F Function
}
// Function is interface that all graphite functions should follow
type Function interface {
SetEvaluator(evaluator Evaluator)
GetEvaluator() Evaluator
Do(e parser.Expr, from, until int32, values map[parser.MetricRequest][]*types.MetricData) ([]*types.MetricData, error)
Description() map[string]types.FunctionDescription
}
// Function is interface that all graphite functions should follow
type RewriteFunction interface {
SetEvaluator(evaluator Evaluator)
GetEvaluator() Evaluator
Do(e parser.Expr, from, until int32, values map[parser.MetricRequest][]*types.MetricData) (bool, []string, error)
Description() map[string]types.FunctionDescription
}