grpc 1.49.1-x86_64-linux → 1.50.0.pre1-x86_64-linux

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 (275) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +54 -153
  3. data/include/grpc/event_engine/endpoint_config.h +11 -5
  4. data/include/grpc/event_engine/event_engine.h +1 -1
  5. data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
  6. data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
  7. data/include/grpc/impl/codegen/atm_windows.h +0 -2
  8. data/include/grpc/impl/codegen/grpc_types.h +6 -0
  9. data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
  10. data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
  11. data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
  12. data/src/core/ext/filters/client_channel/client_channel.h +1 -1
  13. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
  14. data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
  15. data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
  16. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
  17. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
  20. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
  21. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
  27. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
  30. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
  36. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
  37. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
  38. data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
  39. data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
  40. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
  41. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
  42. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
  43. data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
  44. data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
  45. data/src/core/ext/filters/client_channel/subchannel.h +12 -3
  46. data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
  47. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
  48. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
  49. data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
  50. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
  51. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
  52. data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
  53. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
  54. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
  55. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
  56. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
  57. data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
  58. data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
  59. data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
  60. data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
  61. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
  62. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
  63. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
  64. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
  65. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
  66. data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
  67. data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
  68. data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
  69. data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
  70. data/src/core/ext/xds/certificate_provider_store.cc +63 -3
  71. data/src/core/ext/xds/certificate_provider_store.h +9 -1
  72. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
  73. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
  74. data/src/core/ext/xds/xds_api.cc +21 -17
  75. data/src/core/ext/xds/xds_api.h +7 -0
  76. data/src/core/ext/xds/xds_bootstrap.cc +5 -537
  77. data/src/core/ext/xds/xds_bootstrap.h +39 -111
  78. data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
  79. data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
  80. data/src/core/ext/xds/xds_client.cc +219 -145
  81. data/src/core/ext/xds/xds_client.h +19 -17
  82. data/src/core/ext/xds/xds_client_grpc.cc +18 -80
  83. data/src/core/ext/xds/xds_client_grpc.h +2 -25
  84. data/src/core/ext/xds/xds_client_stats.cc +4 -4
  85. data/src/core/ext/xds/xds_cluster.cc +87 -79
  86. data/src/core/ext/xds/xds_cluster.h +5 -5
  87. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
  88. data/src/core/ext/xds/xds_common_types.cc +13 -5
  89. data/src/core/ext/xds/xds_endpoint.cc +8 -6
  90. data/src/core/ext/xds/xds_endpoint.h +3 -4
  91. data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
  92. data/src/core/ext/xds/xds_listener.cc +25 -20
  93. data/src/core/ext/xds/xds_listener.h +3 -4
  94. data/src/core/ext/xds/xds_resource_type.h +11 -8
  95. data/src/core/ext/xds/xds_route_config.cc +15 -16
  96. data/src/core/ext/xds/xds_route_config.h +3 -3
  97. data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
  98. data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
  99. data/src/core/lib/backoff/backoff.cc +2 -4
  100. data/src/core/lib/channel/call_finalization.h +1 -3
  101. data/src/core/lib/channel/channel_args.h +114 -14
  102. data/src/core/lib/channel/channel_trace.cc +3 -4
  103. data/src/core/lib/channel/promise_based_filter.cc +18 -19
  104. data/src/core/lib/channel/status_util.cc +27 -0
  105. data/src/core/lib/channel/status_util.h +10 -0
  106. data/src/core/lib/config/core_configuration.cc +5 -1
  107. data/src/core/lib/config/core_configuration.h +33 -0
  108. data/src/core/lib/debug/stats.cc +26 -30
  109. data/src/core/lib/debug/stats.h +2 -12
  110. data/src/core/lib/debug/stats_data.cc +118 -614
  111. data/src/core/lib/debug/stats_data.h +67 -465
  112. data/src/core/lib/debug/trace.cc +0 -2
  113. data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
  114. data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
  115. data/src/core/lib/event_engine/forkable.cc +1 -1
  116. data/src/core/lib/event_engine/poller.h +14 -12
  117. data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
  118. data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
  119. data/src/core/lib/event_engine/thread_pool.cc +131 -94
  120. data/src/core/lib/event_engine/thread_pool.h +56 -23
  121. data/src/core/lib/event_engine/time_util.cc +30 -0
  122. data/src/core/lib/event_engine/time_util.h +32 -0
  123. data/src/core/lib/event_engine/utils.cc +0 -5
  124. data/src/core/lib/event_engine/utils.h +0 -4
  125. data/src/core/lib/event_engine/windows/iocp.cc +13 -7
  126. data/src/core/lib/event_engine/windows/iocp.h +2 -1
  127. data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
  128. data/src/core/lib/experiments/config.cc +146 -0
  129. data/src/core/lib/experiments/config.h +43 -0
  130. data/src/core/lib/experiments/experiments.cc +75 -0
  131. data/src/core/lib/experiments/experiments.h +56 -0
  132. data/src/core/lib/gpr/alloc.cc +1 -9
  133. data/src/core/lib/gpr/log_windows.cc +0 -1
  134. data/src/core/lib/gpr/string_util_windows.cc +3 -30
  135. data/src/core/lib/gpr/sync_abseil.cc +0 -14
  136. data/src/core/lib/gpr/sync_posix.cc +0 -14
  137. data/src/core/lib/gpr/time_posix.cc +0 -6
  138. data/src/core/lib/gpr/time_precise.h +1 -1
  139. data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
  140. data/src/core/lib/gpr/useful.h +11 -0
  141. data/src/core/lib/{gpr → gprpp}/env.h +25 -12
  142. data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
  143. data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
  144. data/src/core/lib/gprpp/env_windows.cc +56 -0
  145. data/src/core/lib/gprpp/fork.cc +14 -22
  146. data/src/core/lib/gprpp/fork.h +0 -8
  147. data/src/core/lib/gprpp/global_config_env.cc +7 -6
  148. data/src/core/lib/gprpp/notification.h +67 -0
  149. data/src/core/lib/gprpp/packed_table.h +40 -0
  150. data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
  151. data/src/core/lib/gprpp/sorted_pack.h +98 -0
  152. data/src/core/lib/gprpp/status_helper.h +6 -0
  153. data/src/core/lib/gprpp/table.h +9 -1
  154. data/src/core/lib/gprpp/tchar.cc +49 -0
  155. data/src/core/lib/gprpp/tchar.h +33 -0
  156. data/src/core/lib/gprpp/time.cc +21 -0
  157. data/src/core/lib/gprpp/time.h +55 -0
  158. data/src/core/lib/gprpp/validation_errors.cc +61 -0
  159. data/src/core/lib/gprpp/validation_errors.h +110 -0
  160. data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
  161. data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
  162. data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
  163. data/src/core/lib/iomgr/call_combiner.cc +0 -8
  164. data/src/core/lib/iomgr/closure.h +0 -1
  165. data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
  166. data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
  167. data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
  168. data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
  169. data/src/core/lib/iomgr/exec_ctx.cc +0 -10
  170. data/src/core/lib/iomgr/exec_ctx.h +7 -31
  171. data/src/core/lib/iomgr/iocp_windows.cc +1 -2
  172. data/src/core/lib/iomgr/iomgr.cc +6 -8
  173. data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
  174. data/src/core/lib/iomgr/pollset.h +1 -1
  175. data/src/core/lib/iomgr/pollset_set.h +0 -1
  176. data/src/core/lib/iomgr/resolve_address.h +1 -0
  177. data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
  178. data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
  179. data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
  180. data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
  181. data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
  182. data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
  183. data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
  184. data/src/core/lib/iomgr/tcp_client.cc +6 -7
  185. data/src/core/lib/iomgr/tcp_client.h +11 -11
  186. data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
  187. data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
  188. data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
  189. data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
  190. data/src/core/lib/iomgr/tcp_posix.cc +131 -114
  191. data/src/core/lib/iomgr/tcp_posix.h +3 -1
  192. data/src/core/lib/iomgr/tcp_server.cc +5 -4
  193. data/src/core/lib/iomgr/tcp_server.h +9 -6
  194. data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
  195. data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
  196. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
  197. data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
  198. data/src/core/lib/iomgr/tcp_windows.cc +0 -1
  199. data/src/core/lib/iomgr/tcp_windows.h +0 -1
  200. data/src/core/lib/iomgr/timer_generic.cc +4 -4
  201. data/src/core/lib/iomgr/timer_manager.cc +1 -2
  202. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
  203. data/src/core/lib/json/json_object_loader.cc +21 -52
  204. data/src/core/lib/json/json_object_loader.h +56 -76
  205. data/src/core/lib/json/json_util.cc +2 -1
  206. data/src/core/lib/load_balancing/lb_policy.h +5 -5
  207. data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
  208. data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
  209. data/src/core/lib/promise/activity.h +2 -3
  210. data/src/core/lib/promise/context.h +1 -1
  211. data/src/core/lib/promise/sleep.cc +16 -4
  212. data/src/core/lib/promise/sleep.h +8 -2
  213. data/src/core/lib/resolver/resolver.h +13 -3
  214. data/src/core/lib/resource_quota/api.cc +9 -0
  215. data/src/core/lib/resource_quota/api.h +6 -0
  216. data/src/core/lib/resource_quota/arena.cc +1 -3
  217. data/src/core/lib/resource_quota/memory_quota.cc +8 -24
  218. data/src/core/lib/resource_quota/memory_quota.h +6 -19
  219. data/src/core/lib/resource_quota/periodic_update.cc +2 -3
  220. data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
  221. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
  222. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
  223. data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
  224. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
  225. data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
  226. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
  227. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
  228. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
  229. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
  230. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
  231. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
  232. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
  233. data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
  234. data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
  235. data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
  236. data/src/core/lib/surface/call.cc +1 -11
  237. data/src/core/lib/surface/channel.cc +3 -2
  238. data/src/core/lib/surface/completion_queue.cc +16 -28
  239. data/src/core/lib/surface/completion_queue.h +1 -1
  240. data/src/core/lib/surface/completion_queue_factory.cc +5 -0
  241. data/src/core/lib/surface/init.cc +16 -11
  242. data/src/core/lib/surface/init_internally.cc +24 -0
  243. data/src/core/lib/surface/init_internally.h +28 -0
  244. data/src/core/lib/surface/server.cc +1 -7
  245. data/src/core/lib/surface/server.h +4 -6
  246. data/src/core/lib/surface/version.cc +2 -2
  247. data/src/core/lib/transport/bdp_estimator.cc +1 -3
  248. data/src/core/lib/transport/metadata_batch.cc +2 -3
  249. data/src/core/lib/transport/metadata_batch.h +9 -7
  250. data/src/core/lib/transport/parsed_metadata.h +4 -2
  251. data/src/core/lib/transport/status_conversion.cc +1 -3
  252. data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
  253. data/src/core/lib/transport/transport.h +0 -1
  254. data/src/core/lib/transport/transport_impl.h +0 -1
  255. data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
  256. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
  257. data/src/ruby/lib/grpc/2.6/grpc_c.so +0 -0
  258. data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
  259. data/src/ruby/lib/grpc/3.0/grpc_c.so +0 -0
  260. data/src/ruby/lib/grpc/3.1/grpc_c.so +0 -0
  261. data/src/ruby/lib/grpc/grpc_c.so +0 -0
  262. data/src/ruby/lib/grpc/version.rb +1 -1
  263. data/src/ruby/spec/channel_spec.rb +5 -0
  264. data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
  265. data/src/ruby/spec/user_agent_spec.rb +1 -1
  266. metadata +33 -19
  267. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
  268. data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
  269. data/src/core/ext/xds/certificate_provider_registry.h +0 -59
  270. data/src/core/lib/event_engine/promise.h +0 -78
  271. data/src/core/lib/gpr/env_windows.cc +0 -74
  272. data/src/core/lib/gpr/string_windows.h +0 -32
  273. data/src/core/lib/profiling/basic_timers.cc +0 -295
  274. data/src/core/lib/profiling/stap_timers.cc +0 -50
  275. data/src/core/lib/profiling/timers.h +0 -94
