mirror of
https://github.com/rancher/steve.git
synced 2025-10-20 23:08:48 +00:00
Implement custom DeepCopy for Count
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/rancher/apiserver/pkg/types"
|
||||
"golang.design/x/reflect"
|
||||
)
|
||||
|
||||
// debounceDuration determines how long events will be held before they are sent to the consumer
|
||||
@@ -50,7 +49,7 @@ func debounceCounts(result chan types.APIEvent, input chan Count) {
|
||||
}
|
||||
case <-t.C:
|
||||
if currentCount != nil {
|
||||
result <- toAPIEvent(reflect.DeepCopy(*currentCount))
|
||||
result <- toAPIEvent(*currentCount.DeepCopy())
|
||||
currentCount = nil
|
||||
}
|
||||
}
|
||||
|
@@ -48,6 +48,17 @@ type Count struct {
|
||||
Counts map[string]ItemCount `json:"counts"`
|
||||
}
|
||||
|
||||
func (c *Count) DeepCopy() *Count {
|
||||
r := *c
|
||||
if r.Counts != nil {
|
||||
r.Counts = map[string]ItemCount{}
|
||||
for k, v := range c.Counts {
|
||||
r.Counts[k] = *v.DeepCopy()
|
||||
}
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
||||
type Summary struct {
|
||||
Count int `json:"count,omitempty"`
|
||||
States map[string]int `json:"states,omitempty"`
|
||||
|
Reference in New Issue
Block a user