• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SRC_CORE_EXT_XDS_XDS_BOOTSTRAP_H
18 #define GRPC_SRC_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     // Returns a key to be used for uniquely identifying this XdsServer.
54     virtual std::string Key() const = 0;
55 
56     friend bool operator==(const XdsServer& a, const XdsServer& b) {
57       return a.Equals(b);
58     }
59     friend bool operator!=(const XdsServer& a, const XdsServer& b) {
60       return !a.Equals(b);
61     }
62   };
63 
64   class Authority {
65    public:
66     virtual ~Authority() = default;
67 
68     virtual std::vector<const XdsServer*> servers() const = 0;
69   };
70 
71   virtual ~XdsBootstrap() = default;
72 
73   virtual std::string ToString() const = 0;
74 
75   virtual std::vector<const XdsServer*> servers() const = 0;
76 
77   // Returns the node information, or null if not present in the bootstrap
78   // config.
79   virtual const Node* node() const = 0;
80 
81   // Returns a pointer to the specified authority, or null if it does
82   // not exist in this bootstrap config.
83   virtual const Authority* LookupAuthority(const std::string& name) const = 0;
84 };
85 
86 }  // namespace grpc_core
87 
88 #endif  // GRPC_SRC_CORE_EXT_XDS_XDS_BOOTSTRAP_H
89