xdsclient

package
v1.66.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package xdsclient implements a full fledged gRPC client for the xDS API used by the xds resolver and balancer implementations.

Index

Constants

View Source
const NameForServer = "#server"

NameForServer represents the value to be passed as name when creating an xDS client from xDS-enabled gRPC servers. This is a well-known dedicated key value, and is defined in gRFC A71.

Variables

This section is empty.

Functions

func ClearAllCountersForTesting added in v1.40.0

func ClearAllCountersForTesting()

ClearAllCountersForTesting clears all the counters. Should be only used in tests.

func ClearCounterForTesting

func ClearCounterForTesting(clusterName, edsServiceName string)

ClearCounterForTesting clears the counter for the service. Should be only used in tests.

func DumpResources added in v1.66.0

func DumpResources() *v3statuspb.ClientStatusResponse

DumpResources returns the status and contents of all xDS resources.

func SetClient

func SetClient(state resolver.State, c XDSClient) resolver.State

SetClient sets c in state and returns the new state.

Types

type ClusterRequestsCounter added in v1.40.0

type ClusterRequestsCounter struct {
	ClusterName    string
	EDSServiceName string
	// contains filtered or unexported fields
}

ClusterRequestsCounter is used to track the total inflight requests for a service with the provided name.

func GetClusterRequestsCounter added in v1.40.0

func GetClusterRequestsCounter(clusterName, edsServiceName string) *ClusterRequestsCounter

GetClusterRequestsCounter returns the ClusterRequestsCounter with the provided serviceName. If one does not exist, it creates it.

func (*ClusterRequestsCounter) EndRequest added in v1.40.0

func (c *ClusterRequestsCounter) EndRequest()

EndRequest ends a request for a service, decrementing its number of requests by 1.

func (*ClusterRequestsCounter) StartRequest added in v1.40.0

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.

type OptionsForTesting added in v1.65.0

type OptionsForTesting struct {
	// Name is a unique name for this xDS client.
	Name string
	// Contents contain a JSON representation of the bootstrap configuration to
	// be used when creating the xDS client.
	Contents []byte

	// WatchExpiryTimeout is the timeout for xDS resource watch expiry. If
	// unspecified, uses the default value used in non-test code.
	WatchExpiryTimeout time.Duration

	// AuthorityIdleTimeout is the timeout before idle authorities are deleted.
	// If unspecified, uses the default value used in non-test code.
	AuthorityIdleTimeout time.Duration
}

OptionsForTesting contains options to configure xDS client creation for testing purposes only.

type XDSClient

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())

	ReportLoad(*bootstrap.ServerConfig) (*load.Store, func())

	BootstrapConfig() *bootstrap.Config
}

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.

func FromResolverState

func FromResolverState(state resolver.State) XDSClient

FromResolverState returns the Client from state, or nil if not present.

func GetForTesting added in v1.66.0

func GetForTesting(name string) (XDSClient, func(), error)

GetForTesting returns an xDS client created earlier using the given name.

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.

Testing Only

This function should ONLY be used for testing purposes.

func New

func New(name string) (XDSClient, func(), error)

New returns an xDS client configured with bootstrap configuration specified by the ordered list: - file name containing the configuration specified by GRPC_XDS_BOOTSTRAP - actual configuration specified by GRPC_XDS_BOOTSTRAP_CONFIG - fallback configuration set using bootstrap.SetFallbackBootstrapConfig

gRPC client implementations are expected to pass the channel's target URI for the name field, while server implementations are expected to pass a dedicated well-known value "#server", as specified in gRFC A71. The returned client is a reference counted implementation shared among callers using the same name.

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 NewForTesting added in v1.65.0

func NewForTesting(opts OptionsForTesting) (XDSClient, func(), error)

NewForTesting returns an xDS client configured with the provided options.

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.

Testing Only

This function should ONLY be used for testing purposes.

Directories

Path Synopsis
Package internal contains functionality internal to the xdsclient package.
Package internal contains functionality internal to the xdsclient package.
Package load provides functionality to record and maintain load data.
Package load provides functionality to record and maintain load data.
Package transport implements the xDS transport protocol functionality required by the xdsclient.
Package transport implements the xDS transport protocol functionality required by the xdsclient.
internal
Package internal contains functionality internal to the transport package.
Package internal contains functionality internal to the transport package.
Package xdslbregistry provides a registry of converters that convert proto from load balancing configuration, defined by the xDS API spec, to JSON load balancing configuration.
Package xdslbregistry provides a registry of converters that convert proto from load balancing configuration, defined by the xDS API spec, to JSON load balancing configuration.
converter
Package converter provides converters to convert proto load balancing configuration, defined by the xDS API spec, to JSON load balancing configuration.
Package converter provides converters to convert proto load balancing configuration, defined by the xDS API spec, to JSON load balancing configuration.
Package xdsresource implements the xDS data model layer.
Package xdsresource implements the xDS data model layer.
version
Package version defines constants to distinguish between supported xDS API versions.
Package version defines constants to distinguish between supported xDS API versions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL