grpc 1.26.0 → 1.27.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1654 -1519
  3. data/etc/roots.pem +44 -0
  4. data/include/grpc/grpc_security.h +37 -15
  5. data/include/grpc/grpc_security_constants.h +27 -0
  6. data/include/grpc/impl/codegen/grpc_types.h +14 -0
  7. data/include/grpc/impl/codegen/port_platform.h +1 -1
  8. data/src/core/ext/filters/client_channel/client_channel.cc +0 -20
  9. data/src/core/ext/filters/client_channel/http_proxy.cc +4 -4
  10. data/src/core/ext/filters/client_channel/lb_policy.cc +4 -3
  11. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +191 -201
  12. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +3 -2
  15. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +88 -121
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +28 -57
  17. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +0 -7
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +8 -9
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +53 -34
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +18 -5
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +24 -19
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
  23. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -2
  24. data/src/core/ext/filters/client_channel/server_address.cc +6 -9
  25. data/src/core/ext/filters/client_channel/server_address.h +3 -10
  26. data/src/core/ext/filters/client_channel/xds/xds_api.cc +394 -150
  27. data/src/core/ext/filters/client_channel/xds/xds_api.h +75 -35
  28. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +59 -22
  29. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +13 -9
  30. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +8 -6
  31. data/src/core/ext/filters/client_channel/xds/xds_client.cc +456 -175
  32. data/src/core/ext/filters/client_channel/xds/xds_client.h +33 -21
  33. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -8
  34. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -24
  35. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -2
  36. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +13 -5
  37. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +34 -0
  38. data/src/core/lib/channel/channelz.h +11 -1
  39. data/src/core/lib/gpr/time_precise.cc +1 -1
  40. data/src/core/lib/gprpp/optional.h +26 -0
  41. data/src/core/lib/gprpp/string_view.h +14 -10
  42. data/src/core/lib/iomgr/executor.cc +1 -1
  43. data/src/core/lib/iomgr/fork_posix.cc +4 -0
  44. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +87 -0
  45. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +88 -0
  46. data/src/core/lib/iomgr/socket_utils_common_posix.cc +14 -0
  47. data/src/core/lib/iomgr/socket_utils_posix.h +12 -0
  48. data/src/core/lib/iomgr/tcp_custom.h +3 -0
  49. data/src/core/lib/iomgr/tcp_posix.cc +607 -56
  50. data/src/core/lib/iomgr/tcp_server_custom.cc +15 -2
  51. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +8 -0
  52. data/src/core/lib/json/json.h +11 -1
  53. data/src/core/lib/json/json_reader.cc +206 -28
  54. data/src/core/lib/json/json_writer.cc +111 -24
  55. data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -0
  56. data/src/core/lib/security/credentials/composite/composite_credentials.h +5 -1
  57. data/src/core/lib/security/credentials/credentials.h +10 -1
  58. data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -1
  59. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
  60. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -4
  61. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -1
  62. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +20 -0
  63. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +8 -0
  64. data/src/core/lib/security/credentials/tls/{spiffe_credentials.cc → tls_credentials.cc} +23 -24
  65. data/src/core/lib/security/credentials/tls/{spiffe_credentials.h → tls_credentials.h} +9 -9
  66. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -0
  67. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +22 -2
  68. data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +2 -2
  69. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -2
  70. data/src/core/lib/security/security_connector/local/local_security_connector.cc +30 -3
  71. data/src/core/lib/security/security_connector/ssl_utils.cc +45 -3
  72. data/src/core/lib/security/security_connector/ssl_utils.h +12 -0
  73. data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.cc → tls_security_connector.cc} +82 -69
  74. data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.h → tls_security_connector.h} +17 -18
  75. data/src/core/lib/security/transport/client_auth_filter.cc +33 -0
  76. data/src/core/lib/surface/completion_queue.cc +22 -1
  77. data/src/core/lib/surface/version.cc +1 -1
  78. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +11 -1
  79. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
  80. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +3 -3
  81. data/src/core/tsi/fake_transport_security.cc +7 -3
  82. data/src/core/tsi/fake_transport_security.h +2 -0
  83. data/src/core/tsi/ssl_transport_security.cc +144 -8
  84. data/src/core/tsi/ssl_transport_security.h +15 -1
  85. data/src/core/tsi/transport_security.cc +13 -0
  86. data/src/core/tsi/transport_security_grpc.cc +2 -2
  87. data/src/core/tsi/transport_security_grpc.h +2 -2
  88. data/src/core/tsi/transport_security_interface.h +12 -0
  89. data/src/ruby/bin/math_pb.rb +5 -5
  90. data/src/ruby/ext/grpc/rb_call_credentials.c +4 -1
  91. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  92. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
  93. data/src/ruby/lib/grpc/version.rb +1 -1
  94. data/src/ruby/pb/grpc/health/v1/health_pb.rb +3 -3
  95. data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +1 -1
  96. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +23 -13
  97. data/third_party/abseil-cpp/absl/algorithm/algorithm.h +159 -0
  98. data/third_party/abseil-cpp/absl/base/attributes.h +609 -0
  99. data/third_party/abseil-cpp/absl/base/call_once.h +226 -0
  100. data/third_party/abseil-cpp/absl/base/casts.h +184 -0
  101. data/third_party/abseil-cpp/absl/base/config.h +622 -0
  102. data/third_party/abseil-cpp/absl/base/const_init.h +76 -0
  103. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +129 -0
  104. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +389 -0
  105. data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +179 -0
  106. data/third_party/abseil-cpp/absl/base/internal/bits.h +218 -0
  107. data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +107 -0
  108. data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +94 -0
  109. data/third_party/abseil-cpp/absl/base/internal/endian.h +266 -0
  110. data/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +51 -0
  111. data/third_party/abseil-cpp/absl/base/internal/identity.h +37 -0
  112. data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +107 -0
  113. data/third_party/abseil-cpp/absl/base/internal/invoke.h +187 -0
  114. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +107 -0
  115. data/third_party/abseil-cpp/absl/base/internal/per_thread_tls.h +52 -0
  116. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +237 -0
  117. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +179 -0
  118. data/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +58 -0
  119. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +233 -0
  120. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +243 -0
  121. data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +35 -0
  122. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +67 -0
  123. data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +46 -0
  124. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +81 -0
  125. data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +93 -0
  126. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +37 -0
  127. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +414 -0
  128. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +66 -0
  129. data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +271 -0
  130. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +140 -0
  131. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +250 -0
  132. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +108 -0
  133. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +75 -0
  134. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +66 -0
  135. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +158 -0
  136. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +103 -0
  137. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +124 -0
  138. data/third_party/abseil-cpp/absl/base/log_severity.cc +27 -0
  139. data/third_party/abseil-cpp/absl/base/log_severity.h +121 -0
  140. data/third_party/abseil-cpp/absl/base/macros.h +220 -0
  141. data/third_party/abseil-cpp/absl/base/optimization.h +181 -0
  142. data/third_party/abseil-cpp/absl/base/options.h +214 -0
  143. data/third_party/abseil-cpp/absl/base/policy_checks.h +111 -0
  144. data/third_party/abseil-cpp/absl/base/port.h +26 -0
  145. data/third_party/abseil-cpp/absl/base/thread_annotations.h +280 -0
  146. data/third_party/abseil-cpp/absl/container/inlined_vector.h +848 -0
  147. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +265 -0
  148. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +892 -0
  149. data/third_party/abseil-cpp/absl/memory/memory.h +695 -0
  150. data/third_party/abseil-cpp/absl/meta/type_traits.h +759 -0
  151. data/third_party/abseil-cpp/absl/numeric/int128.cc +404 -0
  152. data/third_party/abseil-cpp/absl/numeric/int128.h +1091 -0
  153. data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +302 -0
  154. data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +308 -0
  155. data/third_party/abseil-cpp/absl/strings/ascii.cc +200 -0
  156. data/third_party/abseil-cpp/absl/strings/ascii.h +241 -0
  157. data/third_party/abseil-cpp/absl/strings/charconv.cc +985 -0
  158. data/third_party/abseil-cpp/absl/strings/charconv.h +119 -0
  159. data/third_party/abseil-cpp/absl/strings/escaping.cc +949 -0
  160. data/third_party/abseil-cpp/absl/strings/escaping.h +164 -0
  161. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +156 -0
  162. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +359 -0
  163. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +421 -0
  164. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +504 -0
  165. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +99 -0
  166. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +180 -0
  167. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +58 -0
  168. data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +112 -0
  169. data/third_party/abseil-cpp/absl/strings/internal/memutil.h +148 -0
  170. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +36 -0
  171. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +89 -0
  172. data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +73 -0
  173. data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +248 -0
  174. data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +314 -0
  175. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +455 -0
  176. data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +53 -0
  177. data/third_party/abseil-cpp/absl/strings/internal/utf8.h +50 -0
  178. data/third_party/abseil-cpp/absl/strings/match.cc +40 -0
  179. data/third_party/abseil-cpp/absl/strings/match.h +90 -0
  180. data/third_party/abseil-cpp/absl/strings/numbers.cc +916 -0
  181. data/third_party/abseil-cpp/absl/strings/numbers.h +263 -0
  182. data/third_party/abseil-cpp/absl/strings/str_cat.cc +246 -0
  183. data/third_party/abseil-cpp/absl/strings/str_cat.h +408 -0
  184. data/third_party/abseil-cpp/absl/strings/str_join.h +293 -0
  185. data/third_party/abseil-cpp/absl/strings/str_replace.cc +82 -0
  186. data/third_party/abseil-cpp/absl/strings/str_replace.h +219 -0
  187. data/third_party/abseil-cpp/absl/strings/str_split.cc +139 -0
  188. data/third_party/abseil-cpp/absl/strings/str_split.h +513 -0
  189. data/third_party/abseil-cpp/absl/strings/string_view.cc +235 -0
  190. data/third_party/abseil-cpp/absl/strings/string_view.h +615 -0
  191. data/third_party/abseil-cpp/absl/strings/strip.h +91 -0
  192. data/third_party/abseil-cpp/absl/strings/substitute.cc +171 -0
  193. data/third_party/abseil-cpp/absl/strings/substitute.h +693 -0
  194. data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +48 -0
  195. data/third_party/abseil-cpp/absl/types/bad_optional_access.h +78 -0
  196. data/third_party/abseil-cpp/absl/types/internal/optional.h +396 -0
  197. data/third_party/abseil-cpp/absl/types/internal/span.h +128 -0
  198. data/third_party/abseil-cpp/absl/types/optional.h +776 -0
  199. data/third_party/abseil-cpp/absl/types/span.h +713 -0
  200. data/third_party/abseil-cpp/absl/utility/utility.h +350 -0
  201. data/third_party/upb/upb/decode.c +4 -0
  202. data/third_party/upb/upb/port.c +0 -1
  203. data/third_party/upb/upb/port_def.inc +1 -3
  204. data/third_party/upb/upb/table.c +2 -1
  205. metadata +147 -43
  206. data/src/core/lib/json/json_common.h +0 -34
  207. data/src/core/lib/json/json_reader.h +0 -146
  208. data/src/core/lib/json/json_string.cc +0 -367
  209. data/src/core/lib/json/json_writer.h +0 -84
