grpc 1.49.0.pre1 → 1.50.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 (271) 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 +41 -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 +114 -103
  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 +87 -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 +38 -18
  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 +19 -16
  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 +5 -0
  179. data/src/core/lib/iomgr/resolve_address_windows.cc +5 -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/ext/grpc/extconf.rb +1 -1
  258. data/src/ruby/lib/grpc/version.rb +1 -1
  259. data/src/ruby/spec/channel_spec.rb +5 -0
  260. data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
  261. data/src/ruby/spec/user_agent_spec.rb +1 -1
  262. metadata +31 -17
  263. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
  264. data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
  265. data/src/core/ext/xds/certificate_provider_registry.h +0 -59
  266. data/src/core/lib/event_engine/promise.h +0 -78
  267. data/src/core/lib/gpr/env_windows.cc +0 -74
  268. data/src/core/lib/gpr/string_windows.h +0 -32
  269. data/src/core/lib/profiling/basic_timers.cc +0 -295
  270. data/src/core/lib/profiling/stap_timers.cc +0 -50
  271. data/src/core/lib/profiling/timers.h +0 -94
@@ -36,34 +36,31 @@
36
36
  #include "absl/random/random.h"
37
37
  #include "absl/status/status.h"
38
38
  #include "absl/status/statusor.h"
39
- #include "absl/strings/str_cat.h"
40
- #include "absl/strings/str_join.h"
41
39
  #include "absl/strings/string_view.h"
42
40
  #include "absl/types/variant.h"
43
41
 
44
42
  #include <grpc/impl/codegen/connectivity_state.h>
45
- #include <grpc/support/alloc.h>
46
43
  #include <grpc/support/log.h>
47
44
 
48
45
  #include "src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h"
49
46
  #include "src/core/lib/address_utils/sockaddr_utils.h"
50
47
  #include "src/core/lib/channel/channel_args.h"
48
+ #include "src/core/lib/config/core_configuration.h"
51
49
  #include "src/core/lib/debug/trace.h"
52
- #include "src/core/lib/gpr/env.h"
53
50
  #include "src/core/lib/gpr/string.h"
54
51
  #include "src/core/lib/gprpp/debug_location.h"
52
+ #include "src/core/lib/gprpp/env.h"
55
53
  #include "src/core/lib/gprpp/orphanable.h"
56
54
  #include "src/core/lib/gprpp/ref_counted.h"
57
55
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
56
+ #include "src/core/lib/gprpp/validation_errors.h"
58
57
  #include "src/core/lib/gprpp/work_serializer.h"
59
58
  #include "src/core/lib/iomgr/closure.h"
60
59
  #include "src/core/lib/iomgr/error.h"
61
- #include "src/core/lib/iomgr/exec_ctx.h"
62
60
  #include "src/core/lib/iomgr/iomgr_fwd.h"
63
61
  #include "src/core/lib/iomgr/pollset_set.h"
64
62
  #include "src/core/lib/iomgr/timer.h"
65
63
  #include "src/core/lib/json/json.h"
66
- #include "src/core/lib/json/json_util.h"
67
64
  #include "src/core/lib/load_balancing/lb_policy.h"
68
65
  #include "src/core/lib/load_balancing/lb_policy_factory.h"
69
66
  #include "src/core/lib/load_balancing/lb_policy_registry.h"
@@ -77,10 +74,10 @@ TraceFlag grpc_outlier_detection_lb_trace(false, "outlier_detection_lb");
77
74
 
78
75
  // TODO(donnadionne): Remove once outlier detection is no longer experimental
79
76
  bool XdsOutlierDetectionEnabled() {
80
- char* value = gpr_getenv("GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION");
77
+ auto value = GetEnv("GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION");
78
+ if (!value.has_value()) return false;
81
79
  bool parsed_value;
82
- bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
83
- gpr_free(value);
80
+ bool parse_succeeded = gpr_parse_bool_value(value->c_str(), &parsed_value);
84
81
  return parse_succeeded && parsed_value;
85
82
  }
86
83
 
@@ -125,7 +122,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy {
125
122
 
126
123
  absl::string_view name() const override { return kOutlierDetection; }
127
124
 
128
- void UpdateLocked(UpdateArgs args) override;
125
+ absl::Status UpdateLocked(UpdateArgs args) override;
129
126
  void ExitIdleLocked() override;
130
127
  void ResetBackoffLocked() override;
131
128
 
@@ -296,7 +293,7 @@ class OutlierDetectionLb : public LoadBalancingPolicy {
296
293
  base_ejection_time_in_millis * multiplier_,
297
294
  std::max(base_ejection_time_in_millis,
298
295
  max_ejection_time_in_millis)));
