aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/envoyproxy/go-control-plane/pkg/cache/v3/status.go
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2024-01-30 11:20:39 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2024-01-30 12:12:51 +0300
commitbe737fd8956853e06bd2c4f9fcd4a85188f4c172 (patch)
tree5bd76802fac1096dfd90983c7739d50de367a79f /vendor/github.com/envoyproxy/go-control-plane/pkg/cache/v3/status.go
parentfe62880c46b1f2c9fec779b0dc39f8a92ce256a5 (diff)
downloadydb-be737fd8956853e06bd2c4f9fcd4a85188f4c172.tar.gz
Update vendor/github.com/envoyproxy/go-control-plane to 0.12.0
Diffstat (limited to 'vendor/github.com/envoyproxy/go-control-plane/pkg/cache/v3/status.go')
-rw-r--r--vendor/github.com/envoyproxy/go-control-plane/pkg/cache/v3/status.go54
1 files changed, 48 insertions, 6 deletions
diff --git a/vendor/github.com/envoyproxy/go-control-plane/pkg/cache/v3/status.go b/vendor/github.com/envoyproxy/go-control-plane/pkg/cache/v3/status.go
index 84db1f9821..dca93e02ff 100644
--- a/vendor/github.com/envoyproxy/go-control-plane/pkg/cache/v3/status.go
+++ b/vendor/github.com/envoyproxy/go-control-plane/pkg/cache/v3/status.go
@@ -15,6 +15,7 @@
package cache
import (
+ "sort"
"sync"
"time"
@@ -36,7 +37,7 @@ func (IDHash) ID(node *core.Node) string {
if node == nil {
return ""
}
- return node.Id
+ return node.GetId()
}
var _ NodeHash = IDHash{}
@@ -65,10 +66,12 @@ type statusInfo struct {
node *core.Node
// watches are indexed channels for the response watches and the original requests.
- watches map[int64]ResponseWatch
+ watches map[int64]ResponseWatch
+ orderedWatches keys
// deltaWatches are indexed channels for the delta response watches and the original requests
- deltaWatches map[int64]DeltaResponseWatch
+ deltaWatches map[int64]DeltaResponseWatch
+ orderedDeltaWatches keys
// the timestamp of the last watch request
lastWatchRequestTime time.Time
@@ -105,9 +108,10 @@ type DeltaResponseWatch struct {
// newStatusInfo initializes a status info data structure.
func newStatusInfo(node *core.Node) *statusInfo {
out := statusInfo{
- node: node,
- watches: make(map[int64]ResponseWatch),
- deltaWatches: make(map[int64]DeltaResponseWatch),
+ node: node,
+ watches: make(map[int64]ResponseWatch),
+ orderedWatches: make(keys, 0),
+ deltaWatches: make(map[int64]DeltaResponseWatch),
}
return &out
}
@@ -155,3 +159,41 @@ func (info *statusInfo) setDeltaResponseWatch(id int64, drw DeltaResponseWatch)
defer info.mu.Unlock()
info.deltaWatches[id] = drw
}
+
+// orderResponseWatches will track a list of watch keys and order them if
+// true is passed.
+func (info *statusInfo) orderResponseWatches() {
+ info.orderedWatches = make(keys, len(info.watches))
+
+ var index int
+ for id, watch := range info.watches {
+ info.orderedWatches[index] = key{
+ ID: id,
+ TypeURL: watch.Request.GetTypeUrl(),
+ }
+ index++
+ }
+
+ // Sort our list which we can use in the SetSnapshot functions.
+ // This is only run when we enable ADS on the cache.
+ sort.Sort(info.orderedWatches)
+}
+
+// orderResponseDeltaWatches will track a list of delta watch keys and order them if
+// true is passed.
+func (info *statusInfo) orderResponseDeltaWatches() {
+ info.orderedDeltaWatches = make(keys, len(info.deltaWatches))
+
+ var index int
+ for id, deltaWatch := range info.deltaWatches {
+ info.orderedDeltaWatches[index] = key{
+ ID: id,
+ TypeURL: deltaWatch.Request.GetTypeUrl(),
+ }
+ index++
+ }
+
+ // Sort our list which we can use in the SetSnapshot functions.
+ // This is only run when we enable ADS on the cache.
+ sort.Sort(info.orderedDeltaWatches)
+}