diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-01-31 17:22:33 +0300 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-01-31 17:22:33 +0300 |
commit | 52be5dbdd420165c68e7e90ba8f1d2f00da041f6 (patch) | |
tree | 5d47f5b2ff4e6a7c8e75d33931a1e683949b7229 /vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream | |
parent | ea57c8867ceca391357c3c5ffcc5ba6738b49adc (diff) | |
parent | 809f0cf2fdfddfbeacc2256ffdbaaf5808ce5ed4 (diff) | |
download | ydb-52be5dbdd420165c68e7e90ba8f1d2f00da041f6.tar.gz |
Merge branch 'mergelibs12' into main
Diffstat (limited to 'vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream')
-rw-r--r-- | vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/stream.go | 71 | ||||
-rw-r--r-- | vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/ya.make | 4 |
2 files changed, 45 insertions, 30 deletions
diff --git a/vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/stream.go b/vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/stream.go index b5832b7d58..1664a941e0 100644 --- a/vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/stream.go +++ b/vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/stream.go @@ -6,7 +6,7 @@ import ( discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" ) -// Generic RPC stream. +// Generic RPC stream for state of the world. type Stream interface { grpc.ServerStream @@ -14,6 +14,7 @@ type Stream interface { Recv() (*discovery.DiscoveryRequest, error) } +// Generic RPC Stream for the delta based xDS protocol. type DeltaStream interface { grpc.ServerStream @@ -21,7 +22,7 @@ type DeltaStream interface { Recv() (*discovery.DeltaDiscoveryRequest, error) } -// StreamState will keep track of resource state per type on a stream. +// StreamState will keep track of resource cache state per type on a stream. type StreamState struct { // nolint:golint,revive // Indicates whether the delta stream currently has a wildcard watch wildcard bool @@ -34,11 +35,32 @@ type StreamState struct { // nolint:golint,revive // This field stores the last state sent to the client. resourceVersions map[string]string - // knownResourceNames contains resource names that a client has received previously + // knownResourceNames contains resource names that a client has received previously (SOTW). knownResourceNames map[string]map[string]struct{} - // indicates whether the object has been modified since its creation + // First indicates whether the StreamState has been modified since its creation first bool + + // Ordered indicates whether we want an ordered ADS stream or not + ordered bool +} + +// NewStreamState initializes a stream state. +func NewStreamState(wildcard bool, initialResourceVersions map[string]string) StreamState { + state := StreamState{ + wildcard: wildcard, + subscribedResourceNames: map[string]struct{}{}, + resourceVersions: initialResourceVersions, + first: true, + knownResourceNames: map[string]map[string]struct{}{}, + ordered: false, // Ordered comes from the first request since that's when we discover if they want ADS + } + + if initialResourceVersions == nil { + state.resourceVersions = make(map[string]string) + } + + return state } // GetSubscribedResourceNames returns the list of resources currently explicitly subscribed to @@ -71,31 +93,43 @@ func (s *StreamState) WatchesResources(resourceNames map[string]struct{}) bool { return false } +func (s *StreamState) SetWildcard(wildcard bool) { + s.wildcard = wildcard +} + +// GetResourceVersions returns a map of current resources grouped by type URL. func (s *StreamState) GetResourceVersions() map[string]string { return s.resourceVersions } +// SetResourceVersions sets a list of resource versions by type URL and removes the flag +// of "first" since we can safely assume another request has come through the stream. func (s *StreamState) SetResourceVersions(resourceVersions map[string]string) { s.first = false s.resourceVersions = resourceVersions } +// IsFirst returns whether or not the state of the stream is based upon the initial request. func (s *StreamState) IsFirst() bool { return s.first } -func (s *StreamState) SetWildcard(wildcard bool) { - s.wildcard = wildcard -} - +// IsWildcard returns whether or not an xDS client requested in wildcard mode on the initial request. func (s *StreamState) IsWildcard() bool { return s.wildcard } +// GetKnownResourceNames returns the current known list of resources on a SOTW stream. +func (s *StreamState) GetKnownResourceNames(url string) map[string]struct{} { + return s.knownResourceNames[url] +} + +// SetKnownResourceNames sets a list of resource names in a stream utilizing the SOTW protocol. func (s *StreamState) SetKnownResourceNames(url string, names map[string]struct{}) { s.knownResourceNames[url] = names } +// SetKnownResourceNamesAsList is a helper function to set resource names as a slice input. func (s *StreamState) SetKnownResourceNamesAsList(url string, names []string) { m := map[string]struct{}{} for _, name := range names { @@ -103,24 +137,3 @@ func (s *StreamState) SetKnownResourceNamesAsList(url string, names []string) { } s.knownResourceNames[url] = m } - -func (s *StreamState) GetKnownResourceNames(url string) map[string]struct{} { - return s.knownResourceNames[url] -} - -// NewStreamState initializes a stream state. -func NewStreamState(wildcard bool, initialResourceVersions map[string]string) StreamState { - state := StreamState{ - wildcard: wildcard, - subscribedResourceNames: map[string]struct{}{}, - resourceVersions: initialResourceVersions, - first: true, - knownResourceNames: map[string]map[string]struct{}{}, - } - - if initialResourceVersions == nil { - state.resourceVersions = make(map[string]string) - } - - return state -} diff --git a/vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/ya.make b/vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/ya.make index 6cb4c649be..ff0a7e670b 100644 --- a/vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/ya.make +++ b/vendor/github.com/envoyproxy/go-control-plane/pkg/server/stream/v3/ya.make @@ -2,6 +2,8 @@ GO_LIBRARY() LICENSE(Apache-2.0) -SRCS(stream.go) +SRCS( + stream.go +) END() |