299
- if (change_time < ExecCtx::Get()->Now()) {
296
+ if (change_time < Timestamp::Now()) {
300
297
  Uneject();
301
298
  return true;
302
299
  }
@@ -594,7 +591,7 @@ void OutlierDetectionLb::ResetBackoffLocked() {
594
591
  if (child_policy_ != nullptr) child_policy_->ResetBackoffLocked();
595
592
  }
596
593
 
597
- void OutlierDetectionLb::UpdateLocked(UpdateArgs args) {
594
+ absl::Status OutlierDetectionLb::UpdateLocked(UpdateArgs args) {
598
595
  if (GRPC_TRACE_FLAG_ENABLED(grpc_outlier_detection_lb_trace)) {
599
596
  gpr_log(GPR_INFO, "[outlier_detection_lb %p] Received update", this);
600
597
  }
@@ -615,8 +612,7 @@ void OutlierDetectionLb::UpdateLocked(UpdateArgs args) {
615
612
  if (GRPC_TRACE_FLAG_ENABLED(grpc_outlier_detection_lb_trace)) {
616
613
  gpr_log(GPR_INFO, "[outlier_detection_lb %p] starting timer", this);
617
614
  }
618
- ejection_timer_ =
619
- MakeOrphanable<EjectionTimer>(Ref(), ExecCtx::Get()->Now());
615
+ ejection_timer_ = MakeOrphanable<EjectionTimer>(Ref(), Timestamp::Now());
620
616
  for (const auto& p : subchannel_state_map_) {
621
617
  p.second->RotateBucket(); // Reset call counters.
622
618
  }
@@ -649,6 +645,12 @@ void OutlierDetectionLb::UpdateLocked(UpdateArgs args) {
649
645
  }
650
646
  } else if (!config_->CountingEnabled()) {
651
647
  // If counting is not enabled, reset state.
648
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_outlier_detection_lb_trace)) {
649
+ gpr_log(GPR_INFO,
650
+ "[outlier_detection_lb %p] counting disabled; disabling "
651
+ "ejection for %s (%p)",
652
+ this, address_key.c_str(), subchannel_state.get());
653
+ }
652
654
  subchannel_state->DisableEjection();
653
655
  }
654
656
  current_addresses.emplace(address_key);
@@ -685,7 +687,7 @@ void OutlierDetectionLb::UpdateLocked(UpdateArgs args) {
685
687
  "[outlier_detection_lb %p] Updating child policy handler %p", this,
686
688
  child_policy_.get());
687
689
  }
688
- child_policy_->UpdateLocked(std::move(update_args));
690
+ return child_policy_->UpdateLocked(std::move(update_args));
689
691
  }
690
692
 
