grpc 1.52.0 → 1.53.0.pre2

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 (892) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +50 -5
  3. data/include/grpc/event_engine/event_engine.h +24 -2
  4. data/include/grpc/event_engine/slice_buffer.h +13 -1
  5. data/include/grpc/impl/grpc_types.h +3 -0
  6. data/include/grpc/support/time.h +6 -4
  7. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +148 -0
  8. data/src/core/ext/filters/backend_metrics/backend_metric_filter.h +52 -0
  9. data/src/core/ext/filters/backend_metrics/backend_metric_provider.h +29 -0
  10. data/src/core/ext/filters/channel_idle/channel_idle_filter.h +3 -3
  11. data/src/core/ext/filters/channel_idle/idle_filter_state.h +3 -3
  12. data/src/core/ext/filters/client_channel/backend_metric.h +3 -3
  13. data/src/core/ext/filters/client_channel/backup_poller.h +3 -3
  14. data/src/core/ext/filters/client_channel/channel_connectivity.cc +1 -1
  15. data/src/core/ext/filters/client_channel/client_channel.cc +29 -33
  16. data/src/core/ext/filters/client_channel/client_channel.h +3 -3
  17. data/src/core/ext/filters/client_channel/client_channel_channelz.h +3 -3
  18. data/src/core/ext/filters/client_channel/client_channel_factory.h +3 -3
  19. data/src/core/ext/filters/client_channel/client_channel_service_config.h +3 -3
  20. data/src/core/ext/filters/client_channel/config_selector.h +3 -3
  21. data/src/core/ext/filters/client_channel/connector.h +8 -4
  22. data/src/core/ext/filters/client_channel/dynamic_filters.h +3 -3
  23. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +3 -3
  24. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  25. data/src/core/ext/filters/client_channel/http_proxy.h +3 -3
  26. data/src/core/ext/filters/client_channel/lb_call_state_internal.h +3 -3
  27. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +3 -3
  28. data/src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h +3 -3
  29. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +3 -3
  30. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -7
  31. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +3 -3
  32. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +1 -0
  33. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +3 -3
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +3 -3
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +3 -3
  36. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -3
  37. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +1 -78
  38. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.h +3 -3
  39. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric_internal.h +117 -0
  40. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +3 -3
  41. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +3 -3
  42. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +1 -0
  43. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +3 -3
  44. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.cc +128 -0
  45. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/static_stride_scheduler.h +71 -0
  46. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +972 -0
  47. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +3 -6
  48. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_attributes.h +3 -3
  49. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +3 -3
  50. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +12 -7
  51. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc +275 -107
  52. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.h +10 -3
  53. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_wrr_locality.cc +5 -0
  54. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +3 -3
  55. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +3 -3
  56. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +6 -1
  57. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +1 -2
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +3 -3
  59. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.h +3 -3
  60. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +3 -3
  61. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +1 -0
  62. data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +3 -3
  63. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +3 -7
  64. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +3 -3
  65. data/src/core/ext/filters/client_channel/retry_filter.cc +10 -13
  66. data/src/core/ext/filters/client_channel/retry_filter.h +3 -3
  67. data/src/core/ext/filters/client_channel/retry_service_config.h +3 -3
  68. data/src/core/ext/filters/client_channel/retry_throttle.h +3 -3
  69. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +4 -4
  70. data/src/core/ext/filters/client_channel/subchannel.cc +5 -1
  71. data/src/core/ext/filters/client_channel/subchannel.h +3 -3
  72. data/src/core/ext/filters/client_channel/subchannel_interface_internal.h +3 -3
  73. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +3 -3
  74. data/src/core/ext/filters/client_channel/subchannel_stream_client.h +3 -3
  75. data/src/core/ext/filters/deadline/deadline_filter.cc +40 -48
  76. data/src/core/ext/filters/deadline/deadline_filter.h +6 -10
  77. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +3 -3
  78. data/src/core/ext/filters/fault_injection/fault_injection_service_config_parser.h +3 -3
  79. data/src/core/ext/filters/http/client/http_client_filter.cc +26 -21
  80. data/src/core/ext/filters/http/client/http_client_filter.h +3 -3
  81. data/src/core/ext/filters/http/client_authority_filter.h +3 -3
  82. data/src/core/ext/filters/http/message_compress/compression_filter.cc +109 -117
  83. data/src/core/ext/filters/http/message_compress/compression_filter.h +17 -10
  84. data/src/core/ext/filters/http/server/http_server_filter.cc +25 -24
  85. data/src/core/ext/filters/http/server/http_server_filter.h +3 -3
  86. data/src/core/ext/filters/message_size/message_size_filter.cc +2 -1
  87. data/src/core/ext/filters/message_size/message_size_filter.h +3 -3
  88. data/src/core/ext/filters/rbac/rbac_filter.cc +4 -3
  89. data/src/core/ext/filters/rbac/rbac_filter.h +3 -3
  90. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +3 -3
  91. data/src/core/ext/filters/server_config_selector/server_config_selector.h +3 -3
  92. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.h +3 -3
  93. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +27 -37
  94. data/src/core/ext/filters/stateful_session/stateful_session_filter.h +5 -5
  95. data/src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h +3 -3
  96. data/src/core/ext/transport/chttp2/alpn/alpn.h +3 -3
  97. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -7
  98. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +3 -3
  99. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +1 -0
  100. data/src/core/ext/transport/chttp2/server/chttp2_server.h +3 -3
  101. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +3 -3
  102. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +3 -3
  103. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +195 -111
  104. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +3 -3
  105. data/src/core/ext/transport/chttp2/transport/context_list.h +3 -3
  106. data/src/core/ext/transport/chttp2/transport/decode_huff.h +3 -3
  107. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
  108. data/src/core/ext/transport/chttp2/transport/flow_control.h +3 -3
  109. data/src/core/ext/transport/chttp2/transport/frame.h +3 -3
  110. data/src/core/ext/transport/chttp2/transport/frame_data.cc +2 -0
  111. data/src/core/ext/transport/chttp2/transport/frame_data.h +3 -3
  112. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -0
  113. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +3 -3
  114. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -0
  115. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
  116. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -0
  117. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +3 -3
  118. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +1 -0
  119. data/src/core/ext/transport/chttp2/transport/frame_settings.h +3 -3
  120. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +2 -0
  121. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +3 -3
  122. data/src/core/ext/transport/chttp2/transport/hpack_constants.h +3 -3
  123. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +3 -3
  124. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +3 -3
  125. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +18 -407
  126. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -3
  127. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -0
  128. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +3 -3
  129. data/src/core/ext/transport/chttp2/transport/http2_settings.h +3 -3
  130. data/src/core/ext/transport/chttp2/transport/http_trace.h +3 -3
  131. data/src/core/ext/transport/chttp2/transport/huffsyms.h +3 -3
  132. data/src/core/ext/transport/chttp2/transport/internal.h +28 -23
  133. data/src/core/ext/transport/chttp2/transport/parsing.cc +111 -31
  134. data/src/core/ext/transport/chttp2/transport/stream_map.h +3 -3
  135. data/src/core/ext/transport/chttp2/transport/varint.h +3 -3
  136. data/src/core/ext/transport/chttp2/transport/writing.cc +9 -8
  137. data/src/core/ext/transport/inproc/inproc_transport.h +3 -3
  138. data/src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.c +3 -2
  139. data/src/core/ext/upb-generated/envoy/admin/v3/clusters.upb.h +9 -0
  140. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump_shared.upb.c +38 -2
  141. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump_shared.upb.h +185 -0
  142. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +7 -3
  143. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +44 -0
  144. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +16 -25
  145. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +48 -74
  146. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +30 -7
  147. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +137 -0
  148. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +15 -12
  149. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +83 -51
  150. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +3 -2
  151. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +15 -0
  152. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +17 -2
  153. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +61 -0
  154. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +11 -5
  155. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +37 -6
  156. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +5 -3
  157. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +24 -0
  158. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +5 -3
  159. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +22 -0
  160. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +6 -3
  161. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +24 -0
  162. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -5
  163. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +50 -0
  164. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +57 -16
  165. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +254 -17
  166. data/src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.c +3 -2
  167. data/src/core/ext/upb-generated/envoy/config/trace/v3/datadog.upb.h +9 -0
  168. data/src/core/ext/upb-generated/envoy/config/trace/v3/opentelemetry.upb.c +3 -2
  169. data/src/core/ext/upb-generated/envoy/config/trace/v3/opentelemetry.upb.h +9 -0
  170. data/src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.c +7 -6
  171. data/src/core/ext/upb-generated/envoy/config/trace/v3/zipkin.upb.h +21 -12
  172. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -3
  173. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +23 -0
  174. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +10 -7
  175. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +42 -12
  176. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.c +54 -0
  177. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/client_side_weighted_round_robin/v3/client_side_weighted_round_robin.upb.h +188 -0
  178. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/common/v3/common.upb.c +111 -0
  179. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/common/v3/common.upb.h +444 -0
  180. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.c +7 -3
  181. data/src/core/ext/upb-generated/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.h +24 -0
  182. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +8 -6
  183. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +31 -9
  184. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +5 -3
  185. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +24 -0
  186. data/src/core/ext/upb-generated/envoy/type/matcher/v3/filter_state.upb.c +47 -0
  187. data/src/core/ext/upb-generated/envoy/type/matcher/v3/filter_state.upb.h +113 -0
  188. data/src/core/ext/upb-generated/envoy/type/matcher/v3/status_code_input.upb.c +43 -0
  189. data/src/core/ext/upb-generated/envoy/type/matcher/v3/status_code_input.upb.h +114 -0
  190. data/src/core/ext/upb-generated/envoy/type/v3/ratelimit_unit.upb.h +3 -1
  191. data/src/core/ext/upbdefs-generated/envoy/admin/v3/clusters.upbdefs.c +54 -53
  192. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump_shared.upbdefs.c +34 -13
  193. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump_shared.upbdefs.h +10 -0
  194. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +195 -187
  195. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +232 -224
  196. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +0 -5
  197. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c +95 -75
  198. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.h +5 -0
  199. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +94 -93
  200. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +81 -75
  201. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +189 -187
  202. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c +7 -3
  203. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.h +5 -0
  204. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +71 -66
  205. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +137 -133
  206. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +16 -12
  207. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +140 -133
  208. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +81 -70
  209. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
  210. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +771 -741
  211. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +10 -0
  212. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/datadog.upbdefs.c +16 -14
  213. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/opentelemetry.upbdefs.c +14 -13
  214. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/zipkin.upbdefs.c +20 -18
  215. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +53 -42
  216. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +363 -356
  217. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +149 -145
  218. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +16 -13
  219. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/filter_state.upbdefs.c +48 -0
  220. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/filter_state.upbdefs.h +35 -0
  221. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +14 -14
  222. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/status_code_input.upbdefs.c +40 -0
  223. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/status_code_input.upbdefs.h +40 -0
  224. data/src/core/ext/upbdefs-generated/envoy/type/v3/ratelimit_unit.upbdefs.c +10 -9
  225. data/src/core/ext/xds/certificate_provider_store.h +3 -3
  226. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +1 -0
  227. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +3 -3
  228. data/src/core/ext/xds/upb_utils.h +3 -3
  229. data/src/core/ext/xds/xds_api.h +3 -3
  230. data/src/core/ext/xds/xds_bootstrap.h +3 -3
  231. data/src/core/ext/xds/xds_bootstrap_grpc.cc +1 -0
  232. data/src/core/ext/xds/xds_bootstrap_grpc.h +3 -3
  233. data/src/core/ext/xds/xds_certificate_provider.h +3 -3
  234. data/src/core/ext/xds/xds_channel_args.h +3 -3
  235. data/src/core/ext/xds/xds_channel_stack_modifier.h +3 -3
  236. data/src/core/ext/xds/xds_client.cc +8 -3
  237. data/src/core/ext/xds/xds_client.h +3 -3
  238. data/src/core/ext/xds/xds_client_grpc.cc +0 -1
  239. data/src/core/ext/xds/xds_client_grpc.h +3 -3
  240. data/src/core/ext/xds/xds_client_stats.h +4 -3
  241. data/src/core/ext/xds/xds_cluster.cc +11 -7
  242. data/src/core/ext/xds/xds_cluster.h +6 -6
  243. data/src/core/ext/xds/xds_cluster_specifier_plugin.h +3 -3
  244. data/src/core/ext/xds/xds_common_types.cc +1 -0
  245. data/src/core/ext/xds/xds_common_types.h +3 -3
  246. data/src/core/ext/xds/xds_endpoint.cc +1 -1
  247. data/src/core/ext/xds/xds_endpoint.h +3 -3
  248. data/src/core/ext/xds/xds_health_status.h +30 -3
  249. data/src/core/ext/xds/xds_http_fault_filter.h +3 -3
  250. data/src/core/ext/xds/xds_http_filters.cc +1 -1
  251. data/src/core/ext/xds/xds_http_filters.h +3 -3
  252. data/src/core/ext/xds/xds_http_rbac_filter.h +3 -3
  253. data/src/core/ext/xds/xds_http_stateful_session_filter.h +3 -3
  254. data/src/core/ext/xds/xds_lb_policy_registry.cc +95 -0
  255. data/src/core/ext/xds/xds_lb_policy_registry.h +3 -3
  256. data/src/core/ext/xds/xds_listener.cc +1 -0
  257. data/src/core/ext/xds/xds_listener.h +3 -3
  258. data/src/core/ext/xds/xds_resource_type.h +3 -3
  259. data/src/core/ext/xds/xds_resource_type_impl.h +3 -3
  260. data/src/core/ext/xds/xds_route_config.cc +6 -0
  261. data/src/core/ext/xds/xds_route_config.h +3 -3
  262. data/src/core/ext/xds/xds_routing.h +3 -3
  263. data/src/core/ext/xds/xds_transport.h +3 -3
  264. data/src/core/ext/xds/xds_transport_grpc.h +3 -3
  265. data/src/core/lib/address_utils/parse_address.h +3 -3
  266. data/src/core/lib/address_utils/sockaddr_utils.cc +1 -0
  267. data/src/core/lib/address_utils/sockaddr_utils.h +3 -3
  268. data/src/core/lib/avl/avl.h +3 -3
  269. data/src/core/lib/backoff/backoff.h +3 -3
  270. data/src/core/lib/channel/call_finalization.h +3 -3
  271. data/src/core/lib/channel/call_tracer.h +3 -3
  272. data/src/core/lib/channel/channel_args.cc +1 -0
  273. data/src/core/lib/channel/channel_args.h +11 -5
  274. data/src/core/lib/channel/channel_args_preconditioning.h +3 -3
  275. data/src/core/lib/channel/channel_fwd.h +3 -3
  276. data/src/core/lib/channel/channel_stack.cc +1 -2
  277. data/src/core/lib/channel/channel_stack.h +4 -4
  278. data/src/core/lib/channel/channel_stack_builder.h +3 -3
  279. data/src/core/lib/channel/channel_stack_builder_impl.cc +14 -1
  280. data/src/core/lib/channel/channel_stack_builder_impl.h +3 -3
  281. data/src/core/lib/channel/channel_trace.h +3 -3
  282. data/src/core/lib/channel/channelz.h +3 -3
  283. data/src/core/lib/channel/channelz_registry.h +3 -3
  284. data/src/core/lib/channel/connected_channel.cc +883 -354
  285. data/src/core/lib/channel/connected_channel.h +3 -3
  286. data/src/core/lib/channel/context.h +7 -3
  287. data/src/core/lib/channel/promise_based_filter.cc +532 -260
  288. data/src/core/lib/channel/promise_based_filter.h +124 -44
  289. data/src/core/lib/channel/status_util.h +3 -3
  290. data/src/core/lib/compression/compression_internal.h +3 -3
  291. data/src/core/lib/compression/message_compress.h +3 -3
  292. data/src/core/lib/config/core_configuration.h +3 -3
  293. data/src/core/lib/debug/event_log.h +3 -3
  294. data/src/core/lib/debug/histogram_view.h +3 -3
  295. data/src/core/lib/debug/stats.h +3 -3
  296. data/src/core/lib/debug/stats_data.cc +66 -65
  297. data/src/core/lib/debug/stats_data.h +42 -33
  298. data/src/core/lib/debug/trace.h +4 -26
  299. data/src/core/lib/event_engine/channel_args_endpoint_config.cc +5 -0
  300. data/src/core/lib/event_engine/channel_args_endpoint_config.h +3 -3
  301. data/src/core/lib/event_engine/common_closures.h +3 -3
  302. data/src/core/lib/event_engine/default_event_engine.cc +9 -4
  303. data/src/core/lib/event_engine/default_event_engine.h +30 -6
  304. data/src/core/lib/event_engine/default_event_engine_factory.h +3 -3
  305. data/src/core/lib/event_engine/event_engine.cc +25 -0
  306. data/src/core/lib/event_engine/executor/executor.h +3 -3
  307. data/src/core/lib/event_engine/forkable.cc +11 -6
  308. data/src/core/lib/event_engine/forkable.h +3 -3
  309. data/src/core/lib/event_engine/handle_containers.h +10 -3
  310. data/src/core/lib/event_engine/poller.h +3 -3
  311. data/src/core/lib/event_engine/posix.h +158 -0
  312. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +44 -16
  313. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +14 -4
  314. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +6 -7
  315. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +3 -3
  316. data/src/core/lib/event_engine/posix_engine/event_poller.h +3 -3
  317. data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +3 -3
  318. data/src/core/lib/event_engine/posix_engine/internal_errqueue.h +3 -3
  319. data/src/core/lib/event_engine/posix_engine/lockfree_event.h +3 -3
  320. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +52 -55
  321. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +46 -13
  322. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +82 -12
  323. data/src/core/lib/event_engine/posix_engine/posix_engine.h +23 -9
  324. data/src/core/lib/event_engine/posix_engine/posix_engine_closure.h +3 -3
  325. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +60 -7
  326. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.h +65 -14
  327. data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.cc +0 -1
  328. data/src/core/lib/event_engine/posix_engine/posix_engine_listener_utils.h +6 -6
  329. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +3 -3
  330. data/src/core/lib/event_engine/posix_engine/timer.h +3 -3
  331. data/src/core/lib/event_engine/posix_engine/timer_heap.h +3 -3
  332. data/src/core/lib/event_engine/posix_engine/timer_manager.h +3 -3
  333. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.h +3 -3
  334. data/src/core/lib/event_engine/posix_engine/wakeup_fd_eventfd.h +3 -3
  335. data/src/core/lib/event_engine/posix_engine/wakeup_fd_pipe.h +3 -3
  336. data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix.h +3 -3
  337. data/src/core/lib/event_engine/posix_engine/wakeup_fd_posix_default.h +3 -3
  338. data/src/core/lib/event_engine/resolved_address.cc +19 -0
  339. data/src/core/lib/event_engine/resolved_address_internal.h +34 -0
  340. data/src/core/lib/event_engine/shim.cc +56 -0
  341. data/src/core/lib/event_engine/shim.h +33 -0
  342. data/src/core/lib/event_engine/slice.cc +1 -1
  343. data/src/core/lib/event_engine/tcp_socket_utils.cc +18 -2
  344. data/src/core/lib/event_engine/tcp_socket_utils.h +8 -3
  345. data/src/core/lib/event_engine/thread_local.cc +29 -0
  346. data/src/core/lib/event_engine/thread_local.h +32 -0
  347. data/src/core/lib/event_engine/thread_pool.cc +41 -65
  348. data/src/core/lib/event_engine/thread_pool.h +21 -17
  349. data/src/core/lib/event_engine/time_util.h +3 -3
  350. data/src/core/lib/event_engine/trace.cc +6 -0
  351. data/src/core/lib/event_engine/trace.h +16 -3
  352. data/src/core/lib/event_engine/utils.cc +2 -2
  353. data/src/core/lib/event_engine/utils.h +12 -4
  354. data/src/core/lib/event_engine/windows/iocp.cc +24 -40
  355. data/src/core/lib/event_engine/windows/iocp.h +3 -3
  356. data/src/core/lib/event_engine/windows/win_socket.cc +56 -33
  357. data/src/core/lib/event_engine/windows/win_socket.h +34 -25
  358. data/src/core/lib/event_engine/windows/windows_endpoint.cc +331 -0
  359. data/src/core/lib/event_engine/windows/windows_endpoint.h +103 -0
  360. data/src/core/lib/event_engine/windows/windows_engine.cc +243 -20
  361. data/src/core/lib/event_engine/windows/windows_engine.h +62 -23
  362. data/src/core/lib/experiments/config.cc +16 -1
  363. data/src/core/lib/experiments/config.h +13 -3
  364. data/src/core/lib/experiments/experiments.cc +14 -8
  365. data/src/core/lib/experiments/experiments.h +80 -21
  366. data/src/core/lib/gpr/alloc.h +3 -3
  367. data/src/core/lib/gpr/spinlock.h +3 -3
  368. data/src/core/lib/gpr/string.h +3 -3
  369. data/src/core/lib/gpr/sync_abseil.cc +15 -7
  370. data/src/core/lib/gpr/time_precise.h +3 -3
  371. data/src/core/lib/gpr/tmpfile.h +3 -3
  372. data/src/core/lib/gpr/useful.h +3 -3
  373. data/src/core/lib/gprpp/atomic_utils.h +3 -3
  374. data/src/core/lib/gprpp/bitset.h +3 -3
  375. data/src/core/lib/gprpp/chunked_vector.h +3 -3
  376. data/src/core/lib/gprpp/construct_destruct.h +3 -3
  377. data/src/core/lib/gprpp/cpp_impl_of.h +3 -3
  378. data/src/core/lib/gprpp/crash.h +3 -3
  379. data/src/core/lib/gprpp/debug_location.h +3 -6
  380. data/src/core/lib/gprpp/dual_ref_counted.h +3 -3
  381. data/src/core/lib/gprpp/env.h +3 -3
  382. data/src/core/lib/gprpp/examine_stack.h +3 -3
  383. data/src/core/lib/gprpp/fork.cc +21 -4
  384. data/src/core/lib/gprpp/fork.h +7 -5
  385. data/src/core/lib/gprpp/global_config.h +3 -3
  386. data/src/core/lib/gprpp/global_config_custom.h +3 -3
  387. data/src/core/lib/gprpp/global_config_env.cc +1 -0
  388. data/src/core/lib/gprpp/global_config_env.h +3 -3
  389. data/src/core/lib/gprpp/global_config_generic.h +3 -3
  390. data/src/core/lib/gprpp/host_port.cc +2 -0
  391. data/src/core/lib/gprpp/host_port.h +3 -3
  392. data/src/core/lib/gprpp/load_file.h +3 -3
  393. data/src/core/lib/gprpp/manual_constructor.h +3 -3
  394. data/src/core/lib/gprpp/match.h +3 -3
  395. data/src/core/lib/gprpp/memory.h +3 -3
  396. data/src/core/lib/gprpp/mpscq.h +3 -3
  397. data/src/core/lib/gprpp/no_destruct.h +3 -3
  398. data/src/core/lib/gprpp/notification.h +3 -3
  399. data/src/core/lib/gprpp/orphanable.h +3 -3
  400. data/src/core/lib/gprpp/overload.h +3 -3
  401. data/src/core/lib/gprpp/packed_table.h +3 -3
  402. data/src/core/lib/gprpp/per_cpu.h +3 -3
  403. data/src/core/lib/gprpp/ref_counted.h +3 -3
  404. data/src/core/lib/gprpp/ref_counted_ptr.h +3 -3
  405. data/src/core/lib/gprpp/single_set_ptr.h +3 -3
  406. data/src/core/lib/gprpp/sorted_pack.h +3 -3
  407. data/src/core/lib/gprpp/stat.h +3 -3
  408. data/src/core/lib/gprpp/status_helper.h +3 -3
  409. data/src/core/lib/gprpp/strerror.cc +2 -0
  410. data/src/core/lib/gprpp/strerror.h +3 -3
  411. data/src/core/lib/gprpp/sync.h +3 -3
  412. data/src/core/lib/gprpp/table.h +3 -3
  413. data/src/core/lib/gprpp/tchar.h +3 -3
  414. data/src/core/lib/gprpp/thd.h +3 -3
  415. data/src/core/lib/gprpp/time.cc +1 -0
  416. data/src/core/lib/gprpp/time.h +3 -3
  417. data/src/core/lib/gprpp/time_averaged_stats.h +3 -3
  418. data/src/core/lib/gprpp/time_util.h +3 -3
  419. data/src/core/lib/gprpp/unique_type_name.h +3 -3
  420. data/src/core/lib/gprpp/validation_errors.h +3 -3
  421. data/src/core/lib/gprpp/work_serializer.h +3 -3
  422. data/src/core/lib/handshaker/proxy_mapper.h +3 -3
  423. data/src/core/lib/handshaker/proxy_mapper_registry.h +3 -3
  424. data/src/core/lib/http/format_request.cc +1 -0
  425. data/src/core/lib/http/format_request.h +3 -3
  426. data/src/core/lib/http/httpcli.cc +1 -0
  427. data/src/core/lib/http/httpcli.h +3 -3
  428. data/src/core/lib/http/httpcli_ssl_credentials.h +3 -3
  429. data/src/core/lib/http/parser.h +3 -3
  430. data/src/core/lib/iomgr/block_annotate.h +3 -3
  431. data/src/core/lib/iomgr/buffer_list.h +3 -3
  432. data/src/core/lib/iomgr/call_combiner.cc +4 -4
  433. data/src/core/lib/iomgr/call_combiner.h +3 -3
  434. data/src/core/lib/iomgr/cfstream_handle.h +3 -3
  435. data/src/core/lib/iomgr/closure.cc +27 -0
  436. data/src/core/lib/iomgr/closure.h +5 -3
  437. data/src/core/lib/iomgr/combiner.h +3 -3
  438. data/src/core/lib/iomgr/dynamic_annotations.h +3 -3
  439. data/src/core/lib/iomgr/endpoint.h +3 -3
  440. data/src/core/lib/iomgr/endpoint_cfstream.h +3 -3
  441. data/src/core/lib/iomgr/endpoint_pair.h +3 -3
  442. data/src/core/lib/iomgr/endpoint_pair_windows.cc +10 -2
  443. data/src/core/lib/iomgr/error.h +3 -3
  444. data/src/core/lib/iomgr/error_cfstream.h +3 -3
  445. data/src/core/lib/iomgr/ev_apple.h +3 -3
  446. data/src/core/lib/iomgr/ev_epoll1_linux.h +3 -3
  447. data/src/core/lib/iomgr/ev_poll_posix.h +3 -3
  448. data/src/core/lib/iomgr/ev_posix.h +3 -3
  449. data/src/core/lib/iomgr/event_engine_shims/closure.cc +62 -0
  450. data/src/core/lib/iomgr/event_engine_shims/closure.h +39 -0
  451. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +430 -0
  452. data/src/core/lib/iomgr/event_engine_shims/endpoint.h +43 -0
  453. data/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +91 -0
  454. data/src/core/lib/iomgr/event_engine_shims/tcp_client.h +44 -0
  455. data/src/core/lib/iomgr/exec_ctx.h +3 -3
  456. data/src/core/lib/iomgr/executor.h +3 -3
  457. data/src/core/lib/iomgr/fork_posix.cc +5 -4
  458. data/src/core/lib/iomgr/gethostname.h +3 -3
  459. data/src/core/lib/iomgr/grpc_if_nametoindex.h +3 -3
  460. data/src/core/lib/iomgr/internal_errqueue.h +3 -3
  461. data/src/core/lib/iomgr/iocp_windows.h +3 -3
  462. data/src/core/lib/iomgr/iomgr.h +3 -3
  463. data/src/core/lib/iomgr/iomgr_fwd.h +3 -3
  464. data/src/core/lib/iomgr/iomgr_internal.h +3 -3
  465. data/src/core/lib/iomgr/load_file.h +3 -3
  466. data/src/core/lib/iomgr/lockfree_event.h +3 -3
  467. data/src/core/lib/iomgr/nameser.h +3 -3
  468. data/src/core/lib/iomgr/polling_entity.h +3 -3
  469. data/src/core/lib/iomgr/pollset.h +3 -3
  470. data/src/core/lib/iomgr/pollset_set.h +3 -3
  471. data/src/core/lib/iomgr/pollset_set_windows.h +3 -3
  472. data/src/core/lib/iomgr/pollset_windows.cc +2 -2
  473. data/src/core/lib/iomgr/pollset_windows.h +3 -3
  474. data/src/core/lib/iomgr/port.h +3 -3
  475. data/src/core/lib/iomgr/python_util.h +3 -3
  476. data/src/core/lib/iomgr/resolve_address.h +3 -3
  477. data/src/core/lib/iomgr/resolve_address_impl.h +3 -3
  478. data/src/core/lib/iomgr/resolve_address_posix.h +3 -3
  479. data/src/core/lib/iomgr/resolve_address_windows.h +3 -3
  480. data/src/core/lib/iomgr/resolved_address.h +3 -3
  481. data/src/core/lib/iomgr/sockaddr.h +3 -3
  482. data/src/core/lib/iomgr/sockaddr_posix.h +3 -3
  483. data/src/core/lib/iomgr/sockaddr_windows.h +3 -3
  484. data/src/core/lib/iomgr/socket_factory_posix.h +3 -3
  485. data/src/core/lib/iomgr/socket_mutator.h +3 -3
  486. data/src/core/lib/iomgr/socket_utils.h +3 -3
  487. data/src/core/lib/iomgr/socket_utils_posix.h +3 -3
  488. data/src/core/lib/iomgr/socket_windows.h +3 -3
  489. data/src/core/lib/iomgr/systemd_utils.cc +19 -19
  490. data/src/core/lib/iomgr/systemd_utils.h +24 -24
  491. data/src/core/lib/iomgr/tcp_client.h +3 -3
  492. data/src/core/lib/iomgr/tcp_client_posix.cc +12 -0
  493. data/src/core/lib/iomgr/tcp_client_posix.h +3 -3
  494. data/src/core/lib/iomgr/tcp_client_windows.cc +13 -1
  495. data/src/core/lib/iomgr/tcp_posix.cc +49 -65
  496. data/src/core/lib/iomgr/tcp_posix.h +3 -3
  497. data/src/core/lib/iomgr/tcp_server.h +3 -3
  498. data/src/core/lib/iomgr/tcp_server_posix.cc +219 -4
  499. data/src/core/lib/iomgr/tcp_server_utils_posix.h +13 -3
  500. data/src/core/lib/iomgr/tcp_server_windows.cc +4 -6
  501. data/src/core/lib/iomgr/tcp_windows.h +3 -3
  502. data/src/core/lib/iomgr/timer.h +3 -3
  503. data/src/core/lib/iomgr/timer_generic.h +3 -3
  504. data/src/core/lib/iomgr/timer_heap.h +3 -3
  505. data/src/core/lib/iomgr/timer_manager.h +3 -3
  506. data/src/core/lib/iomgr/unix_sockets_posix.h +3 -3
  507. data/src/core/lib/iomgr/wakeup_fd_pipe.h +3 -3
  508. data/src/core/lib/iomgr/wakeup_fd_posix.h +3 -3
  509. data/src/core/lib/json/json.h +3 -3
  510. data/src/core/lib/json/json_args.h +3 -3
  511. data/src/core/lib/json/json_channel_args.h +3 -3
  512. data/src/core/lib/json/json_object_loader.h +3 -3
  513. data/src/core/lib/json/json_reader.cc +1 -0
  514. data/src/core/lib/json/json_util.h +3 -3
  515. data/src/core/lib/load_balancing/lb_policy.cc +9 -0
  516. data/src/core/lib/load_balancing/lb_policy.h +9 -5
  517. data/src/core/lib/load_balancing/lb_policy_factory.h +3 -3
  518. data/src/core/lib/load_balancing/lb_policy_registry.cc +1 -0
  519. data/src/core/lib/load_balancing/lb_policy_registry.h +3 -3
  520. data/src/core/lib/load_balancing/subchannel_interface.h +8 -6
  521. data/src/core/lib/matchers/matchers.cc +1 -0
  522. data/src/core/lib/matchers/matchers.h +3 -3
  523. data/src/core/lib/promise/activity.cc +8 -6
  524. data/src/core/lib/promise/activity.h +52 -66
  525. data/src/core/lib/promise/arena_promise.h +3 -3
  526. data/src/core/lib/promise/context.h +3 -3
  527. data/src/core/lib/promise/detail/basic_join.h +197 -0
  528. data/src/core/lib/promise/detail/basic_seq.h +10 -16
  529. data/src/core/lib/promise/detail/promise_factory.h +3 -3
  530. data/src/core/lib/promise/detail/promise_like.h +3 -3
  531. data/src/core/lib/promise/detail/status.h +3 -3
  532. data/src/core/lib/promise/detail/switch.h +3 -3
  533. data/src/core/lib/promise/exec_ctx_wakeup_scheduler.h +3 -3
  534. data/src/core/lib/promise/if.h +195 -0
  535. data/src/core/lib/promise/interceptor_list.h +308 -0
  536. data/src/core/lib/promise/intra_activity_waiter.h +9 -3
  537. data/src/core/lib/promise/latch.h +99 -5
  538. data/src/core/lib/promise/loop.h +4 -4
  539. data/src/core/lib/promise/map.h +4 -6
  540. data/src/core/lib/promise/pipe.h +296 -193
  541. data/src/core/lib/promise/poll.h +113 -14
  542. data/src/core/lib/promise/promise.h +4 -5
  543. data/src/core/lib/promise/race.h +6 -9
  544. data/src/core/lib/promise/seq.h +3 -3
  545. data/src/core/lib/promise/sleep.h +3 -3
  546. data/src/core/lib/promise/{pipe.cc → trace.cc} +3 -2
  547. data/src/core/lib/promise/trace.h +24 -0
  548. data/src/core/lib/promise/try_join.h +82 -0
  549. data/src/core/lib/promise/try_seq.h +3 -3
  550. data/src/core/lib/resolver/resolver.h +3 -3
  551. data/src/core/lib/resolver/resolver_factory.h +4 -4
  552. data/src/core/lib/resolver/resolver_registry.cc +15 -0
  553. data/src/core/lib/resolver/resolver_registry.h +3 -3
  554. data/src/core/lib/resolver/server_address.cc +1 -0
  555. data/src/core/lib/resolver/server_address.h +3 -3
  556. data/src/core/lib/resource_quota/api.h +3 -3
  557. data/src/core/lib/resource_quota/arena.cc +36 -9
  558. data/src/core/lib/resource_quota/arena.h +84 -22
  559. data/src/core/lib/resource_quota/memory_quota.h +3 -3
  560. data/src/core/lib/resource_quota/periodic_update.h +3 -3
  561. data/src/core/lib/resource_quota/resource_quota.h +3 -3
  562. data/src/core/lib/resource_quota/thread_quota.h +3 -3
  563. data/src/core/lib/resource_quota/trace.h +3 -3
  564. data/src/core/lib/security/authorization/authorization_engine.h +3 -3
  565. data/src/core/lib/security/authorization/authorization_policy_provider.h +3 -3
  566. data/src/core/lib/security/authorization/evaluate_args.h +3 -3
  567. data/src/core/lib/security/authorization/grpc_authorization_engine.h +3 -3
  568. data/src/core/lib/security/authorization/grpc_server_authz_filter.h +3 -3
  569. data/src/core/lib/security/authorization/matchers.h +3 -3
  570. data/src/core/lib/security/authorization/rbac_policy.cc +1 -0
  571. data/src/core/lib/security/authorization/rbac_policy.h +3 -3
  572. data/src/core/lib/security/certificate_provider/certificate_provider_factory.h +3 -3
  573. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +3 -3
  574. data/src/core/lib/security/context/security_context.h +3 -3
  575. data/src/core/lib/security/credentials/alts/alts_credentials.h +3 -3
  576. data/src/core/lib/security/credentials/alts/check_gcp_environment.h +3 -3
  577. data/src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h +3 -3
  578. data/src/core/lib/security/credentials/call_creds_util.h +3 -3
  579. data/src/core/lib/security/credentials/channel_creds_registry.h +3 -3
  580. data/src/core/lib/security/credentials/composite/composite_credentials.h +3 -3
  581. data/src/core/lib/security/credentials/credentials.h +3 -3
  582. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +1 -0
  583. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +3 -3
  584. data/src/core/lib/security/credentials/external/aws_request_signer.cc +1 -0
  585. data/src/core/lib/security/credentials/external/aws_request_signer.h +3 -3
  586. data/src/core/lib/security/credentials/external/external_account_credentials.cc +1 -0
  587. data/src/core/lib/security/credentials/external/external_account_credentials.h +3 -3
  588. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +3 -3
  589. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +1 -0
  590. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +3 -3
  591. data/src/core/lib/security/credentials/fake/fake_credentials.h +3 -3
  592. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +3 -3
  593. data/src/core/lib/security/credentials/iam/iam_credentials.cc +1 -0
  594. data/src/core/lib/security/credentials/iam/iam_credentials.h +3 -3
  595. data/src/core/lib/security/credentials/insecure/insecure_credentials.h +3 -3
  596. data/src/core/lib/security/credentials/jwt/json_token.h +3 -3
  597. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +4 -3
  598. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +3 -3
  599. data/src/core/lib/security/credentials/local/local_credentials.h +3 -3
  600. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +4 -3
  601. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +3 -3
  602. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +3 -3
  603. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +3 -3
  604. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +1 -1
  605. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +3 -3
  606. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h +3 -3
  607. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +3 -3
  608. data/src/core/lib/security/credentials/tls/tls_credentials.h +3 -3
  609. data/src/core/lib/security/credentials/tls/tls_utils.h +3 -3
  610. data/src/core/lib/security/credentials/xds/xds_credentials.h +3 -3
  611. data/src/core/lib/security/security_connector/alts/alts_security_connector.h +3 -3
  612. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +1 -0
  613. data/src/core/lib/security/security_connector/fake/fake_security_connector.h +3 -3
  614. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +3 -3
  615. data/src/core/lib/security/security_connector/load_system_roots.h +3 -3
  616. data/src/core/lib/security/security_connector/load_system_roots_supported.h +3 -3
  617. data/src/core/lib/security/security_connector/local/local_security_connector.h +3 -3
  618. data/src/core/lib/security/security_connector/security_connector.h +3 -3
  619. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +1 -0
  620. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +3 -3
  621. data/src/core/lib/security/security_connector/ssl_utils.h +3 -3
  622. data/src/core/lib/security/security_connector/ssl_utils_config.h +3 -3
  623. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +3 -3
  624. data/src/core/lib/security/transport/auth_filters.h +27 -5
  625. data/src/core/lib/security/transport/secure_endpoint.h +3 -3
  626. data/src/core/lib/security/transport/security_handshaker.cc +9 -0
  627. data/src/core/lib/security/transport/security_handshaker.h +3 -3
  628. data/src/core/lib/security/transport/server_auth_filter.cc +120 -251
  629. data/src/core/lib/security/transport/tsi_error.h +3 -3
  630. data/src/core/lib/security/util/json_util.h +3 -3
  631. data/src/core/lib/service_config/service_config.h +3 -3
  632. data/src/core/lib/service_config/service_config_call_data.h +3 -3
  633. data/src/core/lib/service_config/service_config_impl.h +3 -3
  634. data/src/core/lib/service_config/service_config_parser.h +3 -3
  635. data/src/core/lib/slice/b64.h +3 -3
  636. data/src/core/lib/slice/percent_encoding.h +3 -3
  637. data/src/core/lib/slice/slice.cc +3 -3
  638. data/src/core/lib/slice/slice.h +14 -21
  639. data/src/core/lib/slice/slice_buffer.h +10 -4
  640. data/src/core/lib/slice/slice_internal.h +3 -3
  641. data/src/core/lib/slice/slice_refcount.cc +20 -0
  642. data/src/core/lib/slice/slice_refcount.h +26 -6
  643. data/src/core/lib/slice/slice_string_helpers.h +3 -3
  644. data/src/core/lib/surface/api_trace.h +3 -3
  645. data/src/core/lib/surface/builtins.h +3 -3
  646. data/src/core/lib/surface/call.cc +866 -252
  647. data/src/core/lib/surface/call.h +31 -3
  648. data/src/core/lib/surface/call_log_batch.cc +1 -0
  649. data/src/core/lib/surface/call_test_only.h +3 -3
  650. data/src/core/lib/surface/call_trace.cc +21 -11
  651. data/src/core/lib/surface/call_trace.h +3 -3
  652. data/src/core/lib/surface/channel.h +3 -3
  653. data/src/core/lib/surface/channel_init.h +3 -3
  654. data/src/core/lib/surface/channel_stack_type.h +3 -3
  655. data/src/core/lib/surface/completion_queue.cc +1 -0
  656. data/src/core/lib/surface/completion_queue.h +3 -3
  657. data/src/core/lib/surface/completion_queue_factory.h +3 -3
  658. data/src/core/lib/surface/event_string.cc +1 -0
  659. data/src/core/lib/surface/event_string.h +3 -3
  660. data/src/core/lib/surface/init.cc +1 -1
  661. data/src/core/lib/surface/init.h +3 -3
  662. data/src/core/lib/surface/init_internally.h +3 -3
  663. data/src/core/lib/surface/lame_client.cc +3 -1
  664. data/src/core/lib/surface/lame_client.h +3 -3
  665. data/src/core/lib/surface/server.cc +273 -27
  666. data/src/core/lib/surface/server.h +6 -3
  667. data/src/core/lib/surface/validate_metadata.h +3 -3
  668. data/src/core/lib/surface/version.cc +2 -2
  669. data/src/core/lib/transport/bdp_estimator.h +3 -3
  670. data/src/core/lib/transport/connectivity_state.h +3 -3
  671. data/src/core/lib/transport/error_utils.h +3 -3
  672. data/src/core/lib/transport/handshaker.cc +11 -0
  673. data/src/core/lib/transport/handshaker.h +4 -4
  674. data/src/core/lib/transport/handshaker_factory.h +3 -3
  675. data/src/core/lib/transport/handshaker_registry.h +3 -3
  676. data/src/core/lib/transport/http2_errors.h +3 -3
  677. data/src/core/lib/transport/http_connect_handshaker.h +3 -3
  678. data/src/core/lib/transport/metadata_batch.cc +11 -0
  679. data/src/core/lib/transport/metadata_batch.h +24 -3
  680. data/src/core/lib/transport/parsed_metadata.h +3 -3
  681. data/src/core/lib/transport/pid_controller.h +3 -3
  682. data/src/core/lib/transport/status_conversion.h +3 -3
  683. data/src/core/lib/transport/tcp_connect_handshaker.cc +0 -1
  684. data/src/core/lib/transport/tcp_connect_handshaker.h +3 -3
  685. data/src/core/lib/transport/timeout_encoding.h +3 -3
  686. data/src/core/lib/transport/transport.cc +3 -8
  687. data/src/core/lib/transport/transport.h +16 -8
  688. data/src/core/lib/transport/transport_fwd.h +3 -3
  689. data/src/core/lib/transport/transport_impl.h +3 -3
  690. data/src/core/lib/transport/transport_op_string.cc +1 -0
  691. data/src/core/lib/uri/uri_parser.cc +1 -1
  692. data/src/core/lib/uri/uri_parser.h +3 -3
  693. data/src/core/plugin_registry/grpc_plugin_registry.cc +5 -0
  694. data/src/core/tsi/alts/crypt/gsec.h +3 -3
  695. data/src/core/tsi/alts/frame_protector/alts_counter.h +3 -3
  696. data/src/core/tsi/alts/frame_protector/alts_crypter.h +3 -3
  697. data/src/core/tsi/alts/frame_protector/alts_frame_protector.h +3 -3
  698. data/src/core/tsi/alts/frame_protector/alts_record_protocol_crypter_common.h +3 -3
  699. data/src/core/tsi/alts/frame_protector/frame_handler.h +3 -3
  700. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +3 -3
  701. data/src/core/tsi/alts/handshaker/alts_shared_resource.h +3 -3
  702. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +3 -3
  703. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +3 -3
  704. data/src/core/tsi/alts/handshaker/alts_tsi_utils.h +3 -3
  705. data/src/core/tsi/alts/handshaker/transport_security_common_api.h +3 -3
  706. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.h +3 -3
  707. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_privacy_integrity_record_protocol.h +3 -3
  708. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol.h +3 -3
  709. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +3 -3
  710. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.h +3 -3
  711. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.h +3 -3
  712. data/src/core/tsi/fake_transport_security.h +3 -3
  713. data/src/core/tsi/local_transport_security.h +3 -3
  714. data/src/core/tsi/ssl/key_logging/ssl_key_logging.cc +1 -1
  715. data/src/core/tsi/ssl/key_logging/ssl_key_logging.h +3 -3
  716. data/src/core/tsi/ssl/session_cache/ssl_session.h +3 -3
  717. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -3
  718. data/src/core/tsi/ssl_transport_security.cc +113 -24
  719. data/src/core/tsi/ssl_transport_security.h +5 -3
  720. data/src/core/tsi/ssl_transport_security_utils.h +3 -3
  721. data/src/core/tsi/ssl_types.h +3 -3
  722. data/src/core/tsi/transport_security.h +3 -3
  723. data/src/core/tsi/transport_security_grpc.h +3 -3
  724. data/src/core/tsi/transport_security_interface.h +3 -3
  725. data/src/ruby/lib/grpc/version.rb +1 -1
  726. data/src/ruby/pb/generate_proto_ruby.sh +0 -6
  727. data/third_party/abseil-cpp/absl/algorithm/container.h +56 -57
  728. data/third_party/abseil-cpp/absl/base/attributes.h +39 -19
  729. data/third_party/abseil-cpp/absl/base/config.h +44 -3
  730. data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +3 -18
  731. data/third_party/abseil-cpp/absl/base/internal/cycleclock_config.h +55 -0
  732. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +2 -1
  733. data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +3 -3
  734. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +2 -2
  735. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +1 -1
  736. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +10 -6
  737. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +23 -24
  738. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +3 -3
  739. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +2 -6
  740. data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +4 -1
  741. data/third_party/abseil-cpp/absl/base/internal/strerror.cc +4 -4
  742. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +14 -10
  743. data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +9 -0
  744. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +4 -0
  745. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +3 -40
  746. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock_config.h +62 -0
  747. data/third_party/abseil-cpp/absl/base/macros.h +4 -21
  748. data/third_party/abseil-cpp/absl/base/optimization.h +58 -6
  749. data/third_party/abseil-cpp/absl/base/options.h +1 -7
  750. data/third_party/abseil-cpp/absl/base/policy_checks.h +15 -13
  751. data/third_party/abseil-cpp/absl/container/fixed_array.h +7 -5
  752. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +0 -7
  753. data/third_party/abseil-cpp/absl/container/inlined_vector.h +66 -18
  754. data/third_party/abseil-cpp/absl/container/internal/common.h +3 -3
  755. data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +132 -0
  756. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +13 -1
  757. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +4 -55
  758. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +50 -5
  759. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +14 -46
  760. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +110 -32
  761. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +155 -4
  762. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +661 -341
  763. data/third_party/abseil-cpp/absl/crc/crc32c.cc +99 -0
  764. data/third_party/abseil-cpp/absl/crc/crc32c.h +183 -0
  765. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +256 -0
  766. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.h +57 -0
  767. data/third_party/abseil-cpp/absl/crc/internal/crc.cc +468 -0
  768. data/third_party/abseil-cpp/absl/crc/internal/crc.h +91 -0
  769. data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +269 -0
  770. data/third_party/abseil-cpp/absl/crc/internal/crc32c.h +39 -0
  771. data/third_party/abseil-cpp/absl/crc/internal/crc32c_inline.h +72 -0
  772. data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.cc +130 -0
  773. data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.h +159 -0
  774. data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +179 -0
  775. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy.h +119 -0
  776. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_fallback.cc +75 -0
  777. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_64.cc +434 -0
  778. data/third_party/abseil-cpp/absl/crc/internal/crc_non_temporal_memcpy.cc +93 -0
  779. data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +725 -0
  780. data/third_party/abseil-cpp/absl/crc/internal/non_temporal_arm_intrinsics.h +79 -0
  781. data/third_party/abseil-cpp/absl/crc/internal/non_temporal_memcpy.h +180 -0
  782. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +1 -1
  783. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +67 -38
  784. data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +1 -1
  785. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +12 -13
  786. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +11 -9
  787. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +1 -1
  788. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +40 -85
  789. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +5 -4
  790. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +33 -8
  791. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +3 -2
  792. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +3 -2
  793. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +118 -94
  794. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +7 -6
  795. data/third_party/abseil-cpp/absl/functional/any_invocable.h +5 -2
  796. data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +47 -26
  797. data/third_party/abseil-cpp/absl/hash/internal/city.cc +10 -10
  798. data/third_party/abseil-cpp/absl/hash/internal/hash.h +18 -4
  799. data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +3 -14
  800. data/third_party/abseil-cpp/absl/memory/memory.h +26 -447
  801. data/third_party/abseil-cpp/absl/meta/type_traits.h +104 -12
  802. data/third_party/abseil-cpp/absl/numeric/bits.h +2 -3
  803. data/third_party/abseil-cpp/absl/numeric/int128.cc +10 -8
  804. data/third_party/abseil-cpp/absl/profiling/internal/sample_recorder.h +14 -6
  805. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +2 -1
  806. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +1 -1
  807. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +2 -23
  808. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +9 -9
  809. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +2 -2
  810. data/third_party/abseil-cpp/absl/random/random.h +6 -6
  811. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +1 -0
  812. data/third_party/abseil-cpp/absl/status/status.cc +19 -12
  813. data/third_party/abseil-cpp/absl/status/status.h +2 -2
  814. data/third_party/abseil-cpp/absl/strings/ascii.cc +5 -5
  815. data/third_party/abseil-cpp/absl/strings/charconv.cc +534 -96
  816. data/third_party/abseil-cpp/absl/strings/cord.cc +92 -40
  817. data/third_party/abseil-cpp/absl/strings/cord.h +71 -80
  818. data/third_party/abseil-cpp/absl/strings/cord_buffer.h +8 -5
  819. data/third_party/abseil-cpp/absl/strings/escaping.cc +73 -62
  820. data/third_party/abseil-cpp/absl/strings/escaping.h +24 -19
  821. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +14 -12
  822. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +4 -4
  823. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +2 -2
  824. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +326 -70
  825. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +8 -4
  826. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.h +26 -14
  827. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree_navigator.cc +5 -5
  828. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_crc.cc +9 -7
  829. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_crc.h +5 -4
  830. data/third_party/abseil-cpp/absl/strings/internal/cordz_functions.h +7 -15
  831. data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.h +3 -3
  832. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +8 -5
  833. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.h +7 -7
  834. data/third_party/abseil-cpp/absl/strings/internal/cordz_statistics.h +4 -4
  835. data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.cc +93 -0
  836. data/third_party/abseil-cpp/absl/strings/internal/damerau_levenshtein_distance.h +34 -0
  837. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +12 -10
  838. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +7 -9
  839. data/third_party/abseil-cpp/absl/strings/internal/has_absl_stringify.h +55 -0
  840. data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +9 -6
  841. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +14 -7
  842. data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +35 -10
  843. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +113 -46
  844. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +126 -29
  845. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +3 -2
  846. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +4 -3
  847. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +49 -287
  848. data/third_party/abseil-cpp/absl/strings/internal/str_format/constexpr_parser.h +351 -0
  849. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +2 -1
  850. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +4 -2
  851. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +215 -181
  852. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +10 -209
  853. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +10 -101
  854. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +2 -1
  855. data/third_party/abseil-cpp/absl/strings/internal/stringify_sink.cc +28 -0
  856. data/third_party/abseil-cpp/absl/strings/internal/stringify_sink.h +57 -0
  857. data/third_party/abseil-cpp/absl/strings/numbers.cc +34 -31
  858. data/third_party/abseil-cpp/absl/strings/str_cat.cc +9 -6
  859. data/third_party/abseil-cpp/absl/strings/str_cat.h +50 -3
  860. data/third_party/abseil-cpp/absl/strings/str_format.h +71 -9
  861. data/third_party/abseil-cpp/absl/strings/string_view.cc +6 -6
  862. data/third_party/abseil-cpp/absl/strings/string_view.h +3 -10
  863. data/third_party/abseil-cpp/absl/strings/substitute.cc +8 -6
  864. data/third_party/abseil-cpp/absl/strings/substitute.h +46 -20
  865. data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +20 -17
  866. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +37 -31
  867. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +22 -8
  868. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +104 -55
  869. data/third_party/abseil-cpp/absl/synchronization/mutex.h +85 -46
  870. data/third_party/abseil-cpp/absl/synchronization/notification.cc +0 -1
  871. data/third_party/abseil-cpp/absl/synchronization/notification.h +0 -1
  872. data/third_party/abseil-cpp/absl/time/civil_time.cc +26 -0
  873. data/third_party/abseil-cpp/absl/time/civil_time.h +25 -0
  874. data/third_party/abseil-cpp/absl/time/clock.cc +17 -11
  875. data/third_party/abseil-cpp/absl/time/duration.cc +7 -7
  876. data/third_party/abseil-cpp/absl/time/format.cc +2 -1
  877. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +1 -1
  878. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +26 -5
  879. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +7 -6
  880. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +36 -35
  881. data/third_party/abseil-cpp/absl/time/time.cc +2 -2
  882. data/third_party/abseil-cpp/absl/time/time.h +253 -158
  883. data/third_party/abseil-cpp/absl/types/internal/span.h +30 -19
  884. data/third_party/abseil-cpp/absl/types/internal/variant.h +28 -40
  885. data/third_party/abseil-cpp/absl/types/span.h +29 -7
  886. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +1 -1
  887. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +1 -2
  888. metadata +75 -10
  889. data/src/core/lib/event_engine/socket_notifier.h +0 -55
  890. data/src/core/lib/promise/for_each.h +0 -155
  891. data/src/core/lib/promise/map_pipe.h +0 -88
  892. data/src/core/lib/promise/try_concurrently.h +0 -342
