grpc 1.60.0 → 1.61.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +208 -165
  3. data/include/grpc/event_engine/event_engine.h +59 -12
  4. data/include/grpc/event_engine/internal/memory_allocator_impl.h +6 -0
  5. data/include/grpc/event_engine/internal/slice_cast.h +12 -0
  6. data/include/grpc/event_engine/memory_allocator.h +3 -1
  7. data/include/grpc/event_engine/slice.h +5 -0
  8. data/include/grpc/grpc_security.h +22 -1
  9. data/include/grpc/impl/call.h +29 -0
  10. data/include/grpc/impl/channel_arg_names.h +12 -1
  11. data/include/grpc/impl/slice_type.h +1 -1
  12. data/include/grpc/module.modulemap +1 -0
  13. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +54 -7
  14. data/src/core/ext/filters/backend_metrics/backend_metric_filter.h +20 -6
  15. data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +10 -13
  16. data/src/core/ext/filters/channel_idle/channel_idle_filter.h +18 -10
  17. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +326 -0
  18. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.h +143 -0
  19. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -2
  20. data/src/core/ext/filters/client_channel/client_channel.cc +32 -6
  21. data/src/core/ext/filters/client_channel/client_channel_internal.h +2 -0
  22. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +1 -1
  23. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +54 -21
  24. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +3 -2
  25. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +2 -1
  26. data/src/core/ext/filters/client_channel/lb_policy/endpoint_list.cc +12 -15
  27. data/src/core/ext/filters/client_channel/lb_policy/endpoint_list.h +8 -5
  28. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +139 -92
  29. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +9 -4
  30. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +9 -4
  31. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +10 -11
  32. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +94 -93
  33. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +5 -3
  34. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +12 -15
  35. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +38 -16
  36. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +25 -28
  37. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +10 -10
  38. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +37 -35
  39. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -9
  40. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +504 -461
  41. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +232 -122
  42. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +8 -6
  43. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +642 -251
  44. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.h +2 -6
  45. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +7 -8
  46. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +2 -1
  47. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +3 -1
  48. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +2 -2
  49. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -2
  50. data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +6 -8
  51. data/src/core/ext/filters/client_channel/resolver/xds/xds_dependency_manager.cc +1031 -0
  52. data/src/core/ext/filters/client_channel/resolver/xds/xds_dependency_manager.h +277 -0
  53. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +128 -270
  54. data/src/core/ext/filters/client_channel/resolver/xds/{xds_resolver.h → xds_resolver_attributes.h} +5 -4
  55. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver_trace.cc +25 -0
  56. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver_trace.h +30 -0
  57. data/src/core/ext/filters/client_channel/retry_filter.cc +1 -0
  58. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +35 -17
  59. data/src/core/ext/filters/deadline/deadline_filter.cc +12 -0
  60. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +17 -13
  61. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +13 -4
  62. data/src/core/ext/filters/http/client/http_client_filter.cc +23 -32
  63. data/src/core/ext/filters/http/client/http_client_filter.h +10 -5
  64. data/src/core/ext/filters/http/client_authority_filter.cc +14 -14
  65. data/src/core/ext/filters/http/client_authority_filter.h +12 -4
  66. data/src/core/ext/filters/http/http_filters_plugin.cc +42 -20
  67. data/src/core/ext/filters/http/message_compress/compression_filter.cc +55 -80
  68. data/src/core/ext/filters/http/message_compress/compression_filter.h +54 -12
  69. data/src/core/ext/filters/http/message_compress/legacy_compression_filter.cc +325 -0
  70. data/src/core/ext/filters/http/message_compress/legacy_compression_filter.h +139 -0
  71. data/src/core/ext/filters/http/server/http_server_filter.cc +41 -41
  72. data/src/core/ext/filters/http/server/http_server_filter.h +11 -4
  73. data/src/core/ext/filters/message_size/message_size_filter.cc +56 -76
  74. data/src/core/ext/filters/message_size/message_size_filter.h +35 -23
  75. data/src/core/ext/filters/rbac/rbac_filter.cc +15 -11
  76. data/src/core/ext/filters/rbac/rbac_filter.h +11 -4
  77. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +25 -13
  78. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +47 -50
  79. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +21 -4
  80. data/src/core/ext/transport/chttp2/alpn/alpn.cc +1 -1
  81. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -2
  82. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +11 -2
  83. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +67 -145
  84. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -3
  85. data/src/core/ext/transport/chttp2/transport/flow_control.cc +21 -82
  86. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -8
  87. data/src/core/ext/transport/chttp2/transport/frame.cc +506 -0
  88. data/src/core/ext/transport/chttp2/transport/frame.h +214 -0
  89. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +1 -1
  90. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +33 -79
  91. data/src/core/ext/transport/chttp2/transport/frame_settings.h +4 -7
  92. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +122 -32
  93. data/src/core/ext/transport/chttp2/transport/http2_settings.h +142 -37
  94. data/src/core/ext/transport/chttp2/transport/internal.h +1 -22
  95. data/src/core/ext/transport/chttp2/transport/parsing.cc +23 -37
  96. data/src/core/ext/transport/chttp2/transport/writing.cc +26 -58
  97. data/src/core/ext/transport/inproc/inproc_transport.cc +172 -13
  98. data/src/core/ext/upb-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upb.h +712 -0
  99. data/src/core/ext/upb-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upb_minitable.c +151 -0
  100. data/src/core/ext/upb-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upb_minitable.h +33 -0
  101. data/src/core/ext/upbdefs-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upbdefs.c +133 -0
  102. data/src/core/ext/upbdefs-gen/envoy/extensions/upstreams/http/v3/http_protocol_options.upbdefs.h +50 -0
  103. data/src/core/ext/xds/certificate_provider_store.cc +2 -1
  104. data/src/core/ext/xds/certificate_provider_store.h +0 -5
  105. data/src/core/ext/xds/xds_api.cc +31 -18
  106. data/src/core/ext/xds/xds_api.h +2 -2
  107. data/src/core/ext/xds/xds_bootstrap.h +3 -0
  108. data/src/core/ext/xds/xds_certificate_provider.cc +88 -287
  109. data/src/core/ext/xds/xds_certificate_provider.h +44 -111
  110. data/src/core/ext/xds/xds_client.cc +420 -414
  111. data/src/core/ext/xds/xds_client.h +31 -22
  112. data/src/core/ext/xds/xds_client_grpc.cc +3 -1
  113. data/src/core/ext/xds/xds_cluster.cc +104 -11
  114. data/src/core/ext/xds/xds_cluster.h +9 -1
  115. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +9 -5
  116. data/src/core/ext/xds/xds_common_types.cc +14 -10
  117. data/src/core/ext/xds/xds_endpoint.cc +9 -4
  118. data/src/core/ext/xds/xds_endpoint.h +5 -1
  119. data/src/core/ext/xds/xds_health_status.cc +12 -2
  120. data/src/core/ext/xds/xds_health_status.h +4 -2
  121. data/src/core/ext/xds/xds_http_rbac_filter.cc +5 -3
  122. data/src/core/ext/xds/xds_listener.cc +14 -8
  123. data/src/core/ext/xds/xds_resource_type_impl.h +6 -4
  124. data/src/core/ext/xds/xds_route_config.cc +34 -22
  125. data/src/core/ext/xds/xds_route_config.h +1 -0
  126. data/src/core/ext/xds/xds_server_config_fetcher.cc +61 -57
  127. data/src/core/ext/xds/xds_transport.h +3 -0
  128. data/src/core/ext/xds/xds_transport_grpc.cc +47 -50
  129. data/src/core/ext/xds/xds_transport_grpc.h +4 -0
  130. data/src/core/lib/channel/call_tracer.cc +12 -0
  131. data/src/core/lib/channel/call_tracer.h +17 -3
  132. data/src/core/lib/channel/channel_args.cc +24 -14
  133. data/src/core/lib/channel/channel_args.h +74 -13
  134. data/src/core/lib/channel/channel_stack.cc +27 -0
  135. data/src/core/lib/channel/channel_stack.h +10 -10
  136. data/src/core/lib/channel/connected_channel.cc +64 -18
  137. data/src/core/lib/channel/promise_based_filter.h +1041 -1
  138. data/src/core/lib/channel/server_call_tracer_filter.cc +43 -35
  139. data/src/core/lib/compression/compression_internal.cc +0 -3
  140. data/src/core/lib/event_engine/ares_resolver.cc +35 -14
  141. data/src/core/lib/event_engine/ares_resolver.h +9 -10
  142. data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +8 -1
  143. data/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.cc +132 -0
  144. data/src/core/lib/event_engine/posix_engine/native_posix_dns_resolver.h +61 -0
  145. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +52 -36
  146. data/src/core/lib/event_engine/posix_engine/posix_engine.h +4 -9
  147. data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +11 -3
  148. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +9 -2
  149. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +7 -0
  150. data/src/core/lib/event_engine/posix_engine/timer_manager.cc +17 -27
  151. data/src/core/lib/event_engine/posix_engine/timer_manager.h +0 -3
  152. data/src/core/lib/event_engine/ref_counted_dns_resolver_interface.h +55 -0
  153. data/src/core/lib/event_engine/windows/native_windows_dns_resolver.cc +114 -0
  154. data/src/core/lib/event_engine/windows/native_windows_dns_resolver.h +51 -0
  155. data/src/core/lib/event_engine/windows/windows_engine.cc +7 -7
  156. data/src/core/lib/experiments/config.cc +13 -0
  157. data/src/core/lib/experiments/config.h +3 -0
  158. data/src/core/lib/experiments/experiments.cc +245 -366
  159. data/src/core/lib/experiments/experiments.h +50 -156
  160. data/src/core/lib/gprpp/debug_location.h +13 -0
  161. data/src/core/lib/gprpp/dual_ref_counted.h +36 -7
  162. data/src/core/lib/gprpp/orphanable.h +27 -0
  163. data/src/core/lib/gprpp/ref_counted.h +63 -22
  164. data/src/core/lib/gprpp/ref_counted_ptr.h +70 -27
  165. data/src/core/lib/gprpp/ref_counted_string.h +13 -0
  166. data/src/core/lib/gprpp/status_helper.cc +1 -2
  167. data/src/core/lib/iomgr/combiner.cc +15 -51
  168. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +31 -0
  169. data/src/core/lib/iomgr/event_engine_shims/endpoint.h +16 -0
  170. data/src/core/lib/iomgr/tcp_client_posix.cc +4 -3
  171. data/src/core/lib/load_balancing/lb_policy.h +1 -1
  172. data/src/core/lib/promise/activity.cc +17 -2
  173. data/src/core/lib/promise/activity.h +5 -4
  174. data/src/core/lib/promise/all_ok.h +80 -0
  175. data/src/core/lib/promise/detail/join_state.h +2077 -0
  176. data/src/core/lib/promise/detail/promise_factory.h +1 -0
  177. data/src/core/lib/promise/detail/promise_like.h +8 -1
  178. data/src/core/lib/promise/detail/seq_state.h +3458 -150
  179. data/src/core/lib/promise/detail/status.h +42 -5
  180. data/src/core/lib/promise/for_each.h +13 -1
  181. data/src/core/lib/promise/if.h +4 -0
  182. data/src/core/lib/promise/latch.h +6 -3
  183. data/src/core/lib/promise/party.cc +33 -31
  184. data/src/core/lib/promise/party.h +142 -6
  185. data/src/core/lib/promise/poll.h +39 -13
  186. data/src/core/lib/promise/promise.h +4 -0
  187. data/src/core/lib/promise/seq.h +107 -7
  188. data/src/core/lib/promise/status_flag.h +196 -0
  189. data/src/core/lib/promise/try_join.h +132 -0
  190. data/src/core/lib/promise/try_seq.h +132 -10
  191. data/src/core/lib/resolver/endpoint_addresses.cc +0 -1
  192. data/src/core/lib/resolver/endpoint_addresses.h +48 -0
  193. data/src/core/lib/resource_quota/arena.h +2 -2
  194. data/src/core/lib/resource_quota/memory_quota.cc +57 -8
  195. data/src/core/lib/resource_quota/memory_quota.h +6 -0
  196. data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +14 -11
  197. data/src/core/lib/security/authorization/grpc_server_authz_filter.h +14 -5
  198. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +4 -0
  199. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +4 -0
  200. data/src/core/lib/security/credentials/external/external_account_credentials.cc +28 -20
  201. data/src/core/lib/security/credentials/external/external_account_credentials.h +4 -0
  202. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +4 -0
  203. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +4 -0
  204. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +4 -0
  205. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +4 -0
  206. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -1
  207. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +0 -3
  208. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +12 -0
  209. data/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.cc +22 -5
  210. data/src/core/lib/security/credentials/tls/grpc_tls_crl_provider.h +1 -5
  211. data/src/core/lib/security/credentials/tls/tls_credentials.cc +16 -0
  212. data/src/core/lib/security/credentials/xds/xds_credentials.cc +21 -28
  213. data/src/core/lib/security/credentials/xds/xds_credentials.h +2 -4
  214. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +4 -3
  215. data/src/core/lib/security/transport/auth_filters.h +71 -4
  216. data/src/core/lib/security/transport/client_auth_filter.cc +2 -4
  217. data/src/core/lib/security/transport/legacy_server_auth_filter.cc +244 -0
  218. data/src/core/lib/security/transport/server_auth_filter.cc +70 -90
  219. data/src/core/lib/slice/slice_buffer.h +3 -0
  220. data/src/core/lib/surface/builtins.cc +1 -1
  221. data/src/core/lib/surface/call.cc +683 -196
  222. data/src/core/lib/surface/call.h +26 -13
  223. data/src/core/lib/surface/call_trace.cc +42 -1
  224. data/src/core/lib/surface/channel.cc +0 -1
  225. data/src/core/lib/surface/channel.h +0 -6
  226. data/src/core/lib/surface/channel_init.h +26 -0
  227. data/src/core/lib/surface/init.cc +14 -8
  228. data/src/core/lib/surface/server.cc +256 -237
  229. data/src/core/lib/surface/server.h +26 -54
  230. data/src/core/lib/surface/version.cc +2 -2
  231. data/src/core/lib/surface/wait_for_cq_end_op.h +94 -0
  232. data/src/core/lib/transport/call_final_info.cc +38 -0
  233. data/src/core/lib/transport/call_final_info.h +54 -0
  234. data/src/core/lib/transport/connectivity_state.cc +3 -2
  235. data/src/core/lib/transport/connectivity_state.h +4 -0
  236. data/src/core/lib/transport/metadata_batch.h +4 -4
  237. data/src/core/lib/transport/transport.cc +70 -19
  238. data/src/core/lib/transport/transport.h +395 -25
  239. data/src/core/plugin_registry/grpc_plugin_registry.cc +3 -0
  240. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +0 -3
  241. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  242. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +1 -1
  243. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -1
  244. data/src/core/tsi/ssl_transport_security.cc +65 -43
  245. data/src/ruby/ext/grpc/rb_channel_args.c +3 -1
  246. data/src/ruby/ext/grpc/rb_grpc.c +0 -1
  247. data/src/ruby/ext/grpc/rb_grpc.h +0 -2
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  249. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
  250. data/src/ruby/lib/grpc/version.rb +1 -1
  251. data/third_party/upb/upb/reflection/def_pool.h +2 -2
  252. data/third_party/zlib/adler32.c +5 -27
  253. data/third_party/zlib/compress.c +5 -16
  254. data/third_party/zlib/crc32.c +86 -162
  255. data/third_party/zlib/deflate.c +233 -336
  256. data/third_party/zlib/deflate.h +8 -8
  257. data/third_party/zlib/gzguts.h +11 -12
  258. data/third_party/zlib/infback.c +7 -23
  259. data/third_party/zlib/inffast.c +1 -4
  260. data/third_party/zlib/inffast.h +1 -1
  261. data/third_party/zlib/inflate.c +30 -99
  262. data/third_party/zlib/inftrees.c +6 -11
  263. data/third_party/zlib/inftrees.h +3 -3
  264. data/third_party/zlib/trees.c +224 -302
  265. data/third_party/zlib/uncompr.c +4 -12
  266. data/third_party/zlib/zconf.h +6 -2
  267. data/third_party/zlib/zlib.h +191 -188
  268. data/third_party/zlib/zutil.c +16 -44
  269. data/third_party/zlib/zutil.h +10 -10
  270. metadata +35 -13
  271. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +0 -1173
  272. data/src/core/lib/event_engine/memory_allocator.cc +0 -74
  273. data/src/core/lib/transport/pid_controller.cc +0 -51
  274. data/src/core/lib/transport/pid_controller.h +0 -116
  275. data/third_party/upb/upb/collections/array.h +0 -17
  276. data/third_party/upb/upb/collections/map.h +0 -17
  277. data/third_party/upb/upb/upb.hpp +0 -18
