-
Notifications
You must be signed in to change notification settings - Fork 495
/
eval_duration_node.go
57 lines (43 loc) · 1.86 KB
/
eval_duration_node.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
package stateful
import (
"fmt"
"regexp"
"time"
"github.com/influxdata/kapacitor/tick/ast"
)
type EvalDurationNode struct {
Duration time.Duration
}
func (n *EvalDurationNode) String() string {
return fmt.Sprintf("%v", n.Duration)
}
func (n *EvalDurationNode) Type(scope ReadOnlyScope) (ast.ValueType, error) {
return ast.TDuration, nil
}
func (n *EvalDurationNode) EvalFloat(scope *Scope, executionState ExecutionState) (float64, error) {
return float64(0), ErrTypeGuardFailed{RequestedType: ast.TFloat, ActualType: ast.TDuration}
}
func (n *EvalDurationNode) EvalInt(scope *Scope, executionState ExecutionState) (int64, error) {
return 0, ErrTypeGuardFailed{RequestedType: ast.TInt, ActualType: ast.TDuration}
}
func (n *EvalDurationNode) EvalString(scope *Scope, executionState ExecutionState) (string, error) {
return "", ErrTypeGuardFailed{RequestedType: ast.TString, ActualType: ast.TDuration}
}
func (n *EvalDurationNode) EvalBool(scope *Scope, executionState ExecutionState) (bool, error) {
return false, ErrTypeGuardFailed{RequestedType: ast.TBool, ActualType: ast.TDuration}
}
func (n *EvalDurationNode) EvalRegex(scope *Scope, executionState ExecutionState) (*regexp.Regexp, error) {
return nil, ErrTypeGuardFailed{RequestedType: ast.TRegex, ActualType: ast.TDuration}
}
func (n *EvalDurationNode) EvalTime(scope *Scope, executionState ExecutionState) (time.Time, error) {
return time.Time{}, ErrTypeGuardFailed{RequestedType: ast.TTime, ActualType: ast.TDuration}
}
func (n *EvalDurationNode) EvalDuration(scope *Scope, executionState ExecutionState) (time.Duration, error) {
return n.Duration, nil
}
func (n *EvalDurationNode) EvalMissing(scope *Scope, executionState ExecutionState) (*ast.Missing, error) {
return nil, ErrTypeGuardFailed{RequestedType: ast.TMissing, ActualType: ast.TDuration}
}
func (n *EvalDurationNode) IsDynamic() bool {
return false
}