@@ -47,6 +47,7 @@
47
47
  #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h"
48
48
  #include "src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h"
49
49
  #include "src/core/ext/xds/xds_bootstrap.h"
50
+ #include "src/core/ext/xds/xds_bootstrap_grpc.h"
50
51
  #include "src/core/ext/xds/xds_client.h"
51
52
  #include "src/core/ext/xds/xds_client_grpc.h"
52
53
  #include "src/core/ext/xds/xds_client_stats.h"
@@ -55,14 +56,15 @@
55
56
  #include "src/core/lib/channel/channel_args.h"
56
57
  #include "src/core/lib/config/core_configuration.h"
57
58
  #include "src/core/lib/debug/trace.h"
58
- #include "src/core/lib/gpr/string.h"
59
59
  #include "src/core/lib/gprpp/debug_location.h"
60
60
  #include "src/core/lib/gprpp/orphanable.h"
61
61
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
62
+ #include "src/core/lib/gprpp/validation_errors.h"
62
63
  #include "src/core/lib/gprpp/work_serializer.h"
63
- #include "src/core/lib/iomgr/error.h"
64
64
  #include "src/core/lib/iomgr/pollset_set.h"
65
65
  #include "src/core/lib/json/json.h"
66
+ #include "src/core/lib/json/json_args.h"
67
+ #include "src/core/lib/json/json_object_loader.h"
66
68
  #include "src/core/lib/load_balancing/lb_policy.h"