@@ -211,26 +211,6 @@ class Server : public InternallyRefCounted<Server>,
211
211
  private:
212
212
  struct RequestedCall;
213
213
 
214
- struct ChannelRegisteredMethod {
215
- ChannelRegisteredMethod() = default;
216
- ChannelRegisteredMethod(RegisteredMethod* server_registered_method_arg,
217
- uint32_t flags_arg, bool has_host_arg,
218
- Slice method_arg, Slice host_arg)
219
- : server_registered_method(server_registered_method_arg),
220
- flags(flags_arg),
221
- has_host(has_host_arg),
222
- method(std::move(method_arg)),
223
- host(std::move(host_arg)) {}
224
-
225
- ~ChannelRegisteredMethod() = default;
226
-
227
- RegisteredMethod* server_registered_method = nullptr;
228
- uint32_t flags;
229
- bool has_host;
230
- Slice method;
231
- Slice host;
232
- };
233
-
234
214
  class RequestMatcherInterface;
235
215
  class RealRequestMatcherFilterStack;
236
216
  class RealRequestMatcherPromises;
@@ -238,7 +218,7 @@ class Server : public InternallyRefCounted<Server>,
238
218
  class AllocatingRequestMatcherBatch;
239
219
  class AllocatingRequestMatcherRegistered;
