/
enum_statics.go
97 lines (80 loc) · 1.71 KB
/
enum_statics.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package traceql
import "fmt"
type StaticType int
const (
TypeNil StaticType = iota
TypeSpanset // type used by spanset pipelines
TypeAttribute // a special constant that indicates the type is determined at query time by the attribute
TypeInt
TypeFloat
TypeString
TypeBoolean
TypeDuration
TypeStatus
TypeKind
)
// isMatchingOperand returns whether two types can be combined with a binary operator. the kind of operator is
// immaterial. see Operator.typesValid() for code that determines if the passed types are valid for the given
// operator.
func (t StaticType) isMatchingOperand(otherT StaticType) bool {
if t == TypeAttribute || otherT == TypeAttribute {
return true
}
if t == otherT {
return true
}
if t.isNumeric() && otherT.isNumeric() {
return true
}
if otherT == TypeNil {
return true
}
return false
}
func (t StaticType) isNumeric() bool {
return t == TypeInt || t == TypeFloat || t == TypeDuration
}
// Status represents valid static values of typeStatus
type Status int
const (
StatusError Status = iota
StatusOk
StatusUnset
)
func (s Status) String() string {
switch s {
case StatusError:
return "error"
case StatusOk:
return "ok"
case StatusUnset:
return "unset"
}
return fmt.Sprintf("status(%d)", s)
}
type Kind int
const (
KindUnspecified Kind = iota
KindInternal
KindClient
KindServer
KindProducer
KindConsumer
)
func (k Kind) String() string {
switch k {
case KindUnspecified:
return "unspecified"
case KindInternal:
return "internal"
case KindClient:
return "client"
case KindServer:
return "server"
case KindProducer:
return "producer"
case KindConsumer:
return "consumer"
}
return fmt.Sprintf("kind(%d)", k)
}