forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eval_int_node.go
34 lines (26 loc) · 1.07 KB
/
eval_int_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
package stateful
import (
"regexp"
"github.com/influxdata/kapacitor/tick"
)
type EvalIntNode struct {
Int64 int64
}
func (n *EvalIntNode) Type(scope ReadOnlyScope, executionState ExecutionState) (ValueType, error) {
return TInt64, nil
}
func (n *EvalIntNode) EvalFloat(scope *tick.Scope, executionState ExecutionState) (float64, error) {
return float64(0), ErrTypeGuardFailed{RequestedType: TFloat64, ActualType: TInt64}
}
func (n *EvalIntNode) EvalInt(scope *tick.Scope, executionState ExecutionState) (int64, error) {
return n.Int64, nil
}
func (n *EvalIntNode) EvalString(scope *tick.Scope, executionState ExecutionState) (string, error) {
return "", ErrTypeGuardFailed{RequestedType: TString, ActualType: TInt64}
}
func (n *EvalIntNode) EvalBool(scope *tick.Scope, executionState ExecutionState) (bool, error) {
return false, ErrTypeGuardFailed{RequestedType: TBool, ActualType: TInt64}
}
func (n *EvalIntNode) EvalRegex(scope *tick.Scope, executionState ExecutionState) (*regexp.Regexp, error) {
return nil, ErrTypeGuardFailed{RequestedType: TRegex, ActualType: TInt64}
}