240
220
 
241
- class ChannelData {
221
+ class ChannelData final : public ServerTransport::Acceptor {
242
222
  public:
243
223
  ChannelData() = default;
244
224
  ~ChannelData();
@@ -251,60 +231,37 @@ class Server : public InternallyRefCounted<Server>,
251
231
  Channel* channel() const { return channel_.get(); }
252
232
  size_t cq_idx() const { return cq_idx_; }
253
233
 
254
- ChannelRegisteredMethod* GetRegisteredMethod(const grpc_slice& host,
255
- const grpc_slice& path);
256
-
257
- ChannelRegisteredMethod* GetRegisteredMethod(const absl::string_view& host,
258
- const absl::string_view& path);
234
+ RegisteredMethod* GetRegisteredMethod(const absl::string_view& host,
235
+ const absl::string_view& path);
259
236
  // Filter vtable functions.
260
237
  static grpc_error_handle InitChannelElement(
261
238
  grpc_channel_element* elem, grpc_channel_element_args* args);
262
239
  static void DestroyChannelElement(grpc_channel_element* elem);
263
240
  static ArenaPromise<ServerMetadataHandle> MakeCallPromise(
264
241
  grpc_channel_element* elem, CallArgs call_args, NextPromiseFactory);
242
+ void InitCall(RefCountedPtr<CallSpineInterface> call);
243
+
244
+ Arena* CreateArena() override;
245
+ absl::StatusOr<CallInitiator> CreateCall(
246
+ ClientMetadata& client_initial_metadata, Arena* arena) override;
265
247
 
266
248
  private:
267
249
  class ConnectivityWatcher;
268
250
 
269
251
  static void AcceptStream(void* arg, Transport* /*transport*/,
270
252
  const void* transport_server_data);
271
- static void SetRegisteredMethodOnMetadata(void* arg,
272
- ServerMetadata* metadata);
253
+ void SetRegisteredMethodOnMetadata(ClientMetadata& metadata);
273
254
 
274
255
  void Destroy() ABSL_EXCLUSIVE_LOCKS_REQUIRED(server_->mu_global_);
275
256
 
276
257
  static void FinishDestroy(void* arg, grpc_error_handle error);
277
258
 
278
- struct StringViewStringViewPairHash
279
- : absl::flat_hash_set<
280
- std::pair<absl::string_view, absl::string_view>>::hasher {
281
- using is_transparent = void;
282
- };
283
-
284
- struct StringViewStringViewPairEq
285
- : std::equal_to<std::pair<absl::string_view, absl::string_view>> {
286
- using is_transparent = void;
287
- };
288
-
289
259
  RefCountedPtr<Server> server_;
290
260
  RefCountedPtr<Channel> channel_;
291
261
  // The index into Server::cqs_ of the CQ used as a starting point for
292
262
  // where to publish new incoming calls.
293
263
  size_t cq_idx_;
294
264
  absl::optional<std::list<ChannelData*>::iterator> list_position_;
295
- // A hash-table of the methods and hosts of the registered methods.
296
- // TODO(vjpai): Convert this to an STL map type as opposed to a direct
297
- // bucket implementation. (Consider performance impact, hash function to
298
- // use, etc.)
299
- std::unique_ptr<std::vector<ChannelRegisteredMethod>>
300
- old_registered_methods_;
301
- // Map of registered methods.
302
- absl::flat_hash_map<std::pair<std::string, std::string> /*host, method*/,
303
- std::unique_ptr<ChannelRegisteredMethod>,
304
- StringViewStringViewPairHash,
305
- StringViewStringViewPairEq>
306
- registered_methods_;
307
- uint32_t registered_method_max_probes_;
308
265
  grpc_closure finish_destroy_channel_closure_;
309
266
  intptr_t channelz_socket_uuid_;
310
267
  };
@@ -413,6 +370,17 @@ class Server : public InternallyRefCounted<Server>,
413
370
  grpc_cq_completion completion;
414
371
  };
