Debian Codegraph @

src/core/ext/xds/xds_bootstrap.h

raw
1 //
2 // Copyright 2019 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #ifndef GRPC_CORE_EXT_XDS_XDS_BOOTSTRAP_H
18 #define GRPC_CORE_EXT_XDS_XDS_BOOTSTRAP_H
19
20 #include <grpc/support/port_platform.h>
21
22 #include <string>
23
24 #include "src/core/lib/json/json.h"
25
26 namespace grpc_core {
27
28 bool XdsFederationEnabled();
29
30 class XdsBootstrap {
31 public:
32 class Node {
33 public:
34 virtual ~Node() = default;
35
36 virtual const std::string& id() const = 0;
37 virtual const std::string& cluster() const = 0;
38 virtual const std::string& locality_region() const = 0;
39 virtual const std::string& locality_zone() const = 0;
40 virtual const std::string& locality_sub_zone() const = 0;
41 virtual const Json::Object& metadata() const = 0;
42 };
43
44 class XdsServer {
45 public:
46 virtual ~XdsServer() = default;
47
48 virtual const std::string& server_uri() const = 0;
49 virtual bool IgnoreResourceDeletion() const = 0;
50
51 virtual bool Equals(const XdsServer& other) const = 0;
52
53 friend bool operator==(const XdsServer& a, const XdsServer& b) {
54 return a.Equals(b);
55 }
56 };
57
58 class Authority {
59 public:
60 virtual ~Authority() = default;
61
62 virtual const XdsServer* server() const = 0;
63 };
64
65 virtual ~XdsBootstrap() = default;
66
67 virtual std::string ToString() const = 0;
68
69 // TODO(roth): We currently support only one server. Fix this when we
70 // add support for fallback for the xds channel.
71 virtual const XdsServer& server() const = 0;
72
73 // Returns the node information, or null if not present in the bootstrap
74 // config.
75 virtual const Node* node() const = 0;
76
77 // Returns a pointer to the specified authority, or null if it does
78 // not exist in this bootstrap config.
79 virtual const Authority* LookupAuthority(const std::string& name) const = 0;
80
81 // If the server exists in the bootstrap config, returns a pointer to
82 // the XdsServer instance in the config. Otherwise, returns null.
83 virtual const XdsServer* FindXdsServer(const XdsServer& server) const = 0;
84 };
85
86 } // namespace grpc_core
87
88 #endif // GRPC_CORE_EXT_XDS_XDS_BOOTSTRAP_H