package xdsresource
import "google.golang.org/grpc/internal/xds/xdsclient/xdsresource"
Package xdsresource implements the xDS data model layer.
Provides resource-type specific functionality to unmarshal xDS protos into internal data structures that contain only fields gRPC is interested in. These internal data structures are passed to components in the xDS stack (resolver/balancers/server) that have expressed interest in receiving updates to specific resources.
Index ¶
- Constants
- Variables
- func Hostname(addr resolver.Address) string
- func IsClusterResource(url string) bool
- func IsEndpointsResource(url string) bool
- func IsHTTPConnManagerResource(url string) bool
- func IsListenerResource(url string) bool
- func IsRouteConfigResource(url string) bool
- func NewClusterResourceTypeDecoder(bc *bootstrap.Config, gServerCfgMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig) xdsclient.Decoder
- func NewEndpointsResourceTypeDecoder(bc *bootstrap.Config) xdsclient.Decoder
- func NewError(t ErrorType, message string) error
- func NewErrorf(t ErrorType, format string, args ...any) error
- func NewListenerResourceTypeDecoder(bc *bootstrap.Config) xdsclient.Decoder
- func NewRouteConfigResourceTypeDecoder(bc *bootstrap.Config) xdsclient.Decoder
- func SetHostname(endpoint resolver.Endpoint, hostname string) resolver.Endpoint
- func SetXDSConfig(state resolver.State, config *XDSConfig) resolver.State
- func UnwrapResource(r *anypb.Any) (*anypb.Any, error)
- func WatchCluster(p Producer, name string, w ClusterWatcher) (cancel func())
- func WatchEndpoints(p Producer, name string, w EndpointsWatcher) (cancel func())
- func WatchListener(p Producer, name string, w ListenerWatcher) (cancel func())
- func WatchRouteConfig(p Producer, name string, w RouteConfigWatcher) (cancel func())
- type AggregateConfig
- type ClusterConfig
- type ClusterResourceData
- func (c *ClusterResourceData) Bytes() []byte
- func (c *ClusterResourceData) Equal(other xdsclient.ResourceData) bool
- type ClusterResult
- type ClusterType
- type ClusterUpdate
- type ClusterWatcher
- type CompositeMatcher
- func RouteToMatcher(r *Route) *CompositeMatcher
- func (a *CompositeMatcher) Match(info iresolver.RPCInfo) bool
- func (a *CompositeMatcher) String() string
- type DNSUpdate
- type DecodeOptions
- type DecodeResult
- type DestinationPrefixEntry
- type Endpoint
- type EndpointConfig
- type EndpointHealthStatus
- type EndpointsResourceData
- func (e *EndpointsResourceData) Bytes() []byte
- func (e *EndpointsResourceData) Equal(other xdsclient.ResourceData) bool
- type EndpointsUpdate
- type EndpointsWatcher
- type ErrorType
- type HTTPConnectionManagerConfig
- type HTTPFilter
- type HashPolicy
- type HashPolicyType
- type HeaderMatcher
- type InboundListenerConfig
- type Int64Range
- type ListenerResourceData
- func (l *ListenerResourceData) Bytes() []byte
- func (l *ListenerResourceData) Equal(other xdsclient.ResourceData) bool
- type ListenerUpdate
- type ListenerWatcher
- type Locality
- type Name
- type NetworkFilterChainConfig
- type NetworkFilterChainMap
- type OverloadDropConfig
- type Producer
- type ProxyAddressMetadataValue
- type ResourceData
- type ResourceWatcher
- type RetryBackoff
- type RetryConfig
- type Route
- type RouteActionType
- type RouteConfigResourceData
- func (r *RouteConfigResourceData) Bytes() []byte
- func (r *RouteConfigResourceData) Equal(other xdsclient.ResourceData) bool
- type RouteConfigUpdate
- type RouteConfigWatcher
- type SecurityConfig
- type ServiceStatus
- type SourcePrefixEntry
- type SourcePrefixes
- type StructMetadataValue
- type Type
- type UpdateErrorMetadata
- type UpdateMetadata
- type UpdateValidatorFunc
- type UpdateWithMD
- type VirtualHost
- type WeightedCluster
- type XDSConfig
Constants ¶
const ( // ClusterResourceTypeName represents the transport agnostic name for the // cluster resource. ClusterResourceTypeName = "ClusterResource" )
const ( // EndpointsResourceTypeName represents the transport agnostic name for the // endpoint resource. EndpointsResourceTypeName = "EndpointsResource" )
const FederationScheme = "xdstp"
FederationScheme is the scheme of a federation resource name.
const ListenerResourceTypeName = "ListenerResource"
ListenerResourceTypeName is a human friendly name for the listener resource.
const ( // RouteConfigTypeName represents the transport agnostic name for the // route config resource. RouteConfigTypeName = "RouteConfigResource" )
Variables ¶
RandInt64n overwrites rand for control in tests.
var ValidateClusterAndConstructClusterUpdateForTesting = validateClusterAndConstructClusterUpdate
ValidateClusterAndConstructClusterUpdateForTesting exports the validateClusterAndConstructClusterUpdate function for testing purposes.
Functions ¶
func Hostname ¶
Hostname returns the hostname from the BalancerAttributes of the given Address. If this attribute is not set, it returns the empty string.
func IsClusterResource ¶
IsClusterResource returns true if the provider URL corresponds to an xDS Cluster resource.
func IsEndpointsResource ¶
IsEndpointsResource returns true if the provider URL corresponds to an xDS Endpoints resource.
func IsHTTPConnManagerResource ¶
IsHTTPConnManagerResource returns true if the provider URL corresponds to an xDS HTTPConnManager resource.
func IsListenerResource ¶
IsListenerResource returns true if the provider URL corresponds to an xDS Listener resource.
func IsRouteConfigResource ¶
IsRouteConfigResource returns true if the provider URL corresponds to an xDS RouteConfig resource.
func NewClusterResourceTypeDecoder ¶
func NewClusterResourceTypeDecoder(bc *bootstrap.Config, gServerCfgMap map[xdsclient.ServerConfig]*bootstrap.ServerConfig) xdsclient.Decoder
NewClusterResourceTypeDecoder returns a xdsclient.Decoder that wraps the xdsresource.clusterType.
func NewEndpointsResourceTypeDecoder ¶
NewEndpointsResourceTypeDecoder returns a xdsclient.Decoder that wraps the xdsresource.endpointsType.
func NewError ¶
NewError creates an xDS client error. The callbacks are called with this error, to pass additional information about the error.
func NewErrorf ¶
NewErrorf creates an xDS client error. The callbacks are called with this error, to pass additional information about the error.
func NewListenerResourceTypeDecoder ¶
NewListenerResourceTypeDecoder returns a xdsclient.Decoder that wraps the xdsresource.listenerType.
func NewRouteConfigResourceTypeDecoder ¶
NewRouteConfigResourceTypeDecoder returns a xdsclient.Decoder that wraps the xdsresource.routeConfigType.
func SetHostname ¶
SetHostname returns a copy of the given endpoint with hostname added as an attribute.
func SetXDSConfig ¶
SetXDSConfig returns a copy of state in which the Attributes field is updated with the XDSConfig.
func UnwrapResource ¶
UnwrapResource unwraps and returns the inner resource if it's in a resource wrapper. The original resource is returned if it's not wrapped.
func WatchCluster ¶
func WatchCluster(p Producer, name string, w ClusterWatcher) (cancel func())
WatchCluster uses xDS to discover the configuration associated with the provided cluster resource name.
func WatchEndpoints ¶
func WatchEndpoints(p Producer, name string, w EndpointsWatcher) (cancel func())
WatchEndpoints uses xDS to discover the configuration associated with the provided endpoints resource name.
func WatchListener ¶
func WatchListener(p Producer, name string, w ListenerWatcher) (cancel func())
WatchListener uses xDS to discover the configuration associated with the provided listener resource name.
func WatchRouteConfig ¶
func WatchRouteConfig(p Producer, name string, w RouteConfigWatcher) (cancel func())
WatchRouteConfig uses xDS to discover the configuration associated with the provided route configuration resource name.
Types ¶
type AggregateConfig ¶
type AggregateConfig struct {
// LeafClusters contains a prioritized list of names of the leaf clusters
// for the cluster.
LeafClusters []string
}
AggregateConfig holds the configuration for an aggregate cluster.
type ClusterConfig ¶
type ClusterConfig struct {
// Cluster configuration for the cluster. This field is always set to a
// non-nil value.
Cluster *ClusterUpdate
// EndpointConfig contains endpoint configuration for a leaf cluster. This
// field is only set for EDS and LOGICAL_DNS clusters.
EndpointConfig *EndpointConfig
// AggregateConfig contains configuration for an aggregate cluster. This
// field is only set for AGGREGATE clusters.
AggregateConfig *AggregateConfig
}
ClusterConfig contains configuration for a single cluster.
type ClusterResourceData ¶
type ClusterResourceData struct {
Resource ClusterUpdate
}
ClusterResourceData wraps the configuration of a Cluster resource as received from the management server.
func (*ClusterResourceData) Bytes ¶
func (c *ClusterResourceData) Bytes() []byte
Bytes returns the protobuf serialized bytes of the cluster resource proto.
func (*ClusterResourceData) Equal ¶
func (c *ClusterResourceData) Equal(other xdsclient.ResourceData) bool
Equal returns true if other is equal to c.
type ClusterResult ¶
type ClusterResult struct {
Config ClusterConfig
Err error
}
ClusterResult contains a cluster's configuration when a valid resource is received from the management server. It contains an error when:
- an invalid resource is received from the management server and a valid resource was not already present or
- the cluster resource does not exist on the management server
type ClusterType ¶
type ClusterType int
ClusterType is the type of cluster from a received CDS response.
const ( // ClusterTypeEDS represents the EDS cluster type, which will delegate endpoint // discovery to the management server. ClusterTypeEDS ClusterType = iota // ClusterTypeLogicalDNS represents the Logical DNS cluster type, which essentially // maps to the gRPC behavior of using the DNS resolver with pick_first LB policy. ClusterTypeLogicalDNS // ClusterTypeAggregate represents the Aggregate Cluster type, which provides a // prioritized list of clusters to use. It is used for failover between clusters // with a different configuration. ClusterTypeAggregate )
type ClusterUpdate ¶
type ClusterUpdate struct {
ClusterType ClusterType
// ClusterName is the clusterName being watched for through CDS.
ClusterName string
// EDSServiceName is an optional name for EDS. If it's not set, the balancer
// should watch ClusterName for the EDS resources.
EDSServiceName string
// LRSServerConfig contains configuration about the xDS server that sent
// this cluster resource. This is also the server where load reports are to
// be sent, for this cluster.
LRSServerConfig *bootstrap.ServerConfig
// SecurityCfg contains security configuration sent by the control plane.
SecurityCfg *SecurityConfig
// MaxRequests for circuit breaking, if any (otherwise nil).
MaxRequests *uint32
// DNSHostName is used only for cluster type DNS. It's the DNS name to
// resolve in "host:port" form
DNSHostName string
// PrioritizedClusterNames is used only for cluster type aggregate. It represents
// a prioritized list of cluster names.
PrioritizedClusterNames []string
// LBPolicy represents the locality and endpoint picking policy in JSON,
// which will be the child policy of xds_cluster_impl.
LBPolicy json.RawMessage
// OutlierDetection is the outlier detection configuration for this cluster.
// If nil, it means this cluster does not use the outlier detection feature.
OutlierDetection json.RawMessage
// Raw is the resource from the xds response.
Raw *anypb.Any
// TelemetryLabels are the string valued metadata of filter_metadata type
// "com.google.csm.telemetry_labels" with keys "service_name" or
// "service_namespace".
TelemetryLabels map[string]string
}
ClusterUpdate contains information from a received CDS response, which is of interest to the registered CDS watcher.
type ClusterWatcher ¶
type ClusterWatcher interface {
// ResourceChanged indicates a new version of the resource is available.
ResourceChanged(resource *ClusterUpdate, done func())
// ResourceError indicates an error occurred while trying to fetch or
// decode the associated resource. The previous version of the resource
// should be considered invalid.
ResourceError(err error, done func())
// AmbientError indicates an error occurred after a resource has been
// received that should not modify the use of that resource but may provide
// useful information about the state of the XDSClient for debugging
// purposes. The previous version of the resource should still be
// considered valid.
AmbientError(err error, done func())
}
ClusterWatcher wraps the callbacks to be invoked for different events corresponding to the cluster resource being watched. gRFC A88 contains an exhaustive list of what method is invoked under what conditions.
type CompositeMatcher ¶
type CompositeMatcher struct {
// contains filtered or unexported fields
}
CompositeMatcher is a matcher that holds onto many matchers and aggregates the matching results.
func RouteToMatcher ¶
func RouteToMatcher(r *Route) *CompositeMatcher
RouteToMatcher converts a route to a Matcher to match incoming RPC's against.
Only expected to be called on a Route that passed validation checks by the xDS client.
func (*CompositeMatcher) Match ¶
func (a *CompositeMatcher) Match(info iresolver.RPCInfo) bool
Match returns true if all matchers return true.
func (*CompositeMatcher) String ¶
func (a *CompositeMatcher) String() string
type DNSUpdate ¶
type DNSUpdate struct {
// Endpoints is the complete list of endpoints returned by the DNS resolver.
Endpoints []resolver.Endpoint
}
DNSUpdate represents the result of a DNS resolution, containing a list of discovered endpoints.
type DecodeOptions ¶
type DecodeOptions struct {
// BootstrapConfig contains the complete bootstrap configuration passed to
// the xDS client. This contains useful data for resource validation.
BootstrapConfig *bootstrap.Config
// ServerConfig contains the server config (from the above bootstrap
// configuration) of the xDS server from which the current resource, for
// which Decode() is being invoked, was received.
ServerConfig *bootstrap.ServerConfig
}
DecodeOptions wraps the options required by ResourceType implementation for decoding configuration received from the xDS management server.
type DecodeResult ¶
type DecodeResult struct {
// Name is the name of the resource being watched.
Name string
// Resource contains the configuration associated with the resource being
// watched.
Resource ResourceData
}
DecodeResult is the result of a decode operation.
type DestinationPrefixEntry ¶
type DestinationPrefixEntry struct {
// Prefix is the destination IP prefix.
Prefix *net.IPNet
// SourceTypeArr contains the source type matchers. The supported source
// types and their associated indices in the array are:
// - 0: Any: matches connection attempts from any source.
// - 1: SameOrLoopback: matches connection attempts from the same host.
// - 2: External: matches connection attempts from a different host.
SourceTypeArr [3]SourcePrefixes
}
DestinationPrefixEntry contains a destination prefix entry and the associated source type matchers.
type Endpoint ¶
type Endpoint struct {
ResolverEndpoint resolver.Endpoint
HealthStatus EndpointHealthStatus
Weight uint32
Metadata map[string]any
}
Endpoint contains information of an endpoint. TODO(i/8757) : Replace Endpoint with resolver.Endpoint struct.
type EndpointConfig ¶
type EndpointConfig struct {
// Endpoint configurartion for the EDS clusters.
EDSUpdate *EndpointsUpdate
// Endpoint configuration for the LOGICAL_DNS clusters.
DNSEndpoints *DNSUpdate
// ResolutionNote stores error encountered while obtaining endpoints data
// for the cluster. It will contain a nil value when a valid endpoint data is
// received. It contains an error when:
// - an invalid resource is received from the management server or
// - the endpoint resource does not exist on the management server
ResolutionNote error
}
EndpointConfig contains configuration corresponding to the endpoints in a cluster. Only one of EDSUpdate or DNSEndpoints will be populated based on the cluster type.
type EndpointHealthStatus ¶
type EndpointHealthStatus int32
EndpointHealthStatus represents the health status of an endpoint.
const ( // EndpointHealthStatusUnknown represents HealthStatus UNKNOWN. EndpointHealthStatusUnknown EndpointHealthStatus = iota // EndpointHealthStatusHealthy represents HealthStatus HEALTHY. EndpointHealthStatusHealthy // EndpointHealthStatusUnhealthy represents HealthStatus UNHEALTHY. EndpointHealthStatusUnhealthy // EndpointHealthStatusDraining represents HealthStatus DRAINING. EndpointHealthStatusDraining // EndpointHealthStatusTimeout represents HealthStatus TIMEOUT. EndpointHealthStatusTimeout // EndpointHealthStatusDegraded represents HealthStatus DEGRADED. EndpointHealthStatusDegraded )
type EndpointsResourceData ¶
type EndpointsResourceData struct {
Resource EndpointsUpdate
}
EndpointsResourceData is an implementation of the xdsclient.ResourceData interface for endpoints resources.
func (*EndpointsResourceData) Bytes ¶
func (e *EndpointsResourceData) Bytes() []byte
Bytes returns the protobuf serialized bytes of the listener resource proto.
func (*EndpointsResourceData) Equal ¶
func (e *EndpointsResourceData) Equal(other xdsclient.ResourceData) bool
Equal returns true if other is equal to e.
type EndpointsUpdate ¶
type EndpointsUpdate struct {
Drops []OverloadDropConfig
// Localities in the EDS response with `load_balancing_weight` field not set
// or explicitly set to 0 are ignored while parsing the resource, and
// therefore do not show up here.
Localities []Locality
// Raw is the resource from the xds response.
Raw *anypb.Any
}
EndpointsUpdate contains an EDS update.
type EndpointsWatcher ¶
type EndpointsWatcher interface {
// ResourceChanged indicates a new version of the resource is available.
ResourceChanged(resource *EndpointsUpdate, done func())
// ResourceError indicates an error occurred while trying to fetch or
// decode the associated resource. The previous version of the resource
// should be considered invalid.
ResourceError(err error, done func())
// AmbientError indicates an error occurred after a resource has been
// received that should not modify the use of that resource but may provide
// useful information about the state of the XDSClient for debugging
// purposes. The previous version of the resource should still be
// considered valid.
AmbientError(err error, done func())
}
EndpointsWatcher wraps the callbacks to be invoked for different events corresponding to the endpoints resource being watched. gRFC A88 contains an exhaustive list of what method is invoked under what conditions.
type ErrorType ¶
type ErrorType int
ErrorType is the type of the error that the watcher will receive from the xds client.
const ( // ErrorTypeUnknown indicates the error doesn't have a specific type. It is // the default value, and is returned if the error is not an xds error. ErrorTypeUnknown ErrorType = iota // ErrorTypeConnection indicates a connection error from the gRPC client. ErrorTypeConnection // ErrorTypeResourceNotFound indicates a resource is not found from the xds // response. It's typically returned if the resource is removed in the xds // server. ErrorTypeResourceNotFound // ErrorTypeResourceTypeUnsupported indicates the receipt of a message from // the management server with resources of an unsupported resource type. ErrorTypeResourceTypeUnsupported // ErrTypeStreamFailedAfterRecv indicates an ADS stream error, after // successful receipt of at least one message from the server. ErrTypeStreamFailedAfterRecv // ErrorTypeNACKed indicates that configuration provided by the xDS management // server was NACKed. ErrorTypeNACKed )
func ErrType ¶
ErrType returns the error's type.
type HTTPConnectionManagerConfig ¶
type HTTPConnectionManagerConfig struct {
// RouteConfigName is the route configuration name corresponding to the
// target which is being watched through LDS.
//
// Exactly one of RouteConfigName and InlineRouteConfig is set.
RouteConfigName string
// InlineRouteConfig is the inline route configuration (RDS response)
// returned inside LDS.
//
// Exactly one of RouteConfigName and InlineRouteConfig is set.
InlineRouteConfig *RouteConfigUpdate
// MaxStreamDuration contains the HTTP connection manager's
// common_http_protocol_options.max_stream_duration field, or zero if
// unset.
MaxStreamDuration time.Duration
// HTTPFilters is a list of HTTP filters (name, config) from the LDS
// response.
HTTPFilters []HTTPFilter
}
HTTPConnectionManagerConfig contains the HTTP connection manager configuration.
type HTTPFilter ¶
type HTTPFilter struct {
// Name is an arbitrary name of the filter. Used for applying override
// settings in virtual host / route / weighted cluster configuration (not
// yet supported).
Name string
// Filter is the HTTP filter found in the registry for the config type.
Filter httpfilter.Filter
// Config contains the filter's configuration
Config httpfilter.FilterConfig
}
HTTPFilter represents one HTTP filter from an LDS response's HTTP connection manager field.
type HashPolicy ¶
type HashPolicy struct {
HashPolicyType HashPolicyType
Terminal bool
// Fields used for type HEADER.
HeaderName string
Regex *regexp.Regexp
RegexSubstitution string
}
HashPolicy specifies the HashPolicy if the upstream cluster uses a hashing load balancer.
type HashPolicyType ¶
type HashPolicyType int
HashPolicyType specifies the type of HashPolicy from a received RDS Response.
const ( // HashPolicyTypeHeader specifies to hash a Header in the incoming request. HashPolicyTypeHeader HashPolicyType = iota // HashPolicyTypeChannelID specifies to hash a unique Identifier of the // Channel. This is a 64-bit random int computed at initialization time. HashPolicyTypeChannelID )
type HeaderMatcher ¶
type HeaderMatcher struct {
Name string
InvertMatch *bool
ExactMatch *string
RegexMatch *regexp.Regexp
PrefixMatch *string
SuffixMatch *string
RangeMatch *Int64Range
PresentMatch *bool
StringMatch *matcher.StringMatcher
}
HeaderMatcher represents header matchers.
type InboundListenerConfig ¶
type InboundListenerConfig struct {
// Address is the local address on which the inbound listener is expected to
// accept incoming connections.
Address string
// Port is the local port on which the inbound listener is expected to
// accept incoming connections.
Port string
// DefaultFilterChain is the default filter chain to use if no other filter
// chain matches.
DefaultFilterChain NetworkFilterChainConfig
// FilterChains contains the filter chains associated with this listener.
FilterChains NetworkFilterChainMap
}
InboundListenerConfig contains information about the inbound listener, i.e the server-side listener.
type Int64Range ¶
Int64Range is a range for header range match.
type ListenerResourceData ¶
type ListenerResourceData struct {
Resource ListenerUpdate
}
ListenerResourceData is an implementation of the xdsclient.ResourceData interface for listener resources.
func (*ListenerResourceData) Bytes ¶
func (l *ListenerResourceData) Bytes() []byte
Bytes returns the protobuf serialized bytes of the listener resource proto.
func (*ListenerResourceData) Equal ¶
func (l *ListenerResourceData) Equal(other xdsclient.ResourceData) bool
Equal returns true if other is equal to l.
type ListenerUpdate ¶
type ListenerUpdate struct {
// APIListener contains the HTTP connection manager configuration.
APIListener *HTTPConnectionManagerConfig
// TCPListener contains inbound listener configuration.
TCPListener *InboundListenerConfig
// Raw is the resource from the xds response.
Raw *anypb.Any
}
ListenerUpdate contains information received in an LDS response, which is of interest to the registered LDS watcher.
type ListenerWatcher ¶
type ListenerWatcher interface {
// ResourceChanged indicates a new version of the resource is available.
ResourceChanged(resource *ListenerUpdate, done func())
// ResourceError indicates an error occurred while trying to fetch or
// decode the associated resource. The previous version of the resource
// should be considered invalid.
ResourceError(err error, done func())
// AmbientError indicates an error occurred after a resource has been
// received that should not modify the use of that resource but may provide
// useful information about the state of the XDSClient for debugging
// purposes. The previous version of the resource should still be
// considered valid.
AmbientError(err error, done func())
}
ListenerWatcher wraps the callbacks to be invoked for different events corresponding to the listener resource being watched. gRFC A88 contains an exhaustive list of what method is invoked under what conditions.
type Locality ¶
type Locality struct {
Endpoints []Endpoint
ID clients.Locality
Priority uint32
Weight uint32
Metadata map[string]any
}
Locality contains information of a locality.
type Name ¶
type Name struct {
Scheme string
Authority string
Type string
ID string
ContextParams map[string]string
// contains filtered or unexported fields
}
Name contains the parsed component of an xDS resource name.
An xDS resource name is in the format of xdstp://[{authority}]/{resource type}/{id/*}?{context parameters}{#processing directive,*}
See https://github.com/cncf/xds/blob/main/proposals/TP1-xds-transport-next.md#uri-based-xds-resource-names for details, and examples.
func ParseName ¶
ParseName splits the name and returns a struct representation of the Name.
If the name isn't a valid new-style xDS name, field ID is set to the input. Note that this is not an error, because we still support the old-style resource names (those not starting with "xdstp:").
The caller can tell if the parsing is successful by checking the returned Scheme.
func (*Name) String ¶
String returns a canonicalized string of name. The context parameters are sorted by the keys.
type NetworkFilterChainConfig ¶
type NetworkFilterChainConfig struct {
// SecurityCfg contains transport socket security configuration.
SecurityCfg *SecurityConfig
// HTTPConnMgr contains the HTTP connection manager configuration.
HTTPConnMgr *HTTPConnectionManagerConfig
}
NetworkFilterChainConfig contains the configuration for a network filter chain on the server side. The only support network filter is the HTTP connection manager.
func (NetworkFilterChainConfig) IsEmpty ¶
func (n NetworkFilterChainConfig) IsEmpty() bool
IsEmpty returns true if the NetworkFilterChainConfig contains no configuration.
type NetworkFilterChainMap ¶
type NetworkFilterChainMap struct {
// DstPrefixes is the list of destination prefix entries to match on.
DstPrefixes []DestinationPrefixEntry
}
NetworkFilterChainMap contains the match configuration for network filter chains on the server side. It is a multi-level map structure to facilitate efficient matching of incoming connections based on destination IP, source {type, IP and port}.
type OverloadDropConfig ¶
OverloadDropConfig contains the config to drop overloads.
type Producer ¶
type Producer interface {
// WatchResource uses xDS to discover the resource associated with the
// provided resource name. The resource type implementation determines how
// xDS responses are are deserialized and validated, as received from the
// xDS management server. Upon receipt of a response from the management
// server, an appropriate callback on the watcher is invoked.
WatchResource(typeURL, resourceName string, watcher xdsclient.ResourceWatcher) (cancel func())
}
Producer contains a single method to discover resource configuration from a remote management server using xDS APIs.
The xdsclient package provides a concrete implementation of this interface.
type ProxyAddressMetadataValue ¶
type ProxyAddressMetadataValue struct {
// Address stores the proxy address configured (A86). It will be in the form
// of host:port. It has to be either IPv6 or IPv4.
Address string
}
ProxyAddressMetadataValue holds the address parsed from the envoy.config.core.v3.Address proto message, as specified in gRFC A86.
type ResourceData ¶
type ResourceData interface {
// RawEqual returns true if the passed in resource data is equal to that of
// the receiver, based on the underlying raw protobuf message.
RawEqual(ResourceData) bool
// ToJSON returns a JSON string representation of the resource data.
ToJSON() string
Raw() *anypb.Any
}
ResourceData contains the configuration data sent by the xDS management server, associated with the resource being watched. Every resource type must provide an implementation of this interface to represent the configuration received from the xDS management server.
type ResourceWatcher ¶
type ResourceWatcher interface {
// ResourceChanged indicates a new version of the resource is available.
ResourceChanged(resourceData ResourceData, done func())
// ResourceError indicates an error occurred while trying to fetch or
// decode the associated resource. The previous version of the resource
// should be considered invalid.
ResourceError(err error, done func())
// AmbientError indicates an error occurred after a resource has been
// received that should not modify the use of that resource but may provide
// useful information about the state of the XDSClient for debugging
// purposes. The previous version of the resource should still be
// considered valid.
AmbientError(err error, done func())
}
ResourceWatcher is notified of the resource updates and errors that are received by the xDS client from the management server.
All methods contain a done parameter which should be called when processing of the update has completed. For example, if processing a resource requires watching new resources, registration of those new watchers should be completed before done is called, which can happen after the ResourceWatcher method has returned. Failure to call done will prevent the xDS client from providing future ResourceWatcher notifications.
type RetryBackoff ¶
type RetryBackoff struct {
BaseInterval time.Duration // initial backoff duration between attempts
MaxInterval time.Duration // maximum backoff duration
}
RetryBackoff describes the backoff policy for retries.
type RetryConfig ¶
type RetryConfig struct {
// RetryOn is a set of status codes on which to retry. Only Canceled,
// DeadlineExceeded, Internal, ResourceExhausted, and Unavailable are
// supported; any other values will be omitted.
RetryOn map[codes.Code]bool
NumRetries uint32 // maximum number of retry attempts
RetryBackoff RetryBackoff // retry backoff policy
}
RetryConfig contains all retry-related configuration in either a VirtualHost or Route.
type Route ¶
type Route struct {
Path *string
Prefix *string
Regex *regexp.Regexp
// Indicates if prefix/path matching should be case insensitive. The default
// is false (case sensitive).
CaseInsensitive bool
Headers []*HeaderMatcher
Fraction *uint32
HashPolicies []*HashPolicy
// If the matchers above indicate a match, the below configuration is used.
// If MaxStreamDuration is nil, it indicates neither of the route action's
// max_stream_duration fields (grpc_timeout_header_max nor
// max_stream_duration) were set. In this case, the ListenerUpdate's
// MaxStreamDuration field should be used. If MaxStreamDuration is set to
// an explicit zero duration, the application's deadline should be used.
MaxStreamDuration *time.Duration
// HTTPFilterConfigOverride contains any HTTP filter config overrides for
// the route which may be present. An individual filter's override may be
// unused if the matching WeightedCluster contains an override for that
// filter.
HTTPFilterConfigOverride map[string]httpfilter.FilterConfig
RetryConfig *RetryConfig
ActionType RouteActionType
// Only one of the following fields (WeightedClusters or
// ClusterSpecifierPlugin) will be set for a route.
WeightedClusters []WeightedCluster
// ClusterSpecifierPlugin is the name of the Cluster Specifier Plugin that
// this Route is linked to, if specified by xDS.
ClusterSpecifierPlugin string
// AutoHostRewrite indicates that the ":authority" header can be rewritten
// to the hostname of the upstream endpoint.
AutoHostRewrite bool
}
Route is both a specification of how to match a request as well as an indication of the action to take upon match.
type RouteActionType ¶
type RouteActionType int
RouteActionType is the action of the route from a received RDS response.
const ( // RouteActionUnsupported are routing types currently unsupported by grpc. // According to A36, "A Route with an inappropriate action causes RPCs // matching that route to fail." RouteActionUnsupported RouteActionType = iota // RouteActionRoute is the expected route type on the client side. Route // represents routing a request to some upstream cluster. On the client // side, if an RPC matches to a route that is not RouteActionRoute, the RPC // will fail according to A36. RouteActionRoute // RouteActionNonForwardingAction is the expected route type on the server // side. NonForwardingAction represents when a route will generate a // response directly, without forwarding to an upstream host. RouteActionNonForwardingAction )
type RouteConfigResourceData ¶
type RouteConfigResourceData struct {
Resource RouteConfigUpdate
}
RouteConfigResourceData is an implementation of the xdsclient.ResourceData interface for route configuration resources.
func (*RouteConfigResourceData) Bytes ¶
func (r *RouteConfigResourceData) Bytes() []byte
Bytes returns the protobuf serialized bytes of the route config resource proto.
func (*RouteConfigResourceData) Equal ¶
func (r *RouteConfigResourceData) Equal(other xdsclient.ResourceData) bool
Equal returns true if other is equal to er.
type RouteConfigUpdate ¶
type RouteConfigUpdate struct {
VirtualHosts []*VirtualHost
// ClusterSpecifierPlugins are the LB Configurations for any
// ClusterSpecifierPlugins referenced by the Route Table.
ClusterSpecifierPlugins map[string]clusterspecifier.BalancerConfig
// Raw is the resource from the xds response.
Raw *anypb.Any
}
RouteConfigUpdate contains information received in an RDS response, which is of interest to the registered RDS watcher.
type RouteConfigWatcher ¶
type RouteConfigWatcher interface {
// ResourceChanged indicates a new version of the resource is available.
ResourceChanged(resource *RouteConfigUpdate, done func())
// ResourceError indicates an error occurred while trying to fetch or
// decode the associated resource. The previous version of the resource
// should be considered invalid.
ResourceError(err error, done func())
// AmbientError indicates an error occurred after a resource has been
// received that should not modify the use of that resource but may provide
// useful information about the state of the XDSClient for debugging
// purposes. The previous version of the resource should still be
// considered valid.
AmbientError(err error, done func())
}
RouteConfigWatcher wraps the callbacks to be invoked for different events corresponding to the route configuration resource being watched. gRFC A88 contains an exhaustive list of what method is invoked under what conditions.
type SecurityConfig ¶
type SecurityConfig struct {
// RootInstanceName identifies the certProvider plugin to be used to fetch
// root certificates. This instance name will be resolved to the plugin name
// and its associated configuration from the certificate_providers field of
// the bootstrap file.
RootInstanceName string
// RootCertName is the certificate name to be passed to the plugin (looked
// up from the bootstrap file) while fetching root certificates.
RootCertName string
// IdentityInstanceName identifies the certProvider plugin to be used to
// fetch identity certificates. This instance name will be resolved to the
// plugin name and its associated configuration from the
// certificate_providers field of the bootstrap file.
IdentityInstanceName string
// IdentityCertName is the certificate name to be passed to the plugin
// (looked up from the bootstrap file) while fetching identity certificates.
IdentityCertName string
// SubjectAltNameMatchers is an optional list of match criteria for SANs
// specified on the peer certificate. Used only on the client-side.
//
// Some intricacies:
// - If this field is empty, then any peer certificate is accepted.
// - If the peer certificate contains a wildcard DNS SAN, and an `exact`
// matcher is configured, a wildcard DNS match is performed instead of a
// regular string comparison.
SubjectAltNameMatchers []matcher.StringMatcher
// RequireClientCert indicates if the server handshake process expects the
// client to present a certificate. Set to true when performing mTLS. Used
// only on the server-side.
RequireClientCert bool
// UseSystemRootCerts indicates that the client should use system root
// certificates to validate the server certificate. This field is mutually
// exclusive with RootCertName and RootInstanceName. Validation performed
// after unmarshalling xDS resources ensures that this field is set only
// when both RootCertName and RootInstanceName are empty.
UseSystemRootCerts bool
}
SecurityConfig contains the security configuration received as part of the Cluster resource on the client-side, and as part of the Listener resource on the server-side.
func (*SecurityConfig) Equal ¶
func (sc *SecurityConfig) Equal(other *SecurityConfig) bool
Equal returns true if sc is equal to other.
type ServiceStatus ¶
type ServiceStatus int
ServiceStatus is the status of the update.
const ( // ServiceStatusUnknown is the default state, before a watch is started for // the resource. ServiceStatusUnknown ServiceStatus = iota // ServiceStatusRequested is when the watch is started, but before and // response is received. ServiceStatusRequested // ServiceStatusNotExist is when the resource doesn't exist in // state-of-the-world responses (e.g. LDS and CDS), which means the resource // is removed by the management server. ServiceStatusNotExist // Resource is removed in the server, in LDS/CDS. // ServiceStatusACKed is when the resource is ACKed. ServiceStatusACKed // ServiceStatusNACKed is when the resource is NACKed. ServiceStatusNACKed )
type SourcePrefixEntry ¶
type SourcePrefixEntry struct {
// Prefix is the source IP prefix.
Prefix *net.IPNet
// PortMap contains the matchers for source ports.
PortMap map[int]NetworkFilterChainConfig
}
SourcePrefixEntry contains a source prefix entry and the associated source port matchers.
type SourcePrefixes ¶
type SourcePrefixes struct {
// Entries is the list of source prefix entries.
Entries []SourcePrefixEntry
}
SourcePrefixes contains a list of source prefix entries to match on.
type StructMetadataValue ¶
type StructMetadataValue struct {
// Data stores the parsed JSON representation of a google.protobuf.Struct.
Data map[string]any
}
StructMetadataValue stores the values in a google.protobuf.Struct from FilterMetadata.
type Type ¶
type Type interface {
// TypeURL is the xDS type URL of this resource type for v3 transport.
TypeURL() string
// TypeName identifies resources in a transport protocol agnostic way. This
// can be used for logging/debugging purposes, as well in cases where the
// resource type name is to be uniquely identified but the actual
// functionality provided by the resource type is not required.
//
// TODO: once Type is renamed to ResourceType, rename TypeName to
// ResourceTypeName.
TypeName() string
// AllResourcesRequiredInSotW indicates whether this resource type requires
// that all resources be present in every SotW response from the server. If
// true, a response that does not include a previously seen resource will be
// interpreted as a deletion of that resource.
AllResourcesRequiredInSotW() bool
// Decode deserializes and validates an xDS resource serialized inside the
// provided `Any` proto, as received from the xDS management server.
//
// If protobuf deserialization fails or resource validation fails,
// returns a non-nil error. Otherwise, returns a fully populated
// DecodeResult.
Decode(*DecodeOptions, *anypb.Any) (*DecodeResult, error)
}
Type wraps all resource-type specific functionality. Each supported resource type will provide an implementation of this interface.
type UpdateErrorMetadata ¶
type UpdateErrorMetadata struct {
// Version is the version of the NACKed response.
Version string
// Err contains why the response was NACKed.
Err error
// Timestamp is when the NACKed response was received.
Timestamp time.Time
}
UpdateErrorMetadata is part of UpdateMetadata. It contains the error state when a response is NACKed.
type UpdateMetadata ¶
type UpdateMetadata struct {
// Status is the status of this resource, e.g. ACKed, NACKed, or
// Not_exist(removed).
Status ServiceStatus
// Version is the version of the xds response. Note that this is the version
// of the resource in use (previous ACKed). If a response is NACKed, the
// NACKed version is in ErrState.
Version string
// Timestamp is when the response is received.
Timestamp time.Time
// ErrState is set when the update is NACKed.
ErrState *UpdateErrorMetadata
}
UpdateMetadata contains the metadata for each update, including timestamp, raw message, and so on.
type UpdateValidatorFunc ¶
UpdateValidatorFunc performs validations on update structs using context/logic available at the xdsClient layer. Since these validation are performed on internal update structs, they can be shared between different API clients.
type UpdateWithMD ¶
type UpdateWithMD struct {
MD UpdateMetadata
Raw *anypb.Any
}
UpdateWithMD contains the raw message of the update and the metadata, including version, raw message, timestamp.
This is to be used for config dump and CSDS, not directly by users (like resolvers/balancers).
type VirtualHost ¶
type VirtualHost struct {
Domains []string
// Routes contains a list of routes, each containing matchers and
// corresponding action.
Routes []*Route
// HTTPFilterConfigOverride contains any HTTP filter config overrides for
// the virtual host which may be present. An individual filter's override
// may be unused if the matching Route contains an override for that
// filter.
HTTPFilterConfigOverride map[string]httpfilter.FilterConfig
RetryConfig *RetryConfig
}
VirtualHost contains the routes for a list of Domains.
Note that the domains in this slice can be a wildcard, not an exact string. The consumer of this struct needs to find the best match for its hostname.
func FindBestMatchingVirtualHost ¶
func FindBestMatchingVirtualHost(host string, vHosts []*VirtualHost) *VirtualHost
FindBestMatchingVirtualHost returns the virtual host whose domains field best matches host
The domains field support 4 different matching pattern types:
- Exact match
- Suffix match (e.g. “*ABC”)
- Prefix match (e.g. “ABC*)
- Universal match (e.g. “*”)
The best match is defined as:
- A match is better if it’s matching pattern type is better.
* Exact match > suffix match > prefix match > universal match.
- If two matches are of the same pattern type, the longer match is
better.
* This is to compare the length of the matching pattern, e.g. “*ABCDE” >
“*ABC”
type WeightedCluster ¶
type WeightedCluster struct {
// Name is the name of the cluster.
Name string
// Weight is the relative weight of the cluster. It will never be zero.
Weight uint32
// HTTPFilterConfigOverride contains any HTTP filter config overrides for
// the weighted cluster which may be present.
HTTPFilterConfigOverride map[string]httpfilter.FilterConfig
}
WeightedCluster contains settings for an xds ActionType.WeightedCluster.
type XDSConfig ¶
type XDSConfig struct {
// Listener holds the listener configuration. It is guaranteed to be
// non-nil.
Listener *ListenerUpdate
// RouteConfig holds the route configuration. It will be populated even if
// the route configuration was inlined into the Listener resource. It is
// guaranteed to be non-nil.
RouteConfig *RouteConfigUpdate
// VirtualHost is selected from the route configuration whose domain field
// offers the best match against the provided dataplane authority. It is
// guaranteed to be non-nil.
VirtualHost *VirtualHost
// Clusters is a map from cluster name to its configuration.
Clusters map[string]*ClusterResult
}
XDSConfig holds the complete gRPC client-side xDS configuration containing all necessary resources.
func XDSConfigFromResolverState ¶
XDSConfigFromResolverState returns XDSConfig stored as an attribute in the resolver state.
Source Files ¶
cluster_resource_type.go endpoints_resource_type.go errors.go filter_chain.go listener_resource_type.go logging.go matcher.go matcher_path.go metadata.go name.go resource_type.go route_config_resource_type.go type.go type_cds.go type_eds.go type_lds.go type_rds.go unmarshal_cds.go unmarshal_eds.go unmarshal_lds.go unmarshal_rds.go xdsconfig.go
Directories ¶
| Path | Synopsis |
|---|---|
| internal/xds/xdsclient/xdsresource/tests | |
| internal/xds/xdsclient/xdsresource/version | Package version defines constants to distinguish between supported xDS API versions. |
- Version
- v1.80.0 (latest)
- Published
- Apr 1, 2026
- Platform
- js/wasm
- Imports
- 49 packages
- Last checked
- 3 hours ago –
Tools for package owners.