67
69
  #include "src/core/lib/load_balancing/lb_policy_factory.h"
68
70
  #include "src/core/lib/load_balancing/lb_policy_registry.h"
@@ -71,7 +73,6 @@
71
73
  #include "src/core/lib/resolver/resolver_registry.h"
72
74
  #include "src/core/lib/resolver/server_address.h"
73
75
  #include "src/core/lib/transport/connectivity_state.h"
74
- #include "src/core/lib/transport/error_utils.h"
75
76
 
76
77
  #define GRPC_EDS_DEFAULT_FALLBACK_TIMEOUT 10000
77
78
 
@@ -91,7 +92,7 @@ class XdsClusterResolverLbConfig : public LoadBalancingPolicy::Config {
91
92
  public:
92
93
  struct DiscoveryMechanism {
93
94
  std::string cluster_name;
94
- absl::optional<XdsBootstrap::XdsServer> lrs_load_reporting_server;
95
+ absl::optional<GrpcXdsBootstrap::GrpcXdsServer> lrs_load_reporting_server;
95
96
  uint32_t max_concurrent_requests;
96
97
  enum DiscoveryMechanismType {
97
98
  EDS,
@@ -100,6 +101,13 @@ class XdsClusterResolverLbConfig : public LoadBalancingPolicy::Config {
100
101
  DiscoveryMechanismType type;
101
102
  std::string eds_service_name;
102
103
  std::string dns_hostname;
104
+
105
+ // This is type Json::Object instead of OutlierDetectionConfig, because we
106
+ // don't actually need to validate the contents of the outlier detection
107
+ // config here. In this case, the JSON is generated by the CDS policy
108
+ // instead of coming from service config, so it's not actually any better
109
+ // to catch the problem here than it is to catch it in the
110
+ // outlier_detection policy itself, so here we just act as a pass-through.
103
111
  absl::optional<Json::Object> outlier_detection_lb_config;
104
112
 
105
113
  bool operator==(const DiscoveryMechanism& other) const {
@@ -111,12 +119,21 @@ class XdsClusterResolverLbConfig : public LoadBalancingPolicy::Config {
111
119
  dns_hostname == other.dns_hostname &&
112
120
  outlier_detection_lb_config == other.outlier_detection_lb_config);
113
121
  }
122
+
123
+ static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
124
+ void JsonPostLoad(const Json& json, const JsonArgs& args,
125
+ ValidationErrors* errors);
114
126
  };
115
127
 
116
- XdsClusterResolverLbConfig(
117
- std::vector<DiscoveryMechanism> discovery_mechanisms, Json xds_lb_policy)
118
- : discovery_mechanisms_(std::move(discovery_mechanisms)),
119
- xds_lb_policy_(std::move(xds_lb_policy)) {}
128
+ XdsClusterResolverLbConfig() = default;
129
+
130
+ XdsClusterResolverLbConfig(const XdsClusterResolverLbConfig&) = delete;
131
+ XdsClusterResolverLbConfig& operator=(const XdsClusterResolverLbConfig&) =
132
+ delete;
133
+
134
+ XdsClusterResolverLbConfig(XdsClusterResolverLbConfig&& other) = delete;
135
+ XdsClusterResolverLbConfig& operator=(XdsClusterResolverLbConfig&& other) =
136
+ delete;
120
137
 
121
138
  absl::string_view name() const override { return kXdsClusterResolver; }
122
139
 
@@ -126,9 +143,13 @@ class XdsClusterResolverLbConfig : public LoadBalancingPolicy::Config {
126
143
 
127
144
  const Json& xds_lb_policy() const { return xds_lb_policy_; }
128
145
 
146
+ static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
147
+ void JsonPostLoad(const Json& json, const JsonArgs& args,
148
+ ValidationErrors* errors);
149
+
129
150
  private:
130
151
  std::vector<DiscoveryMechanism> discovery_mechanisms_;
131
- Json xds_lb_policy_;
152
+ Json xds_lb_policy_ = Json::Object{{"ROUND_ROBIN", Json::Object()}};
132
153
  };
133
154
 
134
155
  // Xds Cluster Resolver LB policy.
@@ -138,7 +159,7 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
138
159
 
139
160
  absl::string_view name() const override { return kXdsClusterResolver; }
140
161
 
141
- void UpdateLocked(UpdateArgs args) override;
162
+ absl::Status UpdateLocked(UpdateArgs args) override;
142
163
  void ResetBackoffLocked() override;
143
164
  void ExitIdleLocked() override;
144
165
 
@@ -380,7 +401,7 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
380
401
 
381
402
  void MaybeDestroyChildPolicyLocked();
382
403
 
383
- void UpdateChildPolicyLocked();
404
+ absl::Status UpdateChildPolicyLocked();
384
405
  OrphanablePtr<LoadBalancingPolicy> CreateChildPolicyLocked(
385
406
  const ChannelArgs& args);
386
407
  ServerAddressList CreateChildPolicyAddressesLocked();
@@ -610,7 +631,7 @@ void XdsClusterResolverLb::MaybeDestroyChildPolicyLocked() {
610
631
  }
611
632
  }
612
633
 
613
- void XdsClusterResolverLb::UpdateLocked(UpdateArgs args) {
634
+ absl::Status XdsClusterResolverLb::UpdateLocked(UpdateArgs args) {
614
635
  if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_cluster_resolver_trace)) {
615
636
  gpr_log(GPR_INFO, "[xds_cluster_resolver_lb %p] Received update", this);
616
637
  }
@@ -621,7 +642,8 @@ void XdsClusterResolverLb::UpdateLocked(UpdateArgs args) {
621
642
  // Update args.
622
643
  args_ = std::move(args.args);
623
644
  // Update child policy if needed.
624
- if (child_policy_ != nullptr) UpdateChildPolicyLocked();
645
+ absl::Status status;
646
+ if (child_policy_ != nullptr) status = UpdateChildPolicyLocked();
625
647
  // Create endpoint watcher if needed.
626
648
  if (is_initial_update) {
627
649
  for (const auto& config : config_->discovery_mechanisms()) {
@@ -647,6 +669,7 @@ void XdsClusterResolverLb::UpdateLocked(UpdateArgs args) {
647
669
  discovery_mechanism.discovery_mechanism->Start();
648
670
  }
649
671
  }
672
+ return status;
650
673
  }
651
674
 
652
675
  void XdsClusterResolverLb::ResetBackoffLocked() {
@@ -755,7 +778,9 @@ void XdsClusterResolverLb::OnEndpointChanged(size_t index,
755
778
  if (!mechanism.latest_update.has_value()) return;
756
779
  }
757
780
  // Update child policy.
758
- UpdateChildPolicyLocked();
781
+ // TODO(roth): If the child policy reports an error with the update,
782
+ // we need to propagate that error back to the resolver somehow.
783
+ (void)UpdateChildPolicyLocked();
759
784
  }
760
785
 
761
786
  void XdsClusterResolverLb::OnError(size_t index, std::string resolution_note) {
@@ -974,7 +999,9 @@ XdsClusterResolverLb::CreateChildPolicyConfigLocked() {
974
999
  "[xds_cluster_resolver_lb %p] generated config for child policy: %s",
975
1000
  this, json_str.c_str());
976
1001
  }
977
- auto config = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(json);
1002
+ auto config =
1003
+ CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig(
1004
+ json);
978
1005
  if (!config.ok()) {
979
1006
  // This should never happen, but if it does, we basically have no
980
1007
  // way to fix it, so we put the channel in TRANSIENT_FAILURE.
@@ -994,11 +1021,11 @@ XdsClusterResolverLb::CreateChildPolicyConfigLocked() {
994
1021
  return std::move(*config);
995
1022
  }
996
1023
 
997
- void XdsClusterResolverLb::UpdateChildPolicyLocked() {
998
- if (shutting_down_) return;
1024
+ absl::Status XdsClusterResolverLb::UpdateChildPolicyLocked() {
1025
+ if (shutting_down_) return absl::OkStatus();
999
1026
  UpdateArgs update_args;
1000
1027
  update_args.config = CreateChildPolicyConfigLocked();
1001
- if (update_args.config == nullptr) return;
1028
+ if (update_args.config == nullptr) return absl::OkStatus();
1002
1029
  update_args.addresses = CreateChildPolicyAddressesLocked();
1003
1030
  update_args.resolution_note = CreateChildPolicyResolutionNoteLocked();
1004
1031
  update_args.args = CreateChildPolicyArgsLocked(args_);
@@ -1009,7 +1036,7 @@ void XdsClusterResolverLb::UpdateChildPolicyLocked() {
1009
1036
  gpr_log(GPR_INFO, "[xds_cluster_resolver_lb %p] Updating child policy %p",
1010
1037
  this, child_policy_.get());
1011
1038
  }
1012
- child_policy_->UpdateLocked(std::move(update_args));
1039
+ return child_policy_->UpdateLocked(std::move(update_args));
1013
1040
  }
1014
1041
 
1015
1042
  ChannelArgs XdsClusterResolverLb::CreateChildPolicyArgsLocked(
@@ -1027,7 +1054,7 @@ XdsClusterResolverLb::CreateChildPolicyLocked(const ChannelArgs& args) {
1027
1054
  lb_policy_args.channel_control_helper =
1028
1055
  absl::make_unique<Helper>(Ref(DEBUG_LOCATION, "Helper"));
1029
1056
  OrphanablePtr<LoadBalancingPolicy> lb_policy =
1030
- LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
1057
+ CoreConfiguration::Get().lb_policy_registry().CreateLoadBalancingPolicy(
1031
1058
  "priority_experimental", std::move(lb_policy_args));
1032
1059
  if (GPR_UNLIKELY(lb_policy == nullptr)) {
1033
1060
  gpr_log(GPR_ERROR,
@@ -1051,6 +1078,117 @@ XdsClusterResolverLb::CreateChildPolicyLocked(const ChannelArgs& args) {
1051
1078
  // factory
1052
1079
  //
1053
1080
 
1081
+ const JsonLoaderInterface*
1082
+ XdsClusterResolverLbConfig::DiscoveryMechanism::JsonLoader(const JsonArgs&) {
1083
+ static const auto* loader =
1084
+ JsonObjectLoader<DiscoveryMechanism>()
1085
+ // Note: Several fields requires custom processing,
1086
+ // so they are handled in JsonPostLoad() instead.
1087
+ .Field("clusterName", &DiscoveryMechanism::cluster_name)
1088
+ .OptionalField("lrsLoadReportingServer",
1089
+ &DiscoveryMechanism::lrs_load_reporting_server)
1090
+ .OptionalField("max_concurrent_requests",
1091
+ &DiscoveryMechanism::max_concurrent_requests)
1092
+ .OptionalField("outlierDetection",
1093
+ &DiscoveryMechanism::outlier_detection_lb_config,
1094
+ "outlier_detection")
1095
+ .Finish();
1096
+ return loader;
1097
+ }
1098
+
1099
+ void XdsClusterResolverLbConfig::DiscoveryMechanism::JsonPostLoad(
1100
+ const Json& json, const JsonArgs& args, ValidationErrors* errors) {
1101
+ // Parse "type".
1102
+ {
1103
+ auto type_field = LoadJsonObjectField<std::string>(json.object_value(),
1104
+ args, "type", errors);
1105
+ if (type_field.has_value()) {
1106
+ if (*type_field == "EDS") {
1107
+ type = DiscoveryMechanismType::EDS;
1108
+ } else if (*type_field == "LOGICAL_DNS") {
1109
+ type = DiscoveryMechanismType::LOGICAL_DNS;
1110
+ } else {
1111
+ ValidationErrors::ScopedField field(errors, ".type");
1112
+ errors->AddError(absl::StrCat("unknown type \"", *type_field, "\""));
1113
+ }
1114
+ }
1115
+ }
1116
+ // Parse "edsServiceName" if type is EDS.
1117
+ if (type == DiscoveryMechanismType::EDS) {
1118
+ auto value = LoadJsonObjectField<std::string>(json.object_value(), args,
1119
+ "edsServiceName", errors,
1120
+ /*required=*/false);
1121
+ if (value.has_value()) eds_service_name = std::move(*value);
1122
+ }
1123
+ // Parse "dnsHostname" if type is LOGICAL_DNS.
1124
+ if (type == DiscoveryMechanismType::LOGICAL_DNS) {
1125
+ auto value = LoadJsonObjectField<std::string>(json.object_value(), args,
1126
+ "dnsHostname", errors);
1127
+ if (value.has_value()) dns_hostname = std::move(*value);
1128
+ }
1129
+ }
1130
+
1131
+ const JsonLoaderInterface* XdsClusterResolverLbConfig::JsonLoader(
1132
+ const JsonArgs&) {
1133
+ static const auto* loader =
1134
+ JsonObjectLoader<XdsClusterResolverLbConfig>()
1135
+ // Note: The "xdsLbPolicy" field requires custom processing,
1136
+ // so it's handled in JsonPostLoad() instead.
1137
+ .Field("discoveryMechanisms",
1138
+ &XdsClusterResolverLbConfig::discovery_mechanisms_)
1139
+ .Finish();
1140
+ return loader;
1141
+ }
1142
+
1143
+ void XdsClusterResolverLbConfig::JsonPostLoad(const Json& json,
1144
+ const JsonArgs& args,
1145
+ ValidationErrors* errors) {
1146
+ // Validate discoveryMechanisms.
1147
+ {
1148
+ ValidationErrors::ScopedField field(errors, ".discoveryMechanisms");
1149
+ if (!errors->FieldHasErrors() && discovery_mechanisms_.empty()) {
1150
+ errors->AddError("must be non-empty");
1151
+ }
1152
+ }
1153
+ // Parse "xdsLbPolicy".
1154
+ {
1155
+ ValidationErrors::ScopedField field(errors, ".xdsLbPolicy");
1156
+ auto it = json.object_value().find("xdsLbPolicy");
1157
+ if (it != json.object_value().end()) {
1158
+ if (it->second.type() != Json::Type::ARRAY) {
1159
+ errors->AddError("is not an array");
1160
+ } else {
1161
+ const Json::Array& array = it->second.array_value();
1162
+ for (size_t i = 0; i < array.size(); ++i) {
1163
+ ValidationErrors::ScopedField field(errors,
1164
+ absl::StrCat("[", i, "]"));
1165
+ if (array[i].type() != Json::Type::OBJECT) {
1166
+ errors->AddError("is not an object");
1167
+ continue;
1168
+ }
1169
+ const Json::Object& policy = array[i].object_value();
1170
+ auto policy_it = policy.find("ROUND_ROBIN");
1171
+ if (policy_it != policy.end()) {
1172
+ ValidationErrors::ScopedField field(errors, "[\"ROUND_ROBIN\"]");
1173
+ if (policy_it->second.type() != Json::Type::OBJECT) {
1174
+ errors->AddError("is not an object");
1175
+ }
1176
+ break;
1177
+ }
1178
+ {
1179
+ ValidationErrors::ScopedField field(errors, "[\"RING_HASH\"]");
1180
+ policy_it = policy.find("RING_HASH");
1181
+ if (policy_it != policy.end()) {
1182
+ LoadFromJson<RingHashConfig>(policy_it->second, args, errors);
1183
+ xds_lb_policy_ = array[i];
1184
+ }
1185
+ }
1186
+ }
1187
+ }
1188
+ }
1189
+ }
1190
+ }
1191
+
1054
1192
  class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1055
1193
  public:
1056
1194
  OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
@@ -1079,198 +1217,19 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1079
1217
  "requires configuration. "
1080
1218
  "Please use loadBalancingConfig field of service config instead.");
1081
1219
  }
1082
- std::vector<grpc_error_handle> error_list;
1083
- std::vector<XdsClusterResolverLbConfig::DiscoveryMechanism>
1084
- discovery_mechanisms;
1085
- auto it = json.object_value().find("discoveryMechanisms");
1086
- if (it == json.object_value().end()) {
1087
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1088
- "field:discoveryMechanisms error:required field missing"));
1089
- } else if (it->second.type() != Json::Type::ARRAY) {
1090
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1091
- "field:discoveryMechanisms error:type should be array"));
1092
- } else {
1093
- const Json::Array& array = it->second.array_value();
1094
- for (size_t i = 0; i < array.size(); ++i) {
1095
- XdsClusterResolverLbConfig::DiscoveryMechanism discovery_mechanism;
1096
- std::vector<grpc_error_handle> discovery_mechanism_errors =
1097
- ParseDiscoveryMechanism(array[i], &discovery_mechanism);
1098
- if (!discovery_mechanism_errors.empty()) {
1099
- grpc_error_handle error = GRPC_ERROR_CREATE_FROM_CPP_STRING(
1100
- absl::StrCat("field:discovery_mechanism element: ", i, " error"));
1101
- for (const grpc_error_handle& discovery_mechanism_error :
1102
- discovery_mechanism_errors) {
1103
- error = grpc_error_add_child(error, discovery_mechanism_error);
1104
- }
1105
- error_list.push_back(error);
1106
- }
1107
- discovery_mechanisms.emplace_back(std::move(discovery_mechanism));
1220
+ class XdsJsonArgs : public JsonArgs {
1221
+ public:
1222
+ bool IsEnabled(absl::string_view key) const override {
1223
+ if (key == "outlier_detection") return XdsOutlierDetectionEnabled();
1224
+ return true;
1108
1225
  }
1109
- }
1110
- if (discovery_mechanisms.empty()) {
1111
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1112
- "field:discovery_mechanism error:list is missing or empty"));
1113
- }
1114
- Json xds_lb_policy = Json::Object{
1115
- {"ROUND_ROBIN", Json::Object()},
1116
1226
  };
1117
- it = json.object_value().find("xdsLbPolicy");
1118
- if (it != json.object_value().end()) {
1119
- if (it->second.type() != Json::Type::ARRAY) {
1120
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1121
- "field:xdsLbPolicy error:type should be array"));
1122
- } else {
1123
- const Json::Array& array = it->second.array_value();
1124
- for (size_t i = 0; i < array.size(); ++i) {
1125
- if (array[i].type() != Json::Type::OBJECT) {
1126
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1127
- "field:xdsLbPolicy error:element should be of type object"));
1128
- continue;
1129
- }
1130
- const Json::Object& policy = array[i].object_value();
1131
- auto policy_it = policy.find("ROUND_ROBIN");
1132
- if (policy_it != policy.end()) {
1133
- if (policy_it->second.type() != Json::Type::OBJECT) {
1134
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1135
- "field:ROUND_ROBIN error:type should be object"));
1136
- }
1137
- break;
1138
- }
1139
- policy_it = policy.find("RING_HASH");
1140
- if (policy_it != policy.end()) {
1141
- xds_lb_policy = array[i];
1142
- auto config = ParseRingHashLbConfig(policy_it->second);
1143
- if (!config.ok()) {
1144
- error_list.emplace_back(
1145
- absl_status_to_grpc_error(config.status()));
1146
- }
1147
- }
1148
- }
1149
- }
1150
- }
1151
- // Construct config.
1152
- if (error_list.empty()) {
1153
- return MakeRefCounted<XdsClusterResolverLbConfig>(
1154
- std::move(discovery_mechanisms), std::move(xds_lb_policy));
1155
- } else {
1156
- grpc_error_handle error = GRPC_ERROR_CREATE_FROM_VECTOR(
1157
- "xds_cluster_resolver_experimental LB policy config", &error_list);
1158
- absl::Status status = grpc_error_to_absl_status(error);
1159
- GRPC_ERROR_UNREF(error);
1160
- return status;
1161
- }
1227
+ return LoadRefCountedFromJson<XdsClusterResolverLbConfig>(
1228
+ json, XdsJsonArgs(),
1229
+ "errors validating xds_cluster_resolver LB policy config");
1162
1230
  }
