-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathinterval_aggregation_clone.go
65 lines (50 loc) · 1.32 KB
/
interval_aggregation_clone.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
package health
// Clone does a deep clone of ia, duplicating all maps and whatnot.
func (ia *IntervalAggregation) Clone() *IntervalAggregation {
dup := &IntervalAggregation{}
dup.IntervalStart = ia.IntervalStart
dup.SerialNumber = ia.SerialNumber
dup.aggregationMaps = *ia.aggregationMaps.Clone()
dup.Jobs = make(map[string]*JobAggregation)
for k, v := range ia.Jobs {
dup.Jobs[k] = v.Clone()
}
return dup
}
func (am *aggregationMaps) Clone() *aggregationMaps {
dup := &aggregationMaps{}
dup.initAggregationMaps()
for k, v := range am.Events {
dup.Events[k] = v
}
for k, v := range am.Gauges {
dup.Gauges[k] = v
}
for k, v := range am.Timers {
dup.Timers[k] = v.Clone()
}
for k, v := range am.EventErrs {
dup.EventErrs[k] = v.Clone()
}
return dup
}
func (ta *TimerAggregation) Clone() *TimerAggregation {
var dup = *ta
return &dup
}
func (ec *ErrorCounter) Clone() *ErrorCounter {
var dup = *ec
return &dup
}
func (ja *JobAggregation) Clone() *JobAggregation {
dup := &JobAggregation{
CountSuccess: ja.CountSuccess,
CountValidationError: ja.CountValidationError,
CountPanic: ja.CountPanic,
CountError: ja.CountError,
CountJunk: ja.CountJunk,
}
dup.aggregationMaps = *ja.aggregationMaps.Clone()
dup.TimerAggregation = ja.TimerAggregation
return dup
}