Skip to content

Commit

Permalink
easwar review 2
Browse files Browse the repository at this point in the history
  • Loading branch information
purnesh42H committed Feb 20, 2025
1 parent 607b380 commit 596a0dd
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 27 deletions.
15 changes: 12 additions & 3 deletions xds/internal/clients/lrsclient/load_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ package lrsclient
import "time"

// LoadStore keep track of the loads for multiple clusters and services that
// are intended to be reported via LRS. One store contains loads reported to
// one LRS server. To track loads for multiple servers, multiple stores can be
// created.
// are intended to be reported via LRS.
//
// LoadStore stores loads reported to a single LRS server. Use multiple stores
// for multiple servers.
//
// It is safe for concurrent use.
type LoadStore struct {
}

Expand All @@ -37,6 +40,8 @@ type LoadStore struct {
//
// If a cluster's Data is empty (no load to report), it's not appended to the
// returned slice.
//
// Calling Stats clears the previous load data from the LoadStore.
func (s *LoadStore) Stats(clusterNames []string) []*Data {
panic("unimplemented")
}
Expand Down Expand Up @@ -95,8 +100,12 @@ type ServerLoadData struct {
// PerClusterReporter defines the methods that the LoadStore uses to track
// per-cluster load reporting data.
type PerClusterReporter interface {
// CallStarted records a call started in the LoadStore.
CallStarted(locality string)
// CallFinished records a call finished in the LoadStore.
CallFinished(locality string, err error)
// CallServerLoad records the server load in the LoadStore.
CallServerLoad(locality, name string, val float64)
// CallDropped records a call dropped in the LoadStore.
CallDropped(category string)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import (
type LRSClient struct {
}

// New returns a new LRS Client configured with the provided config.
func New(config Config) (*LRSClient, error) {
panic("unimplemented")
}

// ReportLoad creates a new load reporting stream for the client. It creates a
// LoadStore and return it for the caller to report loads.
func (c *LRSClient) ReportLoad(serverConfig clients.ServerConfig) *LoadStore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
)

// Config is used to configure an LRS client. After one has been passed to an
// LRS function, it must not be modified. A Config may be used; the LRS package
// will also not modify it.
// LRS function, it must not be modified. A Config may be reused; the LRS
// package will also not modify it.
type Config struct {
// Node is the identity of the client application reporting load to the
// LRS server.
Expand Down
8 changes: 3 additions & 5 deletions xds/internal/clients/xdsclient/resource_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,16 @@ import (
)

// ResourceType wraps all resource-type specific functionality. Each supported
// resource type needs to provide an implementation of this interface.
// resource type needs to provide an implementation of the Decoder.
type ResourceType struct {
// TypeURL is the xDS type URL of this resource type for the v3 xDS
// protocol. This URL is used as the key to look up the corresponding
// ResourceType implementation in the ResourceTypes map provided in the
// Config.
TypeURL string

// TypeName identifies resources in a transport protocol agnostic way. This
// can be used for logging/debugging purposes, as well as in cases where
// the resource type name is to be uniquely identified but the actual
// functionality provided by the resource type is not required.
// TypeName is the shorter representation of the TypeURL to identify the
// resource type. It can be used for logging/debugging purposes.
TypeName string

// AllResourcesRequiredInSotW indicates whether this resource type requires
Expand Down
2 changes: 1 addition & 1 deletion xds/internal/clients/xdsclient/resource_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type ResourceWatcher interface {

// AmbientError indicates an error occurred after a resource has been
// received that should not modify the use of that resource but may be
// provide useful information about the ambient state of the XdsClient for
// provide useful information about the ambient state of the XDSClient for
// debugging purposes. The previous version of the resource should still be
// considered valid.
AmbientError(err error, onCallbackProcessed func())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

// Package xdsclient provides an xDS (Extensible Discovery Service) client.
// Package xdsclient provides an xDS (Discovery Service) client.
//
// It allows applications to:
// - Create xDS client instances with in-memory configurations.
Expand Down Expand Up @@ -47,13 +47,12 @@ func New(config Config) (*XDSClient, error) {

// WatchResource starts watching the specified resource.
//
// typeURL must be present in the XDSClient's configured ResourceTypes. If
// typeURL is not present, watch will not be started. The ResourceType
// obtained from the ResourceTypes against the typeURL will be used to decode
// the matching resource when it is received, and the watcher will be called
// with the result.
// typeURL specifies the resource type implementation to use. The watch fails
// if there is no resource type implementation for the given typeURL. See the
// ResourceTypes field in the Config struct used to create the XDSClient.
//
// Cancel cancels the watch and prevents future calls to the watcher.
// The returned function cancels the watch and prevents future calls to the
// watcher.
func (c *XDSClient) WatchResource(typeURL string, name string, watcher ResourceWatcher) (cancel func()) {
panic("unimplemented")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
)

// Config is used to configure an xDS client. After one has been passed to an
// xDS function, it must not be modified. A Config may be used; the xDS package
// will also not modify it.
// xDS function, it must not be modified. A Config may be reused; the xDS
// package will also not modify it.
type Config struct {
// Servers specifies a list of xDS management servers to connect to. The
// order of the servers in this list reflects the order of preference of
Expand Down Expand Up @@ -71,13 +71,15 @@ type Authority struct {
// gRFC A71: https://github.com/grpc/proposal/blob/master/A71-xds-fallback.md
XDSServers []clients.ServerConfig

// Extensions can be populated with arbitrary data to be passed to the xDS
// Client's user specific implementations. This field can be used to
// provide additional configuration or context specific to the user's
// needs.
// Extensions can be populated with arbitrary authority-specific data to be
// passed from the xDS client configuration down to the user defined
// resource decoder implementations. This allows the user to provide
// authority-specific context or configuration to their resource
// processing logic.

//
// The xDS and LRS clients do not interpret the contents of this field. It
// is the responsibility of the user's implementations to handle and
// interpret these extensions.
// The xDS client do not interpret the contents of this field. It is the
// responsibility of the user's implementations to handle and interpret
// these extensions.
Extensions any
}

0 comments on commit 596a0dd

Please sign in to comment.