client

package
v3.2.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2024 License: Apache-2.0 Imports: 17 Imported by: 8

Documentation

Overview

package client 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

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

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

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

func (c *ClusterRequestsCounter) EndRequest()

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

func (*ClusterRequestsCounter) StartRequest

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(resource.ListenerUpdate, error)) func()
	WatchRouteConfig(string, func(resource.RouteConfigUpdate, error)) func()
	WatchCluster(string, func(resource.ClusterUpdate, error)) func()
	WatchEndpoints(clusterName string, edsCb func(resource.EndpointsUpdate, error)) (cancel func())
	ReportLoad(server string) (*load.Store, func())

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

	BootstrapConfig() *bootstrap.Config
	Close()

	/*
		SetMetadata would reconnect tcp link with new metadata
	*/
	SetMetadata(*_struct.Struct) error
}

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 internal contains functions/structs shared by xds balancers/resolvers.
Package internal contains functions/structs shared by xds balancers/resolvers.
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