package clients

import "google.golang.org/grpc/xds/internal/clients"

Package clients provides implementations of the clients to interact with xDS and LRS servers.

xDS Client

The xDS client allows applications to:

This enables applications to dynamically discover and configure resources such as listeners, routes, clusters, and endpoints from an xDS management server.

LRS Client

The LRS (Load Reporting Service) client allows applications to report load data to an LRS server via the LRS stream. This data can be used for monitoring, traffic management, and other purposes.

Experimental

NOTICE: This package is EXPERIMENTAL and may be changed or removed in a later release.

Index

Types

type Locality

type Locality struct {
	// Region is the region of the xDS client application.
	Region string
	// Zone is the area within a region.
	Zone string
	// SubZone is the further subdivision within a zone.
	SubZone string
}

Locality represents the location of the xDS client application.

type MetricsReporter

type MetricsReporter interface {
	// ReportMetric reports a metric. The metric will be one of the predefined
	// set of types depending on the client (XDSClient or LRSClient).
	//
	// Each client will produce different metrics. Please see the client's
	// documentation for a list of possible metrics events.
	ReportMetric(metric any)
}

MetricsReporter is used by the XDSClient to report metrics.

type Node

type Node struct {
	// ID is a string identifier of the application.
	ID string
	// Cluster is the name of the cluster the application belongs to.
	Cluster string
	// Locality is the location of the application including region, zone,
	// sub-zone.
	Locality Locality
	// Metadata provides additional context about the application by associating
	// arbitrary key-value pairs with it.
	Metadata any
	// UserAgentName is the user agent name of application.
	UserAgentName string
	// UserAgentVersion is the user agent version of application.
	UserAgentVersion string
}

Node represents the identity of the xDS client, allowing xDS and LRS servers to identify the source of xDS requests.

type ServerIdentifier

type ServerIdentifier struct {
	// ServerURI is the target URI of the server.
	ServerURI string

	// Extensions can be populated with arbitrary data to be passed to the
	// TransportBuilder and/or xDS Client's ResourceType implementations.
	// This field can be used to provide additional configuration or context
	// specific to the user's needs.
	//
	// The xDS and LRS clients do not interpret the contents of this field.
	// It is the responsibility of the user's custom TransportBuilder and/or
	// ResourceType implementations to handle and interpret these extensions.
	//
	// For example, a custom TransportBuilder might use this field to
	// configure a specific security credentials.
	//
	// Extensions may be any type that is comparable, as they are used as map
	// keys internally. If Extensions are not able to be used as a map key,
	// the client may panic.
	//
	// See: https://go.dev/ref/spec#Comparison_operators
	//
	// Any equivalent extensions in all ServerIdentifiers present in a single
	// client's configuration should have the same value. Not following this
	// restriction may result in excess resource usage.
	Extensions any
}

ServerIdentifier holds identifying information for connecting to an xDS management or LRS server.

type Stream

type Stream interface {
	// Send sends the provided message on the stream.
	Send([]byte) error

	// Recv blocks until the next message is received on the stream.
	Recv() ([]byte, error)
}

Stream provides methods to send and receive messages on a stream. Messages are represented as a byte slice.

type Transport

type Transport interface {
	// NewStream creates a new streaming call to the server for the specific
	// RPC method name. The returned Stream interface can be used to send and
	// receive messages on the stream.
	NewStream(context.Context, string) (Stream, error)

	// Close closes the Transport.
	Close()
}

Transport provides the functionality to communicate with an xDS or LRS server using streaming calls.

type TransportBuilder

type TransportBuilder interface {
	// Build creates a new Transport instance to the server based on the
	// provided ServerIdentifier.
	Build(serverIdentifier ServerIdentifier) (Transport, error)
}

TransportBuilder provides the functionality to create a communication channel to an xDS or LRS server.

Source Files

config.go transport_builder.go

Directories

PathSynopsis
xds/internal/clients/grpctransportPackage grpctransport provides an implementation of the clients.TransportBuilder interface using gRPC.
xds/internal/clients/internalPackage internal contains helpers for xDS and LRS clients.
xds/internal/clients/internal/backoffPackage backoff implements the backoff strategy for clients.
xds/internal/clients/internal/bufferPackage buffer provides an implementation of an unbounded buffer.
xds/internal/clients/internal/prettyPackage pretty defines helper functions to pretty-print structs for logging.
xds/internal/clients/internal/syncutilPackage syncutil implements additional synchronization primitives built upon the sync package.
xds/internal/clients/internal/testutilsPackage testutils contains testing helpers for xDS and LRS clients.
xds/internal/clients/internal/testutils/e2ePackage e2e provides utilities for end2end testing of xDS and LRS clients functionalities.
xds/internal/clients/internal/testutils/fakeserverPackage fakeserver provides a fake implementation of the management server.
xds/internal/clients/lrsclientPackage lrsclient provides an LRS (Load Reporting Service) client.
xds/internal/clients/xdsclientPackage xdsclient provides an xDS (* Discovery Service) client.
xds/internal/clients/xdsclient/internalPackage internal contains functionality internal to the xdsclient package.
xds/internal/clients/xdsclient/internal/xdsresourcePackage xdsresource defines constants to distinguish between supported xDS API versions.
xds/internal/clients/xdsclient/metricsPackage metrics defines all metrics that can be produced by an xDS client.
xds/internal/clients/xdsclient/test
Version
v1.74.0-dev
Published
May 15, 2025
Platform
js/wasm
Imports
1 packages
Last checked
3 hours ago

Tools for package owners.