grpc 1.60.0 → 1.61.0.pre2

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
@@ -51,6 +51,7 @@
51
51
  #include "src/core/lib/channel/channel_trace.h"
52
52
  #include "src/core/lib/channel/channelz.h"
53
53
  #include "src/core/lib/config/core_configuration.h"
54
+ #include "src/core/lib/debug/stats.h"
54
55
  #include "src/core/lib/experiments/experiments.h"
55
56
  #include "src/core/lib/gpr/useful.h"
56
57
  #include "src/core/lib/gprpp/crash.h"
@@ -67,6 +68,7 @@
67
68
  #include "src/core/lib/promise/poll.h"
68
69
  #include "src/core/lib/promise/promise.h"
69
70
  #include "src/core/lib/promise/seq.h"
71
+ #include "src/core/lib/promise/try_join.h"
70
72
  #include "src/core/lib/promise/try_seq.h"
71
73
  #include "src/core/lib/slice/slice_buffer.h"
72
74
  #include "src/core/lib/slice/slice_internal.h"
@@ -75,6 +77,7 @@
75
77
  #include "src/core/lib/surface/channel.h"
76
78
  #include "src/core/lib/surface/channel_stack_type.h"
77
79
  #include "src/core/lib/surface/completion_queue.h"
80
+ #include "src/core/lib/surface/wait_for_cq_end_op.h"
78
81
  #include "src/core/lib/transport/connectivity_state.h"
79
82
  #include "src/core/lib/transport/error_utils.h"
80
83
 