1163
1231
 
1164
1232
  private:
1165
- static std::vector<grpc_error_handle> ParseDiscoveryMechanism(
1166
- const Json& json,
1167
- XdsClusterResolverLbConfig::DiscoveryMechanism* discovery_mechanism) {
1168
- std::vector<grpc_error_handle> error_list;
1169
- if (json.type() != Json::Type::OBJECT) {
1170
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1171
- "value should be of type object"));
1172
- return error_list;
1173
- }
1174
- // Cluster name.
1175
- auto it = json.object_value().find("clusterName");
1176
- if (it == json.object_value().end()) {
1177
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1178
- "field:clusterName error:required field missing"));
1179
- } else if (it->second.type() != Json::Type::STRING) {
1180
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1181
- "field:clusterName error:type should be string"));
1182
- } else {
1183
- discovery_mechanism->cluster_name = it->second.string_value();
1184
- }
1185
- // LRS load reporting server name.
1186
- it = json.object_value().find("lrsLoadReportingServer");
1187
- if (it != json.object_value().end()) {
1188
- if (it->second.type() != Json::Type::OBJECT) {
1189
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1190
- "field:lrsLoadReportingServer error:type should be object"));
1191
- } else {
1192
- grpc_error_handle parse_error;
1193
- discovery_mechanism->lrs_load_reporting_server.emplace(
1194
- XdsBootstrap::XdsServer::Parse(it->second, &parse_error));
1195
- if (!GRPC_ERROR_IS_NONE(parse_error)) {
1196
- error_list.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
1197
- absl::StrCat("errors parsing lrs_load_reporting_server")));
1198
- error_list.push_back(parse_error);
1199
- }
1200
- }
1201
- }
1202
- // Max concurrent requests.
1203
- discovery_mechanism->max_concurrent_requests = 1024;
1204
- it = json.object_value().find("max_concurrent_requests");
1205
- if (it != json.object_value().end()) {
1206
- if (it->second.type() != Json::Type::NUMBER) {
1207
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1208
- "field:max_concurrent_requests error:must be of type number"));
1209
- } else {
1210
- discovery_mechanism->max_concurrent_requests =
1211
- gpr_parse_nonnegative_int(it->second.string_value().c_str());
1212
- }
1213
- }
1214
- if (XdsOutlierDetectionEnabled()) {
1215
- it = json.object_value().find("outlierDetection");
1216
- if (it != json.object_value().end()) {
1217
- if (it->second.type() != Json::Type::OBJECT) {
1218
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1219
- "field:outlierDetection error:type should be object"));
1220
- } else {
1221
- // No need to validate the contents of the outlier detection config,
1222
- // because in this particular case, the JSON is generated by the CDS
1223
- // policy instead of coming from service config, so it's not actually
1224
- // any better to catch the problem here than it is to catch it in the
1225
- // outlier_detection policy itself, so here we just act as a
1226
- // pass-through.
1227
- discovery_mechanism->outlier_detection_lb_config =
1228
- it->second.object_value();
1229
- }
1230
- }
1231
- }
1232
- // Discovery Mechanism type
1233
- it = json.object_value().find("type");
1234
- if (it == json.object_value().end()) {
1235
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1236
- "field:type error:required field missing"));
1237
- } else if (it->second.type() != Json::Type::STRING) {
1238
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1239
- "field:type error:type should be string"));
1240
- } else {
1241
- if (it->second.string_value() == "EDS") {
1242
- discovery_mechanism->type = XdsClusterResolverLbConfig::
1243
- DiscoveryMechanism::DiscoveryMechanismType::EDS;
1244
- it = json.object_value().find("edsServiceName");
1245
- if (it != json.object_value().end()) {
1246
- if (it->second.type() != Json::Type::STRING) {
1247
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1248
- "field:edsServiceName error:type should be string"));
1249
- } else {
1250
- discovery_mechanism->eds_service_name = it->second.string_value();
1251
- }
1252
- }
1253
- } else if (it->second.string_value() == "LOGICAL_DNS") {
1254
- discovery_mechanism->type = XdsClusterResolverLbConfig::
1255
- DiscoveryMechanism::DiscoveryMechanismType::LOGICAL_DNS;
1256
- it = json.object_value().find("dnsHostname");
1257
- if (it == json.object_value().end()) {
1258
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1259
- "field:dnsHostname error:required field missing"));
1260
- } else if (it->second.type() != Json::Type::STRING) {
1261
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1262
- "field:dnsHostname error:type should be string"));
1263
- } else {
1264
- discovery_mechanism->dns_hostname = it->second.string_value();
1265
- }
1266
- } else {
1267
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1268
- "field:type error:invalid type"));
1269
- }
1270
- }
1271
- return error_list;
1272
- }
1273
-
1274
1233
  class XdsClusterResolverChildHandler : public ChildPolicyHandler {
1275
1234
  public:
1276
1235
  XdsClusterResolverChildHandler(RefCountedPtr<XdsClient> xds_client,
@@ -1333,16 +1292,9 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1333
1292
 
1334
1293
  } // namespace
1335
1294
 
1336
- } // namespace grpc_core
1337
-
1338
- //
1339
- // Plugin registration
1340
- //
1341
-
1342
- void grpc_lb_policy_xds_cluster_resolver_init() {
1343
- grpc_core::LoadBalancingPolicyRegistry::Builder::
1344
- RegisterLoadBalancingPolicyFactory(
1345
- absl::make_unique<grpc_core::XdsClusterResolverLbFactory>());
1295
+ void RegisterXdsClusterResolverLbPolicy(CoreConfiguration::Builder* builder) {
1296
+ builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
1297
+ absl::make_unique<XdsClusterResolverLbFactory>());
1346
1298
  }
