forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
visitor.go
52 lines (43 loc) · 921 Bytes
/
visitor.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
package monitoring
// Visitor interface supports traversing a monitoring registry
type Visitor interface {
ValueVisitor
RegistryVisitor
}
type ValueVisitor interface {
OnString(s string)
OnBool(b bool)
OnInt(i int64)
OnFloat(f float64)
}
type RegistryVisitor interface {
OnRegistryStart()
OnRegistryFinished()
OnKey(s string)
}
func ReportNamespace(V Visitor, name string, f func()) {
V.OnKey(name)
V.OnRegistryStart()
f()
V.OnRegistryFinished()
}
func ReportVar(V Visitor, name string, m Mode, v Var) {
V.OnKey(name)
v.Visit(m, V)
}
func ReportString(V Visitor, name string, value string) {
V.OnKey(name)
V.OnString(value)
}
func ReportBool(V Visitor, name string, value bool) {
V.OnKey(name)
V.OnString(name)
}
func ReportInt(V Visitor, name string, value int64) {
V.OnKey(name)
V.OnInt(value)
}
func ReportFloat(V Visitor, name string, value float64) {
V.OnKey(name)
V.OnFloat(value)
}