This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
/
types.go
168 lines (138 loc) · 4.16 KB
/
types.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// argument types. to let functions describe their inputs and outputs
package expr
import "regexp"
// Arg is an argument to a GraphiteFunc
// note how every implementation has a val property.
// this property should point to value accessible to the function.
// the value will be set up by the planner; it assures that
// by the time Func.Exec() is called, the function has access to all
// needed inputs, whether simple values, or in the case of ArgSeries*
// inputs other functions to call which will feed it data.
type Arg interface {
Key() string
Optional() bool
}
// ArgIn is a special type that allows one of multiple arguments
type ArgIn struct {
key string
opt bool
args []Arg
}
func (a ArgIn) Key() string { return a.key }
func (a ArgIn) Optional() bool { return a.opt }
// ArgSeries is a single series argument
// not generally used as input since graphite functions typically take multiple series as input
// but is useful to describe output
type ArgSeries struct {
key string
opt bool
val *GraphiteFunc
}
func (a ArgSeries) Key() string { return a.key }
func (a ArgSeries) Optional() bool { return a.opt }
// ArgSeriesList is a list of series argument, it can be 0..N series
type ArgSeriesList struct {
key string
opt bool
val *GraphiteFunc
}
func (a ArgSeriesList) Key() string { return a.key }
func (a ArgSeriesList) Optional() bool { return a.opt }
// ArgSeriesLists represents one or more lists of series inputs.
type ArgSeriesLists struct {
key string
opt bool
val *[]GraphiteFunc
}
func (a ArgSeriesLists) Key() string { return a.key }
func (a ArgSeriesLists) Optional() bool { return a.opt }
// ArgInt is a number without decimals
type ArgInt struct {
key string
opt bool
validator []Validator
val *int64
}
func (a ArgInt) Key() string { return a.key }
func (a ArgInt) Optional() bool { return a.opt }
// ArgInts represents one or more numbers without decimals
type ArgInts struct {
key string
opt bool
validator []Validator
val *[]int64
}
func (a ArgInts) Key() string { return a.key }
func (a ArgInts) Optional() bool { return a.opt }
// floating point number; potentially with decimals
type ArgFloat struct {
key string
opt bool
validator []Validator
val *float64
}
func (a ArgFloat) Key() string { return a.key }
func (a ArgFloat) Optional() bool { return a.opt }
// string
type ArgString struct {
key string
opt bool
validator []Validator
val *string
}
func (a ArgString) Key() string { return a.key }
func (a ArgString) Optional() bool { return a.opt }
// ArgStrings represents one or more strings
type ArgStrings struct {
key string
opt bool
validator []Validator
val *[]string
}
func (a ArgStrings) Key() string { return a.key }
func (a ArgStrings) Optional() bool { return a.opt }
// like string, but should result in a regex
type ArgRegex struct {
key string
opt bool
validator []Validator
val **regexp.Regexp
}
func (a ArgRegex) Key() string { return a.key }
func (a ArgRegex) Optional() bool { return a.opt }
// True or False
type ArgBool struct {
key string
opt bool
val *bool
}
func (a ArgBool) Key() string { return a.key }
func (a ArgBool) Optional() bool { return a.opt }
// Array of mixed strings or ints
type ArgStringsOrInts struct {
key string
opt bool
validator []Validator
val *[]expr
}
func (a ArgStringsOrInts) Key() string { return a.key }
func (a ArgStringsOrInts) Optional() bool { return a.opt }
// mixed string or int
type ArgStringOrInt struct {
key string
opt bool
validator []Validator
val *expr
}
func (a ArgStringOrInt) Key() string { return a.key }
func (a ArgStringOrInt) Optional() bool { return a.opt }
// When an argument is a special value without quotes (such as None or INF)
// This should NOT be used together with ArgSeries, ArgSeriesList, ArgSeriesLists inside an ArgIn as that causes ambiguity
type ArgQuotelessString struct {
key string
opt bool
validator []Validator
val *string
}
func (a ArgQuotelessString) Key() string { return a.key }
func (a ArgQuotelessString) Optional() bool { return a.opt }