1347
1299
 
1348
- void grpc_lb_policy_xds_cluster_resolver_shutdown() {}
1300
+ } // namespace grpc_core
@@ -284,7 +284,7 @@ static grpc_core::Timestamp calculate_next_ares_backup_poll_alarm(
284
284
  "request:%p ev_driver=%p. next ares process poll time in "
285
285
  "%" PRId64 " ms",
286
286
  driver->request, driver, until_next_ares_backup_poll_alarm.millis());
287
- return grpc_core::ExecCtx::Get()->Now() + until_next_ares_backup_poll_alarm;
287
+ return grpc_core::Timestamp::Now() + until_next_ares_backup_poll_alarm;
288
288
  }
289
289
 
290
290
  static void on_timeout(void* arg, grpc_error_handle error) {
@@ -496,7 +496,7 @@ void grpc_ares_ev_driver_start_locked(grpc_ares_ev_driver* ev_driver)
496
496
  GRPC_CLOSURE_INIT(&ev_driver->on_timeout_locked, on_timeout, ev_driver,
497
497
  grpc_schedule_on_exec_ctx);
498
498
  grpc_timer_init(&ev_driver->query_timeout,
499
- grpc_core::ExecCtx::Get()->Now() + timeout,
499
+ grpc_core::Timestamp::Now() + timeout,
500
500
  &ev_driver->on_timeout_locked);
501
501
  // Initialize the backup poll alarm
502
502
  grpc_core::Timestamp next_ares_backup_poll_alarm =
@@ -82,7 +82,7 @@ class NativeClientChannelDNSResolver : public PollingResolver {
82
82
  public:
83
83
  Request() = default;
84
84
 
85
- void Orphan() override {}
85
+ void Orphan() override { delete this; }
86
86
  };
87
87
 
88
88
  void OnResolved(
@@ -42,9 +42,8 @@
42
42
  #include "src/core/ext/xds/xds_client_grpc.h"
43
43
  #include "src/core/lib/channel/channel_args.h"
44
44
  #include "src/core/lib/config/core_configuration.h"
45
- #include "src/core/lib/gpr/env.h"
46
45
  #include "src/core/lib/gprpp/debug_location.h"
47
- #include "src/core/lib/gprpp/memory.h"
46
+ #include "src/core/lib/gprpp/env.h"
48
47
  #include "src/core/lib/gprpp/orphanable.h"
49
48
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
50
49
  #include "src/core/lib/gprpp/time.h"
@@ -53,7 +52,6 @@
53
52
  #include "src/core/lib/http/parser.h"
54
53
  #include "src/core/lib/iomgr/closure.h"
55
54
  #include "src/core/lib/iomgr/error.h"
56
- #include "src/core/lib/iomgr/exec_ctx.h"
57
55
  #include "src/core/lib/iomgr/polling_entity.h"
58
56
  #include "src/core/lib/json/json.h"
59
57
  #include "src/core/lib/resolver/resolver.h"
@@ -168,12 +166,12 @@ GoogleCloud2ProdResolver::MetadataQuery::MetadataQuery(
168
166
  const_cast<char*>(GRPC_ARG_RESOURCE_QUOTA),
169
167
  resolver_->resource_quota_.get(), grpc_resource_quota_arg_vtable());
170
168
  grpc_channel_args args = {1, &resource_quota_arg};
171
- http_request_ = HttpRequest::Get(
172
- std::move(*uri), &args, pollent, &request,
173
- ExecCtx::Get()->Now() + Duration::Seconds(10), // 10s timeout
174
- &on_done_, &response_,
175
- RefCountedPtr<grpc_channel_credentials>(
176
- grpc_insecure_credentials_create()));
169
+ http_request_ =
170
+ HttpRequest::Get(std::move(*uri), &args, pollent, &request,
171
+ Timestamp::Now() + Duration::Seconds(10), // 10s timeout
172
+ &on_done_, &response_,
173
+ RefCountedPtr<grpc_channel_credentials>(
174
+ grpc_insecure_credentials_create()));
177
175
  http_request_->Start();
178
176
  }
179
177
 
@@ -285,8 +283,8 @@ GoogleCloud2ProdResolver::GoogleCloud2ProdResolver(ResolverArgs args)
285
283
  // they may be talking to a completely different xDS server than we
286
284
  // want to.
287
285
  // TODO(roth): When we implement xDS federation, remove this constraint.
288
- UniquePtr<char>(gpr_getenv("GRPC_XDS_BOOTSTRAP")) != nullptr ||
289
- UniquePtr<char>(gpr_getenv("GRPC_XDS_BOOTSTRAP_CONFIG")) != nullptr) {
286
+ GetEnv("GRPC_XDS_BOOTSTRAP").has_value() ||
287
+ GetEnv("GRPC_XDS_BOOTSTRAP_CONFIG").has_value()) {
290
288
  using_dns_ = true;
291
289
  child_resolver_ =
292
290
  CoreConfiguration::Get().resolver_registry().CreateResolver(
@@ -373,11 +371,11 @@ void GoogleCloud2ProdResolver::StartXdsResolver() {
373
371
  };
374
372
  }
375
373
  // Allow the TD server uri to be overridden for testing purposes.
376
- UniquePtr<char> override_server(
377
- gpr_getenv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI"));
374
+ auto override_server =
375
+ GetEnv("GRPC_TEST_ONLY_GOOGLE_C2P_RESOLVER_TRAFFIC_DIRECTOR_URI");
378
376
  const char* server_uri =
379
- override_server != nullptr && strlen(override_server.get()) > 0
380
- ? override_server.get()
377
+ override_server.has_value() && !override_server->empty()
378
+ ? override_server->c_str()
381
379
  : "directpath-pa.googleapis.com";
382
380
  Json xds_server = Json::Array{
383
381
  Json::Object{