xdsclient

package
v1.45.0-dev Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 17 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

This section is empty.

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 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 XDSClient

type XDSClient interface {
	WatchListener(string, func(xdsresource.ListenerUpdate, error)) func()
	WatchRouteConfig(string, func(xdsresource.RouteConfigUpdate, error)) func()
	WatchCluster(string, func(xdsresource.ClusterUpdate, error)) func()
	WatchEndpoints(clusterName string, edsCb func(xdsresource.EndpointsUpdate, error)) (cancel func())
	ReportLoad(server string) (*load.Store, func())

	DumpLDS() map[string]xdsresource.UpdateWithMD
	DumpRDS() map[string]xdsresource.UpdateWithMD
	DumpCDS() map[string]xdsresource.UpdateWithMD
	DumpEDS() map[string]xdsresource.UpdateWithMD

	BootstrapConfig() *bootstrap.Config
	Close()
}

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 New

func New() (XDSClient, error)

New returns a new xdsClient configured by the bootstrap file specified in env variable GRPC_XDS_BOOTSTRAP or GRPC_XDS_BOOTSTRAP_CONFIG.

The returned xdsClient is a singleton. This function creates the xds client if it doesn't already exist.

Note that the first invocation of New() or NewWithConfig() sets the client singleton. The following calls will return the singleton xds client without checking or using the config.

func NewClientWithBootstrapContents

func NewClientWithBootstrapContents(contents []byte) (XDSClient, error)

NewClientWithBootstrapContents returns an xds client for this config, separate from the global singleton. This should be used for testing purposes only.

func NewWithConfig

func NewWithConfig(config *bootstrap.Config) (XDSClient, error)

NewWithConfig returns a new xdsClient configured by the given config.

The returned xdsClient is a singleton. This function creates the xds client if it doesn't already exist.

Note that the first invocation of New() or NewWithConfig() sets the client singleton. The following calls will return the singleton xds client without checking or using the config.

This function is internal only, for c2p resolver and testing to use. DO NOT use this elsewhere. Use New() instead.

func NewWithConfigForTesting

func NewWithConfigForTesting(config *bootstrap.Config, watchExpiryTimeout time.Duration) (XDSClient, error)

NewWithConfigForTesting is exported for testing only.

Note that this function doesn't set the singleton, so that the testing states don't leak.

Directories

Path Synopsis
Package bootstrap provides the functionality to initialize certain aspects of an xDS client by reading a bootstrap file.
Package bootstrap provides the functionality to initialize certain aspects of an xDS client by reading a bootstrap file.
Package controller contains implementation to connect to the control plane.
Package controller contains implementation to connect to the control plane.
version
Package version defines APIs to deal with different versions of xDS.
Package version defines APIs to deal with different versions of xDS.
version/v2
Package v2 provides xDS v2 transport protocol specific functionality.
Package v2 provides xDS v2 transport protocol specific functionality.
version/v3
Package v3 provides xDS v3 transport protocol specific functionality.
Package v3 provides xDS v3 transport protocol specific functionality.
Package load provides functionality to record and maintain load data.
Package load provides functionality to record and maintain load data.
Package pubsub implements a utility type to maintain resource watchers and the updates.
Package pubsub implements a utility type to maintain resource watchers and the updates.
Package xdsresource contains functions to proto xds updates (unmarshal from proto), and types for the resource updates.
Package xdsresource contains functions to proto xds updates (unmarshal from proto), and types for the resource updates.
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