691
693
  void OutlierDetectionLb::MaybeUpdatePickerLocked() {
@@ -829,7 +831,7 @@ void OutlierDetectionLb::EjectionTimer::OnTimerLocked(grpc_error_handle error) {
829
831
  std::map<SubchannelState*, double> failure_percentage_ejection_candidates;
830
832
  size_t ejected_host_count = 0;
831
833
  double success_rate_sum = 0;
832
- auto time_now = ExecCtx::Get()->Now();
834
+ auto time_now = Timestamp::Now();
833
835
  auto& config = parent_->config_->outlier_detection_config();
834
836
  for (auto& state : parent_->subchannel_state_map_) {
835
837
  auto* subchannel_state = state.second.get();
@@ -1000,7 +1002,7 @@ void OutlierDetectionLb::EjectionTimer::OnTimerLocked(grpc_error_handle error) {
1000
1002
  }
1001
1003
  timer_pending_ = false;
1002
1004
  parent_->ejection_timer_ =
1003
- MakeOrphanable<EjectionTimer>(parent_, ExecCtx::Get()->Now());
1005
+ MakeOrphanable<EjectionTimer>(parent_, Timestamp::Now());
1004
1006
  }
1005
1007
  Unref(DEBUG_LOCATION, "Timer");
1006
1008
  GRPC_ERROR_UNREF(error);
@@ -1029,94 +1031,35 @@ class OutlierDetectionLbFactory : public LoadBalancingPolicyFactory {
1029
1031
  "configuration. Please use loadBalancingConfig field of service "
1030
1032
  "config instead.");
1031
1033
  }
1032
- std::vector<std::string> errors;
1033
- std::vector<grpc_error_handle> error_list;
1034
- // Outlier detection config
1034
+ ValidationErrors errors;
1035
1035
  OutlierDetectionConfig outlier_detection_config;
1036
- auto it = json.object_value().find("successRateEjection");
1037
- if (it != json.object_value().end()) {
1038
- if (it->second.type() != Json::Type::OBJECT) {
1039
- errors.emplace_back(
1040
- "field:successRateEjection error:type must be object");
1041
- } else {
1042
- OutlierDetectionConfig::SuccessRateEjection success_config;
1043
- const Json::Object& object = it->second.object_value();
1044
- ParseJsonObjectField(object, "stdevFactor",
1045
- &success_config.stdev_factor, &error_list,
1046
- /*required=*/false);
1047
- ParseJsonObjectField(object, "enforcementPercentage",
1048
- &success_config.enforcement_percentage,
1049
- &error_list, /*required=*/false);
1050
- ParseJsonObjectField(object, "minimumHosts",
1051
- &success_config.minimum_hosts, &error_list,
1052
- /*required=*/false);
1053
- ParseJsonObjectField(object, "requestVolume",
1054
- &success_config.request_volume, &error_list,
1055
- /*required=*/false);
1056
- outlier_detection_config.success_rate_ejection = success_config;
1057
- }
1058
- }
1059
- it = json.object_value().find("failurePercentageEjection");
1060
- if (it != json.object_value().end()) {
1061
- if (it->second.type() != Json::Type::OBJECT) {
1062
- errors.emplace_back(
1063
- "field:successRateEjection error:type must be object");
1064
- } else {
1065
- OutlierDetectionConfig::FailurePercentageEjection failure_config;
1066
- const Json::Object& object = it->second.object_value();
1067
- ParseJsonObjectField(object, "threshold", &failure_config.threshold,
1068
- &error_list, /*required=*/false);
1069
- ParseJsonObjectField(object, "enforcementPercentage",
1070
- &failure_config.enforcement_percentage,
1071
- &error_list, /*required=*/false);
1072
- ParseJsonObjectField(object, "minimumHosts",
1073
- &failure_config.minimum_hosts, &error_list,
1074
- /*required=*/false);
1075
- ParseJsonObjectField(object, "requestVolume",
1076
- &failure_config.request_volume, &error_list,
1077
- /*required=*/false);
1078
- outlier_detection_config.failure_percentage_ejection = failure_config;
1079
- }
1080
- }
1081
- ParseJsonObjectFieldAsDuration(json.object_value(), "interval",
1082
- &outlier_detection_config.interval,
1083
- &error_list, /*required=*/false);
1084
- ParseJsonObjectFieldAsDuration(json.object_value(), "baseEjectionTime",
1085
- &outlier_detection_config.base_ejection_time,
1086
- &error_list, /*required=*/false);
1087
- if (!ParseJsonObjectFieldAsDuration(
1088
- json.object_value(), "maxEjectionTime",
1089
- &outlier_detection_config.max_ejection_time, &error_list,
1090
- /*required=*/false)) {
1091
- outlier_detection_config.max_ejection_time = std::max(
1092
- outlier_detection_config.base_ejection_time, Duration::Seconds(300));
1093
- }
1094
- ParseJsonObjectField(json.object_value(), "maxEjectionPercent",
1095
- &outlier_detection_config.max_ejection_percent,
1096
- &error_list, /*required=*/false);
1097
1036
  RefCountedPtr<LoadBalancingPolicy::Config> child_policy;
1098
- it = json.object_value().find("childPolicy");
1099
- if (it == json.object_value().end()) {
1100
- errors.emplace_back("field:childPolicy error:required field missing");
1101
- } else {
1102
- auto child_policy_config =
1103
- LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(it->second);
1104
- if (!child_policy_config.ok()) {
1105
- errors.emplace_back(
1106
- absl::StrCat("error parsing childPolicy field: ",
1107
- child_policy_config.status().message()));
1108
- } else {
1109
- child_policy = std::move(*child_policy_config);
1037
+ {
1038
+ ValidationErrors::ScopedField field(
1039
+ &errors, "[\"outlier_detection_experimental\"]");
1040
+ outlier_detection_config =
1041
+ LoadFromJson<OutlierDetectionConfig>(json, JsonArgs(), &errors);
1042
+ // Parse childPolicy manually.
1043
+ {
1044
+ ValidationErrors::ScopedField field(&errors, ".childPolicy");
1045
+ auto it = json.object_value().find("childPolicy");
1046
+ if (it == json.object_value().end()) {
1047
+ errors.AddError("field not present");
1048
+ } else {
1049
+ auto child_policy_config = CoreConfiguration::Get()
1050
+ .lb_policy_registry()
1051
+ .ParseLoadBalancingConfig(it->second);
1052
+ if (!child_policy_config.ok()) {
1053
+ errors.AddError(child_policy_config.status().message());
1054
+ } else {
1055
+ child_policy = std::move(*child_policy_config);
1056
+ }
1057
+ }
1110
1058
  }
1111
1059
  }
1112
- for (auto& error : error_list) {
1113
- errors.emplace_back(grpc_error_std_string(error));
1114
- GRPC_ERROR_UNREF(error);
1115
- }
1116
- if (!errors.empty()) {
1117
- return absl::InvalidArgumentError(
1118
- absl::StrCat("outlier_detection_experimental LB policy config: [",
1119
- absl::StrJoin(errors, "; "), "]"));
1060
+ if (!errors.ok()) {
1061
+ return errors.status(
1062
+ "errors validating outlier_detection LB policy config");
1120
1063
  }
1121
1064
  return MakeRefCounted<OutlierDetectionLbConfig>(outlier_detection_config,
1122
1065
  std::move(child_policy));
@@ -1125,18 +1068,73 @@ class OutlierDetectionLbFactory : public LoadBalancingPolicyFactory {
1125
1068
 
1126
1069
  } // namespace
1127
1070
 
1128
- } // namespace grpc_core
1071
+ //
1072
+ // OutlierDetectionConfig
1073
+ //
1074
+
1075
+ const JsonLoaderInterface*
1076
+ OutlierDetectionConfig::SuccessRateEjection::JsonLoader(const JsonArgs&) {
1077
+ static const auto* loader =
1078
+ JsonObjectLoader<SuccessRateEjection>()
1079
+ .OptionalField("stdevFactor", &SuccessRateEjection::stdev_factor)
1080
+ .OptionalField("enforcementPercentage",
1081
+ &SuccessRateEjection::enforcement_percentage)
1082
+ .OptionalField("minimumHosts", &SuccessRateEjection::minimum_hosts)
1083
+ .OptionalField("requestVolume", &SuccessRateEjection::request_volume)
1084
+ .Finish();
1085
+ return loader;
1086
+ }
1087
+
1088
+ const JsonLoaderInterface*
1089
+ OutlierDetectionConfig::FailurePercentageEjection::JsonLoader(const JsonArgs&) {
1090
+ static const auto* loader =
1091
+ JsonObjectLoader<FailurePercentageEjection>()
1092
+ .OptionalField("threshold", &FailurePercentageEjection::threshold)
1093
+ .OptionalField("enforcementPercentage",
1094
+ &FailurePercentageEjection::enforcement_percentage)
1095
+ .OptionalField("minimumHosts",
1096
+ &FailurePercentageEjection::minimum_hosts)
1097
+ .OptionalField("requestVolume",
1098
+ &FailurePercentageEjection::request_volume)
1099
+ .Finish();
1100
+ return loader;
1101
+ }
1102
+
1103
+ const JsonLoaderInterface* OutlierDetectionConfig::JsonLoader(const JsonArgs&) {
1104
+ static const auto* loader =
1105
+ JsonObjectLoader<OutlierDetectionConfig>()
1106
+ .OptionalField("interval", &OutlierDetectionConfig::interval)
1107
+ .OptionalField("baseEjectionTime",
1108
+ &OutlierDetectionConfig::base_ejection_time)
1109
+ .OptionalField("maxEjectionTime",
1110
+ &OutlierDetectionConfig::max_ejection_time)
1111
+ .OptionalField("maxEjectionPercent",
1112
+ &OutlierDetectionConfig::max_ejection_percent)
1113
+ .OptionalField("successRateEjection",
1114
+ &OutlierDetectionConfig::success_rate_ejection)
1115
+ .OptionalField("failurePercentageEjection",
1116
+ &OutlierDetectionConfig::failure_percentage_ejection)
1117
+ .Finish();
1118
+ return loader;
1119
+ }
1120
+
1121
+ void OutlierDetectionConfig::JsonPostLoad(const Json& json, const JsonArgs&,
1122
+ ValidationErrors* /*errors*/) {
1123
+ if (json.object_value().find("maxEjectionTime") ==
1124
+ json.object_value().end()) {
1125
+ max_ejection_time = std::max(base_ejection_time, Duration::Seconds(300));
1126
+ }
1127
+ }
1129
1128
 
1130
1129
  //
1131
1130
  // Plugin registration
1132
1131
  //
1133
1132
 
1134
- void grpc_lb_policy_outlier_detection_init() {
1135
- if (grpc_core::XdsOutlierDetectionEnabled()) {
1136
- grpc_core::LoadBalancingPolicyRegistry::Builder::
1137
- RegisterLoadBalancingPolicyFactory(
1138
- absl::make_unique<grpc_core::OutlierDetectionLbFactory>());
1133
+ void RegisterOutlierDetectionLbPolicy(CoreConfiguration::Builder* builder) {
1134
+ if (XdsOutlierDetectionEnabled()) {
1135
+ builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
1136
+ absl::make_unique<OutlierDetectionLbFactory>());
1139
1137
  }
1140
1138
  }
1141
1139
 
1142
- void grpc_lb_policy_outlier_detection_shutdown() {}
1140
+ } // namespace grpc_core
@@ -24,6 +24,10 @@
24
24
  #include "absl/types/optional.h"
25
25
 
26
26
  #include "src/core/lib/gprpp/time.h"
27
+ #include "src/core/lib/gprpp/validation_errors.h"
28
+ #include "src/core/lib/json/json.h"
29
+ #include "src/core/lib/json/json_args.h"
30
+ #include "src/core/lib/json/json_object_loader.h"
27
31
 
28
32
  namespace grpc_core {
29
33
 
@@ -40,12 +44,16 @@ struct OutlierDetectionConfig {
40
44
  uint32_t minimum_hosts = 5;
41
45
  uint32_t request_volume = 100;
42
46
 
47
+ SuccessRateEjection() {}
48
+
43
49
  bool operator==(const SuccessRateEjection& other) const {
44
50
  return stdev_factor == other.stdev_factor &&
45
51
  enforcement_percentage == other.enforcement_percentage &&
46
52
  minimum_hosts == other.minimum_hosts &&
47
53
  request_volume == other.request_volume;
48
54
  }
55
+
56
+ static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
49
57
  };
50
58
  struct FailurePercentageEjection {
51
59
  uint32_t threshold = 85;
@@ -53,12 +61,16 @@ struct OutlierDetectionConfig {
53
61
  uint32_t minimum_hosts = 5;
54
62
  uint32_t request_volume = 50;
55
63
 
64
+ FailurePercentageEjection() {}
65
+
56
66
  bool operator==(const FailurePercentageEjection& other) const {
57
67
  return threshold == other.threshold &&
58
68
  enforcement_percentage == other.enforcement_percentage &&
59
69
  minimum_hosts == other.minimum_hosts &&
60
70
  request_volume == other.request_volume;
61
71
  }
72
+
73
+ static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
62
74
  };
63
75
  absl::optional<SuccessRateEjection> success_rate_ejection;
64
76
  absl::optional<FailurePercentageEjection> failure_percentage_ejection;
@@ -71,6 +83,10 @@ struct OutlierDetectionConfig {
71
83
  success_rate_ejection == other.success_rate_ejection &&
72
84
  failure_percentage_ejection == other.failure_percentage_ejection;
73
85
  }
86
+
87
+ static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
88
+ void JsonPostLoad(const Json& json, const JsonArgs&,
89
+ ValidationErrors* errors);
74
90
  };
75
91
 
76
92
  } // namespace grpc_core
@@ -38,6 +38,7 @@
38
38
 
39
39
  #include "src/core/ext/filters/client_channel/lb_policy/subchannel_list.h"
40
40
  #include "src/core/lib/channel/channel_args.h"
41
+ #include "src/core/lib/config/core_configuration.h"
41
42
  #include "src/core/lib/debug/trace.h"
42
43
  #include "src/core/lib/gprpp/debug_location.h"
43
44
  #include "src/core/lib/gprpp/orphanable.h"
@@ -68,7 +69,7 @@ class PickFirst : public LoadBalancingPolicy {
68
69
 
69
70
  absl::string_view name() const override { return kPickFirst; }
70
71
 
71
- void UpdateLocked(UpdateArgs args) override;
72
+ absl::Status UpdateLocked(UpdateArgs args) override;
72
73
  void ExitIdleLocked() override;
73
74
  void ResetBackoffLocked() override;
74
75
 
@@ -162,9 +163,9 @@ class PickFirst : public LoadBalancingPolicy {
162
163
  // Lateset update args.
163
164
  UpdateArgs latest_update_args_;
164
165
  // All our subchannels.
165
- OrphanablePtr<PickFirstSubchannelList> subchannel_list_;
166
+ RefCountedPtr<PickFirstSubchannelList> subchannel_list_;
166
167
  // Latest pending subchannel list.
167
- OrphanablePtr<PickFirstSubchannelList> latest_pending_subchannel_list_;
168
+ RefCountedPtr<PickFirstSubchannelList> latest_pending_subchannel_list_;
168
169
  // Selected subchannel in \a subchannel_list_.
169
170
  PickFirstSubchannelData* selected_ = nullptr;
170
171
  // Are we in IDLE state?
@@ -227,11 +228,11 @@ void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
227
228
  "[PF %p] Shutting down previous pending subchannel list %p", this,
228
229
  latest_pending_subchannel_list_.get());
229
230
  }
230
- latest_pending_subchannel_list_ = MakeOrphanable<PickFirstSubchannelList>(
231
+ latest_pending_subchannel_list_ = MakeRefCounted<PickFirstSubchannelList>(
231
232
  this, std::move(addresses), latest_update_args_.args);
232
233
  latest_pending_subchannel_list_->StartWatchingLocked();
233
234
  // Empty update or no valid subchannels. Put the channel in
234
- // TRANSIENT_FAILURE.
235
+ // TRANSIENT_FAILURE and request re-resolution.
235
236
  if (latest_pending_subchannel_list_->num_subchannels() == 0) {
236
237
  absl::Status status =
237
238
  latest_update_args_.addresses.ok()
@@ -241,6 +242,7 @@ void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
241
242
  channel_control_helper()->UpdateState(
242
243
  GRPC_CHANNEL_TRANSIENT_FAILURE, status,
243
244
  absl::make_unique<TransientFailurePicker>(status));
245
+ channel_control_helper()->RequestReresolution();
244
246
  }
245
247
  // Otherwise, if this is the initial update, report CONNECTING.
246
248
  else if (subchannel_list_.get() == nullptr) {
@@ -262,7 +264,7 @@ void PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked() {
262
264
  }
263
265
  }
264
266
 
265
- void PickFirst::UpdateLocked(UpdateArgs args) {
267
+ absl::Status PickFirst::UpdateLocked(UpdateArgs args) {
266
268
  if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_pick_first_trace)) {
267
269
  if (args.addresses.ok()) {
268
270
  gpr_log(GPR_INFO,
@@ -275,6 +277,13 @@ void PickFirst::UpdateLocked(UpdateArgs args) {
275
277
  }
276
278
  // Add GRPC_ARG_INHIBIT_HEALTH_CHECKING channel arg.
277
279
  args.args = args.args.Set(GRPC_ARG_INHIBIT_HEALTH_CHECKING, 1);
280
+ // Set return status based on the address list.
281
+ absl::Status status;
282
+ if (!args.addresses.ok()) {
283
+ status = args.addresses.status();
284
+ } else if (args.addresses->empty()) {
285
+ status = absl::UnavailableError("address list must not be empty");
286
+ }
278
287
  // If the update contains a resolver error and we have a previous update
279
288
  // that was not a resolver error, keep using the previous addresses.
280
289
  if (!args.addresses.ok() && latest_update_args_.config != nullptr) {
@@ -287,6 +296,7 @@ void PickFirst::UpdateLocked(UpdateArgs args) {
287
296
  if (!idle_) {
288
297
  AttemptToConnectUsingLatestUpdateArgsLocked();
289
298
  }
299
+ return status;
290
300
  }
291
301
 
292
302
  void PickFirst::PickFirstSubchannelData::ProcessConnectivityChangeLocked(
@@ -527,12 +537,9 @@ class PickFirstFactory : public LoadBalancingPolicyFactory {
527
537
 
528
538
  } // namespace
529
539
 
530
- } // namespace grpc_core
531
-
532
- void grpc_lb_policy_pick_first_init() {
533
- grpc_core::LoadBalancingPolicyRegistry::Builder::
534
- RegisterLoadBalancingPolicyFactory(
535
- absl::make_unique<grpc_core::PickFirstFactory>());
540
+ void RegisterPickFirstLbPolicy(CoreConfiguration::Builder* builder) {
541
+ builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
542
+ absl::make_unique<PickFirstFactory>());
536
543
  }
537
544
 
538
- void grpc_lb_policy_pick_first_shutdown() {}
545
+ } // namespace grpc_core