@@ -24,12 +24,15 @@
24
24
  #include <string.h>
25
25
 
26
26
  #include <algorithm>
27
+ #include <functional>
28
+ #include <initializer_list>
27
29
  #include <memory>
28
30
  #include <string>
29
31
  #include <utility>
30
32
  #include <vector>
31
33
 
32
34
  #include "absl/base/thread_annotations.h"
35
+ #include "absl/container/inlined_vector.h"
33
36
  #include "absl/status/status.h"
34
37
  #include "absl/strings/str_cat.h"
35
38
  #include "absl/strings/str_join.h"
@@ -37,6 +40,7 @@
37
40
  #include "absl/types/variant.h"
38
41
 
39
42
  #include <grpc/grpc.h>
43
+ #include <grpc/status.h>
40
44
  #include <grpc/support/alloc.h>
41
45
  #include <grpc/support/log.h>
42
46
 
@@ -45,6 +49,7 @@
45
49
  #include "src/core/lib/channel/channel_stack.h"
46
50
  #include "src/core/lib/channel/context.h"
47
51
  #include "src/core/lib/debug/trace.h"
52
+ #include "src/core/lib/experiments/experiments.h"
48
53
  #include "src/core/lib/gpr/alloc.h"
49
54
  #include "src/core/lib/gprpp/debug_location.h"
