google.golang.org/grpc@v1.74.2/xds/internal/clients/config.go (about) 1 /* 2 * 3 * Copyright 2024 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 clients provides implementations of the clients to interact with 20 // xDS and LRS servers. 21 // 22 // # xDS Client 23 // 24 // The xDS client allows applications to: 25 // - Create client instances with in-memory configurations. 26 // - Register watches for named resources. 27 // - Receive resources via the ADS (Aggregated Discovery Service) stream. 28 // 29 // This enables applications to dynamically discover and configure resources 30 // such as listeners, routes, clusters, and endpoints from an xDS management 31 // server. 32 // 33 // # LRS Client 34 // 35 // The LRS (Load Reporting Service) client allows applications to report load 36 // data to an LRS server via the LRS stream. This data can be used for 37 // monitoring, traffic management, and other purposes. 38 // 39 // # Experimental 40 // 41 // NOTICE: This package is EXPERIMENTAL and may be changed or removed 42 // in a later release. 43 package clients 44 45 // ServerIdentifier holds identifying information for connecting to an xDS 46 // management or LRS server. 47 type ServerIdentifier struct { 48 // ServerURI is the target URI of the server. 49 ServerURI string 50 51 // Extensions can be populated with arbitrary data to be passed to the 52 // TransportBuilder and/or xDS Client's ResourceType implementations. 53 // This field can be used to provide additional configuration or context 54 // specific to the user's needs. 55 // 56 // The xDS and LRS clients do not interpret the contents of this field. 57 // It is the responsibility of the user's custom TransportBuilder and/or 58 // ResourceType implementations to handle and interpret these extensions. 59 // 60 // For example, a custom TransportBuilder might use this field to 61 // configure a specific security credentials. 62 // 63 // Extensions may be any type that is comparable, as they are used as map 64 // keys internally. If Extensions are not able to be used as a map key, 65 // the client may panic. 66 // 67 // See: https://go.dev/ref/spec#Comparison_operators 68 // 69 // Any equivalent extensions in all ServerIdentifiers present in a single 70 // client's configuration should have the same value. Not following this 71 // restriction may result in excess resource usage. 72 Extensions any 73 } 74 75 // Node represents the identity of the xDS client, allowing xDS and LRS servers 76 // to identify the source of xDS requests. 77 type Node struct { 78 // ID is a string identifier of the application. 79 ID string 80 // Cluster is the name of the cluster the application belongs to. 81 Cluster string 82 // Locality is the location of the application including region, zone, 83 // sub-zone. 84 Locality Locality 85 // Metadata provides additional context about the application by associating 86 // arbitrary key-value pairs with it. 87 Metadata any 88 // UserAgentName is the user agent name of application. 89 UserAgentName string 90 // UserAgentVersion is the user agent version of application. 91 UserAgentVersion string 92 } 93 94 // Locality represents the location of the xDS client application. 95 type Locality struct { 96 // Region is the region of the xDS client application. 97 Region string 98 // Zone is the area within a region. 99 Zone string 100 // SubZone is the further subdivision within a zone. 101 SubZone string 102 } 103 104 // MetricsReporter is used by the XDSClient to report metrics. 105 type MetricsReporter interface { 106 // ReportMetric reports a metric. The metric will be one of the predefined 107 // set of types depending on the client (XDSClient or LRSClient). 108 // 109 // Each client will produce different metrics. Please see the client's 110 // documentation for a list of possible metrics events. 111 ReportMetric(metric any) 112 }