@@ -27,6 +27,7 @@
27
27
  #include "src/core/ext/filters/client_channel/xds/xds_client_stats.h"
28
28
  #include "src/core/lib/gprpp/map.h"
29
29
  #include "src/core/lib/gprpp/memory.h"
30
+ #include "src/core/lib/gprpp/optional.h"
30
31
  #include "src/core/lib/gprpp/orphanable.h"
31
32
  #include "src/core/lib/gprpp/ref_counted.h"
32
33
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
@@ -85,9 +86,9 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
85
86
  // keep a raw pointer to the watcher, which may be used only for
86
87
  // cancellation. (Because the caller does not own the watcher, the
87
88
  // pointer must not be used for any other purpose.)
88
- void WatchClusterData(StringView cluster,
89
+ void WatchClusterData(StringView cluster_name,
89
90
  std::unique_ptr<ClusterWatcherInterface> watcher);
90
- void CancelClusterDataWatch(StringView cluster,
91
+ void CancelClusterDataWatch(StringView cluster_name,
91
92
  ClusterWatcherInterface* watcher);
92
93
 
93
94
  // Start and cancel endpoint data watch for a cluster.
@@ -95,15 +96,15 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
95
96
  // keep a raw pointer to the watcher, which may be used only for
96
97
  // cancellation. (Because the caller does not own the watcher, the
97
98
  // pointer must not be used for any other purpose.)
98
- void WatchEndpointData(StringView cluster,
99
+ void WatchEndpointData(StringView eds_service_name,
99
100
  std::unique_ptr<EndpointWatcherInterface> watcher);
100
- void CancelEndpointDataWatch(StringView cluster,
101
+ void CancelEndpointDataWatch(StringView eds_service_name,
101
102
  EndpointWatcherInterface* watcher);
102
103
 
103
- // Adds and removes client stats for cluster.
104
- void AddClientStats(StringView lrs_server, StringView cluster,
104
+ // Adds and removes client stats for \a cluster_name.
105
+ void AddClientStats(StringView /*lrs_server*/, StringView cluster_name,
105
106
  XdsClientStats* client_stats);
106
- void RemoveClientStats(StringView lrs_server, StringView cluster,
107
+ void RemoveClientStats(StringView /*lrs_server*/, StringView cluster_name,
107
108
  XdsClientStats* client_stats);
108
109
 
109
110
  // Resets connection backoff state.
@@ -115,6 +116,8 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
115
116
  const grpc_channel_args& args);
116
117
 
117
118
  private:
119
+ static const grpc_arg_pointer_vtable kXdsClientVtable;
120
+
118
121
  // Contains a channel to the xds server and all the data related to the
119
122
  // channel. Holds a ref to the xds client object.
120
123
  // TODO(roth): This is separate from the XdsClient object because it was
@@ -144,9 +147,6 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
144
147
  AdsCallState* ads_calld() const;
145
148
  LrsCallState* lrs_calld() const;
146
149
 
147
- void MaybeStartAdsCall();
148
- void StopAdsCall();
149
-
150
150
  void MaybeStartLrsCall();
151
151
  void StopLrsCall();
152
152
 
@@ -155,6 +155,9 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
155
155
  void StartConnectivityWatchLocked();
156
156
  void CancelConnectivityWatchLocked();
157
157
 
158
+ void OnResourceNamesChanged(const std::string& type_url);
159
+ void OnWatcherRemoved();
160
+
158
161
  private:
159
162
  class StateWatcher;
160
163
 
@@ -173,13 +176,18 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
173
176
 
174
177
  struct ClusterState {
175
178
  std::map<ClusterWatcherInterface*, std::unique_ptr<ClusterWatcherInterface>>
176
- cluster_watchers;
179
+ watchers;
180
+ // The latest data seen from CDS.
181
+ Optional<CdsUpdate> update;
182
+ };
183
+
184
+ struct EndpointState {
177
185
  std::map<EndpointWatcherInterface*,
178
186
  std::unique_ptr<EndpointWatcherInterface>>
179
- endpoint_watchers;
187
+ watchers;
180
188
  std::set<XdsClientStats*> client_stats;
181
189
  // The latest data seen from EDS.
182
- EdsUpdate eds_update;
190
+ EdsUpdate update;
183
191
  };
184
192
 
185
193
  // Sends an error notification to all watchers.
@@ -189,12 +197,22 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
189
197
  // normal method instead of a closure callback.
190
198
  static void NotifyOnServiceConfig(void* arg, grpc_error* error);
191
199
 
200
+ std::set<StringView> WatchedClusterNames() const;
201
+
202
+ std::set<StringView> EdsServiceNames() const;
203
+
204
+ std::map<StringView, std::set<XdsClientStats*>> ClientStatsMap() const;
205
+
192
206
  // Channel arg vtable functions.
193
207
  static void* ChannelArgCopy(void* p);
194
208
  static void ChannelArgDestroy(void* p);
195
209
  static int ChannelArgCmp(void* p, void* q);
196
210
 
197
- static const grpc_arg_pointer_vtable kXdsClientVtable;
211
+ // All the received clusters are cached, no matter they are watched or not.
212
+ std::map<StringView /*cluster_name*/, ClusterState, StringLess> cluster_map_;
213
+ // Only the watched EDS service names are stored.
214
+ std::map<StringView /*eds_service_name*/, EndpointState, StringLess>
215
+ endpoint_map_;
198
216
 
199
217
  grpc_core::UniquePtr<char> build_version_;
200
218
 
@@ -203,7 +221,7 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
203
221
 
204
222
  std::unique_ptr<XdsBootstrap> bootstrap_;
205
223
 
206
- grpc_core::UniquePtr<char> server_name_;
224
+ std::string server_name_;
207
225
  std::unique_ptr<ServiceConfigWatcherInterface> service_config_watcher_;
208
226
  // TODO(juanlishen): Once we implement LDS support, this will no
209
227
  // longer be needed.
@@ -212,12 +230,6 @@ class XdsClient : public InternallyRefCounted<XdsClient> {
212
230
  // The channel for communicating with the xds server.
213
231
  OrphanablePtr<ChannelState> chand_;
214
232
 
215
- // TODO(juanlishen): As part of adding CDS support, replace
216
- // cluster_state_ with a map keyed by cluster name, so that we can
217
- // support multiple clusters for both CDS and EDS.
218
- ClusterState cluster_state_;
219
- // Map<StringView /*cluster*/, ClusterState, StringLess> clusters_;
220
-
221
233
  bool shutting_down_ = false;
222
234
  };
223
235
 
@@ -87,11 +87,10 @@ XdsClientStats::LocalityStats::GetSnapshotAndReset() {
87
87
  {
88
88
  MutexLock lock(&load_metric_stats_mu_);
89
89
  for (auto& p : load_metric_stats_) {
90
- const char* metric_name = p.first.get();
90
+ const std::string& metric_name = p.first;
91
91
  LoadMetric& metric_value = p.second;
92
- snapshot.load_metric_stats.emplace(
93
- grpc_core::UniquePtr<char>(gpr_strdup(metric_name)),
94
- metric_value.GetSnapshotAndReset());
92
+ snapshot.load_metric_stats.emplace(metric_name,
93
+ metric_value.GetSnapshotAndReset());
95
94
  }
96
95
  }
97
96
  return snapshot;
@@ -178,14 +177,12 @@ void XdsClientStats::PruneLocalityStats() {
178
177
  }
179
178
  }
180
179
 
181
- void XdsClientStats::AddCallDropped(
182
- const grpc_core::UniquePtr<char>& category) {
180
+ void XdsClientStats::AddCallDropped(const std::string& category) {
183
181
  total_dropped_requests_.FetchAdd(1, MemoryOrder::RELAXED);
184
182
  MutexLock lock(&dropped_requests_mu_);
185
183
  auto iter = dropped_requests_.find(category);
186
184
  if (iter == dropped_requests_.end()) {
187
- dropped_requests_.emplace(
188
- grpc_core::UniquePtr<char>(gpr_strdup(category.get())), 1);
185
+ dropped_requests_.emplace(category, 1);
189
186
  } else {
190
187
  ++iter->second;
191
188
  }
@@ -38,46 +38,43 @@ class XdsLocalityName : public RefCounted<XdsLocalityName> {
38
38
  struct Less {
39
39
  bool operator()(const RefCountedPtr<XdsLocalityName>& lhs,
40
40
  const RefCountedPtr<XdsLocalityName>& rhs) const {
41
- int cmp_result = strcmp(lhs->region_.get(), rhs->region_.get());
41
+ int cmp_result = lhs->region_.compare(rhs->region_);
42
42
  if (cmp_result != 0) return cmp_result < 0;
43
- cmp_result = strcmp(lhs->zone_.get(), rhs->zone_.get());
43
+ cmp_result = lhs->zone_.compare(rhs->zone_);
44
44
  if (cmp_result != 0) return cmp_result < 0;
45
- return strcmp(lhs->sub_zone_.get(), rhs->sub_zone_.get()) < 0;
45
+ return lhs->sub_zone_.compare(rhs->sub_zone_) < 0;
46
46
  }
47
47
  };
48
48
 
49
- XdsLocalityName(grpc_core::UniquePtr<char> region,
50
- grpc_core::UniquePtr<char> zone,
51
- grpc_core::UniquePtr<char> subzone)
49
+ XdsLocalityName(std::string region, std::string zone, std::string subzone)
52
50
  : region_(std::move(region)),
53
51
  zone_(std::move(zone)),
54
52
  sub_zone_(std::move(subzone)) {}
55
53
 
56
54
  bool operator==(const XdsLocalityName& other) const {
57
- return strcmp(region_.get(), other.region_.get()) == 0 &&
58
- strcmp(zone_.get(), other.zone_.get()) == 0 &&
59
- strcmp(sub_zone_.get(), other.sub_zone_.get()) == 0;
55
+ return region_ == other.region_ && zone_ == other.zone_ &&
56
+ sub_zone_ == other.sub_zone_;
60
57
  }
61
58
 
62
- const char* region() const { return region_.get(); }
63
- const char* zone() const { return zone_.get(); }
64
- const char* sub_zone() const { return sub_zone_.get(); }
59
+ const std::string& region() const { return region_; }
60
+ const std::string& zone() const { return zone_; }
61
+ const std::string& sub_zone() const { return sub_zone_; }
65
62
 
66
63
  const char* AsHumanReadableString() {
67
64
  if (human_readable_string_ == nullptr) {
68
65
  char* tmp;
69
66
  gpr_asprintf(&tmp, "{region=\"%s\", zone=\"%s\", sub_zone=\"%s\"}",
70
- region_.get(), zone_.get(), sub_zone_.get());
67
+ region_.c_str(), zone_.c_str(), sub_zone_.c_str());
71
68
  human_readable_string_.reset(tmp);
72
69
  }
73
70
  return human_readable_string_.get();
74
71
  }
75
72
 
76
73
  private:
77
- grpc_core::UniquePtr<char> region_;
78
- grpc_core::UniquePtr<char> zone_;
79
- grpc_core::UniquePtr<char> sub_zone_;
80
- grpc_core::UniquePtr<char> human_readable_string_;
74
+ std::string region_;
75
+ std::string zone_;
76
+ std::string sub_zone_;
77
+ UniquePtr<char> human_readable_string_;
81
78
  };
82
79
 
83
80
  // The stats classes (i.e., XdsClientStats, LocalityStats, and LoadMetric) can
@@ -112,10 +109,8 @@ class XdsClientStats {
112
109
  double total_metric_value_{0};
113
110
  };
114
111
 
115
- using LoadMetricMap =
116
- std::map<grpc_core::UniquePtr<char>, LoadMetric, StringLess>;
117
- using LoadMetricSnapshotMap =
118
- std::map<grpc_core::UniquePtr<char>, LoadMetric::Snapshot, StringLess>;
112
+ using LoadMetricMap = std::map<std::string, LoadMetric>;
113
+ using LoadMetricSnapshotMap = std::map<std::string, LoadMetric::Snapshot>;
119
114
 
120
115
  struct Snapshot {
121
116
  // TODO(juanlishen): Change this to const method when const_iterator is
@@ -187,8 +182,7 @@ class XdsClientStats {
187
182
  using LocalityStatsSnapshotMap =
188
183
  std::map<RefCountedPtr<XdsLocalityName>, LocalityStats::Snapshot,
189
184
  XdsLocalityName::Less>;
190
- using DroppedRequestsMap =
191
- std::map<grpc_core::UniquePtr<char>, uint64_t, StringLess>;
185
+ using DroppedRequestsMap = std::map<std::string, uint64_t>;
192
186
  using DroppedRequestsSnapshotMap = DroppedRequestsMap;
193
187
 
194
188
  struct Snapshot {
@@ -211,7 +205,7 @@ class XdsClientStats {
211
205
  RefCountedPtr<LocalityStats> FindLocalityStats(
212
206
  const RefCountedPtr<XdsLocalityName>& locality_name);
213
207
  void PruneLocalityStats();
214
- void AddCallDropped(const grpc_core::UniquePtr<char>& category);
208
+ void AddCallDropped(const std::string& category);
215
209
 
216
210
  private:
217
211
  // The stats for each locality.
@@ -3008,8 +3008,8 @@ void Chttp2IncomingByteStream::NextLocked(void* arg,
3008
3008
  }
3009
3009
  } else if (s->read_closed) {
3010
3010
  if (bs->remaining_bytes_ != 0) {
3011
- s->byte_stream_error =
3012
- GRPC_ERROR_CREATE_FROM_STATIC_STRING("Truncated message");
3011
+ s->byte_stream_error = GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
3012
+ "Truncated message", &s->read_closed_error, 1);
3013
3013
  grpc_core::ExecCtx::Run(DEBUG_LOCATION, bs->next_action_.on_complete,
3014
3014
  GRPC_ERROR_REF(s->byte_stream_error));
3015
3015
  if (s->data_parser.parsing_frame != nullptr) {
@@ -71,20 +71,22 @@ const upb_msglayout grpc_lb_v1_ClientStats_msginit = {
71
71
  UPB_SIZE(40, 48), 6, false,
72
72
  };
73
73
 
74
- static const upb_msglayout *const grpc_lb_v1_LoadBalanceResponse_submsgs[2] = {
74
+ static const upb_msglayout *const grpc_lb_v1_LoadBalanceResponse_submsgs[3] = {
75
+ &grpc_lb_v1_FallbackResponse_msginit,
75
76
  &grpc_lb_v1_InitialLoadBalanceResponse_msginit,
76
77
  &grpc_lb_v1_ServerList_msginit,
77
78
  };
78
79
 
79
- static const upb_msglayout_field grpc_lb_v1_LoadBalanceResponse__fields[2] = {
80
- {1, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 0, 11, 1},
81
- {2, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 1, 11, 1},
80
+ static const upb_msglayout_field grpc_lb_v1_LoadBalanceResponse__fields[3] = {
81
+ {1, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 1, 11, 1},
82
+ {2, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 2, 11, 1},
83
+ {3, UPB_SIZE(0, 0), UPB_SIZE(-5, -9), 0, 11, 1},
82
84
  };
83
85
 
84
86
  const upb_msglayout grpc_lb_v1_LoadBalanceResponse_msginit = {
85
87
  &grpc_lb_v1_LoadBalanceResponse_submsgs[0],
86
88
  &grpc_lb_v1_LoadBalanceResponse__fields[0],
87
- UPB_SIZE(8, 16), 2, false,
89
+ UPB_SIZE(8, 16), 3, false,
88
90
  };
89
91
 
90
92
  static const upb_msglayout *const grpc_lb_v1_InitialLoadBalanceResponse_submsgs[1] = {
@@ -129,5 +131,11 @@ const upb_msglayout grpc_lb_v1_Server_msginit = {
129
131
  UPB_SIZE(24, 48), 4, false,
130
132
  };
131
133
 
134
+ const upb_msglayout grpc_lb_v1_FallbackResponse_msginit = {
135
+ NULL,
136
+ NULL,
137
+ UPB_SIZE(0, 0), 0, false,
138
+ };
139
+
132
140
  #include "upb/port_undef.inc"
133
141
 
@@ -28,6 +28,7 @@ struct grpc_lb_v1_LoadBalanceResponse;
28
28
  struct grpc_lb_v1_InitialLoadBalanceResponse;
29
29
  struct grpc_lb_v1_ServerList;
30
30
  struct grpc_lb_v1_Server;
31
+ struct grpc_lb_v1_FallbackResponse;
31
32
  typedef struct grpc_lb_v1_LoadBalanceRequest grpc_lb_v1_LoadBalanceRequest;
32
33
  typedef struct grpc_lb_v1_InitialLoadBalanceRequest grpc_lb_v1_InitialLoadBalanceRequest;
33
34
  typedef struct grpc_lb_v1_ClientStatsPerToken grpc_lb_v1_ClientStatsPerToken;
@@ -36,6 +37,7 @@ typedef struct grpc_lb_v1_LoadBalanceResponse grpc_lb_v1_LoadBalanceResponse;
36
37
  typedef struct grpc_lb_v1_InitialLoadBalanceResponse grpc_lb_v1_InitialLoadBalanceResponse;
37
38
  typedef struct grpc_lb_v1_ServerList grpc_lb_v1_ServerList;
38
39
  typedef struct grpc_lb_v1_Server grpc_lb_v1_Server;
40
+ typedef struct grpc_lb_v1_FallbackResponse grpc_lb_v1_FallbackResponse;
39
41
  extern const upb_msglayout grpc_lb_v1_LoadBalanceRequest_msginit;
40
42
  extern const upb_msglayout grpc_lb_v1_InitialLoadBalanceRequest_msginit;
41
43
  extern const upb_msglayout grpc_lb_v1_ClientStatsPerToken_msginit;
@@ -44,6 +46,7 @@ extern const upb_msglayout grpc_lb_v1_LoadBalanceResponse_msginit;
44
46
  extern const upb_msglayout grpc_lb_v1_InitialLoadBalanceResponse_msginit;
45
47
  extern const upb_msglayout grpc_lb_v1_ServerList_msginit;
46
48
  extern const upb_msglayout grpc_lb_v1_Server_msginit;
49
+ extern const upb_msglayout grpc_lb_v1_FallbackResponse_msginit;
47
50
  struct google_protobuf_Duration;
48
51
  struct google_protobuf_Timestamp;
49
52
  extern const upb_msglayout google_protobuf_Duration_msginit;
@@ -221,6 +224,7 @@ UPB_INLINE char *grpc_lb_v1_LoadBalanceResponse_serialize(const grpc_lb_v1_LoadB
221
224
  typedef enum {
222
225
  grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_initial_response = 1,
223
226
  grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_server_list = 2,
227
+ grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_fallback_response = 3,
224
228
  grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_NOT_SET = 0
225
229
  } grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_oneofcases;
226
230
  UPB_INLINE grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_oneofcases grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_case(const grpc_lb_v1_LoadBalanceResponse* msg) { return (grpc_lb_v1_LoadBalanceResponse_load_balance_response_type_oneofcases)UPB_FIELD_AT(msg, int32_t, UPB_SIZE(4, 8)); }
@@ -229,6 +233,8 @@ UPB_INLINE bool grpc_lb_v1_LoadBalanceResponse_has_initial_response(const grpc_l
229
233
  UPB_INLINE const grpc_lb_v1_InitialLoadBalanceResponse* grpc_lb_v1_LoadBalanceResponse_initial_response(const grpc_lb_v1_LoadBalanceResponse *msg) { return UPB_READ_ONEOF(msg, const grpc_lb_v1_InitialLoadBalanceResponse*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 1, NULL); }
230
234
  UPB_INLINE bool grpc_lb_v1_LoadBalanceResponse_has_server_list(const grpc_lb_v1_LoadBalanceResponse *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 2); }
231
235
  UPB_INLINE const grpc_lb_v1_ServerList* grpc_lb_v1_LoadBalanceResponse_server_list(const grpc_lb_v1_LoadBalanceResponse *msg) { return UPB_READ_ONEOF(msg, const grpc_lb_v1_ServerList*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 2, NULL); }
236
+ UPB_INLINE bool grpc_lb_v1_LoadBalanceResponse_has_fallback_response(const grpc_lb_v1_LoadBalanceResponse *msg) { return _upb_has_oneof_field(msg, UPB_SIZE(4, 8), 3); }
237
+ UPB_INLINE const grpc_lb_v1_FallbackResponse* grpc_lb_v1_LoadBalanceResponse_fallback_response(const grpc_lb_v1_LoadBalanceResponse *msg) { return UPB_READ_ONEOF(msg, const grpc_lb_v1_FallbackResponse*, UPB_SIZE(0, 0), UPB_SIZE(4, 8), 3, NULL); }
232
238
 
233
239
  UPB_INLINE void grpc_lb_v1_LoadBalanceResponse_set_initial_response(grpc_lb_v1_LoadBalanceResponse *msg, grpc_lb_v1_InitialLoadBalanceResponse* value) {
234
240
  UPB_WRITE_ONEOF(msg, grpc_lb_v1_InitialLoadBalanceResponse*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 1);
@@ -254,6 +260,18 @@ UPB_INLINE struct grpc_lb_v1_ServerList* grpc_lb_v1_LoadBalanceResponse_mutable_
254
260
  }
255
261
  return sub;
256
262
  }
263
+ UPB_INLINE void grpc_lb_v1_LoadBalanceResponse_set_fallback_response(grpc_lb_v1_LoadBalanceResponse *msg, grpc_lb_v1_FallbackResponse* value) {
264
+ UPB_WRITE_ONEOF(msg, grpc_lb_v1_FallbackResponse*, UPB_SIZE(0, 0), value, UPB_SIZE(4, 8), 3);
265
+ }
266
+ UPB_INLINE struct grpc_lb_v1_FallbackResponse* grpc_lb_v1_LoadBalanceResponse_mutable_fallback_response(grpc_lb_v1_LoadBalanceResponse *msg, upb_arena *arena) {
267
+ struct grpc_lb_v1_FallbackResponse* sub = (struct grpc_lb_v1_FallbackResponse*)grpc_lb_v1_LoadBalanceResponse_fallback_response(msg);
268
+ if (sub == NULL) {
269
+ sub = (struct grpc_lb_v1_FallbackResponse*)upb_msg_new(&grpc_lb_v1_FallbackResponse_msginit, arena);
270
+ if (!sub) return NULL;
271
+ grpc_lb_v1_LoadBalanceResponse_set_fallback_response(msg, sub);
272
+ }
273
+ return sub;
274
+ }
257
275
 
258
276
  /* grpc.lb.v1.InitialLoadBalanceResponse */
259
277
 
@@ -350,6 +368,22 @@ UPB_INLINE void grpc_lb_v1_Server_set_drop(grpc_lb_v1_Server *msg, bool value) {
350
368
  UPB_FIELD_AT(msg, bool, UPB_SIZE(4, 4)) = value;
351
369
  }
352
370
 
371
+ /* grpc.lb.v1.FallbackResponse */
372
+
373
+ UPB_INLINE grpc_lb_v1_FallbackResponse *grpc_lb_v1_FallbackResponse_new(upb_arena *arena) {
374
+ return (grpc_lb_v1_FallbackResponse *)upb_msg_new(&grpc_lb_v1_FallbackResponse_msginit, arena);
375
+ }
376
+ UPB_INLINE grpc_lb_v1_FallbackResponse *grpc_lb_v1_FallbackResponse_parse(const char *buf, size_t size,
377
+ upb_arena *arena) {
378
+ grpc_lb_v1_FallbackResponse *ret = grpc_lb_v1_FallbackResponse_new(arena);
379
+ return (ret && upb_decode(buf, size, ret, &grpc_lb_v1_FallbackResponse_msginit, arena)) ? ret : NULL;
380
+ }
381
+ UPB_INLINE char *grpc_lb_v1_FallbackResponse_serialize(const grpc_lb_v1_FallbackResponse *msg, upb_arena *arena, size_t *len) {
382
+ return upb_encode(msg, &grpc_lb_v1_FallbackResponse_msginit, arena, len);
383
+ }
384
+
385
+
386
+
353
387
  #ifdef __cplusplus
354
388
  } /* extern "C" */
355
389
  #endif
@@ -148,7 +148,17 @@ class CallCountingHelper {
148
148
  // Make sure the size is exactly one cache line.
149
149
  uint8_t padding[GPR_CACHELINE_SIZE - 3 * sizeof(Atomic<intptr_t>) -
150
150
  sizeof(Atomic<gpr_cycle_counter>)];
151
- } GPR_ALIGN_STRUCT(GPR_CACHELINE_SIZE);
151
+ }
152
+ #if GRPC_USE_ABSL
153
+ // TODO(soheilhy,veblush): Revist this after abseil integration.
154
+ // This has a problem when using abseil inlined_vector because it
155
+ // carries an alignment attribute properly but our allocator doesn't
156
+ // respect this. To avoid UBSAN errors, this should be removed with
157
+ // abseil inlined_vector.
158
+ ;
159
+ #else
160
+ GPR_ALIGN_STRUCT(GPR_CACHELINE_SIZE);
161
+ #endif
152
162
 
153
163
  struct CounterData {
154
164
  int64_t calls_started = 0;
@@ -31,7 +31,7 @@
31
31
 
32
32
  #include "src/core/lib/gpr/time_precise.h"
33
33
 
34
- #if GPR_CYCLE_COUNTER_RDTSC_32 or GPR_CYCLE_COUNTER_RDTSC_64
34
+ #if GPR_CYCLE_COUNTER_RDTSC_32 || GPR_CYCLE_COUNTER_RDTSC_64
35
35
  #if GPR_LINUX
36
36
  static bool read_freq_from_kernel(double* freq) {
37
37
  // Google production kernel export the frequency for us in kHz.
@@ -19,6 +19,24 @@
19
19
  #ifndef GRPC_CORE_LIB_GPRPP_OPTIONAL_H
20
20
  #define GRPC_CORE_LIB_GPRPP_OPTIONAL_H
21
21
 
22
+ #include <grpc/support/port_platform.h>
23
+
24
+ // TODO(yashykt): Remove false once migration to abseil is done.
25
+ #if false && GRPC_USE_ABSL
26
+
27
+ #include "absl/types/optional.h"
28
+
29
+ namespace grpc_core {
30
+
31
+ template <typename T>
32
+ using Optional = absl::optional<T>;
33
+
34
+ } // namespace grpc_core
35
+
36
+ #else
37
+
38
+ #include <utility>
39
+
22
40
  namespace grpc_core {
23
41
 
24
42
  /* A make-shift alternative for absl::Optional. This can be removed in favor of
@@ -27,11 +45,17 @@ template <typename T>
27
45
  class Optional {
28
46
  public:
29
47
  Optional() : value_() {}
48
+
30
49
  void set(const T& val) {
31
50
  value_ = val;
32
51
  set_ = true;
33
52
  }
34
53
 
54
+ void set(T&& val) {
55
+ value_ = std::move(val);
56
+ set_ = true;
57
+ }
58
+
35
59
  bool has_value() const { return set_; }
36
60
 
37
61
  void reset() { set_ = false; }
@@ -45,4 +69,6 @@ class Optional {
45
69
 
46
70
  } /* namespace grpc_core */
47
71
 
72
+ #endif
73
+
48
74
  #endif /* GRPC_CORE_LIB_GPRPP_OPTIONAL_H */