50
55
  #include "src/core/lib/gprpp/match.h"
@@ -59,10 +64,11 @@
59
64
  #include "src/core/lib/promise/activity.h"
60
65
  #include "src/core/lib/promise/arena_promise.h"
61
66
  #include "src/core/lib/promise/context.h"
62
- #include "src/core/lib/promise/latch.h"
67
+ #include "src/core/lib/promise/detail/basic_seq.h"
63
68
  #include "src/core/lib/promise/pipe.h"
64
69
  #include "src/core/lib/promise/poll.h"
65
70
  #include "src/core/lib/resource_quota/arena.h"
71
+ #include "src/core/lib/slice/slice.h"
66
72
  #include "src/core/lib/slice/slice_buffer.h"
67
73
  #include "src/core/lib/surface/call.h"
68
74
  #include "src/core/lib/surface/call_trace.h"
@@ -222,8 +228,7 @@ static grpc_error_handle connected_channel_init_channel_elem(
222
228
  grpc_channel_element* elem, grpc_channel_element_args* args) {
223
229
  channel_data* cd = static_cast<channel_data*>(elem->channel_data);
224
230
  GPR_ASSERT(args->is_last);
225
- cd->transport = grpc_channel_args_find_pointer<grpc_transport>(
226
- args->channel_args, GRPC_ARG_TRANSPORT);
231
+ cd->transport = args->channel_args.GetObject<grpc_transport>();
227
232
  return absl::OkStatus();
228
233
  }
