func ClearAllCountersForTesting()
ClearAllCountersForTesting clears all the counters. Should be only used in tests.
func ClearCounterForTesting(clusterName, edsServiceName string)
ClearCounterForTesting clears the counter for the service. Should be only used in tests.
func SetClient(state resolver.State, c XDSClient) resolver.State
SetClient sets c in state and returns the new state.
ClusterRequestsCounter is used to track the total inflight requests for a service with the provided name.
type ClusterRequestsCounter struct { ClusterName string EDSServiceName string // contains filtered or unexported fields }
func GetClusterRequestsCounter(clusterName, edsServiceName string) *ClusterRequestsCounter
GetClusterRequestsCounter returns the ClusterRequestsCounter with the provided serviceName. If one does not exist, it creates it.
func (c *ClusterRequestsCounter) EndRequest()
EndRequest ends a request for a service, decrementing its number of requests by 1.
func (c *ClusterRequestsCounter) StartRequest(max uint32) error
StartRequest starts a request for a cluster, incrementing its number of requests by 1. Returns an error if the max number of requests is exceeded.
XDSClient is a full fledged gRPC client which queries a set of discovery APIs (collectively termed as xDS) on a remote management server, to discover various dynamic resources.
type XDSClient interface { // WatchResource uses xDS to discover the resource associated with the // provided resource name. The resource type implementation determines how // xDS requests are sent out and how responses are deserialized and // validated. Upon receipt of a response from the management server, an // appropriate callback on the watcher is invoked. // // Most callers will not have a need to use this API directly. They will // instead use a resource-type-specific wrapper API provided by the relevant // resource type implementation. // // // During a race (e.g. an xDS response is received while the user is calling // cancel()), there's a small window where the callback can be called after // the watcher is canceled. Callers need to handle this case. WatchResource(rType xdsresource.Type, resourceName string, watcher xdsresource.ResourceWatcher) (cancel func()) // DumpResources returns the status of the xDS resources. Returns a map of // resource type URLs to a map of resource names to resource state. DumpResources() map[string]map[string]xdsresource.UpdateWithMD ReportLoad(*bootstrap.ServerConfig) (*load.Store, func()) BootstrapConfig() *bootstrap.Config }
func FromResolverState(state resolver.State) XDSClient
FromResolverState returns the Client from state, or nil if not present.
func New() (XDSClient, func(), error)
New returns a new xDS client configured by the bootstrap file specified in env variable GRPC_XDS_BOOTSTRAP or GRPC_XDS_BOOTSTRAP_CONFIG.
The returned client is a reference counted singleton instance. This function creates a new client only when one doesn't already exist.
The second return value represents a close function which releases the caller's reference on the returned client. The caller is expected to invoke it once they are done using the client. The underlying client will be closed only when all references are released, and it is safe for the caller to invoke this close function multiple times.
func NewWithBootstrapContentsForTesting(contents []byte) (XDSClient, func(), error)
NewWithBootstrapContentsForTesting returns an xDS client for this config, separate from the global singleton.
The second return value represents a close function which the caller is expected to invoke once they are done using the client. It is safe for the caller to invoke this close function multiple times.
This function should ONLY be used for testing purposes.
func NewWithConfig(config *bootstrap.Config) (XDSClient, func(), error)
NewWithConfig returns a new xDS client configured by the given config.
The second return value represents a close function which releases the caller's reference on the returned client. The caller is expected to invoke it once they are done using the client. The underlying client will be closed only when all references are released, and it is safe for the caller to invoke this close function multiple times.
This function should ONLY be used for internal (c2p resolver) and/or testing purposese. DO NOT use this elsewhere. Use New() instead.
func NewWithConfigForTesting(config *bootstrap.Config, watchExpiryTimeout, authorityIdleTimeout time.Duration) (XDSClient, func(), error)
NewWithConfigForTesting returns an xDS client for the specified bootstrap config, separate from the global singleton.
The second return value represents a close function which the caller is expected to invoke once they are done using the client. It is safe for the caller to invoke this close function multiple times.
This function should ONLY be used for testing purposes. TODO(easwars): Document the new close func.
Name | Synopsis |
---|---|
.. |