@@ -82,57 +85,6 @@ namespace grpc_core {
82
85
 
83
86
  TraceFlag grpc_server_channel_trace(false, "server_channel");
84
87
 
85
- //
86
- // Server::RequestedCall
87
- //
88
-
89
- struct Server::RequestedCall {
90
- enum class Type { BATCH_CALL, REGISTERED_CALL };
91
-
92
- RequestedCall(void* tag_arg, grpc_completion_queue* call_cq,
93
- grpc_call** call_arg, grpc_metadata_array* initial_md,
94
- grpc_call_details* details)
95
- : type(Type::BATCH_CALL),
96
- tag(tag_arg),
97
- cq_bound_to_call(call_cq),
98
- call(call_arg),
99
- initial_metadata(initial_md) {
100
- data.batch.details = details;
101
- }
102
-
103
- RequestedCall(void* tag_arg, grpc_completion_queue* call_cq,
104
- grpc_call** call_arg, grpc_metadata_array* initial_md,
105
- RegisteredMethod* rm, gpr_timespec* deadline,
106
- grpc_byte_buffer** optional_payload)
107
- : type(Type::REGISTERED_CALL),
108
- tag(tag_arg),
109
- cq_bound_to_call(call_cq),
110
- call(call_arg),
111
- initial_metadata(initial_md) {
112
- data.registered.method = rm;
113
- data.registered.deadline = deadline;
114
- data.registered.optional_payload = optional_payload;
115
- }
116
-
117
- MultiProducerSingleConsumerQueue::Node mpscq_node;
118
- const Type type;
119
- void* const tag;
120
- grpc_completion_queue* const cq_bound_to_call;
121
- grpc_call** const call;
122
- grpc_cq_completion completion;
123
- grpc_metadata_array* const initial_metadata;
124
- union {
125
- struct {
126
- grpc_call_details* details;
127
- } batch;
128
- struct {
129
- RegisteredMethod* method;
130
- gpr_timespec* deadline;
131
- grpc_byte_buffer** optional_payload;
132
- } registered;
133
- } data;
134
- };
135
-
136
88
  //
137
89
  // Server::RegisteredMethod
138
90
  //
@@ -248,6 +200,87 @@ class Server::RequestMatcherInterface {
248
200
  virtual Server* server() const = 0;
249
201
  };
250
202
 
203
+ //
204
+ // Server::RequestedCall
205
+ //
206
+
207
+ struct Server::RequestedCall {
208
+ enum class Type { BATCH_CALL, REGISTERED_CALL };
209
+
210
+ RequestedCall(void* tag_arg, grpc_completion_queue* call_cq,
211
+ grpc_call** call_arg, grpc_metadata_array* initial_md,
212
+ grpc_call_details* details)
213
+ : type(Type::BATCH_CALL),
214
+ tag(tag_arg),
215
+ cq_bound_to_call(call_cq),
216
+ call(call_arg),
217
+ initial_metadata(initial_md) {
218
+ data.batch.details = details;
219
+ }
220
+
221
+ RequestedCall(void* tag_arg, grpc_completion_queue* call_cq,
222
+ grpc_call** call_arg, grpc_metadata_array* initial_md,
223
+ RegisteredMethod* rm, gpr_timespec* deadline,
224
+ grpc_byte_buffer** optional_payload)
225
+ : type(Type::REGISTERED_CALL),
226
+ tag(tag_arg),
227
+ cq_bound_to_call(call_cq),
228
+ call(call_arg),
229
+ initial_metadata(initial_md) {
230
+ data.registered.method = rm;
231
+ data.registered.deadline = deadline;
232
+ data.registered.optional_payload = optional_payload;
233
+ }
234
+
235
+ void Complete(NextResult<MessageHandle> payload, ClientMetadata& md) {
236
+ Timestamp deadline = GetContext<CallContext>()->deadline();
237
+ switch (type) {
238
+ case RequestedCall::Type::BATCH_CALL:
239
+ GPR_ASSERT(!payload.has_value());
240
+ data.batch.details->host =
241
+ CSliceRef(md.get_pointer(HttpAuthorityMetadata())->c_slice());
242
+ data.batch.details->method =
243
+ CSliceRef(md.Take(HttpPathMetadata())->c_slice());
244
+ data.batch.details->deadline =
245
+ deadline.as_timespec(GPR_CLOCK_MONOTONIC);
246
+ break;
247
+ case RequestedCall::Type::REGISTERED_CALL:
248
+ md.Remove(HttpPathMetadata());
249
+ *data.registered.deadline = deadline.as_timespec(GPR_CLOCK_MONOTONIC);
250
+ if (data.registered.optional_payload != nullptr) {
251
+ if (payload.has_value()) {
252
+ auto* sb = payload.value()->payload()->c_slice_buffer();
253
+ *data.registered.optional_payload =
254
+ grpc_raw_byte_buffer_create(sb->slices, sb->count);
255
+ } else {
256
+ *data.registered.optional_payload = nullptr;
257
+ }
258
+ }
259
+ break;
260
+ default:
261
+ GPR_UNREACHABLE_CODE(abort());
262
+ }
263
+ }
264
+
265
+ MultiProducerSingleConsumerQueue::Node mpscq_node;
266
+ const Type type;
267
+ void* const tag;
268
+ grpc_completion_queue* const cq_bound_to_call;
269
+ grpc_call** const call;
270
+ grpc_cq_completion completion;
271
+ grpc_metadata_array* const initial_metadata;
272
+ union {
273
+ struct {
274
+ grpc_call_details* details;
275
+ } batch;
276
+ struct {
277
+ RegisteredMethod* method;
278
+ gpr_timespec* deadline;
279
+ grpc_byte_buffer** optional_payload;
280
+ } registered;
281
+ } data;
282
+ };
283
+
251
284
  // The RealRequestMatcher is an implementation of RequestMatcherInterface that
252
285
  // actually uses all the features of RequestMatcherInterface: expecting the
253
286
  // application to explicitly request RPCs and then matching those to incoming
@@ -757,6 +790,9 @@ class ChannelBroadcaster {
757
790
  const grpc_channel_filter Server::kServerTopFilter = {
758
791
  Server::CallData::StartTransportStreamOpBatch,
759
792
  Server::ChannelData::MakeCallPromise,
793
+ [](grpc_channel_element*, CallSpineInterface*) {
794
+ // TODO(ctiller): remove the server filter when call-v3 is finalized
795
+ },
760
796
  grpc_channel_next_op,
761
797
  sizeof(Server::CallData),
762
798
  Server::CallData::InitCallElement,
@@ -794,7 +830,11 @@ RefCountedPtr<channelz::ServerNode> CreateChannelzNode(
794
830
  Server::Server(const ChannelArgs& args)
795
831
  : channel_args_(args),
796
832
  channelz_node_(CreateChannelzNode(args)),
797
- server_call_tracer_factory_(ServerCallTracerFactory::Get(args)) {}
833
+ server_call_tracer_factory_(ServerCallTracerFactory::Get(args)),
834
+ max_time_in_pending_queue_(Duration::Seconds(
835
+ channel_args_
836
+ .GetInt(GRPC_ARG_SERVER_MAX_UNREQUESTED_TIME_IN_SERVER_SECONDS)
837
+ .value_or(30))) {}
798
838
 
799
839
  Server::~Server() {
800
840
  // Remove the cq pollsets from the config_fetcher.
@@ -814,7 +854,8 @@ void Server::AddListener(OrphanablePtr<ListenerInterface> listener) {
814
854
  channelz::ListenSocketNode* listen_socket_node =
815
855
  listener->channelz_listen_socket_node();
816
856
  if (listen_socket_node != nullptr && channelz_node_ != nullptr) {
817
- channelz_node_->AddChildListenSocket(listen_socket_node->Ref());
857
+ channelz_node_->AddChildListenSocket(
858
+ listen_socket_node->RefAsSubclass<channelz::ListenSocketNode>());
818
859
  }
819
860
  listeners_.emplace_back(std::move(listener));
820
861
  }
@@ -838,9 +879,9 @@ void Server::Start() {
838
879
  if (unregistered_request_matcher_ == nullptr) {
839
880
  unregistered_request_matcher_ = make_real_request_matcher();
840
881
  }
841
- for (std::unique_ptr<RegisteredMethod>& rm : registered_methods_) {
842
- if (rm->matcher == nullptr) {
843
- rm->matcher = make_real_request_matcher();
882
+ for (auto& rm : registered_methods_) {
883
+ if (rm.second->matcher == nullptr) {
884
+ rm.second->matcher = make_real_request_matcher();
844
885
  }
845
886
  }
846
887
  {
@@ -927,20 +968,11 @@ void Server::RegisterCompletionQueue(grpc_completion_queue* cq) {
927
968
  cqs_.push_back(cq);
928
969
  }
929
970
 
930
- namespace {
931
-
932
- bool streq(const std::string& a, const char* b) {
933
- return (a.empty() && b == nullptr) ||
934
- ((b != nullptr) && !strcmp(a.c_str(), b));
935
- }
936
-
937
- } // namespace
938
-
939
971
  Server::RegisteredMethod* Server::RegisterMethod(
940
972
  const char* method, const char* host,
941
973
  grpc_server_register_method_payload_handling payload_handling,
942
974
  uint32_t flags) {
943
- if (IsRegisteredMethodsMapEnabled() && started_) {
975
+ if (started_) {
944
976
  Crash("Attempting to register method after server started");
945
977
  }
946
978
 
@@ -949,21 +981,21 @@ Server::RegisteredMethod* Server::RegisterMethod(
949
981
  "grpc_server_register_method method string cannot be NULL");
950
982
  return nullptr;
951
983
  }
952
- for (std::unique_ptr<RegisteredMethod>& m : registered_methods_) {
953
- if (streq(m->method, method) && streq(m->host, host)) {
954
- gpr_log(GPR_ERROR, "duplicate registration for %s@%s", method,
955
- host ? host : "*");
956
- return nullptr;
957
- }
984
+ auto key = std::make_pair(host ? host : "", method);
985
+ if (registered_methods_.find(key) != registered_methods_.end()) {
986
+ gpr_log(GPR_ERROR, "duplicate registration for %s@%s", method,
987
+ host ? host : "*");
988
+ return nullptr;
958
989
  }
959
990
  if (flags != 0) {
960
991
  gpr_log(GPR_ERROR, "grpc_server_register_method invalid flags 0x%08x",
961
992
  flags);
962
993
  return nullptr;
963
994
  }
964
- registered_methods_.emplace_back(std::make_unique<RegisteredMethod>(
965
- method, host, payload_handling, flags));
966
- return registered_methods_.back().get();
995
+ auto it = registered_methods_.emplace(
996
+ key, std::make_unique<RegisteredMethod>(method, host, payload_handling,
997
+ flags));
998
+ return it.first->second.get();
967
999
  }
968
1000
 
969
1001
  void Server::DoneRequestEvent(void* req, grpc_cq_completion* /*c*/) {
@@ -1014,9 +1046,9 @@ void Server::KillPendingWorkLocked(grpc_error_handle error) {
1014
1046
  if (started_) {
1015
1047
  unregistered_request_matcher_->KillRequests(error);
1016
1048
  unregistered_request_matcher_->ZombifyPending();
1017
- for (std::unique_ptr<RegisteredMethod>& rm : registered_methods_) {
1018
- rm->matcher->KillRequests(error);
1019
- rm->matcher->ZombifyPending();
1049
+ for (auto& rm : registered_methods_) {
1050
+ rm.second->matcher->KillRequests(error);
1051
+ rm.second->matcher->ZombifyPending();
1020
1052
  }
1021
1053
  }
1022
1054
  }
@@ -1251,7 +1283,6 @@ class Server::ChannelData::ConnectivityWatcher
1251
1283
  //
1252
1284
 
1253
1285
  Server::ChannelData::~ChannelData() {
1254
- old_registered_methods_.reset();
1255
1286
  if (server_ != nullptr) {
1256
1287
  if (server_->channelz_node_ != nullptr && channelz_socket_uuid_ != 0) {
1257
1288
  server_->channelz_node_->RemoveChildSocket(channelz_socket_uuid_);
@@ -1267,6 +1298,20 @@ Server::ChannelData::~ChannelData() {
1267
1298
  }
1268
1299
  }
1269
1300
 
1301
+ Arena* Server::ChannelData::CreateArena() {
1302
+ const auto initial_size = channel_->CallSizeEstimate();
1303
+ global_stats().IncrementCallInitialSize(initial_size);
1304
+ return Arena::Create(initial_size, channel_->allocator());
1305
+ }
1306
+
1307
+ absl::StatusOr<CallInitiator> Server::ChannelData::CreateCall(
1308
+ ClientMetadata& client_initial_metadata, Arena* arena) {
1309
+ SetRegisteredMethodOnMetadata(client_initial_metadata);
1310
+ auto call = MakeServerCall(server_.get(), channel_.get(), arena);
1311
+ InitCall(call);
1312
+ return CallInitiator(std::move(call));
1313
+ }
1314
+
1270
1315
  void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
1271
1316
  RefCountedPtr<Channel> channel,
1272
1317
  size_t cq_idx, Transport* transport,
@@ -1275,50 +1320,6 @@ void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
1275
1320
  channel_ = channel;
1276
1321
  cq_idx_ = cq_idx;
1277
1322
  channelz_socket_uuid_ = channelz_socket_uuid;
1278
- // Build a lookup table phrased in terms of mdstr's in this channels context
1279
- // to quickly find registered methods.
1280
- size_t num_registered_methods = server_->registered_methods_.size();
1281
- if (!IsRegisteredMethodsMapEnabled() && num_registered_methods > 0) {
1282
- uint32_t max_probes = 0;
1283
- size_t slots = 2 * num_registered_methods;
1284
- old_registered_methods_ =
1285
- std::make_unique<std::vector<ChannelRegisteredMethod>>(slots);
1286
- for (std::unique_ptr<RegisteredMethod>& rm : server_->registered_methods_) {
1287
- Slice host;
1288
- Slice method = Slice::FromExternalString(rm->method);
1289
- const bool has_host = !rm->host.empty();
1290
- if (has_host) {
1291
- host = Slice::FromExternalString(rm->host);
1292
- }
1293
- uint32_t hash = MixHash32(has_host ? host.Hash() : 0, method.Hash());
1294
- uint32_t probes = 0;
1295
- for (probes = 0; (*old_registered_methods_)[(hash + probes) % slots]
1296
- .server_registered_method != nullptr;
1297
- probes++) {
1298
- }
1299
- if (probes > max_probes) max_probes = probes;
1300
- ChannelRegisteredMethod* crm =
1301
- &(*old_registered_methods_)[(hash + probes) % slots];
1302
- crm->server_registered_method = rm.get();
1303
- crm->flags = rm->flags;
1304
- crm->has_host = has_host;
1305
- if (has_host) {
1306
- crm->host = std::move(host);
1307
- }
1308
- crm->method = std::move(method);
1309
- }
1310
- GPR_ASSERT(slots <= UINT32_MAX);
1311
- registered_method_max_probes_ = max_probes;
1312
- } else if (IsRegisteredMethodsMapEnabled()) {
1313
- for (std::unique_ptr<RegisteredMethod>& rm : server_->registered_methods_) {
1314
- auto key = std::make_pair(!rm->host.empty() ? rm->host : "", rm->method);
1315
- registered_methods_.emplace(
1316
- key, std::make_unique<ChannelRegisteredMethod>(
1317
- rm.get(), rm->flags, /*has_host=*/!rm->host.empty(),
1318
- Slice::FromExternalString(rm->method),
1319
- Slice::FromExternalString(rm->host)));
1320
- }
1321
- }
1322
1323
  // Publish channel.
1323
1324
  {
1324
1325
  MutexLock lock(&server_->mu_global_);
@@ -1327,13 +1328,25 @@ void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
1327
1328
  }
1328
1329
  // Start accept_stream transport op.
1329
1330
  grpc_transport_op* op = grpc_make_transport_op(nullptr);
1330
- op->set_accept_stream = true;
1331
- op->set_accept_stream_fn = AcceptStream;
1332
- if (IsRegisteredMethodLookupInTransportEnabled()) {
1333
- op->set_registered_method_matcher_fn = SetRegisteredMethodOnMetadata;
1331
+ int accept_stream_types = 0;
1332
+ if (transport->filter_stack_transport() != nullptr) {
1333
+ ++accept_stream_types;
1334
+ op->set_accept_stream = true;
1335
+ op->set_accept_stream_fn = AcceptStream;
1336
+ if (IsRegisteredMethodLookupInTransportEnabled()) {
1337
+ op->set_registered_method_matcher_fn = [](void* arg,
1338
+ ClientMetadata* metadata) {
1339
+ static_cast<ChannelData*>(arg)->SetRegisteredMethodOnMetadata(
1340
+ *metadata);
1341
+ };
1342
+ }
1343
+ op->set_accept_stream_user_data = this;
1344
+ }
1345
+ if (transport->server_transport() != nullptr) {
1346
+ ++accept_stream_types;
1347
+ transport->server_transport()->SetAcceptor(this);
1334
1348
  }
1335
- // op->set_registered_method_matcher_fn = Registered
1336
- op->set_accept_stream_user_data = this;
1349
+ GPR_ASSERT(accept_stream_types == 1);
1337
1350
  op->start_connectivity_watch = MakeOrphanable<ConnectivityWatcher>(this);
1338
1351
  if (server_->ShutdownCalled()) {
1339
1352
  op->disconnect_with_error = GRPC_ERROR_CREATE("Server shutdown");
@@ -1341,75 +1354,41 @@ void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
1341
1354
  transport->PerformOp(op);
1342
1355
  }
1343
1356
 
1344
- Server::ChannelRegisteredMethod* Server::ChannelData::GetRegisteredMethod(
1345
- const grpc_slice& host, const grpc_slice& path) {
1346
- if (old_registered_methods_ == nullptr) return nullptr;
1347
- // TODO(ctiller): unify these two searches
1348
- // check for an exact match with host
1349
- uint32_t hash = MixHash32(grpc_slice_hash(host), grpc_slice_hash(path));
1350
- for (size_t i = 0; i <= registered_method_max_probes_; i++) {
1351
- ChannelRegisteredMethod* rm = &(
1352
- *old_registered_methods_)[(hash + i) % old_registered_methods_->size()];
1353
- if (rm->server_registered_method == nullptr) break;
1354
- if (!rm->has_host) continue;
1355
- if (rm->host != host) continue;
1356
- if (rm->method != path) continue;
1357
- return rm;
1358
- }
1359
- // check for a wildcard method definition (no host set)
1360
- hash = MixHash32(0, grpc_slice_hash(path));
1361
- for (size_t i = 0; i <= registered_method_max_probes_; i++) {
1362
- ChannelRegisteredMethod* rm = &(
1363
- *old_registered_methods_)[(hash + i) % old_registered_methods_->size()];
1364
- if (rm->server_registered_method == nullptr) break;
1365
- if (rm->has_host) continue;
1366
- if (rm->method != path) continue;
1367
- return rm;
1368
- }
1369
- return nullptr;
1370
- }
1371
-
1372
- Server::ChannelRegisteredMethod* Server::ChannelData::GetRegisteredMethod(
1357
+ Server::RegisteredMethod* Server::ChannelData::GetRegisteredMethod(
1373
1358
  const absl::string_view& host, const absl::string_view& path) {
1374
- if (registered_methods_.empty()) return nullptr;
1359
+ if (server_->registered_methods_.empty()) return nullptr;
1375
1360
  // check for an exact match with host
1376
- auto it = registered_methods_.find(std::make_pair(host, path));
1377
- if (it != registered_methods_.end()) {
1361
+ auto it = server_->registered_methods_.find(std::make_pair(host, path));
1362
+ if (it != server_->registered_methods_.end()) {
1378
1363
  return it->second.get();
1379
1364
  }
1380
1365
  // check for wildcard method definition (no host set)
1381
- it = registered_methods_.find(std::make_pair("", path));
1382
- if (it != registered_methods_.end()) {
1366
+ it = server_->registered_methods_.find(std::make_pair("", path));
1367
+ if (it != server_->registered_methods_.end()) {
1383
1368
  return it->second.get();
1384
1369
  }
1385
1370
  return nullptr;
1386
1371
  }
1387
1372
 
1388
1373
  void Server::ChannelData::SetRegisteredMethodOnMetadata(
1389
- void* arg, ServerMetadata* metadata) {
1390
- auto* chand = static_cast<Server::ChannelData*>(arg);
1391
- auto* authority = metadata->get_pointer(HttpAuthorityMetadata());
1374
+ ClientMetadata& metadata) {
1375
+ auto* authority = metadata.get_pointer(HttpAuthorityMetadata());
1392
1376
  if (authority == nullptr) {
1393
- authority = metadata->get_pointer(HostMetadata());
1377
+ authority = metadata.get_pointer(HostMetadata());
1394
1378
  if (authority == nullptr) {
1395
1379
  // Authority not being set is an RPC error.
1396
1380
  return;
1397
1381
  }
1398
1382
  }
1399
- auto* path = metadata->get_pointer(HttpPathMetadata());
1383
+ auto* path = metadata.get_pointer(HttpPathMetadata());
1400
1384
  if (path == nullptr) {
1401
1385
  // Path not being set would result in an RPC error.
1402
1386
  return;
1403
1387
  }
1404
- ChannelRegisteredMethod* method;
1405
- if (!IsRegisteredMethodsMapEnabled()) {
1406
- method = chand->GetRegisteredMethod(authority->c_slice(), path->c_slice());
1407
- } else {
1408
- method = chand->GetRegisteredMethod(authority->as_string_view(),
1409
- path->as_string_view());
1410
- }
1388
+ RegisteredMethod* method =
1389
+ GetRegisteredMethod(authority->as_string_view(), path->as_string_view());
1411
1390
  // insert in metadata
1412
- metadata->Set(GrpcRegisteredMethod(), method);
1391
+ metadata.Set(GrpcRegisteredMethod(), method);
1413
1392
  }
1414
1393
 
1415
1394
  void Server::ChannelData::AcceptStream(void* arg, Transport* /*transport*/,
@@ -1451,17 +1430,89 @@ auto CancelledDueToServerShutdown() {
1451
1430
  }
1452
1431
  } // namespace
1453
1432
 
1433
+ void Server::ChannelData::InitCall(RefCountedPtr<CallSpineInterface> call) {
1434
+ call->SpawnGuarded("request_matcher", [this, call]() {
1435
+ return TrySeq(
1436
+ // Wait for initial metadata to pass through all filters
1437
+ Map(call->client_initial_metadata().receiver.Next(),
1438
+ [](NextResult<ClientMetadataHandle> md)
1439
+ -> absl::StatusOr<ClientMetadataHandle> {
1440
+ if (!md.has_value()) {
1441
+ return absl::InternalError("Missing metadata");
1442
+ }
1443
+ if (!md.value()->get_pointer(HttpPathMetadata())) {
1444
+ return absl::InternalError("Missing :path header");
1445
+ }
1446
+ if (!md.value()->get_pointer(HttpAuthorityMetadata())) {
1447
+ return absl::InternalError("Missing :authority header");
1448
+ }
1449
+ return std::move(*md);
1450
+ }),
1451
+ // Match request with requested call
1452
+ [this, call](ClientMetadataHandle md) {
1453
+ auto* registered_method = static_cast<RegisteredMethod*>(
1454
+ md->get(GrpcRegisteredMethod()).value_or(nullptr));
1455
+ RequestMatcherInterface* rm;
1456
+ grpc_server_register_method_payload_handling payload_handling =
1457
+ GRPC_SRM_PAYLOAD_NONE;
1458
+ if (registered_method == nullptr) {
1459
+ rm = server_->unregistered_request_matcher_.get();
1460
+ } else {
1461
+ rm = registered_method->matcher.get();
1462
+ }
1463
+ auto maybe_read_first_message = If(
1464
+ payload_handling == GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER,
1465
+ [call]() {
1466
+ return call->client_to_server_messages().receiver.Next();
1467
+ },
1468
+ []() -> NextResult<MessageHandle> {
1469
+ return NextResult<MessageHandle>();
1470
+ });
1471
+ return TryJoin<absl::StatusOr>(
1472
+ Map(std::move(maybe_read_first_message),
1473
+ [](NextResult<MessageHandle> n) {
1474
+ return ValueOrFailure<NextResult<MessageHandle>>{
1475
+ std::move(n)};
1476
+ }),
1477
+ rm->MatchRequest(cq_idx()), [md = std::move(md)]() mutable {
1478
+ return ValueOrFailure<ClientMetadataHandle>(std::move(md));
1479
+ });
1480
+ },
1481
+ // Publish call to cq
1482
+ [](std::tuple<NextResult<MessageHandle>,
1483
+ RequestMatcherInterface::MatchResult,
1484
+ ClientMetadataHandle>
1485
+ r) {
1486
+ RequestMatcherInterface::MatchResult& mr = std::get<1>(r);
1487
+ auto md = std::move(std::get<2>(r));
1488
+ auto* rc = mr.TakeCall();
1489
+ rc->Complete(std::move(std::get<0>(r)), *md);
1490
+ auto* call_context = GetContext<CallContext>();
1491
+ *rc->call = call_context->c_call();
1492
+ grpc_call_set_completion_queue(call_context->c_call(),
1493
+ rc->cq_bound_to_call);
1494
+ call_context->server_call_context()->PublishInitialMetadata(
1495
+ std::move(md), rc->initial_metadata);
1496
+ // TODO(ctiller): publish metadata
1497
+ return Map(WaitForCqEndOp(false, rc->tag, absl::OkStatus(), mr.cq()),
1498
+ [rc = std::unique_ptr<RequestedCall>(rc)](Empty) {
1499
+ return absl::OkStatus();
1500
+ });
1501
+ });
1502
+ });
1503
+ }
1504
+
1454
1505
  ArenaPromise<ServerMetadataHandle> Server::ChannelData::MakeCallPromise(
1455
1506
  grpc_channel_element* elem, CallArgs call_args, NextPromiseFactory) {
1456
1507
  auto* chand = static_cast<Server::ChannelData*>(elem->channel_data);
1457
1508
  auto* server = chand->server_.get();
1458
- absl::optional<Slice> path =
1459
- call_args.client_initial_metadata->Take(HttpPathMetadata());
1460
1509
  if (server->ShutdownCalled()) return CancelledDueToServerShutdown();
1461
1510
  auto cleanup_ref =
1462
1511
  absl::MakeCleanup([server] { server->ShutdownUnrefOnRequest(); });
1463
1512
  if (!server->ShutdownRefOnRequest()) return CancelledDueToServerShutdown();
1464
- if (!path.has_value()) {
1513
+ auto path_ptr =
1514
+ call_args.client_initial_metadata->get_pointer(HttpPathMetadata());
1515
+ if (path_ptr == nullptr) {
1465
1516
  return [] {
1466
1517
  return ServerMetadataFromStatus(
1467
1518
  absl::InternalError("Missing :path header"));
@@ -1475,27 +1526,22 @@ ArenaPromise<ServerMetadataHandle> Server::ChannelData::MakeCallPromise(
1475
1526
  absl::InternalError("Missing :authority header"));
1476
1527
  };
1477
1528
  }
1478
- Timestamp deadline = GetContext<CallContext>()->deadline();
1479
1529
  // Find request matcher.
1480
1530
  RequestMatcherInterface* matcher;
1481
- ChannelRegisteredMethod* rm = nullptr;
1531
+ RegisteredMethod* rm = nullptr;
1482
1532
  if (IsRegisteredMethodLookupInTransportEnabled()) {
1483
- rm = static_cast<ChannelRegisteredMethod*>(
1533
+ rm = static_cast<RegisteredMethod*>(
1484
1534
  call_args.client_initial_metadata->get(GrpcRegisteredMethod())
1485
1535
  .value_or(nullptr));
1486
1536
  } else {
1487
- if (!IsRegisteredMethodsMapEnabled()) {
1488
- rm = chand->GetRegisteredMethod(host_ptr->c_slice(), path->c_slice());
1489
- } else {
1490
- rm = chand->GetRegisteredMethod(host_ptr->as_string_view(),
1491
- path->as_string_view());
1492
- }
1537
+ rm = chand->GetRegisteredMethod(host_ptr->as_string_view(),
1538
+ path_ptr->as_string_view());
1493
1539
  }
1494
1540
  ArenaPromise<absl::StatusOr<NextResult<MessageHandle>>>
1495
1541
  maybe_read_first_message([] { return NextResult<MessageHandle>(); });
1496
1542
  if (rm != nullptr) {
1497
- matcher = rm->server_registered_method->matcher.get();
1498
- switch (rm->server_registered_method->payload_handling) {
1543
+ matcher = rm->matcher.get();
1544
+ switch (rm->payload_handling) {
1499
1545
  case GRPC_SRM_PAYLOAD_NONE:
1500
1546
  break;
1501
1547
  case GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER:
@@ -1526,8 +1572,7 @@ ArenaPromise<ServerMetadataHandle> Server::ChannelData::MakeCallPromise(
1526
1572
  return std::make_pair(std::move(*mr), std::move(payload));
1527
1573
  });
1528
1574
  },
1529
- [host_ptr, path = std::move(path), deadline,
1530
- call_args =
1575
+ [call_args =
1531
1576
  std::move(call_args)](std::pair<RequestMatcherInterface::MatchResult,
1532
1577
  NextResult<MessageHandle>>
1533
1578
  r) mutable {
@@ -1535,41 +1580,19 @@ ArenaPromise<ServerMetadataHandle> Server::ChannelData::MakeCallPromise(
1535
1580
  auto& payload = r.second;
1536
1581
  auto* rc = mr.TakeCall();
1537
1582
  auto* cq_for_new_request = mr.cq();
1538
- switch (rc->type) {
1539
- case RequestedCall::Type::BATCH_CALL:
1540
- GPR_ASSERT(!payload.has_value());
1541
- rc->data.batch.details->host = CSliceRef(host_ptr->c_slice());
1542
- rc->data.batch.details->method = CSliceRef(path->c_slice());
1543
- rc->data.batch.details->deadline =
1544
- deadline.as_timespec(GPR_CLOCK_MONOTONIC);
1545
- break;
1546
- case RequestedCall::Type::REGISTERED_CALL:
1547
- *rc->data.registered.deadline =
1548
- deadline.as_timespec(GPR_CLOCK_MONOTONIC);
1549
- if (rc->data.registered.optional_payload != nullptr) {
1550
- if (payload.has_value()) {
1551
- auto* sb = payload.value()->payload()->c_slice_buffer();
1552
- *rc->data.registered.optional_payload =
1553
- grpc_raw_byte_buffer_create(sb->slices, sb->count);
1554
- } else {
1555
- *rc->data.registered.optional_payload = nullptr;
1556
- }
1557
- }
1558
- break;
1559
- default:
1560
- GPR_UNREACHABLE_CODE(abort());
1561
- }
1562
- return GetContext<CallContext>()
1563
- ->server_call_context()
1564
- ->MakeTopOfServerCallPromise(
1565
- std::move(call_args), rc->cq_bound_to_call,
1566
- rc->initial_metadata,
1567
- [rc, cq_for_new_request](grpc_call* call) {
1568
- *rc->call = call;
1569
- grpc_cq_end_op(cq_for_new_request, rc->tag, absl::OkStatus(),
1570
- Server::DoneRequestEvent, rc, &rc->completion,
1571
- true);
1572
- });
1583
+ auto* server_call_context =
1584
+ GetContext<CallContext>()->server_call_context();
1585
+ rc->Complete(std::move(payload), *call_args.client_initial_metadata);
1586
+ server_call_context->PublishInitialMetadata(
1587
+ std::move(call_args.client_initial_metadata), rc->initial_metadata);
1588
+ return server_call_context->MakeTopOfServerCallPromise(
1589
+ std::move(call_args), rc->cq_bound_to_call,
1590
+ [rc, cq_for_new_request](grpc_call* call) {
1591
+ *rc->call = call;
1592
+ grpc_cq_end_op(cq_for_new_request, rc->tag, absl::OkStatus(),
1593
+ Server::DoneRequestEvent, rc, &rc->completion,
1594
+ true);
1595
+ });
1573
1596
  });
1574
1597
  }
1575
1598
 
@@ -1749,22 +1772,18 @@ void Server::CallData::StartNewRpc(grpc_call_element* elem) {
1749
1772
  grpc_server_register_method_payload_handling payload_handling =
1750
1773
  GRPC_SRM_PAYLOAD_NONE;
1751
1774
  if (path_.has_value() && host_.has_value()) {
1752
- ChannelRegisteredMethod* rm;
1775
+ RegisteredMethod* rm;
1753
1776
  if (IsRegisteredMethodLookupInTransportEnabled()) {
1754
- rm = static_cast<ChannelRegisteredMethod*>(
1777
+ rm = static_cast<RegisteredMethod*>(
1755
1778
  recv_initial_metadata_->get(GrpcRegisteredMethod())
1756
1779
  .value_or(nullptr));
1757
1780
  } else {
1758
- if (!IsRegisteredMethodsMapEnabled()) {
1759
- rm = chand->GetRegisteredMethod(host_->c_slice(), path_->c_slice());
1760
- } else {
1761
- rm = chand->GetRegisteredMethod(host_->as_string_view(),
1762
- path_->as_string_view());
1763
- }
1781
+ rm = chand->GetRegisteredMethod(host_->as_string_view(),
1782
+ path_->as_string_view());
1764
1783
  }
1765
1784
  if (rm != nullptr) {
1766
- matcher_ = rm->server_registered_method->matcher.get();
1767
- payload_handling = rm->server_registered_method->payload_handling;
1785
+ matcher_ = rm->matcher.get();
1786
+ payload_handling = rm->payload_handling;
1768
1787
  }
1769
1788
  }
1770
1789
  // Start recv_message op if needed.