229
234
 
@@ -243,37 +248,39 @@ static void connected_channel_get_channel_info(
243
248
  namespace grpc_core {
244
249
  namespace {
245
250
 
246
- class ClientStream : public Orphanable {
251
+ #if defined(GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_CLIENT_CALL) || \
252
+ defined(GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_SERVER_CALL)
253
+ class ConnectedChannelStream : public Orphanable {
247
254
  public:
248
- ClientStream(grpc_transport* transport, CallArgs call_args)
249
- : transport_(transport),
250
- stream_(nullptr, StreamDeleter(this)),
251
- server_initial_metadata_latch_(call_args.server_initial_metadata),
252
- client_to_server_messages_(call_args.outgoing_messages),
253
- server_to_client_messages_(call_args.incoming_messages),
254
- client_initial_metadata_(std::move(call_args.client_initial_metadata)) {
255
- call_context_->IncrementRefCount("client_stream");
256
- GRPC_STREAM_REF_INIT(
257
- &stream_refcount_, 1,
258
- [](void* p, grpc_error_handle) {
259
- static_cast<ClientStream*>(p)->BeginDestroy();
260
- },
261
- this, "client_stream");
262
- if (grpc_call_trace.enabled()) {
263
- gpr_log(GPR_INFO, "%sInitImpl: intitial_metadata=%s",
264
- Activity::current()->DebugTag().c_str(),
265
- client_initial_metadata_->DebugString().c_str());
266
- }
255
+ grpc_transport* transport() { return transport_; }
256
+ grpc_closure* stream_destroyed_closure() { return &stream_destroyed_; }
257
+
258
+ void IncrementRefCount(const char* reason) {
259
+ #ifndef NDEBUG
260
+ grpc_stream_ref(&stream_refcount_, reason);
261
+ #else
262
+ (void)reason;
263
+ grpc_stream_ref(&stream_refcount_);
264
+ #endif
265
+ }
266
+
267
+ void Unref(const char* reason) {
268
+ #ifndef NDEBUG
269
+ grpc_stream_unref(&stream_refcount_, reason);
270
+ #else
271
+ (void)reason;
272
+ grpc_stream_unref(&stream_refcount_);
273
+ #endif
267
274
  }
268
275
 
269
- void Orphan() override {
276
+ void Orphan() final {
270
277
  bool finished;
271
278
  {
272
- MutexLock lock(&mu_);
279
+ MutexLock lock(mu());
273
280
  if (grpc_call_trace.enabled()) {
274
- gpr_log(GPR_INFO, "%sDropStream: %s",
281
+ gpr_log(GPR_INFO, "%s[connected] DropStream: %s finished=%s",
275
282
  Activity::current()->DebugTag().c_str(),
276
- ActiveOpsString().c_str());
283
+ ActiveOpsString().c_str(), finished_ ? "true" : "false");
277
284
  }
278
285
  finished = finished_;
279
286
  }
@@ -284,271 +291,262 @@ class ClientStream : public Orphanable {
284
291
  auto* cancel_op =
285
292
  GetContext<Arena>()->New<grpc_transport_stream_op_batch>();
286
293
  cancel_op->cancel_stream = true;
287
- cancel_op->payload = &batch_payload_;
288
- auto* stream = stream_.get();
294
+ cancel_op->payload = batch_payload();
295
+ auto* s = stream();
289
296
  cancel_op->on_complete = NewClosure(
290
297
  [this](grpc_error_handle) { Unref("shutdown client stream"); });
291
- batch_payload_.cancel_stream.cancel_error = absl::CancelledError();
292
- grpc_transport_perform_stream_op(transport_, stream, cancel_op);
298
+ batch_payload()->cancel_stream.cancel_error = absl::CancelledError();
299
+ grpc_transport_perform_stream_op(transport(), s, cancel_op);
293
300
  }
294
301
  Unref("orphan client stream");
295
302
  }
296
303
 
297
- void IncrementRefCount(const char* reason) {
298
- #ifndef NDEBUG
299
- grpc_stream_ref(&stream_refcount_, reason);
300
- #else
301
- (void)reason;
302
- grpc_stream_ref(&stream_refcount_);
303
- #endif
304
- }
305
-
306
- void Unref(const char* reason) {
307
- #ifndef NDEBUG
308
- grpc_stream_unref(&stream_refcount_, reason);
309
- #else
310
- (void)reason;
311
- grpc_stream_unref(&stream_refcount_);
312
- #endif
304
+ protected:
305
+ explicit ConnectedChannelStream(grpc_transport* transport)
306
+ : transport_(transport), stream_(nullptr, StreamDeleter(this)) {
307
+ call_context_->IncrementRefCount("connected_channel_stream");
308
+ GRPC_STREAM_REF_INIT(
309
+ &stream_refcount_, 1,
310
+ [](void* p, grpc_error_handle) {
311
+ static_cast<ConnectedChannelStream*>(p)->BeginDestroy();
312
+ },
313
+ this, "client_stream");
313
314
  }
314
315
 
315
- void BeginDestroy() {
316
- if (stream_ != nullptr) {
317
- stream_.reset();
318
- } else {
319
- StreamDestroyed();
320
- }
316
+ grpc_stream* stream() { return stream_.get(); }
317
+ void SetStream(grpc_stream* stream) { stream_.reset(stream); }
318
+ grpc_stream_refcount* stream_refcount() { return &stream_refcount_; }
319
+ Mutex* mu() const ABSL_LOCK_RETURNED(mu_) { return &mu_; }
320
+ grpc_transport_stream_op_batch_payload* batch_payload() {
321
+ return &batch_payload_;
321
322
  }
323
+ bool finished() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { return finished_; }
324
+ void set_finished() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) { finished_ = true; }
325
+ virtual std::string ActiveOpsString() const
326
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) = 0;
322
327
 
323
- Poll<ServerMetadataHandle> PollOnce() {
324
- MutexLock lock(&mu_);
325
- GPR_ASSERT(!finished_);
326
-
328
+ void SchedulePush(grpc_transport_stream_op_batch* batch)
329
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
327
330
  if (grpc_call_trace.enabled()) {
328
- gpr_log(GPR_INFO, "%sPollConnectedChannel: %s",
331
+ gpr_log(GPR_DEBUG, "%s[connected] Push batch to transport: %s",
329
332
  Activity::current()->DebugTag().c_str(),
330
- ActiveOpsString().c_str());
333
+ grpc_transport_stream_op_batch_string(batch).c_str());
331
334
  }
332
-
333
- auto push_recv_message = [this]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
334
- recv_message_state_ = PendingReceiveMessage{};
335
- auto& pending_recv_message =
336
- absl::get<PendingReceiveMessage>(recv_message_state_);
337
- memset(&recv_message_, 0, sizeof(recv_message_));
338
- recv_message_.payload = &batch_payload_;
339
- recv_message_.on_complete = nullptr;
340
- recv_message_.recv_message = true;
341
- batch_payload_.recv_message.recv_message = &pending_recv_message.payload;
342
- batch_payload_.recv_message.flags = &pending_recv_message.flags;
343
- batch_payload_.recv_message.call_failed_before_recv_message = nullptr;
344
- batch_payload_.recv_message.recv_message_ready =
345
- &recv_message_batch_done_;
346
- IncrementRefCount("recv_message");
347
- recv_message_waker_ = Activity::current()->MakeOwningWaker();
348
- push_recv_message_ = true;
349
- SchedulePush();
350
- };
351
-
352
- if (!std::exchange(requested_metadata_, true)) {
353
- if (grpc_call_trace.enabled()) {
354
- gpr_log(GPR_INFO, "%sPollConnectedChannel: requesting metadata",
355
- Activity::current()->DebugTag().c_str());
356
- }
357
- stream_.reset(static_cast<grpc_stream*>(
358
- GetContext<Arena>()->Alloc(transport_->vtable->sizeof_stream)));
359
- grpc_transport_init_stream(transport_, stream_.get(), &stream_refcount_,
360
- nullptr, GetContext<Arena>());
361
- grpc_transport_set_pops(transport_, stream_.get(),
362
- GetContext<CallContext>()->polling_entity());
363
- memset(&metadata_, 0, sizeof(metadata_));
364
- metadata_.send_initial_metadata = true;
365
- metadata_.recv_initial_metadata = true;
366
- metadata_.recv_trailing_metadata = true;
367
- metadata_.payload = &batch_payload_;
368
- metadata_.on_complete = &metadata_batch_done_;
369
- batch_payload_.send_initial_metadata.send_initial_metadata =
370
- client_initial_metadata_.get();
371
- batch_payload_.send_initial_metadata.peer_string =
372
- GetContext<CallContext>()->peer_string_atm_ptr();
373
- server_initial_metadata_ =
374
- GetContext<Arena>()->MakePooled<ServerMetadata>(GetContext<Arena>());
375
- batch_payload_.recv_initial_metadata.recv_initial_metadata =
376
- server_initial_metadata_.get();
377
- batch_payload_.recv_initial_metadata.recv_initial_metadata_ready =
378
- &recv_initial_metadata_ready_;
379
- batch_payload_.recv_initial_metadata.trailing_metadata_available =
380
- nullptr;
381
- batch_payload_.recv_initial_metadata.peer_string = nullptr;
382
- server_trailing_metadata_ =
383
- GetContext<Arena>()->MakePooled<ServerMetadata>(GetContext<Arena>());
384
- batch_payload_.recv_trailing_metadata.recv_trailing_metadata =
385
- server_trailing_metadata_.get();
386
- batch_payload_.recv_trailing_metadata.collect_stats =
387
- &GetContext<CallContext>()->call_stats()->transport_stream_stats;
388
- batch_payload_.recv_trailing_metadata.recv_trailing_metadata_ready =
389
- &recv_trailing_metadata_ready_;
390
- push_metadata_ = true;
391
- IncrementRefCount("metadata_batch_done");
392
- IncrementRefCount("initial_metadata_ready");
393
- IncrementRefCount("trailing_metadata_ready");
394
- initial_metadata_waker_ = Activity::current()->MakeOwningWaker();
395
- trailing_metadata_waker_ = Activity::current()->MakeOwningWaker();
396
- SchedulePush();
335
+ if (push_batches_.empty()) {
336
+ IncrementRefCount("push");
337
+ ExecCtx::Run(DEBUG_LOCATION, &push_, absl::OkStatus());
397
338
  }
339
+ push_batches_.push_back(batch);
340
+ }
341
+
342
+ void PollSendMessage(PipeReceiver<MessageHandle>* outgoing_messages,
343
+ ClientMetadataHandle* client_trailing_metadata)
344
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
398
345
  if (absl::holds_alternative<Closed>(send_message_state_)) {
399
346
  message_to_send_.reset();
400
347
  }
401
348
  if (absl::holds_alternative<Idle>(send_message_state_)) {
402
349
  message_to_send_.reset();
403
- send_message_state_ = client_to_server_messages_->Next();
350
+ send_message_state_.emplace<PipeReceiverNextType<MessageHandle>>(
351
+ outgoing_messages->Next());
404
352
  }
405
- if (auto* next = absl::get_if<PipeReceiver<MessageHandle>::NextType>(
353
+ if (auto* next = absl::get_if<PipeReceiverNextType<MessageHandle>>(
406
354
  &send_message_state_)) {
407
355
  auto r = (*next)();
408
- if (auto* p = absl::get_if<NextResult<MessageHandle>>(&r)) {
356
+ if (auto* p = r.value_if_ready()) {
409
357
  memset(&send_message_, 0, sizeof(send_message_));
410
- send_message_.payload = &batch_payload_;
358
+ send_message_.payload = batch_payload();
411
359
  send_message_.on_complete = &send_message_batch_done_;
412
360
  // No value => half close from above.
413
361
  if (p->has_value()) {
414
- message_to_send_ = std::move(**p);
362
+ message_to_send_ = std::move(*p);
415
363
  send_message_state_ = SendMessageToTransport{};
416
364
  send_message_.send_message = true;
417
- batch_payload_.send_message.send_message =
418
- message_to_send_->payload();
419
- batch_payload_.send_message.flags = message_to_send_->flags();
365
+ batch_payload()->send_message.send_message =
366
+ (*message_to_send_)->payload();
367
+ batch_payload()->send_message.flags = (*message_to_send_)->flags();
420
368
  } else {
421
369
  if (grpc_call_trace.enabled()) {
422
- gpr_log(GPR_INFO, "%sPollConnectedChannel: half close",
370
+ gpr_log(GPR_INFO, "%s[connected] PollConnectedChannel: half close",
423
371
  Activity::current()->DebugTag().c_str());
424
372
  }
425
373
  GPR_ASSERT(!absl::holds_alternative<Closed>(send_message_state_));
426
- client_trailing_metadata_ =
427
- GetContext<Arena>()->MakePooled<ClientMetadata>(
428
- GetContext<Arena>());
429
374
  send_message_state_ = Closed{};
430
375
  send_message_.send_trailing_metadata = true;
431
- batch_payload_.send_trailing_metadata.send_trailing_metadata =
432
- client_trailing_metadata_.get();
433
- batch_payload_.send_trailing_metadata.sent = nullptr;
376
+ if (client_trailing_metadata != nullptr) {
377
+ *client_trailing_metadata =
378
+ GetContext<Arena>()->MakePooled<ClientMetadata>(
379
+ GetContext<Arena>());
380
+ batch_payload()->send_trailing_metadata.send_trailing_metadata =
381
+ client_trailing_metadata->get();
382
+ batch_payload()->send_trailing_metadata.sent = nullptr;
383
+ } else {
384
+ return; // Skip rest of function for server
385
+ }
434
386
  }
435
387
  IncrementRefCount("send_message");
436
388
  send_message_waker_ = Activity::current()->MakeOwningWaker();
437
- push_send_message_ = true;
438
- SchedulePush();
389
+ SchedulePush(&send_message_);
439
390
  }
440
391
  }
392
+ }
393
+
394
+ void PollRecvMessage(PipeSender<MessageHandle>*& incoming_messages)
395
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
441
396
  if (auto* pending =
442
397
  absl::get_if<PendingReceiveMessage>(&recv_message_state_)) {
443
398
  if (pending->received) {
444
399
  if (pending->payload.has_value()) {
445
400
  if (grpc_call_trace.enabled()) {
446
401
  gpr_log(GPR_INFO,
447
- "%sRecvMessageBatchDone: received payload of %" PRIdPTR
448
- " bytes",
402
+ "%s[connected] PollRecvMessage: received payload of "
403
+ "%" PRIdPTR " bytes",
449
404
  recv_message_waker_.ActivityDebugTag().c_str(),
450
405
  pending->payload->Length());
451
406
  }
452
- recv_message_state_ = server_to_client_messages_->Push(
453
- GetContext<Arena>()->MakePooled<Message>(
407
+ recv_message_state_ =
408
+ incoming_messages->Push(GetContext<Arena>()->MakePooled<Message>(
454
409
  std::move(*pending->payload), pending->flags));
455
410
  } else {
456
411
  if (grpc_call_trace.enabled()) {
457
- gpr_log(GPR_INFO, "%sRecvMessageBatchDone: received no payload",
412
+ gpr_log(GPR_INFO,
413
+ "%s[connected] PollRecvMessage: received no payload",
458
414
  recv_message_waker_.ActivityDebugTag().c_str());
459
415
  }
460
416
  recv_message_state_ = Closed{};
461
- std::exchange(server_to_client_messages_, nullptr)->Close();
417
+ std::exchange(incoming_messages, nullptr)->Close();
462
418
  }
463
419
  }
464
420
  }
465
- if (server_initial_metadata_state_ ==
466
- ServerInitialMetadataState::kReceivedButNotSet) {
467
- server_initial_metadata_state_ = ServerInitialMetadataState::kSet;
468
- server_initial_metadata_latch_->Set(server_initial_metadata_.get());
469
- }
470
421
  if (absl::holds_alternative<Idle>(recv_message_state_)) {
471
422
  if (grpc_call_trace.enabled()) {
472
- gpr_log(GPR_INFO, "%sPollConnectedChannel: requesting message",
423
+ gpr_log(GPR_INFO, "%s[connected] PollRecvMessage: requesting message",
473
424
  Activity::current()->DebugTag().c_str());
474
425
  }
475
- push_recv_message();
476
- }
477
- if (server_initial_metadata_state_ == ServerInitialMetadataState::kSet &&
478
- !absl::holds_alternative<PipeSender<MessageHandle>::PushType>(
479
- recv_message_state_) &&
480
- !absl::holds_alternative<PendingReceiveMessage>(recv_message_state_) &&
481
- std::exchange(queued_trailing_metadata_, false)) {
482
- if (grpc_call_trace.enabled()) {
483
- gpr_log(GPR_INFO,
484
- "%sPollConnectedChannel: finished request, returning: {%s}; "
485
- "active_ops: %s",
486
- Activity::current()->DebugTag().c_str(),
487
- server_trailing_metadata_->DebugString().c_str(),
488
- ActiveOpsString().c_str());
489
- }
490
- finished_ = true;
491
- return ServerMetadataHandle(std::move(server_trailing_metadata_));
426
+ PushRecvMessage();
492
427
  }
493
428
  if (auto* push = absl::get_if<PipeSender<MessageHandle>::PushType>(
494
429
  &recv_message_state_)) {
495
430
  auto r = (*push)();
496
- if (bool* result = absl::get_if<bool>(&r)) {
431
+ if (bool* result = r.value_if_ready()) {
497
432
  if (*result) {
498
433
  if (!finished_) {
499
434
  if (grpc_call_trace.enabled()) {
500
435
  gpr_log(GPR_INFO,
501
- "%sPollConnectedChannel: pushed message; requesting next",
436
+ "%s[connected] PollRecvMessage: pushed message; "
437
+ "requesting next",
502
438
  Activity::current()->DebugTag().c_str());
503
439
  }
504
- push_recv_message();
440
+ PushRecvMessage();
505
441
  } else {
506
442
  if (grpc_call_trace.enabled()) {
507
443
  gpr_log(GPR_INFO,
508
- "%sPollConnectedChannel: pushed message and finished; "
444
+ "%s[connected] PollRecvMessage: pushed message "
445
+ "and finished; "
509
446
  "marking closed",
510
447
  Activity::current()->DebugTag().c_str());
511
448
  }
512
449
  recv_message_state_ = Closed{};
450
+ std::exchange(incoming_messages, nullptr)->Close();
513
451
  }
514
452
  } else {
515
453
  if (grpc_call_trace.enabled()) {
516
454
  gpr_log(GPR_INFO,
517
- "%sPollConnectedChannel: failed to push message; marking "
455
+ "%s[connected] PollRecvMessage: failed to push "
456
+ "message; marking "
518
457
  "closed",
519
458
  Activity::current()->DebugTag().c_str());
520
459
  }
521
460
  recv_message_state_ = Closed{};
461
+ std::exchange(incoming_messages, nullptr)->Close();
522
462
  }
523
463
  }
524
464
  }
525
- return Pending{};
526
465
  }
527
466
 
528
- void RecvInitialMetadataReady(grpc_error_handle error) {
529
- GPR_ASSERT(error == absl::OkStatus());
530
- {
531
- MutexLock lock(&mu_);
532
- server_initial_metadata_state_ =
533
- ServerInitialMetadataState::kReceivedButNotSet;
534
- initial_metadata_waker_.Wakeup();
467
+ std::string SendMessageString() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) {
468
+ return Match(
469
+ send_message_state_, [](Idle) -> std::string { return "IDLE"; },
470
+ [](Closed) -> std::string { return "CLOSED"; },
471
+ [](const PipeReceiverNextType<MessageHandle>&) -> std::string {
472
+ return "WAITING";
473
+ },
474
+ [](SendMessageToTransport) -> std::string { return "SENDING"; });
475
+ }
476
+
477
+ std::string RecvMessageString() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) {
478
+ return Match(
479
+ recv_message_state_, [](Idle) -> std::string { return "IDLE"; },
480
+ [](Closed) -> std::string { return "CLOSED"; },
481
+ [](const PendingReceiveMessage&) -> std::string { return "WAITING"; },
482
+ [](const absl::optional<MessageHandle>& message) -> std::string {
483
+ return absl::StrCat(
484
+ "READY:", message.has_value()
485
+ ? absl::StrCat((*message)->payload()->Length(), "b")
486
+ : "EOS");
487
+ },
488
+ [](const PipeSender<MessageHandle>::PushType&) -> std::string {
489
+ return "PUSHING";
490
+ });
491
+ }
492
+
493
+ bool IsPromiseReceiving() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) {
494
+ return absl::holds_alternative<PipeSender<MessageHandle>::PushType>(
495
+ recv_message_state_) ||
496
+ absl::holds_alternative<PendingReceiveMessage>(recv_message_state_);
497
+ }
498
+
499
+ private:
500
+ struct SendMessageToTransport {};
501
+ struct Idle {};
502
+ struct Closed {};
503
+
504
+ class StreamDeleter {
505
+ public:
506
+ explicit StreamDeleter(ConnectedChannelStream* impl) : impl_(impl) {}
507
+ void operator()(grpc_stream* stream) const {
508
+ if (stream == nullptr) return;
509
+ grpc_transport_destroy_stream(impl_->transport(), stream,
510
+ impl_->stream_destroyed_closure());
535
511
  }
536
- Unref("initial_metadata_ready");
512
+
513
+ private:
514
+ ConnectedChannelStream* impl_;
515
+ };
516
+ using StreamPtr = std::unique_ptr<grpc_stream, StreamDeleter>;
517
+
518
+ void StreamDestroyed() {
519
+ call_context_->RunInContext([this] {
520
+ auto* cc = call_context_;
521
+ this->~ConnectedChannelStream();
522
+ cc->Unref("child_stream");
523
+ });
537
524
  }
538
525
 
539
- void RecvTrailingMetadataReady(grpc_error_handle error) {
540
- GPR_ASSERT(error == absl::OkStatus());
541
- {
542
- MutexLock lock(&mu_);
543
- queued_trailing_metadata_ = true;
544
- trailing_metadata_waker_.Wakeup();
526
+ void BeginDestroy() {
527
+ if (stream_ != nullptr) {
528
+ stream_.reset();
529
+ } else {
530
+ StreamDestroyed();
545
531
  }
546
- Unref("trailing_metadata_ready");
547
532
  }
548
533
 
549
- void MetadataBatchDone(grpc_error_handle error) {
550
- GPR_ASSERT(error == absl::OkStatus());
551
- Unref("metadata_batch_done");
534
+ // Called from outside the activity to push work down to the transport.
535
+ void Push() {
536
+ PushBatches push_batches;
537
+ {
538
+ MutexLock lock(&mu_);
539
+ push_batches.swap(push_batches_);
540
+ }
541
+ for (auto* batch : push_batches) {
542
+ if (stream() != nullptr) {
543
+ grpc_transport_perform_stream_op(transport(), stream(), batch);
544
+ } else {
545
+ grpc_transport_stream_op_batch_finish_with_failure_from_transport(
546
+ batch, absl::CancelledError());
547
+ }
548
+ }
549
+ Unref("push");
552
550
  }
553
551
 
554
552
  void SendMessageBatchDone(grpc_error_handle error) {
@@ -571,21 +569,24 @@ class ClientStream : public Orphanable {
571
569
 
572
570
  void RecvMessageBatchDone(grpc_error_handle error) {
573
571
  {
574
- MutexLock lock(&mu_);
572
+ MutexLock lock(mu());
575
573
  if (error != absl::OkStatus()) {
576
574
  if (grpc_call_trace.enabled()) {
577
- gpr_log(GPR_INFO, "%sRecvMessageBatchDone: error=%s",
575
+ gpr_log(GPR_INFO, "%s[connected] RecvMessageBatchDone: error=%s",
578
576
  recv_message_waker_.ActivityDebugTag().c_str(),
579
577
  StatusToString(error).c_str());
580
578
  }
581
579
  } else if (absl::holds_alternative<Closed>(recv_message_state_)) {
582
580
  if (grpc_call_trace.enabled()) {
583
- gpr_log(GPR_INFO, "%sRecvMessageBatchDone: already closed, ignoring",
581
+ gpr_log(GPR_INFO,
582
+ "%s[connected] RecvMessageBatchDone: already closed, "
583
+ "ignoring",
584
584
  recv_message_waker_.ActivityDebugTag().c_str());
585
585
  }
586
586
  } else {
587
587
  if (grpc_call_trace.enabled()) {
588
- gpr_log(GPR_INFO, "%sRecvMessageBatchDone: received message",
588
+ gpr_log(GPR_INFO,
589
+ "%s[connected] RecvMessageBatchDone: received message",
589
590
  recv_message_waker_.ActivityDebugTag().c_str());
590
591
  }
591
592
  auto pending =
@@ -599,95 +600,250 @@ class ClientStream : public Orphanable {
599
600
  Unref("recv_message");
600
601
  }
601
602
 
602
- // Called from outside the activity to push work down to the transport.
603
- void Push() {
604
- auto do_push = [this](grpc_transport_stream_op_batch* batch) {
605
- if (stream_ != nullptr) {
606
- grpc_transport_perform_stream_op(transport_, stream_.get(), batch);
607
- } else {
608
- grpc_transport_stream_op_batch_finish_with_failure_from_transport(
609
- batch, absl::CancelledError());
603
+ void PushRecvMessage() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
604
+ recv_message_state_ = PendingReceiveMessage{};
605
+ auto& pending_recv_message =
606
+ absl::get<PendingReceiveMessage>(recv_message_state_);
607
+ memset(&recv_message_, 0, sizeof(recv_message_));
608
+ recv_message_.payload = batch_payload();
609
+ recv_message_.on_complete = nullptr;
610
+ recv_message_.recv_message = true;
611
+ batch_payload()->recv_message.recv_message = &pending_recv_message.payload;
612
+ batch_payload()->recv_message.flags = &pending_recv_message.flags;
613
+ batch_payload()->recv_message.call_failed_before_recv_message = nullptr;
614
+ batch_payload()->recv_message.recv_message_ready =
615
+ &recv_message_batch_done_;
616
+ IncrementRefCount("recv_message");
617
+ recv_message_waker_ = Activity::current()->MakeOwningWaker();
618
+ SchedulePush(&recv_message_);
619
+ }
620
+
621
+ mutable Mutex mu_;
622
+ grpc_transport* const transport_;
623
+ CallContext* const call_context_{GetContext<CallContext>()};
624
+ grpc_closure stream_destroyed_ =
625
+ MakeMemberClosure<ConnectedChannelStream,
626
+ &ConnectedChannelStream::StreamDestroyed>(
627
+ this, DEBUG_LOCATION);
628
+ grpc_stream_refcount stream_refcount_;
629
+ StreamPtr stream_;
630
+ using PushBatches = absl::InlinedVector<grpc_transport_stream_op_batch*, 3>;
631
+ PushBatches push_batches_ ABSL_GUARDED_BY(mu_);
632
+ grpc_closure push_ =
633
+ MakeMemberClosure<ConnectedChannelStream, &ConnectedChannelStream::Push>(
634
+ this, DEBUG_LOCATION);
635
+
636
+ NextResult<MessageHandle> message_to_send_ ABSL_GUARDED_BY(mu_);
637
+ absl::variant<Idle, Closed, PipeReceiverNextType<MessageHandle>,
638
+ SendMessageToTransport>
639
+ send_message_state_ ABSL_GUARDED_BY(mu_);
640
+ grpc_transport_stream_op_batch send_message_;
641
+ grpc_closure send_message_batch_done_ =
642
+ MakeMemberClosure<ConnectedChannelStream,
643
+ &ConnectedChannelStream::SendMessageBatchDone>(
644
+ this, DEBUG_LOCATION);
645
+
646
+ struct PendingReceiveMessage {
647
+ absl::optional<SliceBuffer> payload;
648
+ uint32_t flags;
649
+ bool received = false;
650
+ };
651
+ absl::variant<Idle, PendingReceiveMessage, Closed,
652
+ PipeSender<MessageHandle>::PushType>
653
+ recv_message_state_ ABSL_GUARDED_BY(mu_);
654
+ grpc_closure recv_message_batch_done_ =
655
+ MakeMemberClosure<ConnectedChannelStream,
656
+ &ConnectedChannelStream::RecvMessageBatchDone>(
657
+ this, DEBUG_LOCATION);
658
+ grpc_transport_stream_op_batch recv_message_;
659
+
660
+ Waker send_message_waker_ ABSL_GUARDED_BY(mu_);
661
+ Waker recv_message_waker_ ABSL_GUARDED_BY(mu_);
662
+ bool finished_ ABSL_GUARDED_BY(mu_) = false;
663
+
664
+ grpc_transport_stream_op_batch_payload batch_payload_{
665
+ GetContext<grpc_call_context_element>()};
666
+ };
667
+ #endif
668
+
669
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_CLIENT_CALL
670
+ class ClientStream : public ConnectedChannelStream {
671
+ public:
672
+ ClientStream(grpc_transport* transport, CallArgs call_args)
673
+ : ConnectedChannelStream(transport),
674
+ server_initial_metadata_pipe_(call_args.server_initial_metadata),
675
+ client_to_server_messages_(call_args.client_to_server_messages),
676
+ server_to_client_messages_(call_args.server_to_client_messages),
677
+ client_initial_metadata_(std::move(call_args.client_initial_metadata)) {
678
+ if (grpc_call_trace.enabled()) {
679
+ gpr_log(GPR_INFO, "%s[connected] InitImpl: intitial_metadata=%s",
680
+ Activity::current()->DebugTag().c_str(),
681
+ client_initial_metadata_->DebugString().c_str());
682
+ }
683
+ }
684
+
685
+ Poll<ServerMetadataHandle> PollOnce() {
686
+ MutexLock lock(mu());
687
+ GPR_ASSERT(!finished());
688
+
689
+ if (grpc_call_trace.enabled()) {
690
+ gpr_log(GPR_INFO, "%s[connected] PollConnectedChannel: %s",
691
+ Activity::current()->DebugTag().c_str(),
692
+ ActiveOpsString().c_str());
693
+ }
694
+
695
+ if (!std::exchange(requested_metadata_, true)) {
696
+ if (grpc_call_trace.enabled()) {
697
+ gpr_log(GPR_INFO,
698
+ "%s[connected] PollConnectedChannel: requesting metadata",
699
+ Activity::current()->DebugTag().c_str());
610
700
  }
611
- };
612
- bool push_metadata;
613
- bool push_send_message;
614
- bool push_recv_message;
701
+ SetStream(static_cast<grpc_stream*>(
702
+ GetContext<Arena>()->Alloc(transport()->vtable->sizeof_stream)));
703
+ grpc_transport_init_stream(transport(), stream(), stream_refcount(),
704
+ nullptr, GetContext<Arena>());
705
+ grpc_transport_set_pops(transport(), stream(),
706
+ GetContext<CallContext>()->polling_entity());
707
+ memset(&metadata_, 0, sizeof(metadata_));
708
+ metadata_.send_initial_metadata = true;
709
+ metadata_.recv_initial_metadata = true;
710
+ metadata_.recv_trailing_metadata = true;
711
+ metadata_.payload = batch_payload();
712
+ metadata_.on_complete = &metadata_batch_done_;
713
+ batch_payload()->send_initial_metadata.send_initial_metadata =
714
+ client_initial_metadata_.get();
715
+ batch_payload()->send_initial_metadata.peer_string =
716
+ GetContext<CallContext>()->peer_string_atm_ptr();
717
+ server_initial_metadata_ =
718
+ GetContext<Arena>()->MakePooled<ServerMetadata>(GetContext<Arena>());
719
+ batch_payload()->recv_initial_metadata.recv_initial_metadata =
720
+ server_initial_metadata_.get();
721
+ batch_payload()->recv_initial_metadata.recv_initial_metadata_ready =
722
+ &recv_initial_metadata_ready_;
723
+ batch_payload()->recv_initial_metadata.trailing_metadata_available =
724
+ nullptr;
725
+ batch_payload()->recv_initial_metadata.peer_string = nullptr;
726
+ server_trailing_metadata_ =
727
+ GetContext<Arena>()->MakePooled<ServerMetadata>(GetContext<Arena>());
728
+ batch_payload()->recv_trailing_metadata.recv_trailing_metadata =
729
+ server_trailing_metadata_.get();
730
+ batch_payload()->recv_trailing_metadata.collect_stats =
731
+ &GetContext<CallContext>()->call_stats()->transport_stream_stats;
732
+ batch_payload()->recv_trailing_metadata.recv_trailing_metadata_ready =
733
+ &recv_trailing_metadata_ready_;
734
+ IncrementRefCount("metadata_batch_done");
735
+ IncrementRefCount("initial_metadata_ready");
736
+ IncrementRefCount("trailing_metadata_ready");
737
+ initial_metadata_waker_ = Activity::current()->MakeOwningWaker();
738
+ trailing_metadata_waker_ = Activity::current()->MakeOwningWaker();
739
+ SchedulePush(&metadata_);
740
+ }
741
+ if (server_initial_metadata_state_ ==
742
+ ServerInitialMetadataState::kReceivedButNotPushed) {
743
+ server_initial_metadata_state_ = ServerInitialMetadataState::kPushing;
744
+ server_initial_metadata_push_promise_ =
745
+ server_initial_metadata_pipe_->Push(
746
+ std::move(server_initial_metadata_));
747
+ }
748
+ if (server_initial_metadata_state_ ==
749
+ ServerInitialMetadataState::kPushing) {
750
+ auto r = (*server_initial_metadata_push_promise_)();
751
+ if (r.ready()) {
752
+ server_initial_metadata_state_ = ServerInitialMetadataState::kPushed;
753
+ server_initial_metadata_push_promise_.reset();
754
+ }
755
+ }
756
+ PollSendMessage(client_to_server_messages_, &client_trailing_metadata_);
757
+ PollRecvMessage(server_to_client_messages_);
758
+ if (server_initial_metadata_state_ == ServerInitialMetadataState::kPushed &&
759
+ !IsPromiseReceiving() &&
760
+ std::exchange(queued_trailing_metadata_, false)) {
761
+ if (grpc_call_trace.enabled()) {
762
+ gpr_log(GPR_INFO,
763
+ "%s[connected] PollConnectedChannel: finished request, "
764
+ "returning: {%s}; "
765
+ "active_ops: %s",
766
+ Activity::current()->DebugTag().c_str(),
767
+ server_trailing_metadata_->DebugString().c_str(),
768
+ ActiveOpsString().c_str());
769
+ }
770
+ set_finished();
771
+ return ServerMetadataHandle(std::move(server_trailing_metadata_));
772
+ }
773
+ return Pending{};
774
+ }
775
+
776
+ void RecvInitialMetadataReady(grpc_error_handle error) {
777
+ GPR_ASSERT(error == absl::OkStatus());
615
778
  {
616
- MutexLock lock(&mu_);
617
- push_metadata = std::exchange(push_metadata_, false);
618
- push_send_message = std::exchange(push_send_message_, false);
619
- push_recv_message = std::exchange(push_recv_message_, false);
620
- scheduled_push_ = false;
621
- }
622
- if (push_metadata) do_push(&metadata_);
623
- if (push_send_message) do_push(&send_message_);
624
- if (push_recv_message) do_push(&recv_message_);
625
- Unref("push");
779
+ MutexLock lock(mu());
780
+ server_initial_metadata_state_ =
781
+ ServerInitialMetadataState::kReceivedButNotPushed;
782
+ initial_metadata_waker_.Wakeup();
783
+ }
784
+ Unref("initial_metadata_ready");
626
785
  }
627
786
 
628
- void StreamDestroyed() {
629
- call_context_->RunInContext([this] {
630
- auto* cc = call_context_;
631
- this->~ClientStream();
632
- cc->Unref("child_stream");
633
- });
787
+ void RecvTrailingMetadataReady(grpc_error_handle error) {
788
+ GPR_ASSERT(error == absl::OkStatus());
789
+ {
790
+ MutexLock lock(mu());
791
+ queued_trailing_metadata_ = true;
792
+ if (grpc_call_trace.enabled()) {
793
+ gpr_log(GPR_DEBUG,
794
+ "%s[connected] RecvTrailingMetadataReady: "
795
+ "queued_trailing_metadata_ "
796
+ "set to true; active_ops: %s",
797
+ trailing_metadata_waker_.ActivityDebugTag().c_str(),
798
+ ActiveOpsString().c_str());
799
+ }
800
+ trailing_metadata_waker_.Wakeup();
801
+ }
802
+ Unref("trailing_metadata_ready");
634
803
  }
635
804
 
636
- private:
637
- struct Idle {};
638
- struct Closed {};
639
- struct SendMessageToTransport {};
805
+ void MetadataBatchDone(grpc_error_handle error) {
806
+ GPR_ASSERT(error == absl::OkStatus());
807
+ Unref("metadata_batch_done");
808
+ }
640
809
 
810
+ private:
641
811
  enum class ServerInitialMetadataState : uint8_t {
642
812
  // Initial metadata has not been received from the server.
643
813
  kNotReceived,
644
814
  // Initial metadata has been received from the server via the transport, but
645
- // has not yet been set on the latch to publish it up the call stack.
646
- kReceivedButNotSet,
815
+ // has not yet been pushed onto the pipe to publish it up the call stack.
816
+ kReceivedButNotPushed,
647
817
  // Initial metadata has been received from the server via the transport and
648
- // has been set on the latch to publish it up the call stack.
649
- kSet,
650
- };
651
-
652
- class StreamDeleter {
653
- public:
654
- explicit StreamDeleter(ClientStream* impl) : impl_(impl) {}
655
- void operator()(grpc_stream* stream) const {
656
- if (stream == nullptr) return;
657
- grpc_transport_destroy_stream(impl_->transport_, stream,
658
- &impl_->stream_destroyed_);
659
- }
660
-
661
- private:
662
- ClientStream* impl_;
818
+ // has been pushed on the pipe to publish it up the call stack.
819
+ // It's still in the pipe and has not been removed by the call at the top
820
+ // yet.
821
+ kPushing,
822
+ // Initial metadata has been received from the server via the transport and
823
+ // has been pushed on the pipe to publish it up the call stack AND removed
824
+ // by the call at the top.
825
+ kPushed,
663
826
  };
664
- using StreamPtr = std::unique_ptr<grpc_stream, StreamDeleter>;
665
-
666
- void SchedulePush() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
667
- if (std::exchange(scheduled_push_, true)) return;
668
- IncrementRefCount("push");
669
- ExecCtx::Run(DEBUG_LOCATION, &push_, absl::OkStatus());
670
- }
671
827
 
672
- std::string ActiveOpsString() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
828
+ std::string ActiveOpsString() const override
829
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) {
673
830
  std::vector<std::string> ops;
674
- if (finished_) ops.push_back("FINISHED");
675
- // Pushes
676
- std::vector<std::string> pushes;
677
- if (push_metadata_) pushes.push_back("metadata");
678
- if (push_send_message_) pushes.push_back("send_message");
679
- if (push_recv_message_) pushes.push_back("recv_message");
680
- if (!pushes.empty()) {
681
- ops.push_back(
682
- absl::StrCat(scheduled_push_ ? "push:" : "unscheduled-push:",
683
- absl::StrJoin(pushes, ",")));
684
- } else if (scheduled_push_) {
685
- ops.push_back("push:nothing");
831
+ if (finished()) ops.push_back("FINISHED");
832
+ // Outstanding Operations on Transport
833
+ std::vector<std::string> waiting;
834
+ if (initial_metadata_waker_ != Waker()) {
835
+ waiting.push_back("initial_metadata");
836
+ }
837
+ if (trailing_metadata_waker_ != Waker()) {
838
+ waiting.push_back("trailing_metadata");
839
+ }
840
+ if (!waiting.empty()) {
841
+ ops.push_back(absl::StrCat("waiting:", absl::StrJoin(waiting, ",")));
686
842
  }
687
843
  // Results from transport
688
844
  std::vector<std::string> queued;
689
845
  if (server_initial_metadata_state_ ==
690
- ServerInitialMetadataState::kReceivedButNotSet) {
846
+ ServerInitialMetadataState::kReceivedButNotPushed) {
691
847
  queued.push_back("initial_metadata");
692
848
  }
693
849
  if (queued_trailing_metadata_) queued.push_back("trailing_metadata");
@@ -707,94 +863,31 @@ class ClientStream : public Orphanable {
707
863
  return absl::StrJoin(ops, " ");
708
864
  }
709
865
 
710
- std::string SendMessageString() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
711
- return Match(
712
- send_message_state_, [](Idle) -> std::string { return "IDLE"; },
713
- [](Closed) -> std::string { return "CLOSED"; },
714
- [](const PipeReceiver<MessageHandle>::NextType&) -> std::string {
715
- return "WAITING";
716
- },
717
- [](SendMessageToTransport) -> std::string { return "SENDING"; });
718
- }
719
-
720
- std::string RecvMessageString() const ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
721
- return Match(
722
- recv_message_state_, [](Idle) -> std::string { return "IDLE"; },
723
- [](Closed) -> std::string { return "CLOSED"; },
724
- [](const PendingReceiveMessage&) -> std::string { return "WAITING"; },
725
- [](const absl::optional<MessageHandle>& message) -> std::string {
726
- return absl::StrCat(
727
- "READY:", message.has_value()
728
- ? absl::StrCat((*message)->payload()->Length(), "b")
729
- : "EOS");
730
- },
731
- [](const PipeSender<MessageHandle>::PushType&) -> std::string {
732
- return "PUSHING";
733
- });
734
- }
735
-
736
- Mutex mu_;
737
866
  bool requested_metadata_ = false;
738
- bool push_metadata_ ABSL_GUARDED_BY(mu_) = false;
739
- bool push_send_message_ ABSL_GUARDED_BY(mu_) = false;
740
- bool push_recv_message_ ABSL_GUARDED_BY(mu_) = false;
741
- bool scheduled_push_ ABSL_GUARDED_BY(mu_) = false;
742
867
  ServerInitialMetadataState server_initial_metadata_state_
743
- ABSL_GUARDED_BY(mu_) = ServerInitialMetadataState::kNotReceived;
744
- bool queued_trailing_metadata_ ABSL_GUARDED_BY(mu_) = false;
745
- bool finished_ ABSL_GUARDED_BY(mu_) = false;
746
- CallContext* const call_context_{GetContext<CallContext>()};
747
- Waker initial_metadata_waker_ ABSL_GUARDED_BY(mu_);
748
- Waker trailing_metadata_waker_ ABSL_GUARDED_BY(mu_);
749
- Waker send_message_waker_ ABSL_GUARDED_BY(mu_);
750
- Waker recv_message_waker_ ABSL_GUARDED_BY(mu_);
751
- grpc_transport* const transport_;
752
- grpc_stream_refcount stream_refcount_;
753
- StreamPtr stream_;
754
- Latch<ServerMetadata*>* server_initial_metadata_latch_;
868
+ ABSL_GUARDED_BY(mu()) = ServerInitialMetadataState::kNotReceived;
869
+ bool queued_trailing_metadata_ ABSL_GUARDED_BY(mu()) = false;
870
+ Waker initial_metadata_waker_ ABSL_GUARDED_BY(mu());
871
+ Waker trailing_metadata_waker_ ABSL_GUARDED_BY(mu());
872
+ PipeSender<ServerMetadataHandle>* server_initial_metadata_pipe_;
755
873
  PipeReceiver<MessageHandle>* client_to_server_messages_;
756
874
  PipeSender<MessageHandle>* server_to_client_messages_;
757
- MessageHandle message_to_send_ ABSL_GUARDED_BY(mu_);
758
- absl::variant<Idle, Closed, PipeReceiver<MessageHandle>::NextType,
759
- SendMessageToTransport>
760
- send_message_state_ ABSL_GUARDED_BY(mu_);
761
- struct PendingReceiveMessage {
762
- absl::optional<SliceBuffer> payload;
763
- uint32_t flags;
764
- bool received = false;
765
- };
766
- absl::variant<Idle, PendingReceiveMessage, Closed,
767
- PipeSender<MessageHandle>::PushType>
768
- recv_message_state_ ABSL_GUARDED_BY(mu_);
769
875
  grpc_closure recv_initial_metadata_ready_ =
770
876
  MakeMemberClosure<ClientStream, &ClientStream::RecvInitialMetadataReady>(
771
877
  this, DEBUG_LOCATION);
772
878
  grpc_closure recv_trailing_metadata_ready_ =
773
879
  MakeMemberClosure<ClientStream, &ClientStream::RecvTrailingMetadataReady>(
774
880
  this, DEBUG_LOCATION);
775
- grpc_closure push_ = MakeMemberClosure<ClientStream, &ClientStream::Push>(
776
- this, DEBUG_LOCATION);
777
881
  ClientMetadataHandle client_initial_metadata_;
778
882
  ClientMetadataHandle client_trailing_metadata_;
779
883
  ServerMetadataHandle server_initial_metadata_;
780
884
  ServerMetadataHandle server_trailing_metadata_;
885
+ absl::optional<PipeSender<ServerMetadataHandle>::PushType>
886
+ server_initial_metadata_push_promise_;
781
887
  grpc_transport_stream_op_batch metadata_;
782
888
  grpc_closure metadata_batch_done_ =
783
889
  MakeMemberClosure<ClientStream, &ClientStream::MetadataBatchDone>(
784
890
  this, DEBUG_LOCATION);
785
- grpc_transport_stream_op_batch send_message_;
786
- grpc_closure send_message_batch_done_ =
787
- MakeMemberClosure<ClientStream, &ClientStream::SendMessageBatchDone>(
788
- this, DEBUG_LOCATION);
789
- grpc_closure recv_message_batch_done_ =
790
- MakeMemberClosure<ClientStream, &ClientStream::RecvMessageBatchDone>(
791
- this, DEBUG_LOCATION);
792
- grpc_transport_stream_op_batch recv_message_;
793
- grpc_transport_stream_op_batch_payload batch_payload_{
794
- GetContext<grpc_call_context_element>()};
795
- grpc_closure stream_destroyed_ =
796
- MakeMemberClosure<ClientStream, &ClientStream::StreamDestroyed>(
797
- this, DEBUG_LOCATION);
798
891
  };
799
892
 
800
893
  class ClientConnectedCallPromise {
@@ -815,7 +908,8 @@ class ClientConnectedCallPromise {
815
908
  }
816
909
 
817
910
  static ArenaPromise<ServerMetadataHandle> Make(grpc_transport* transport,
818
- CallArgs call_args) {
911
+ CallArgs call_args,
912
+ NextPromiseFactory) {
819
913
  return ClientConnectedCallPromise(transport, std::move(call_args));
820
914
  }
821
915
 
@@ -824,9 +918,434 @@ class ClientConnectedCallPromise {
824
918
  private:
825
919
  OrphanablePtr<ClientStream> impl_;
826
920
  };
921
+ #endif
922
+
923
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_SERVER_CALL
924
+ class ServerStream final : public ConnectedChannelStream {
925
+ public:
926
+ ServerStream(grpc_transport* transport,
927
+ NextPromiseFactory next_promise_factory)
928
+ : ConnectedChannelStream(transport) {
929
+ SetStream(static_cast<grpc_stream*>(
930
+ GetContext<Arena>()->Alloc(transport->vtable->sizeof_stream)));
931
+ grpc_transport_init_stream(
932
+ transport, stream(), stream_refcount(),
933
+ GetContext<CallContext>()->server_call_context()->server_stream_data(),
934
+ GetContext<Arena>());
935
+ grpc_transport_set_pops(transport, stream(),
936
+ GetContext<CallContext>()->polling_entity());
937
+
938
+ // Fetch initial metadata
939
+ auto& gim = call_state_.emplace<GettingInitialMetadata>(this);
940
+ gim.recv_initial_metadata_ready_waker =
941
+ Activity::current()->MakeOwningWaker();
942
+ memset(&gim.recv_initial_metadata, 0, sizeof(gim.recv_initial_metadata));
943
+ gim.recv_initial_metadata.payload = batch_payload();
944
+ gim.recv_initial_metadata.on_complete = nullptr;
945
+ gim.recv_initial_metadata.recv_initial_metadata = true;
946
+ gim.next_promise_factory = std::move(next_promise_factory);
947
+ batch_payload()->recv_initial_metadata.recv_initial_metadata =
948
+ gim.client_initial_metadata.get();
949
+ batch_payload()->recv_initial_metadata.recv_initial_metadata_ready =
950
+ &gim.recv_initial_metadata_ready;
951
+ SchedulePush(&gim.recv_initial_metadata);
952
+
953
+ // Fetch trailing metadata (to catch cancellations)
954
+ auto& gtm =
955
+ client_trailing_metadata_state_.emplace<WaitingForTrailingMetadata>();
956
+ gtm.recv_trailing_metadata_ready =
957
+ MakeMemberClosure<ServerStream,
958
+ &ServerStream::RecvTrailingMetadataReady>(this);
959
+ memset(&gtm.recv_trailing_metadata, 0, sizeof(gtm.recv_trailing_metadata));
960
+ gtm.recv_trailing_metadata.payload = batch_payload();
961
+ gtm.recv_trailing_metadata.recv_trailing_metadata = true;
962
+ batch_payload()->recv_trailing_metadata.recv_trailing_metadata =
963
+ gtm.result.get();
964
+ batch_payload()->recv_trailing_metadata.collect_stats =
965
+ &GetContext<CallContext>()->call_stats()->transport_stream_stats;
966
+ batch_payload()->recv_trailing_metadata.recv_trailing_metadata_ready =
967
+ &gtm.recv_trailing_metadata_ready;
968
+ SchedulePush(&gtm.recv_trailing_metadata);
969
+ gtm.waker = Activity::current()->MakeOwningWaker();
970
+ }
971
+
972
+ Poll<ServerMetadataHandle> PollOnce() {
973
+ MutexLock lock(mu());
974
+
975
+ auto poll_send_initial_metadata = [this]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(
976
+ mu()) {
977
+ if (auto* promise =
978
+ absl::get_if<PipeReceiverNextType<ServerMetadataHandle>>(
979
+ &server_initial_metadata_)) {
980
+ auto r = (*promise)();
981
+ if (auto* md = r.value_if_ready()) {
982
+ if (grpc_call_trace.enabled()) {
983
+ gpr_log(
984
+ GPR_INFO, "%s[connected] got initial metadata %s",
985
+ Activity::current()->DebugTag().c_str(),
986
+ (md->has_value() ? (**md)->DebugString() : "<trailers-only>")
987
+ .c_str());
988
+ }
989
+ memset(&send_initial_metadata_, 0, sizeof(send_initial_metadata_));
990
+ send_initial_metadata_.send_initial_metadata = true;
991
+ send_initial_metadata_.payload = batch_payload();
992
+ send_initial_metadata_.on_complete = &send_initial_metadata_done_;
993
+ batch_payload()->send_initial_metadata.send_initial_metadata =
994
+ server_initial_metadata_
995
+ .emplace<ServerMetadataHandle>(std::move(**md))
996
+ .get();
997
+ batch_payload()->send_initial_metadata.peer_string = nullptr;
998
+ SchedulePush(&send_initial_metadata_);
999
+ return true;
1000
+ } else {
1001
+ return false;
1002
+ }
1003
+ } else {
1004
+ return true;
1005
+ }
1006
+ };
1007
+
1008
+ if (grpc_call_trace.enabled()) {
1009
+ gpr_log(GPR_INFO, "%s[connected] PollConnectedChannel: %s",
1010
+ Activity::current()->DebugTag().c_str(),
1011
+ ActiveOpsString().c_str());
1012
+ }
1013
+
1014
+ poll_send_initial_metadata();
1015
+
1016
+ if (auto* p = absl::get_if<GotClientHalfClose>(
1017
+ &client_trailing_metadata_state_)) {
1018
+ pipes_.client_to_server.sender.Close();
1019
+ if (!p->result.ok()) {
1020
+ // client cancelled, we should cancel too
1021
+ if (absl::holds_alternative<absl::monostate>(call_state_) ||
1022
+ absl::holds_alternative<GotInitialMetadata>(call_state_) ||
1023
+ absl::holds_alternative<MessageLoop>(call_state_)) {
1024
+ if (!absl::holds_alternative<ServerMetadataHandle>(
1025
+ server_initial_metadata_)) {
1026
+ // pretend we've sent initial metadata to stop that op from
1027
+ // progressing if it's stuck somewhere above us in the stack
1028
+ server_initial_metadata_.emplace<ServerMetadataHandle>();
1029
+ }
1030
+ // cancel the call - this status will be returned to the server bottom
1031
+ // promise
1032
+ call_state_.emplace<Complete>(
1033
+ Complete{ServerMetadataFromStatus(p->result)});
1034
+ }
1035
+ }
1036
+ }
1037
+
1038
+ if (auto* p = absl::get_if<GotInitialMetadata>(&call_state_)) {
1039
+ incoming_messages_ = &pipes_.client_to_server.sender;
1040
+ auto promise = p->next_promise_factory(CallArgs{
1041
+ std::move(p->client_initial_metadata),
1042
+ &pipes_.server_initial_metadata.sender,
1043
+ &pipes_.client_to_server.receiver, &pipes_.server_to_client.sender});
1044
+ call_state_.emplace<MessageLoop>(
1045
+ MessageLoop{&pipes_.server_to_client.receiver, std::move(promise)});
1046
+ server_initial_metadata_
1047
+ .emplace<PipeReceiverNextType<ServerMetadataHandle>>(
1048
+ pipes_.server_initial_metadata.receiver.Next());
1049
+ }
1050
+ if (incoming_messages_ != nullptr) {
1051
+ PollRecvMessage(incoming_messages_);
1052
+ }
1053
+ if (auto* p = absl::get_if<MessageLoop>(&call_state_)) {
1054
+ if (absl::holds_alternative<ServerMetadataHandle>(
1055
+ server_initial_metadata_)) {
1056
+ PollSendMessage(p->outgoing_messages, nullptr);
1057
+ }
1058
+ auto poll = p->promise();
1059
+ if (auto* r = poll.value_if_ready()) {
1060
+ if (grpc_call_trace.enabled()) {
1061
+ gpr_log(GPR_INFO, "%s[connected] got trailing metadata %s; %s",
1062
+ Activity::current()->DebugTag().c_str(),
1063
+ (*r)->DebugString().c_str(), ActiveOpsString().c_str());
1064
+ }
1065
+ auto& completing = call_state_.emplace<Completing>();
1066
+ completing.server_trailing_metadata = std::move(*r);
1067
+ completing.on_complete =
1068
+ MakeMemberClosure<ServerStream,
1069
+ &ServerStream::SendTrailingMetadataDone>(this);
1070
+ completing.waker = Activity::current()->MakeOwningWaker();
1071
+ auto& op = completing.send_trailing_metadata;
1072
+ memset(&op, 0, sizeof(op));
1073
+ op.payload = batch_payload();
1074
+ op.on_complete = &completing.on_complete;
1075
+ // If we've gotten initial server metadata, we can send trailing
1076
+ // metadata.
1077
+ // Otherwise we need to cancel the call.
1078
+ // There could be an unlucky ordering, so we poll here to make sure.
1079
+ if (poll_send_initial_metadata()) {
1080
+ op.send_trailing_metadata = true;
1081
+ batch_payload()->send_trailing_metadata.send_trailing_metadata =
1082
+ completing.server_trailing_metadata.get();
1083
+ batch_payload()->send_trailing_metadata.sent = &completing.sent;
1084
+ } else {
1085
+ op.cancel_stream = true;
1086
+ const auto status_code =
1087
+ completing.server_trailing_metadata->get(GrpcStatusMetadata())
1088
+ .value_or(GRPC_STATUS_UNKNOWN);
1089
+ batch_payload()->cancel_stream.cancel_error = grpc_error_set_int(
1090
+ absl::Status(static_cast<absl::StatusCode>(status_code),
1091
+ completing.server_trailing_metadata
1092
+ ->GetOrCreatePointer(GrpcMessageMetadata())
1093
+ ->as_string_view()),
1094
+ StatusIntProperty::kRpcStatus, status_code);
1095
+ }
1096
+ SchedulePush(&op);
1097
+ }
1098
+ }
1099
+ if (auto* p = absl::get_if<Complete>(&call_state_)) {
1100
+ set_finished();
1101
+ return std::move(p->result);
1102
+ }
1103
+ return Pending{};
1104
+ }
1105
+
1106
+ private:
1107
+ // Call state: we've asked the transport for initial metadata and are
1108
+ // waiting for it before proceeding.
1109
+ struct GettingInitialMetadata {
1110
+ explicit GettingInitialMetadata(ServerStream* stream)
1111
+ : recv_initial_metadata_ready(
1112
+ MakeMemberClosure<ServerStream,
1113
+ &ServerStream::RecvInitialMetadataReady>(
1114
+ stream)) {}
1115
+ // The batch we're using to get initial metadata.
1116
+ grpc_transport_stream_op_batch recv_initial_metadata;
1117
+ // Waker to re-enter the activity once the transport returns.
1118
+ Waker recv_initial_metadata_ready_waker;
1119
+ // Initial metadata storage for the transport.
1120
+ ClientMetadataHandle client_initial_metadata =
1121
+ GetContext<Arena>()->MakePooled<ClientMetadata>(GetContext<Arena>());
1122
+ // Closure for the transport to call when it's ready.
1123
+ grpc_closure recv_initial_metadata_ready;
1124
+ // Next promise factory to use once we have initial metadata.
1125
+ NextPromiseFactory next_promise_factory;
1126
+ };
1127
+
1128
+ // Call state: transport has returned initial metadata, we're waiting to
1129
+ // re-enter the activity to process it.
1130
+ struct GotInitialMetadata {
1131
+ ClientMetadataHandle client_initial_metadata;
1132
+ NextPromiseFactory next_promise_factory;
1133
+ };
1134
+
1135
+ // Call state: we're sending/receiving messages and processing the filter
1136
+ // stack.
1137
+ struct MessageLoop {
1138
+ PipeReceiver<MessageHandle>* outgoing_messages;
1139
+ ArenaPromise<ServerMetadataHandle> promise;
1140
+ };
1141
+
1142
+ // Call state: promise stack has returned trailing metadata, we're sending it
1143
+ // to the transport to communicate.
1144
+ struct Completing {
1145
+ ServerMetadataHandle server_trailing_metadata;
1146
+ grpc_transport_stream_op_batch send_trailing_metadata;
1147
+ grpc_closure on_complete;
1148
+ bool sent = false;
1149
+ Waker waker;
1150
+ };
1151
+
1152
+ // Call state: server metadata has been communicated to the transport and sent
1153
+ // to the client.
1154
+ // The metadata will be returned down to the server call to tick the
1155
+ // cancellation bit or not on the originating batch.
1156
+ struct Complete {
1157
+ ServerMetadataHandle result;
1158
+ };
1159
+
1160
+ // Trailing metadata state: we've asked the transport for trailing metadata
1161
+ // and are waiting for it before proceeding.
1162
+ struct WaitingForTrailingMetadata {
1163
+ ClientMetadataHandle result =
1164
+ GetContext<Arena>()->MakePooled<ClientMetadata>(GetContext<Arena>());
1165
+ grpc_transport_stream_op_batch recv_trailing_metadata;
1166
+ grpc_closure recv_trailing_metadata_ready;
1167
+ Waker waker;
1168
+ };
1169
+
1170
+ // We've received trailing metadata from the transport - which indicates reads
1171
+ // are closed.
1172
+ // We convert to an absl::Status here and use that to drive a decision to
1173
+ // cancel the call (on error) or not.
1174
+ struct GotClientHalfClose {
1175
+ absl::Status result;
1176
+ };
1177
+
1178
+ void RecvInitialMetadataReady(absl::Status status) {
1179
+ MutexLock lock(mu());
1180
+ auto& getting = absl::get<GettingInitialMetadata>(call_state_);
1181
+ auto waker = std::move(getting.recv_initial_metadata_ready_waker);
1182
+ if (grpc_call_trace.enabled()) {
1183
+ gpr_log(GPR_DEBUG, "%sGOT INITIAL METADATA: err=%s %s",
1184
+ waker.ActivityDebugTag().c_str(), status.ToString().c_str(),
1185
+ getting.client_initial_metadata->DebugString().c_str());
1186
+ }
1187
+ GotInitialMetadata got{std::move(getting.client_initial_metadata),
1188
+ std::move(getting.next_promise_factory)};
1189
+ call_state_.emplace<GotInitialMetadata>(std::move(got));
1190
+ waker.Wakeup();
1191
+ }
1192
+
1193
+ void SendTrailingMetadataDone(absl::Status result) {
1194
+ MutexLock lock(mu());
1195
+ auto& completing = absl::get<Completing>(call_state_);
1196
+ auto md = std::move(completing.server_trailing_metadata);
1197
+ auto waker = std::move(completing.waker);
1198
+ if (grpc_call_trace.enabled()) {
1199
+ gpr_log(GPR_DEBUG, "%sSEND TRAILING METADATA DONE: err=%s sent=%s %s",
1200
+ waker.ActivityDebugTag().c_str(), result.ToString().c_str(),
1201
+ completing.sent ? "true" : "false", md->DebugString().c_str());
1202
+ }
1203
+ md->Set(GrpcStatusFromWire(), completing.sent);
1204
+ if (!result.ok()) {
1205
+ md->Clear();
1206
+ md->Set(GrpcStatusMetadata(),
1207
+ static_cast<grpc_status_code>(result.code()));
1208
+ md->Set(GrpcMessageMetadata(), Slice::FromCopiedString(result.message()));
1209
+ md->Set(GrpcStatusFromWire(), false);
1210
+ }
1211
+ call_state_.emplace<Complete>(Complete{std::move(md)});
1212
+ waker.Wakeup();
1213
+ }
1214
+
1215
+ std::string ActiveOpsString() const override
1216
+ ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) {
1217
+ std::vector<std::string> ops;
1218
+ ops.push_back(absl::StrCat(
1219
+ "call_state:",
1220
+ Match(
1221
+ call_state_,
1222
+ [](const absl::monostate&) { return "absl::monostate"; },
1223
+ [](const GettingInitialMetadata&) { return "GETTING"; },
1224
+ [](const GotInitialMetadata&) { return "GOT"; },
1225
+ [](const MessageLoop&) { return "RUNNING"; },
1226
+ [](const Completing&) { return "COMPLETING"; },
1227
+ [](const Complete&) { return "COMPLETE"; })));
1228
+ ops.push_back(
1229
+ absl::StrCat("client_trailing_metadata_state:",
1230
+ Match(
1231
+ client_trailing_metadata_state_,
1232
+ [](const absl::monostate&) -> std::string {
1233
+ return "absl::monostate";
1234
+ },
1235
+ [](const WaitingForTrailingMetadata&) -> std::string {
1236
+ return "WAITING";
1237
+ },
1238
+ [](const GotClientHalfClose& got) -> std::string {
1239
+ return absl::StrCat("GOT:", got.result.ToString());
1240
+ })));
1241
+ // Send initial metadata
1242
+ ops.push_back(absl::StrCat(
1243
+ "server_initial_metadata_state:",
1244
+ Match(
1245
+ server_initial_metadata_,
1246
+ [](const absl::monostate&) { return "absl::monostate"; },
1247
+ [](const PipeReceiverNextType<ServerMetadataHandle>&) {
1248
+ return "WAITING";
1249
+ },
1250
+ [](const ServerMetadataHandle&) { return "GOT"; })));
1251
+ // Send message
1252
+ std::string send_message_state = SendMessageString();
1253
+ if (send_message_state != "WAITING") {
1254
+ ops.push_back(absl::StrCat("send_message:", send_message_state));
1255
+ }
1256
+ // Receive message
1257
+ std::string recv_message_state = RecvMessageString();
1258
+ if (recv_message_state != "IDLE") {
1259
+ ops.push_back(absl::StrCat("recv_message:", recv_message_state));
1260
+ }
1261
+ return absl::StrJoin(ops, " ");
1262
+ }
1263
+
1264
+ void SendInitialMetadataDone() {}
1265
+
1266
+ void RecvTrailingMetadataReady(absl::Status error) {
1267
+ MutexLock lock(mu());
1268
+ auto& state =
1269
+ absl::get<WaitingForTrailingMetadata>(client_trailing_metadata_state_);
1270
+ if (grpc_call_trace.enabled()) {
1271
+ gpr_log(GPR_INFO,
1272
+ "%sRecvTrailingMetadataReady: error:%s metadata:%s state:%s",
1273
+ state.waker.ActivityDebugTag().c_str(), error.ToString().c_str(),
1274
+ state.result->DebugString().c_str(), ActiveOpsString().c_str());
1275
+ }
1276
+ auto waker = std::move(state.waker);
1277
+ ServerMetadataHandle result = std::move(state.result);
1278
+ if (error.ok()) {
1279
+ auto* message = result->get_pointer(GrpcMessageMetadata());
1280
+ error = absl::Status(
1281
+ static_cast<absl::StatusCode>(
1282
+ result->get(GrpcStatusMetadata()).value_or(GRPC_STATUS_UNKNOWN)),
1283
+ message == nullptr ? "" : message->as_string_view());
1284
+ }
1285
+ client_trailing_metadata_state_.emplace<GotClientHalfClose>(
1286
+ GotClientHalfClose{error});
1287
+ waker.Wakeup();
1288
+ }
1289
+
1290
+ struct Pipes {
1291
+ Pipe<MessageHandle> server_to_client;
1292
+ Pipe<MessageHandle> client_to_server;
1293
+ Pipe<ServerMetadataHandle> server_initial_metadata;
1294
+ };
1295
+
1296
+ using CallState =
1297
+ absl::variant<absl::monostate, GettingInitialMetadata, GotInitialMetadata,
1298
+ MessageLoop, Completing, Complete>;
1299
+ CallState call_state_ ABSL_GUARDED_BY(mu()) = absl::monostate{};
1300
+ using ClientTrailingMetadataState =
1301
+ absl::variant<absl::monostate, WaitingForTrailingMetadata,
1302
+ GotClientHalfClose>;
1303
+ ClientTrailingMetadataState client_trailing_metadata_state_
1304
+ ABSL_GUARDED_BY(mu()) = absl::monostate{};
1305
+ absl::variant<absl::monostate, PipeReceiverNextType<ServerMetadataHandle>,
1306
+ ServerMetadataHandle>
1307
+ ABSL_GUARDED_BY(mu()) server_initial_metadata_ = absl::monostate{};
1308
+ PipeSender<MessageHandle>* incoming_messages_ = nullptr;
1309
+ grpc_transport_stream_op_batch send_initial_metadata_;
1310
+ grpc_closure send_initial_metadata_done_ =
1311
+ MakeMemberClosure<ServerStream, &ServerStream::SendInitialMetadataDone>(
1312
+ this);
1313
+ Pipes pipes_ ABSL_GUARDED_BY(mu());
1314
+ };
1315
+
1316
+ class ServerConnectedCallPromise {
1317
+ public:
1318
+ ServerConnectedCallPromise(grpc_transport* transport,
1319
+ NextPromiseFactory next_promise_factory)
1320
+ : impl_(GetContext<Arena>()->New<ServerStream>(
1321
+ transport, std::move(next_promise_factory))) {}
1322
+
1323
+ ServerConnectedCallPromise(const ServerConnectedCallPromise&) = delete;
1324
+ ServerConnectedCallPromise& operator=(const ServerConnectedCallPromise&) =
1325
+ delete;
1326
+ ServerConnectedCallPromise(ServerConnectedCallPromise&& other) noexcept
1327
+ : impl_(std::exchange(other.impl_, nullptr)) {}
1328
+ ServerConnectedCallPromise& operator=(
1329
+ ServerConnectedCallPromise&& other) noexcept {
1330
+ impl_ = std::move(other.impl_);
1331
+ return *this;
1332
+ }
1333
+
1334
+ static ArenaPromise<ServerMetadataHandle> Make(grpc_transport* transport,
1335
+ CallArgs,
1336
+ NextPromiseFactory next) {
1337
+ return ServerConnectedCallPromise(transport, std::move(next));
1338
+ }
1339
+
1340
+ Poll<ServerMetadataHandle> operator()() { return impl_->PollOnce(); }
1341
+
1342
+ private:
1343
+ OrphanablePtr<ServerStream> impl_;
1344
+ };
1345
+ #endif
827
1346
 
828
1347
  template <ArenaPromise<ServerMetadataHandle> (*make_call_promise)(
829
- grpc_transport*, CallArgs)>
1348
+ grpc_transport*, CallArgs, NextPromiseFactory)>
830
1349
  grpc_channel_filter MakeConnectedFilter() {
831
1350
  // Create a vtable that contains both the legacy call methods (for filter
832
1351
  // stack based calls) and the new promise based method for creating promise
@@ -834,16 +1353,15 @@ grpc_channel_filter MakeConnectedFilter() {
834
1353
  // In this way the filter can be inserted into either kind of channel stack,
835
1354
  // and only if all the filters in the stack are promise based will the call
836
1355
  // be promise based.
1356
+ auto make_call_wrapper = +[](grpc_channel_element* elem, CallArgs call_args,
1357
+ NextPromiseFactory next) {
1358
+ grpc_transport* transport =
1359
+ static_cast<channel_data*>(elem->channel_data)->transport;
1360
+ return make_call_promise(transport, std::move(call_args), std::move(next));
1361
+ };
837
1362
  return {
838
- connected_channel_start_transport_stream_op_batch,
839
- make_call_promise == nullptr
840
- ? nullptr
841
- : +[](grpc_channel_element* elem, CallArgs call_args,
842
- NextPromiseFactory) {
843
- grpc_transport* transport =
844
- static_cast<channel_data*>(elem->channel_data)->transport;
845
- return make_call_promise(transport, std::move(call_args));
846
- },
1363
+ connected_channel_start_transport_stream_op_batch,
1364
+ make_call_promise != nullptr ? make_call_wrapper : nullptr,
847
1365
  connected_channel_start_transport_op,
848
1366
  sizeof(call_data),
849
1367
  connected_channel_init_call_elem,
@@ -857,7 +1375,7 @@ grpc_channel_filter MakeConnectedFilter() {
857
1375
  // and I'm not sure what that is yet.
858
1376
  // This is only "safe" because call stacks place no additional data
859
1377
  // after the last call element, and the last call element MUST be the
860
- // connected channel.
1378
+ // connected channel.
861
1379
  channel_stack->call_stack_size += grpc_transport_stream_size(
862
1380
  static_cast<channel_data*>(elem->channel_data)->transport);
863
1381
  },
@@ -868,17 +1386,28 @@ grpc_channel_filter MakeConnectedFilter() {
868
1386
  }
869
1387
 
870
1388
  ArenaPromise<ServerMetadataHandle> MakeTransportCallPromise(
871
- grpc_transport* transport, CallArgs call_args) {
1389
+ grpc_transport* transport, CallArgs call_args, NextPromiseFactory) {
872
1390
  return transport->vtable->make_call_promise(transport, std::move(call_args));
873
1391
  }
874
1392
 
875
1393
  const grpc_channel_filter kPromiseBasedTransportFilter =
876
1394
  MakeConnectedFilter<MakeTransportCallPromise>();
877
1395
 
1396
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_CLIENT_CALL
878
1397
  const grpc_channel_filter kClientEmulatedFilter =
879
1398
  MakeConnectedFilter<ClientConnectedCallPromise::Make>();
1399
+ #else
1400
+ const grpc_channel_filter kClientEmulatedFilter =
1401
+ MakeConnectedFilter<nullptr>();
1402
+ #endif
880
1403
 
881
- const grpc_channel_filter kNoPromiseFilter = MakeConnectedFilter<nullptr>();
1404
+ #ifdef GRPC_EXPERIMENT_IS_INCLUDED_PROMISE_BASED_SERVER_CALL
1405
+ const grpc_channel_filter kServerEmulatedFilter =
1406
+ MakeConnectedFilter<ServerConnectedCallPromise::Make>();
1407
+ #else
1408
+ const grpc_channel_filter kServerEmulatedFilter =
1409
+ MakeConnectedFilter<nullptr>();
1410
+ #endif
882
1411
 
883
1412
  } // namespace
884
1413
  } // namespace grpc_core
@@ -903,8 +1432,8 @@ bool grpc_add_connected_filter(grpc_core::ChannelStackBuilder* builder) {
903
1432
  builder->AppendFilter(&grpc_core::kClientEmulatedFilter);
904
1433
  } else {
905
1434
  // Option 3: the transport does not support promise based calls, and we're
906
- // on the server so we can't construct promise based calls just yet.
907
- builder->AppendFilter(&grpc_core::kNoPromiseFilter);
1435
+ // on the server so we use the server filter.
1436
+ builder->AppendFilter(&grpc_core::kServerEmulatedFilter);
908
1437
  }
909
1438
  return true;
910
1439
  }