415
372
 
373
+ struct StringViewStringViewPairHash
374
+ : absl::flat_hash_set<
375
+ std::pair<absl::string_view, absl::string_view>>::hasher {
376
+ using is_transparent = void;
377
+ };
378
+
379
+ struct StringViewStringViewPairEq
380
+ : std::equal_to<std::pair<absl::string_view, absl::string_view>> {
381
+ using is_transparent = void;
382
+ };
383
+
416
384
  static void ListenerDestroyDone(void* arg, grpc_error_handle error);
417
385
 
418
386
  static void DoneShutdownEvent(void* server,
@@ -498,7 +466,11 @@ class Server : public InternallyRefCounted<Server>,
498
466
  bool starting_ ABSL_GUARDED_BY(mu_global_) = false;
499
467
  CondVar starting_cv_;
500
468
 
501
- std::vector<std::unique_ptr<RegisteredMethod>> registered_methods_;
469
+ // Map of registered methods.
470
+ absl::flat_hash_map<std::pair<std::string, std::string> /*host, method*/,
471
+ std::unique_ptr<RegisteredMethod>,
472
+ StringViewStringViewPairHash, StringViewStringViewPairEq>
473
+ registered_methods_;
502
474
 
503
475
  // Request matcher for unregistered methods.
504
476
  std::unique_ptr<RequestMatcherInterface> unregistered_request_matcher_;
@@ -521,7 +493,7 @@ class Server : public InternallyRefCounted<Server>,
521
493
  0,
522
494
  channel_args_.GetInt(GRPC_ARG_SERVER_MAX_PENDING_REQUESTS_HARD_LIMIT)
523
495
  .value_or(3000)))};
