google.golang.org/grpc@v1.74.2/xds/internal/clients/xdsclient/xdsconfig.go (about)

     1  /*
     2   *
     3   * Copyright 2025 gRPC authors.
     4   *
     5   * Licensed under the Apache License, Version 2.0 (the "License");
     6   * you may not use this file except in compliance with the License.
     7   * You may obtain a copy of the License at
     8   *
     9   *     http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   */
    18  
    19  package xdsclient
    20  
    21  import (
    22  	"google.golang.org/grpc/xds/internal/clients"
    23  )
    24  
    25  // Config is used to configure an xDS client. After one has been passed to the
    26  // xDS client's New function, no part of it may be modified. A Config may be
    27  // reused; the xdsclient package will also not modify it.
    28  type Config struct {
    29  	// Servers specifies a list of xDS management servers to connect to. The
    30  	// order of the servers in this list reflects the order of preference of
    31  	// the data returned by those servers. The xDS client uses the first
    32  	// available server from the list.
    33  	//
    34  	// See gRFC A71 for more details on fallback behavior when the primary
    35  	// xDS server is unavailable.
    36  	//
    37  	// gRFC A71: https://github.com/grpc/proposal/blob/master/A71-xds-fallback.md
    38  	Servers []ServerConfig
    39  
    40  	// Authorities defines the configuration for each xDS authority.  Federated resources
    41  	// will be fetched from the servers specified by the corresponding Authority.
    42  	Authorities map[string]Authority
    43  
    44  	// Node is the identity of the xDS client connecting to the xDS
    45  	// management server.
    46  	Node clients.Node
    47  
    48  	// TransportBuilder is used to create connections to xDS management servers.
    49  	TransportBuilder clients.TransportBuilder
    50  
    51  	// ResourceTypes is a map from resource type URLs to resource type
    52  	// implementations. Each resource type URL uniquely identifies a specific
    53  	// kind of xDS resource, and the corresponding resource type implementation
    54  	// provides logic for parsing, validating, and processing resources of that
    55  	// type.
    56  	//
    57  	// For example: "type.googleapis.com/envoy.config.listener.v3.Listener"
    58  	ResourceTypes map[string]ResourceType
    59  
    60  	// MetricsReporter is used to report registered metrics. If unset, no
    61  	// metrics will be reported.
    62  	MetricsReporter clients.MetricsReporter
    63  }
    64  
    65  // ServerConfig contains configuration for an xDS management server.
    66  type ServerConfig struct {
    67  	ServerIdentifier clients.ServerIdentifier
    68  
    69  	// IgnoreResourceDeletion is a server feature which if set to true,
    70  	// indicates that resource deletion errors from xDS management servers can
    71  	// be ignored and cached resource data can be used.
    72  	//
    73  	// This will be removed in the future once we implement gRFC A88
    74  	// and two new fields FailOnDataErrors and
    75  	// ResourceTimerIsTransientError will be introduced.
    76  	IgnoreResourceDeletion bool
    77  
    78  	// TODO: Link to gRFC A88
    79  }
    80  
    81  // Authority contains configuration for an xDS control plane authority.
    82  //
    83  // See: https://www.envoyproxy.io/docs/envoy/latest/xds/core/v3/resource_locator.proto#xds-core-v3-resourcelocator
    84  type Authority struct {
    85  	// XDSServers contains the list of server configurations for this authority.
    86  	//
    87  	// See Config.Servers for more details.
    88  	XDSServers []ServerConfig
    89  }
    90  
    91  func isServerConfigEqual(a, b *ServerConfig) bool {
    92  	return a.ServerIdentifier == b.ServerIdentifier && a.IgnoreResourceDeletion == b.IgnoreResourceDeletion
    93  }