524
- Duration max_time_in_pending_queue_{Duration::Seconds(30)};
496
+ const Duration max_time_in_pending_queue_;
525
497
  absl::BitGen bitgen_ ABSL_GUARDED_BY(mu_call_);
526
498
 
527
499
  std::list<ChannelData*> channels_;
@@ -23,6 +23,6 @@
23
23
 
24
24
  #include <grpc/grpc.h>
25
25
 
26
- const char* grpc_version_string(void) { return "37.0.0"; }
26
+ const char* grpc_version_string(void) { return "38.0.0"; }
27
27
 
28
- const char* grpc_g_stands_for(void) { return "gjallarhorn"; }
28
+ const char* grpc_g_stands_for(void) { return "grand"; }
@@ -0,0 +1,94 @@
1
+ // Copyright 2023 gRPC authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #ifndef GRPC_SRC_CORE_LIB_SURFACE_WAIT_FOR_CQ_END_OP_H
16
+ #define GRPC_SRC_CORE_LIB_SURFACE_WAIT_FOR_CQ_END_OP_H
17
+
18
+ #include <grpc/support/port_platform.h>
19
+
20
+ #include "src/core/lib/iomgr/exec_ctx.h"
21
+ #include "src/core/lib/promise/activity.h"
22
+ #include "src/core/lib/surface/completion_queue.h"
23
+
24
+ namespace grpc_core {
25
+
26
+ // Defines a promise that calls grpc_cq_end_op() (on first poll) and then waits
27
+ // for the callback supplied to grpc_cq_end_op() to be called, before resolving
28
+ // to Empty{}
29
+ class WaitForCqEndOp {
30
+ public:
31
+ WaitForCqEndOp(bool is_closure, void* tag, grpc_error_handle error,
32
+ grpc_completion_queue* cq)
33
+ : state_{NotStarted{is_closure, tag, std::move(error), cq}} {}
34
+
35
+ Poll<Empty> operator()() {
36
+ if (auto* n = absl::get_if<NotStarted>(&state_)) {
37
+ if (n->is_closure) {
38
+ ExecCtx::Run(DEBUG_LOCATION, static_cast<grpc_closure*>(n->tag),
39
+ std::move(n->error));
40
+ return Empty{};
41
+ } else {
42
+ auto not_started = std::move(*n);
43
+ auto& started =
44
+ state_.emplace<Started>(Activity::current()->MakeOwningWaker());
45
+ grpc_cq_end_op(
46
+ not_started.cq, not_started.tag, std::move(not_started.error),
47
+ [](void* p, grpc_cq_completion*) {
48
+ auto started = static_cast<Started*>(p);
49
+ started->done.store(true, std::memory_order_release);
50
+ },
51
+ &started, &started.completion);
52
+ }
53
+ }
54
+ auto& started = absl::get<Started>(state_);
55
+ if (started.done.load(std::memory_order_acquire)) {
56
+ return Empty{};
57
+ } else {
58
+ return Pending{};
59
+ }
60
+ }
61
+
62
+ WaitForCqEndOp(const WaitForCqEndOp&) = delete;
63
+ WaitForCqEndOp& operator=(const WaitForCqEndOp&) = delete;
64
+ WaitForCqEndOp(WaitForCqEndOp&& other) noexcept
65
+ : state_(std::move(absl::get<NotStarted>(other.state_))) {
66
+ other.state_.emplace<Invalid>();
67
+ }
68
+ WaitForCqEndOp& operator=(WaitForCqEndOp&& other) noexcept {
69
+ state_ = std::move(absl::get<NotStarted>(other.state_));
70
+ other.state_.emplace<Invalid>();
71
+ return *this;
72
+ }
73
+
74
+ private:
75
+ struct NotStarted {
76
+ bool is_closure;
77
+ void* tag;
78
+ grpc_error_handle error;
79
+ grpc_completion_queue* cq;
80
+ };
81
+ struct Started {
82
+ explicit Started(Waker waker) : waker(std::move(waker)) {}
83
+ Waker waker;
84
+ grpc_cq_completion completion;
85
+ std::atomic<bool> done{false};
86
+ };
87
+ struct Invalid {};
88
+ using State = absl::variant<NotStarted, Started, Invalid>;
89
+ State state_{Invalid{}};
90
+ };
91
+
92
+ } // namespace grpc_core
93
+
94
+ #endif // GRPC_SRC_CORE_LIB_SURFACE_WAIT_FOR_CQ_END_OP_H
@@ -0,0 +1,38 @@
1
+ // Copyright 2024 gRPC authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #include <grpc/support/port_platform.h>
16
+
17
+ #include "src/core/lib/transport/call_final_info.h"
18
+
19
+ #include <utility>
20
+
21
+ static void move64bits(uint64_t* from, uint64_t* to) {
22
+ *to += *from;
23
+ *from = 0;
24
+ }
25
+
26
+ void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from,
27
+ grpc_transport_one_way_stats* to) {
28
+ move64bits(&from->framing_bytes, &to->framing_bytes);
29
+ move64bits(&from->data_bytes, &to->data_bytes);
30
+ move64bits(&from->header_bytes, &to->header_bytes);
31
+ }
32
+
33
+ void grpc_transport_move_stats(grpc_transport_stream_stats* from,
34
+ grpc_transport_stream_stats* to) {
35
+ grpc_transport_move_one_way_stats(&from->incoming, &to->incoming);
36
+ grpc_transport_move_one_way_stats(&from->outgoing, &to->outgoing);
37
+ to->latency = std::exchange(from->latency, gpr_inf_future(GPR_TIMESPAN));
38
+ }
@@ -0,0 +1,54 @@
1
+ // Copyright 2024 gRPC authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #ifndef GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FINAL_INFO_H
16
+ #define GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FINAL_INFO_H
17
+
18
+ #include <grpc/support/port_platform.h>
19
+
20
+ #include <cstdint>
21
+
22
+ #include <grpc/status.h>
23
+ #include <grpc/support/time.h>
24
+
25
+ struct grpc_transport_one_way_stats {
26
+ uint64_t framing_bytes = 0;
27
+ uint64_t data_bytes = 0;
28
+ uint64_t header_bytes = 0;
29
+ };
30
+
31
+ struct grpc_transport_stream_stats {
32
+ grpc_transport_one_way_stats incoming;
33
+ grpc_transport_one_way_stats outgoing;
34
+ gpr_timespec latency = gpr_inf_future(GPR_TIMESPAN);
35
+ };
36
+
37
+ void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from,
38
+ grpc_transport_one_way_stats* to);
39
+
40
+ void grpc_transport_move_stats(grpc_transport_stream_stats* from,
41
+ grpc_transport_stream_stats* to);
42
+
43
+ struct grpc_call_stats {
44
+ grpc_transport_stream_stats transport_stream_stats;
45
+ gpr_timespec latency; // From call creating to enqueing of received status
46
+ };
47
+ /// Information about the call upon completion.
48
+ struct grpc_call_final_info {
49
+ grpc_call_stats stats;
50
+ grpc_status_code final_status = GRPC_STATUS_OK;
51
+ const char* error_string = nullptr;
52
+ };
53
+
54
+ #endif // GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FINAL_INFO_H
@@ -91,8 +91,9 @@ class AsyncConnectivityStateWatcherInterface::Notifier {
91
91
 
92
92
  void AsyncConnectivityStateWatcherInterface::Notify(
93
93
  grpc_connectivity_state state, const absl::Status& status) {
94
- new Notifier(Ref(), state, status,
95
- work_serializer_); // Deletes itself when done.
94
+ // Deletes itself when done.
95
+ new Notifier(RefAsSubclass<AsyncConnectivityStateWatcherInterface>(), state,
96
+ status, work_serializer_);
96
97
  }
97
98
 
98
99
  //
@@ -128,6 +128,10 @@ class ConnectivityStateTracker {
128
128
  // Not thread safe; access must be serialized with an external lock.
129
129
  absl::Status status() const { return status_; }
130
130
 
131
+ // Returns the number of watchers.
132
+ // Not thread safe; access must be serialized with an external lock.
133
+ size_t NumWatchers() const { return watchers_.size(); }
134
+
131
135
  private:
132
136
  const char* name_;
133
137
  std::atomic<grpc_connectivity_state> state_{grpc_connectivity_state()};
@@ -410,7 +410,8 @@ struct GrpcLbClientStatsMetadata {
410
410
  static const char* DisplayMemento(MementoType) {
411
411
  return "<internal-lb-stats>";
412
412
  }
413
- static MementoType ParseMemento(Slice, bool, MetadataParseErrorFn) {
413
+ static MementoType ParseMemento(Slice, bool, MetadataParseErrorFn error) {
414
+ error("not a valid value for grpclb_client_stats", Slice());
414
415
  return nullptr;
415
416
  }
416
417
  };
@@ -649,9 +650,8 @@ class ParseHelper {
649
650
  return ParsedMetadata<Container>(
650
651
  typename ParsedMetadata<Container>::FromSlicePair{},
651
652
  Slice::FromCopiedString(key),
652
- IsUniquelyUnownedEnabled() && will_keep_past_request_lifetime_
653
- ? value_.TakeUniquelyOwned()
654
- : std::move(value_),
653
+ will_keep_past_request_lifetime_ ? value_.TakeUniquelyOwned()
654
+ : std::move(value_),
655
655
  transport_size_);
656
656
  }
657
657
 
@@ -35,6 +35,9 @@
35
35
  #include "src/core/lib/event_engine/default_event_engine.h"
36
36
  #include "src/core/lib/gprpp/time.h"
37
37
  #include "src/core/lib/iomgr/exec_ctx.h"
38
+ #include "src/core/lib/promise/for_each.h"
39
+ #include "src/core/lib/promise/promise.h"
40
+ #include "src/core/lib/promise/try_seq.h"
38
41
  #include "src/core/lib/slice/slice.h"
39
42
  #include "src/core/lib/transport/error_utils.h"
40
43
 
@@ -83,25 +86,6 @@ void grpc_stream_ref_init(grpc_stream_refcount* refcount, int /*initial_refs*/,
83
86
  : nullptr);
84
87
  }
85
88
 
86
- static void move64bits(uint64_t* from, uint64_t* to) {
87
- *to += *from;
88
- *from = 0;
89
- }
90
-
91
- void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from,
92
- grpc_transport_one_way_stats* to) {
93
- move64bits(&from->framing_bytes, &to->framing_bytes);
94
- move64bits(&from->data_bytes, &to->data_bytes);
95
- move64bits(&from->header_bytes, &to->header_bytes);
96
- }
97
-
98
- void grpc_transport_move_stats(grpc_transport_stream_stats* from,
99
- grpc_transport_stream_stats* to) {
100
- grpc_transport_move_one_way_stats(&from->incoming, &to->incoming);
101
- grpc_transport_move_one_way_stats(&from->outgoing, &to->outgoing);
102
- to->latency = std::exchange(from->latency, gpr_inf_future(GPR_TIMESPAN));
103
- }
104
-
105
89
  namespace grpc_core {
106
90
  void Transport::SetPollingEntity(grpc_stream* stream,
107
91
  grpc_polling_entity* pollset_or_pollset_set) {
@@ -268,4 +252,71 @@ std::string Message::DebugString() const {
268
252
  return out;
269
253
  }
270
254
 
255
+ void ForwardCall(CallHandler call_handler, CallInitiator call_initiator,
256
+ ClientMetadataHandle client_initial_metadata) {
257
+ // Send initial metadata.
258
+ call_initiator.SpawnGuarded(
259
+ "send_initial_metadata",
260
+ [client_initial_metadata = std::move(client_initial_metadata),
261
+ call_initiator]() mutable {
262
+ return call_initiator.PushClientInitialMetadata(
263
+ std::move(client_initial_metadata));
264
+ });
265
+ // Read messages from handler into initiator.
266
+ call_handler.SpawnGuarded(
267
+ "read_messages", [call_handler, call_initiator]() mutable {
268
+ return ForEach(OutgoingMessages(call_handler),
269
+ [call_initiator](MessageHandle msg) mutable {
270
+ // Need to spawn a job into the initiator's activity to
271
+ // push the message in.
272
+ return call_initiator.SpawnWaitable(
273
+ "send_message",
274
+ [msg = std::move(msg), call_initiator]() mutable {
275
+ return call_initiator.CancelIfFails(
276
+ call_initiator.PushMessage(std::move(msg)));
277
+ });
278
+ });
279
+ });
280
+ call_initiator.SpawnInfallible("read_the_things", [call_initiator,
281
+ call_handler]() mutable {
282
+ return Seq(
283
+ call_initiator.CancelIfFails(TrySeq(
284
+ call_initiator.PullServerInitialMetadata(),
285
+ [call_handler](ServerMetadataHandle md) mutable {
286
+ call_handler.SpawnGuarded(
287
+ "recv_initial_metadata",
288
+ [md = std::move(md), call_handler]() mutable {
289
+ return call_handler.PushServerInitialMetadata(
290
+ std::move(md));
291
+ });
292
+ return Success{};
293
+ },
294
+ ForEach(OutgoingMessages(call_initiator),
295
+ [call_handler](MessageHandle msg) mutable {
296
+ return call_handler.SpawnWaitable(
297
+ "recv_message",
298
+ [msg = std::move(msg), call_handler]() mutable {
299
+ return call_handler.CancelIfFails(
300
+ call_handler.PushMessage(std::move(msg)));
301
+ });
302
+ }),
303
+ ImmediateOkStatus())),
304
+ call_initiator.PullServerTrailingMetadata(),
305
+ [call_handler](ServerMetadataHandle md) mutable {
306
+ call_handler.SpawnGuarded(
307
+ "recv_trailing_metadata",
308
+ [md = std::move(md), call_handler]() mutable {
309
+ return call_handler.PushServerTrailingMetadata(std::move(md));
310
+ });
311
+ return Empty{};
312
+ });
313
+ });
314
+ }
315
+
316
+ CallInitiatorAndHandler MakeCall(
317
+ grpc_event_engine::experimental::EventEngine* event_engine, Arena* arena) {
318
+ auto spine = CallSpine::Create(event_engine, arena);
319
+ return {CallInitiator(spine), CallHandler(spine)};
320
+ }
321
+
271
322
  } // namespace grpc_core