[build] move channel out of grpc_base (#35924)

This adds the following new targets:
- `channel`: A virtual interface for a channel.
- `legacy_channel`: A channel implementation that supports the filter stack and call v2.
- `channel_create`: A standalone function to create a channel.
- `server_interface`: A base class with a few accessor methods used in surface/call.cc.
- `server`: The actual server implementation.
- `api_trace`, `call_tracer`, `server_call_tracer_filter`, `call_finalization`: These were split out of `grpc_base` to avoid various dependency problems.
- `compression`: This is a combination of the previously existing `compression_internal` target and the compression code that was part of `grpc_base`.

Closes #35924

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35924 from markdroth:channel_interface 94a7fffddb
PiperOrigin-RevId: 612512438
pull/35791/head^2
Mark D. Roth 9 months ago committed by Copybara-Service
parent 4ce4f4ea3a
commit 0213523907
  1. 295
      BUILD
  2. 16
      CMakeLists.txt
  3. 10
      Makefile
  4. 9
      Package.swift
  5. 28
      build_autogenerated.yaml
  6. 5
      config.m4
  7. 5
      config.w32
  8. 8
      gRPC-C++.podspec
  9. 13
      gRPC-Core.podspec
  10. 9
      grpc.gemspec
  11. 14
      grpc.gyp
  12. 9
      package.xml
  13. 98
      src/core/BUILD
  14. 250
      src/core/client_channel/channel_connectivity.cc
  15. 11
      src/core/client_channel/client_channel_filter.cc
  16. 5
      src/core/client_channel/client_channel_filter.h
  17. 9
      src/core/ext/transport/binder/client/channel_create_impl.cc
  18. 3
      src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc
  19. 10
      src/core/ext/transport/chttp2/client/chttp2_connector.cc
  20. 2
      src/core/ext/transport/cronet/BUILD
  21. 5
      src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
  22. 9
      src/core/ext/transport/inproc/inproc_transport.cc
  23. 3
      src/core/ext/transport/inproc/legacy_inproc_transport.cc
  24. 47
      src/core/ext/xds/xds_transport_grpc.cc
  25. 6
      src/core/ext/xds/xds_transport_grpc.h
  26. 2
      src/core/lib/channel/call_finalization.h
  27. 2
      src/core/lib/channel/call_tracer.h
  28. 3
      src/core/lib/channel/channelz.h
  29. 33
      src/core/lib/compression/compression_internal.cc
  30. 3
      src/core/lib/compression/compression_internal.h
  31. 26
      src/core/lib/surface/builtins.h
  32. 16
      src/core/lib/surface/call.cc
  33. 6
      src/core/lib/surface/call.h
  34. 426
      src/core/lib/surface/channel.cc
  35. 195
      src/core/lib/surface/channel.h
  36. 100
      src/core/lib/surface/channel_create.cc
  37. 35
      src/core/lib/surface/channel_create.h
  38. 69
      src/core/lib/surface/channel_ping.cc
  39. 31
      src/core/lib/surface/lame_client.cc
  40. 9
      src/core/lib/surface/lame_client.h
  41. 418
      src/core/lib/surface/legacy_channel.cc
  42. 118
      src/core/lib/surface/legacy_channel.h
  43. 19
      src/core/lib/surface/server.cc
  44. 16
      src/core/lib/surface/server.h
  45. 43
      src/core/lib/surface/server_interface.h
  46. 43
      src/core/load_balancing/grpclb/grpclb.cc
  47. 42
      src/core/load_balancing/rls/rls.cc
  48. 19
      src/core/plugin_registry/grpc_plugin_registry.cc
  49. 1
      src/core/plugin_registry/grpc_plugin_registry_extra.cc
  50. 1
      src/core/plugin_registry/grpc_plugin_registry_noextra.cc
  51. 10
      src/core/tsi/alts/handshaker/alts_handshaker_client.cc
  52. 1
      src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
  53. 1
      src/cpp/ext/csm/BUILD
  54. 1
      src/cpp/ext/otel/BUILD
  55. 5
      src/python/grpcio/grpc_core_dependencies.py
  56. 1
      test/core/bad_connection/BUILD
  57. 4
      test/core/bad_connection/close_fd_test.cc
  58. 5
      test/core/end2end/fixtures/sockpair_fixture.h
  59. 5
      test/core/end2end/fuzzers/client_fuzzer.cc
  60. 4
      test/core/surface/lame_client_test.cc
  61. 13
      test/core/surface/secure_channel_create_test.cc
  62. 5
      test/core/transport/binder/end2end/fuzzers/client_fuzzer.cc
  63. 3
      test/core/transport/binder/end2end/testing_channel_create.cc
  64. 5
      test/core/transport/chaotic_good/BUILD
  65. 5
      test/cpp/microbenchmarks/fullstack_fixtures.h
  66. 1
      test/cpp/performance/BUILD
  67. 5
      test/cpp/performance/writes_per_rpc_test.cc
  68. 9
      tools/doxygen/Doxyfile.c++.internal
  69. 9
      tools/doxygen/Doxyfile.core.internal
  70. 1
      tools/run_tests/sanity/core_banned_functions.py

295
BUILD

@ -554,6 +554,7 @@ grpc_cc_library(
],
visibility = ["@grpc:public"],
deps = [
"api_trace",
"channel_arg_names",
"channel_stack_builder",
"config",
@ -567,6 +568,7 @@ grpc_cc_library(
"grpc_trace",
"http_connect_handshaker",
"iomgr_timer",
"server",
"//src/core:channel_args",
"//src/core:channel_init",
"//src/core:channel_stack_type",
@ -578,6 +580,7 @@ grpc_cc_library(
"//src/core:http_proxy_mapper",
"//src/core:init_internally",
"//src/core:posix_event_engine_timer_manager",
"//src/core:server_call_tracer_filter",
"//src/core:service_config_channel_arg_filter",
"//src/core:slice",
"//src/core:tcp_connect_handshaker",
@ -629,6 +632,7 @@ grpc_cc_library(
"@grpc:public",
],
deps = [
"api_trace",
"channel_arg_names",
"channel_stack_builder",
"config",
@ -649,6 +653,7 @@ grpc_cc_library(
"iomgr_timer",
"promise",
"ref_counted_ptr",
"server",
"sockaddr_utils",
"tsi_base",
"uri_parser",
@ -676,6 +681,7 @@ grpc_cc_library(
"//src/core:json",
"//src/core:posix_event_engine_timer_manager",
"//src/core:ref_counted",
"//src/core:server_call_tracer_filter",
"//src/core:service_config_channel_arg_filter",
"//src/core:slice",
"//src/core:slice_refcount",
@ -1101,6 +1107,9 @@ grpc_cc_library(
],
tags = ["nofixdeps"],
deps = [
"api_trace",
"channel",
"channel_create",
"config",
"debug_location",
"exec_ctx",
@ -1113,6 +1122,7 @@ grpc_cc_library(
"grpc_public_hdrs",
"orphanable",
"ref_counted_ptr",
"server",
"//src/core:arena",
"//src/core:channel_args",
"//src/core:channel_args_preconditioning",
@ -1251,6 +1261,7 @@ grpc_cc_library(
],
visibility = ["@grpc:public"],
deps = [
"api_trace",
"gpr",
"grpc_base",
"grpc_public_hdrs",
@ -1405,6 +1416,21 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "api_trace",
srcs = [
"//src/core:lib/surface/api_trace.cc",
],
hdrs = [
"//src/core:lib/surface/api_trace.h",
],
language = "c++",
deps = [
"gpr",
"grpc_trace",
],
)
grpc_cc_library(
name = "byte_buffer",
srcs = [
@ -1416,6 +1442,7 @@ grpc_cc_library(
"exec_ctx",
"gpr_public_hdrs",
"grpc_public_hdrs",
"//src/core:compression",
"//src/core:slice",
],
)
@ -1626,31 +1653,253 @@ grpc_cc_library(
)
grpc_cc_library(
name = "grpc_base",
name = "call_tracer",
srcs = [
"//src/core:lib/channel/call_tracer.cc",
],
hdrs = [
"//src/core:lib/channel/call_tracer.h",
],
external_deps = [
"absl/status",
"absl/strings",
],
language = "c++",
visibility = ["@grpc:alt_grpc_base_legacy"],
deps = [
"config",
"gpr",
"legacy_context",
"tcp_tracer",
"//src/core:arena",
"//src/core:call_final_info",
"//src/core:channel_args",
"//src/core:context",
"//src/core:error",
"//src/core:metadata_batch",
"//src/core:slice_buffer",
],
)
grpc_cc_library(
name = "channel",
srcs = [
"//src/core:lib/surface/channel.cc",
],
hdrs = [
"//src/core:lib/surface/channel.h",
],
external_deps = [
"absl/base:core_headers",
"absl/status:statusor",
"absl/strings",
"absl/types:optional",
],
language = "c++",
visibility = ["@grpc:alt_grpc_base_legacy"],
deps = [
"api_trace",
"channel_arg_names",
"channelz",
"cpp_impl_of",
"event_engine_base_hdrs",
"exec_ctx",
"gpr",
"grpc_public_hdrs",
"grpc_trace",
"orphanable",
"ref_counted_ptr",
"stats",
"//src/core:arena",
"//src/core:channel_args",
"//src/core:channel_stack_type",
"//src/core:compression",
"//src/core:connectivity_state",
"//src/core:iomgr_fwd",
"//src/core:ref_counted",
"//src/core:slice",
"//src/core:stats_data",
"//src/core:time",
],
)
grpc_cc_library(
name = "legacy_channel",
srcs = [
"//src/core:lib/surface/legacy_channel.cc",
],
hdrs = [
"//src/core:lib/surface/legacy_channel.h",
],
external_deps = [
"absl/base:core_headers",
"absl/status",
"absl/status:statusor",
"absl/types:optional",
],
language = "c++",
visibility = ["@grpc:alt_grpc_base_legacy"],
deps = [
"api_trace",
"channel",
"channelz",
"config",
"exec_ctx",
"gpr",
"grpc_base",
"grpc_client_channel",
"ref_counted_ptr",
"stats",
"//src/core:arena",
"//src/core:call_factory",
"//src/core:channel_args",
"//src/core:channel_fwd",
"//src/core:channel_init",
"//src/core:channel_stack_type",
"//src/core:closure",
"//src/core:dual_ref_counted",
"//src/core:error",
"//src/core:init_internally",
"//src/core:iomgr_fwd",
"//src/core:metrics",
"//src/core:slice",
"//src/core:stats_data",
"//src/core:time",
],
)
grpc_cc_library(
name = "channel_create",
srcs = [
"//src/core:lib/surface/channel_create.cc",
],
hdrs = [
"//src/core:lib/surface/channel_create.h",
],
external_deps = [
"absl/base:core_headers",
"absl/status:statusor",
"absl/strings",
"absl/types:optional",
],
language = "c++",
visibility = ["@grpc:alt_grpc_base_legacy"],
deps = [
"channel",
"channel_arg_names",
"channelz",
"gpr",
"grpc_base",
"grpc_public_hdrs",
"legacy_channel",
"ref_counted_ptr",
"stats",
"//src/core:arena",
"//src/core:channel_args",
"//src/core:channel_stack_type",
"//src/core:iomgr_fwd",
"//src/core:ref_counted",
"//src/core:slice",
"//src/core:stats_data",
],
)
grpc_cc_library(
name = "server",
srcs = [
"//src/core:lib/surface/server.cc",
],
hdrs = [
"//src/core:lib/surface/server.h",
],
external_deps = [
"absl/base:core_headers",
"absl/cleanup",
"absl/container:flat_hash_map",
"absl/container:flat_hash_set",
"absl/hash",
"absl/random",
"absl/status",
"absl/status:statusor",
"absl/strings",
"absl/types:optional",
],
language = "c++",
visibility = ["@grpc:alt_grpc_base_legacy"],
deps = [
"api_trace",
"call_combiner",
"call_tracer",
"channel",
"channel_arg_names",
"channelz",
"config",
"cpp_impl_of",
"debug_location",
"exec_ctx",
"gpr",
"grpc_base",
"grpc_public_hdrs",
"grpc_trace",
"iomgr",
"legacy_channel",
"orphanable",
"promise",
"ref_counted_ptr",
"stats",
"//src/core:1999",
"//src/core:activity",
"//src/core:arena",
"//src/core:arena_promise",
"//src/core:cancel_callback",
"//src/core:channel_args",
"//src/core:channel_args_preconditioning",
"//src/core:channel_fwd",
"//src/core:channel_stack_type",
"//src/core:closure",
"//src/core:connectivity_state",
"//src/core:context",
"//src/core:dual_ref_counted",
"//src/core:error",
"//src/core:error_utils",
"//src/core:experiments",
"//src/core:iomgr_fwd",
"//src/core:map",
"//src/core:metadata_batch",
"//src/core:pipe",
"//src/core:poll",
"//src/core:pollset_set",
"//src/core:random_early_detection",
"//src/core:seq",
"//src/core:server_interface",
"//src/core:slice",
"//src/core:slice_buffer",
"//src/core:status_helper",
"//src/core:time",
"//src/core:try_join",
"//src/core:try_seq",
"//src/core:useful",
],
)
grpc_cc_library(
name = "grpc_base",
srcs = [
"//src/core:lib/channel/channel_stack.cc",
"//src/core:lib/channel/channel_stack_builder_impl.cc",
"//src/core:lib/channel/connected_channel.cc",
"//src/core:lib/channel/promise_based_filter.cc",
"//src/core:lib/channel/server_call_tracer_filter.cc",
"//src/core:lib/channel/status_util.cc",
"//src/core:lib/compression/compression.cc",
"//src/core:lib/compression/message_compress.cc",
"//src/core:lib/slice/b64.cc",
"//src/core:lib/surface/api_trace.cc",
"//src/core:lib/surface/builtins.cc",
"//src/core:lib/surface/call.cc",
"//src/core:lib/surface/call_details.cc",
"//src/core:lib/surface/call_log_batch.cc",
"//src/core:lib/surface/channel.cc",
"//src/core:lib/surface/channel_ping.cc",
"//src/core:lib/surface/completion_queue.cc",
"//src/core:lib/surface/completion_queue_factory.cc",
"//src/core:lib/surface/event_string.cc",
"//src/core:lib/surface/lame_client.cc",
"//src/core:lib/surface/metadata_array.cc",
"//src/core:lib/surface/server.cc",
"//src/core:lib/surface/validate_metadata.cc",
"//src/core:lib/surface/version.cc",
"//src/core:lib/surface/wait_for_cq_end_op.cc",
@ -1659,8 +1908,6 @@ grpc_cc_library(
"//src/core:lib/transport/transport_op_string.cc",
],
hdrs = [
"//src/core:lib/channel/call_finalization.h",
"//src/core:lib/channel/call_tracer.h",
"//src/core:lib/channel/channel_stack.h",
"//src/core:lib/channel/channel_stack_builder_impl.h",
"//src/core:lib/channel/connected_channel.h",
@ -1668,17 +1915,13 @@ grpc_cc_library(
"//src/core:lib/channel/status_util.h",
"//src/core:lib/compression/message_compress.h",
"//src/core:lib/slice/b64.h",
"//src/core:lib/surface/api_trace.h",
"//src/core:lib/surface/builtins.h",
"//src/core:lib/surface/call.h",
"//src/core:lib/surface/call_test_only.h",
"//src/core:lib/surface/channel.h",
"//src/core:lib/surface/completion_queue.h",
"//src/core:lib/surface/completion_queue_factory.h",
"//src/core:lib/surface/event_string.h",
"//src/core:lib/surface/init.h",
"//src/core:lib/surface/lame_client.h",
"//src/core:lib/surface/server.h",
"//src/core:lib/surface/validate_metadata.h",
"//src/core:lib/surface/wait_for_cq_end_op.h",
"//src/core:lib/transport/batch_builder.h",
@ -1716,9 +1959,12 @@ grpc_cc_library(
public_hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS,
visibility = ["@grpc:alt_grpc_base_legacy"],
deps = [
"api_trace",
"byte_buffer",
"call_combiner",
"call_trace",
"call_tracer",
"channel",
"channel_arg_names",
"channel_stack_builder",
"channelz",
@ -1755,6 +2001,7 @@ grpc_cc_library(
"//src/core:call_factory",
"//src/core:call_filters",
"//src/core:call_final_info",
"//src/core:call_finalization",
"//src/core:call_spine",
"//src/core:cancel_callback",
"//src/core:channel_args",
@ -1765,7 +2012,7 @@ grpc_cc_library(
"//src/core:channel_stack_trace",
"//src/core:channel_stack_type",
"//src/core:closure",
"//src/core:compression_internal",
"//src/core:compression",
"//src/core:connectivity_state",
"//src/core:construct_destruct",
"//src/core:context",
@ -1818,6 +2065,7 @@ grpc_cc_library(
"//src/core:resource_quota",
"//src/core:resource_quota_trace",
"//src/core:seq",
"//src/core:server_interface",
"//src/core:slice",
"//src/core:slice_buffer",
"//src/core:slice_cast",
@ -2013,6 +2261,7 @@ grpc_cc_library(
public_hdrs = GRPC_PUBLIC_HDRS,
visibility = ["@grpc:public"],
deps = [
"api_trace",
"call_trace",
"channel_arg_names",
"channelz",
@ -2196,6 +2445,7 @@ grpc_cc_library(
"legacy_context",
"ref_counted_ptr",
"resource_quota_api",
"server",
"//src/core:arena",
"//src/core:channel_args",
"//src/core:channel_fwd",
@ -2274,6 +2524,7 @@ grpc_cc_library(
"legacy_context",
"ref_counted_ptr",
"resource_quota_api",
"server",
"//src/core:arena",
"//src/core:channel_args",
"//src/core:channel_init",
@ -2539,6 +2790,7 @@ grpc_cc_library(
],
visibility = ["@grpc:grpc++_test"],
deps = [
"channel",
"grpc++",
"grpc_base",
],
@ -2585,6 +2837,7 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:grpc_opencensus_plugin"],
deps = [
"call_tracer",
"config",
"gpr",
"grpc++_base",
@ -3313,7 +3566,6 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_client_channel",
srcs = [
"//src/core:client_channel/channel_connectivity.cc",
"//src/core:client_channel/client_channel_factory.cc",
"//src/core:client_channel/client_channel_filter.cc",
"//src/core:client_channel/client_channel_plugin.cc",
@ -3356,8 +3608,10 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:client_channel"],
deps = [
"api_trace",
"backoff",
"call_combiner",
"call_tracer",
"channel_arg_names",
"channelz",
"config",
@ -3670,6 +3924,7 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:public"],
deps = [
"api_trace",
"exec_ctx",
"gpr",
"grpc_base",
@ -3757,6 +4012,9 @@ grpc_cc_library(
deps = [
"alts_upb",
"alts_util",
"channel",
"channel_create",
"exec_ctx",
"gpr",
"grpc_base",
"grpc_security_base",
@ -3921,6 +4179,7 @@ grpc_cc_library(
visibility = ["@grpc:http"],
deps = [
"call_trace",
"call_tracer",
"channel_arg_names",
"config",
"gpr",
@ -3935,7 +4194,7 @@ grpc_cc_library(
"//src/core:channel_args",
"//src/core:channel_fwd",
"//src/core:channel_stack_type",
"//src/core:compression_internal",
"//src/core:compression",
"//src/core:context",
"//src/core:experiments",
"//src/core:grpc_message_size_filter",
@ -4217,6 +4476,7 @@ grpc_cc_library(
"absl/types:variant",
],
deps = [
"call_tracer",
"chttp2_legacy_frame",
"gpr",
"gpr_platform",
@ -4367,6 +4627,7 @@ grpc_cc_library(
language = "c++",
visibility = ["@grpc:grpclb"],
deps = [
"call_tracer",
"channel_arg_names",
"channelz",
"chttp2_context_list_entry",

16
CMakeLists.txt generated

@ -1778,7 +1778,6 @@ endif()
add_library(grpc
src/core/client_channel/backup_poller.cc
src/core/client_channel/channel_connectivity.cc
src/core/client_channel/client_channel_channelz.cc
src/core/client_channel/client_channel_factory.cc
src/core/client_channel/client_channel_filter.cc
@ -2453,15 +2452,14 @@ add_library(grpc
src/core/lib/slice/slice_refcount.cc
src/core/lib/slice/slice_string_helpers.cc
src/core/lib/surface/api_trace.cc
src/core/lib/surface/builtins.cc
src/core/lib/surface/byte_buffer.cc
src/core/lib/surface/byte_buffer_reader.cc
src/core/lib/surface/call.cc
src/core/lib/surface/call_details.cc
src/core/lib/surface/call_log_batch.cc
src/core/lib/surface/channel.cc
src/core/lib/surface/channel_create.cc
src/core/lib/surface/channel_init.cc
src/core/lib/surface/channel_ping.cc
src/core/lib/surface/channel_stack_type.cc
src/core/lib/surface/completion_queue.cc
src/core/lib/surface/completion_queue_factory.cc
@ -2469,6 +2467,7 @@ add_library(grpc
src/core/lib/surface/init.cc
src/core/lib/surface/init_internally.cc
src/core/lib/surface/lame_client.cc
src/core/lib/surface/legacy_channel.cc
src/core/lib/surface/metadata_array.cc
src/core/lib/surface/server.cc
src/core/lib/surface/validate_metadata.cc
@ -2879,7 +2878,6 @@ endif()
add_library(grpc_unsecure
src/core/client_channel/backup_poller.cc
src/core/client_channel/channel_connectivity.cc
src/core/client_channel/client_channel_channelz.cc
src/core/client_channel/client_channel_factory.cc
src/core/client_channel/client_channel_filter.cc
@ -3184,15 +3182,14 @@ add_library(grpc_unsecure
src/core/lib/slice/slice_refcount.cc
src/core/lib/slice/slice_string_helpers.cc
src/core/lib/surface/api_trace.cc
src/core/lib/surface/builtins.cc
src/core/lib/surface/byte_buffer.cc
src/core/lib/surface/byte_buffer_reader.cc
src/core/lib/surface/call.cc
src/core/lib/surface/call_details.cc
src/core/lib/surface/call_log_batch.cc
src/core/lib/surface/channel.cc
src/core/lib/surface/channel_create.cc
src/core/lib/surface/channel_init.cc
src/core/lib/surface/channel_ping.cc
src/core/lib/surface/channel_stack_type.cc
src/core/lib/surface/completion_queue.cc
src/core/lib/surface/completion_queue_factory.cc
@ -3200,6 +3197,7 @@ add_library(grpc_unsecure
src/core/lib/surface/init.cc
src/core/lib/surface/init_internally.cc
src/core/lib/surface/lame_client.cc
src/core/lib/surface/legacy_channel.cc
src/core/lib/surface/metadata_array.cc
src/core/lib/surface/server.cc
src/core/lib/surface/validate_metadata.cc
@ -5111,7 +5109,6 @@ add_library(grpc_authorization_provider
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/metrics.cc
src/core/lib/channel/promise_based_filter.cc
src/core/lib/channel/server_call_tracer_filter.cc
src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
src/core/lib/compression/compression_internal.cc
@ -5312,7 +5309,6 @@ add_library(grpc_authorization_provider
src/core/lib/slice/slice_refcount.cc
src/core/lib/slice/slice_string_helpers.cc
src/core/lib/surface/api_trace.cc
src/core/lib/surface/builtins.cc
src/core/lib/surface/byte_buffer.cc
src/core/lib/surface/byte_buffer_reader.cc
src/core/lib/surface/call.cc
@ -5320,7 +5316,6 @@ add_library(grpc_authorization_provider
src/core/lib/surface/call_log_batch.cc
src/core/lib/surface/channel.cc
src/core/lib/surface/channel_init.cc
src/core/lib/surface/channel_ping.cc
src/core/lib/surface/channel_stack_type.cc
src/core/lib/surface/completion_queue.cc
src/core/lib/surface/completion_queue_factory.cc
@ -5328,7 +5323,6 @@ add_library(grpc_authorization_provider
src/core/lib/surface/init_internally.cc
src/core/lib/surface/lame_client.cc
src/core/lib/surface/metadata_array.cc
src/core/lib/surface/server.cc
src/core/lib/surface/validate_metadata.cc
src/core/lib/surface/version.cc
src/core/lib/surface/wait_for_cq_end_op.cc
@ -8438,6 +8432,7 @@ add_executable(call_filters_test
src/core/ext/upb-gen/google/protobuf/descriptor.upb_minitable.c
src/core/ext/upb-gen/google/rpc/status.upb_minitable.c
src/core/lib/channel/channel_args.cc
src/core/lib/compression/compression.cc
src/core/lib/compression/compression_internal.cc
src/core/lib/debug/trace.cc
src/core/lib/experiments/config.cc
@ -8462,6 +8457,7 @@ add_executable(call_filters_test
src/core/lib/slice/slice_buffer.cc
src/core/lib/slice/slice_refcount.cc
src/core/lib/slice/slice_string_helpers.cc
src/core/lib/surface/api_trace.cc
src/core/lib/surface/channel_stack_type.cc
src/core/lib/transport/call_filters.cc
src/core/lib/transport/call_final_info.cc

10
Makefile generated

@ -959,7 +959,6 @@ endif
# transitive_deps: ['address_sorting', 'gpr', 'grpc_abseil', 'cares', 'z', 're2', 'upb_textformat_lib', 'upb_json_lib', 'utf8_range_lib', 'upb_message_lib', 'upb_mem_lib', 'upb_base_lib', 'libssl']
LIBGRPC_SRC = \
src/core/client_channel/backup_poller.cc \
src/core/client_channel/channel_connectivity.cc \
src/core/client_channel/client_channel_channelz.cc \
src/core/client_channel/client_channel_factory.cc \
src/core/client_channel/client_channel_filter.cc \
@ -1634,15 +1633,14 @@ LIBGRPC_SRC = \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/builtins.cc \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \
src/core/lib/surface/call.cc \
src/core/lib/surface/call_details.cc \
src/core/lib/surface/call_log_batch.cc \
src/core/lib/surface/channel.cc \
src/core/lib/surface/channel_create.cc \
src/core/lib/surface/channel_init.cc \
src/core/lib/surface/channel_ping.cc \
src/core/lib/surface/channel_stack_type.cc \
src/core/lib/surface/completion_queue.cc \
src/core/lib/surface/completion_queue_factory.cc \
@ -1650,6 +1648,7 @@ LIBGRPC_SRC = \
src/core/lib/surface/init.cc \
src/core/lib/surface/init_internally.cc \
src/core/lib/surface/lame_client.cc \
src/core/lib/surface/legacy_channel.cc \
src/core/lib/surface/metadata_array.cc \
src/core/lib/surface/server.cc \
src/core/lib/surface/validate_metadata.cc \
@ -1893,7 +1892,6 @@ endif
# transitive_deps: ['address_sorting', 'gpr', 'grpc_abseil', 'cares', 'z', 'utf8_range_lib', 'upb_message_lib', 'upb_mem_lib', 'upb_base_lib']
LIBGRPC_UNSECURE_SRC = \
src/core/client_channel/backup_poller.cc \
src/core/client_channel/channel_connectivity.cc \
src/core/client_channel/client_channel_channelz.cc \
src/core/client_channel/client_channel_factory.cc \
src/core/client_channel/client_channel_filter.cc \
@ -2198,15 +2196,14 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/builtins.cc \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \
src/core/lib/surface/call.cc \
src/core/lib/surface/call_details.cc \
src/core/lib/surface/call_log_batch.cc \
src/core/lib/surface/channel.cc \
src/core/lib/surface/channel_create.cc \
src/core/lib/surface/channel_init.cc \
src/core/lib/surface/channel_ping.cc \
src/core/lib/surface/channel_stack_type.cc \
src/core/lib/surface/completion_queue.cc \
src/core/lib/surface/completion_queue_factory.cc \
@ -2214,6 +2211,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/surface/init.cc \
src/core/lib/surface/init_internally.cc \
src/core/lib/surface/lame_client.cc \
src/core/lib/surface/legacy_channel.cc \
src/core/lib/surface/metadata_array.cc \
src/core/lib/surface/server.cc \
src/core/lib/surface/validate_metadata.cc \

9
Package.swift generated

@ -117,7 +117,6 @@ let package = Package(
"include/grpc/support/workaround_list.h",
"src/core/client_channel/backup_poller.cc",
"src/core/client_channel/backup_poller.h",
"src/core/client_channel/channel_connectivity.cc",
"src/core/client_channel/client_channel_channelz.cc",
"src/core/client_channel/client_channel_channelz.h",
"src/core/client_channel/client_channel_factory.cc",
@ -1760,8 +1759,6 @@ let package = Package(
"src/core/lib/slice/slice_string_helpers.h",
"src/core/lib/surface/api_trace.cc",
"src/core/lib/surface/api_trace.h",
"src/core/lib/surface/builtins.cc",
"src/core/lib/surface/builtins.h",
"src/core/lib/surface/byte_buffer.cc",
"src/core/lib/surface/byte_buffer_reader.cc",
"src/core/lib/surface/call.cc",
@ -1772,9 +1769,10 @@ let package = Package(
"src/core/lib/surface/call_trace.h",
"src/core/lib/surface/channel.cc",
"src/core/lib/surface/channel.h",
"src/core/lib/surface/channel_create.cc",
"src/core/lib/surface/channel_create.h",
"src/core/lib/surface/channel_init.cc",
"src/core/lib/surface/channel_init.h",
"src/core/lib/surface/channel_ping.cc",
"src/core/lib/surface/channel_stack_type.cc",
"src/core/lib/surface/channel_stack_type.h",
"src/core/lib/surface/completion_queue.cc",
@ -1789,9 +1787,12 @@ let package = Package(
"src/core/lib/surface/init_internally.h",
"src/core/lib/surface/lame_client.cc",
"src/core/lib/surface/lame_client.h",
"src/core/lib/surface/legacy_channel.cc",
"src/core/lib/surface/legacy_channel.h",
"src/core/lib/surface/metadata_array.cc",
"src/core/lib/surface/server.cc",
"src/core/lib/surface/server.h",
"src/core/lib/surface/server_interface.h",
"src/core/lib/surface/validate_metadata.cc",
"src/core/lib/surface/validate_metadata.h",
"src/core/lib/surface/version.cc",

@ -1111,11 +1111,11 @@ libs:
- src/core/lib/slice/slice_refcount.h
- src/core/lib/slice/slice_string_helpers.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/builtins.h
- src/core/lib/surface/call.h
- src/core/lib/surface/call_test_only.h
- src/core/lib/surface/call_trace.h
- src/core/lib/surface/channel.h
- src/core/lib/surface/channel_create.h
- src/core/lib/surface/channel_init.h
- src/core/lib/surface/channel_stack_type.h
- src/core/lib/surface/completion_queue.h
@ -1124,7 +1124,9 @@ libs:
- src/core/lib/surface/init.h
- src/core/lib/surface/init_internally.h
- src/core/lib/surface/lame_client.h
- src/core/lib/surface/legacy_channel.h
- src/core/lib/surface/server.h
- src/core/lib/surface/server_interface.h
- src/core/lib/surface/validate_metadata.h
- src/core/lib/surface/wait_for_cq_end_op.h
- src/core/lib/transport/batch_builder.h
@ -1236,7 +1238,6 @@ libs:
- third_party/xxhash/xxhash.h
src:
- src/core/client_channel/backup_poller.cc
- src/core/client_channel/channel_connectivity.cc
- src/core/client_channel/client_channel_channelz.cc
- src/core/client_channel/client_channel_factory.cc
- src/core/client_channel/client_channel_filter.cc
@ -1911,15 +1912,14 @@ libs:
- src/core/lib/slice/slice_refcount.cc
- src/core/lib/slice/slice_string_helpers.cc
- src/core/lib/surface/api_trace.cc
- src/core/lib/surface/builtins.cc
- src/core/lib/surface/byte_buffer.cc
- src/core/lib/surface/byte_buffer_reader.cc
- src/core/lib/surface/call.cc
- src/core/lib/surface/call_details.cc
- src/core/lib/surface/call_log_batch.cc
- src/core/lib/surface/channel.cc
- src/core/lib/surface/channel_create.cc
- src/core/lib/surface/channel_init.cc
- src/core/lib/surface/channel_ping.cc
- src/core/lib/surface/channel_stack_type.cc
- src/core/lib/surface/completion_queue.cc
- src/core/lib/surface/completion_queue_factory.cc
@ -1927,6 +1927,7 @@ libs:
- src/core/lib/surface/init.cc
- src/core/lib/surface/init_internally.cc
- src/core/lib/surface/lame_client.cc
- src/core/lib/surface/legacy_channel.cc
- src/core/lib/surface/metadata_array.cc
- src/core/lib/surface/server.cc
- src/core/lib/surface/validate_metadata.cc
@ -2577,11 +2578,11 @@ libs:
- src/core/lib/slice/slice_refcount.h
- src/core/lib/slice/slice_string_helpers.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/builtins.h
- src/core/lib/surface/call.h
- src/core/lib/surface/call_test_only.h
- src/core/lib/surface/call_trace.h
- src/core/lib/surface/channel.h
- src/core/lib/surface/channel_create.h
- src/core/lib/surface/channel_init.h
- src/core/lib/surface/channel_stack_type.h
- src/core/lib/surface/completion_queue.h
@ -2590,7 +2591,9 @@ libs:
- src/core/lib/surface/init.h
- src/core/lib/surface/init_internally.h
- src/core/lib/surface/lame_client.h
- src/core/lib/surface/legacy_channel.h
- src/core/lib/surface/server.h
- src/core/lib/surface/server_interface.h
- src/core/lib/surface/validate_metadata.h
- src/core/lib/surface/wait_for_cq_end_op.h
- src/core/lib/transport/batch_builder.h
@ -2692,7 +2695,6 @@ libs:
- third_party/upb/upb/wire/types.h
src:
- src/core/client_channel/backup_poller.cc
- src/core/client_channel/channel_connectivity.cc
- src/core/client_channel/client_channel_channelz.cc
- src/core/client_channel/client_channel_factory.cc
- src/core/client_channel/client_channel_filter.cc
@ -2997,15 +2999,14 @@ libs:
- src/core/lib/slice/slice_refcount.cc
- src/core/lib/slice/slice_string_helpers.cc
- src/core/lib/surface/api_trace.cc
- src/core/lib/surface/builtins.cc
- src/core/lib/surface/byte_buffer.cc
- src/core/lib/surface/byte_buffer_reader.cc
- src/core/lib/surface/call.cc
- src/core/lib/surface/call_details.cc
- src/core/lib/surface/call_log_batch.cc
- src/core/lib/surface/channel.cc
- src/core/lib/surface/channel_create.cc
- src/core/lib/surface/channel_init.cc
- src/core/lib/surface/channel_ping.cc
- src/core/lib/surface/channel_stack_type.cc
- src/core/lib/surface/completion_queue.cc
- src/core/lib/surface/completion_queue_factory.cc
@ -3013,6 +3014,7 @@ libs:
- src/core/lib/surface/init.cc
- src/core/lib/surface/init_internally.cc
- src/core/lib/surface/lame_client.cc
- src/core/lib/surface/legacy_channel.cc
- src/core/lib/surface/metadata_array.cc
- src/core/lib/surface/server.cc
- src/core/lib/surface/validate_metadata.cc
@ -4654,7 +4656,6 @@ libs:
- src/core/lib/slice/slice_refcount.h
- src/core/lib/slice/slice_string_helpers.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/builtins.h
- src/core/lib/surface/call.h
- src/core/lib/surface/call_test_only.h
- src/core/lib/surface/call_trace.h
@ -4667,7 +4668,7 @@ libs:
- src/core/lib/surface/init.h
- src/core/lib/surface/init_internally.h
- src/core/lib/surface/lame_client.h
- src/core/lib/surface/server.h
- src/core/lib/surface/server_interface.h
- src/core/lib/surface/validate_metadata.h
- src/core/lib/surface/wait_for_cq_end_op.h
- src/core/lib/transport/batch_builder.h
@ -4756,7 +4757,6 @@ libs:
- src/core/lib/channel/connected_channel.cc
- src/core/lib/channel/metrics.cc
- src/core/lib/channel/promise_based_filter.cc
- src/core/lib/channel/server_call_tracer_filter.cc
- src/core/lib/channel/status_util.cc
- src/core/lib/compression/compression.cc
- src/core/lib/compression/compression_internal.cc
@ -4957,7 +4957,6 @@ libs:
- src/core/lib/slice/slice_refcount.cc
- src/core/lib/slice/slice_string_helpers.cc
- src/core/lib/surface/api_trace.cc
- src/core/lib/surface/builtins.cc
- src/core/lib/surface/byte_buffer.cc
- src/core/lib/surface/byte_buffer_reader.cc
- src/core/lib/surface/call.cc
@ -4965,7 +4964,6 @@ libs:
- src/core/lib/surface/call_log_batch.cc
- src/core/lib/surface/channel.cc
- src/core/lib/surface/channel_init.cc
- src/core/lib/surface/channel_ping.cc
- src/core/lib/surface/channel_stack_type.cc
- src/core/lib/surface/completion_queue.cc
- src/core/lib/surface/completion_queue_factory.cc
@ -4973,7 +4971,6 @@ libs:
- src/core/lib/surface/init_internally.cc
- src/core/lib/surface/lame_client.cc
- src/core/lib/surface/metadata_array.cc
- src/core/lib/surface/server.cc
- src/core/lib/surface/validate_metadata.cc
- src/core/lib/surface/version.cc
- src/core/lib/surface/wait_for_cq_end_op.cc
@ -6407,6 +6404,7 @@ targets:
- src/core/lib/slice/slice_internal.h
- src/core/lib/slice/slice_refcount.h
- src/core/lib/slice/slice_string_helpers.h
- src/core/lib/surface/api_trace.h
- src/core/lib/surface/channel_stack_type.h
- src/core/lib/transport/call_filters.h
- src/core/lib/transport/call_final_info.h
@ -6447,6 +6445,7 @@ targets:
- src/core/ext/upb-gen/google/protobuf/descriptor.upb_minitable.c
- src/core/ext/upb-gen/google/rpc/status.upb_minitable.c
- src/core/lib/channel/channel_args.cc
- src/core/lib/compression/compression.cc
- src/core/lib/compression/compression_internal.cc
- src/core/lib/debug/trace.cc
- src/core/lib/experiments/config.cc
@ -6471,6 +6470,7 @@ targets:
- src/core/lib/slice/slice_buffer.cc
- src/core/lib/slice/slice_refcount.cc
- src/core/lib/slice/slice_string_helpers.cc
- src/core/lib/surface/api_trace.cc
- src/core/lib/surface/channel_stack_type.cc
- src/core/lib/transport/call_filters.cc
- src/core/lib/transport/call_final_info.cc

5
config.m4 generated

@ -42,7 +42,6 @@ if test "$PHP_GRPC" != "no"; then
PHP_NEW_EXTENSION(grpc,
src/core/client_channel/backup_poller.cc \
src/core/client_channel/channel_connectivity.cc \
src/core/client_channel/client_channel_channelz.cc \
src/core/client_channel/client_channel_factory.cc \
src/core/client_channel/client_channel_filter.cc \
@ -762,15 +761,14 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/slice/slice_refcount.cc \
src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/builtins.cc \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \
src/core/lib/surface/call.cc \
src/core/lib/surface/call_details.cc \
src/core/lib/surface/call_log_batch.cc \
src/core/lib/surface/channel.cc \
src/core/lib/surface/channel_create.cc \
src/core/lib/surface/channel_init.cc \
src/core/lib/surface/channel_ping.cc \
src/core/lib/surface/channel_stack_type.cc \
src/core/lib/surface/completion_queue.cc \
src/core/lib/surface/completion_queue_factory.cc \
@ -778,6 +776,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/surface/init.cc \
src/core/lib/surface/init_internally.cc \
src/core/lib/surface/lame_client.cc \
src/core/lib/surface/legacy_channel.cc \
src/core/lib/surface/metadata_array.cc \
src/core/lib/surface/server.cc \
src/core/lib/surface/validate_metadata.cc \

5
config.w32 generated

@ -7,7 +7,6 @@ if (PHP_GRPC != "no") {
EXTENSION("grpc",
"src\\core\\client_channel\\backup_poller.cc " +
"src\\core\\client_channel\\channel_connectivity.cc " +
"src\\core\\client_channel\\client_channel_channelz.cc " +
"src\\core\\client_channel\\client_channel_factory.cc " +
"src\\core\\client_channel\\client_channel_filter.cc " +
@ -727,15 +726,14 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\slice\\slice_refcount.cc " +
"src\\core\\lib\\slice\\slice_string_helpers.cc " +
"src\\core\\lib\\surface\\api_trace.cc " +
"src\\core\\lib\\surface\\builtins.cc " +
"src\\core\\lib\\surface\\byte_buffer.cc " +
"src\\core\\lib\\surface\\byte_buffer_reader.cc " +
"src\\core\\lib\\surface\\call.cc " +
"src\\core\\lib\\surface\\call_details.cc " +
"src\\core\\lib\\surface\\call_log_batch.cc " +
"src\\core\\lib\\surface\\channel.cc " +
"src\\core\\lib\\surface\\channel_create.cc " +
"src\\core\\lib\\surface\\channel_init.cc " +
"src\\core\\lib\\surface\\channel_ping.cc " +
"src\\core\\lib\\surface\\channel_stack_type.cc " +
"src\\core\\lib\\surface\\completion_queue.cc " +
"src\\core\\lib\\surface\\completion_queue_factory.cc " +
@ -743,6 +741,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\surface\\init.cc " +
"src\\core\\lib\\surface\\init_internally.cc " +
"src\\core\\lib\\surface\\lame_client.cc " +
"src\\core\\lib\\surface\\legacy_channel.cc " +
"src\\core\\lib\\surface\\metadata_array.cc " +
"src\\core\\lib\\surface\\server.cc " +
"src\\core\\lib\\surface\\validate_metadata.cc " +

8
gRPC-C++.podspec generated

@ -1217,11 +1217,11 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/builtins.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',
'src/core/lib/surface/call_trace.h',
'src/core/lib/surface/channel.h',
'src/core/lib/surface/channel_create.h',
'src/core/lib/surface/channel_init.h',
'src/core/lib/surface/channel_stack_type.h',
'src/core/lib/surface/completion_queue.h',
@ -1230,7 +1230,9 @@ Pod::Spec.new do |s|
'src/core/lib/surface/init.h',
'src/core/lib/surface/init_internally.h',
'src/core/lib/surface/lame_client.h',
'src/core/lib/surface/legacy_channel.h',
'src/core/lib/surface/server.h',
'src/core/lib/surface/server_interface.h',
'src/core/lib/surface/validate_metadata.h',
'src/core/lib/surface/wait_for_cq_end_op.h',
'src/core/lib/transport/batch_builder.h',
@ -2476,11 +2478,11 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/builtins.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',
'src/core/lib/surface/call_trace.h',
'src/core/lib/surface/channel.h',
'src/core/lib/surface/channel_create.h',
'src/core/lib/surface/channel_init.h',
'src/core/lib/surface/channel_stack_type.h',
'src/core/lib/surface/completion_queue.h',
@ -2489,7 +2491,9 @@ Pod::Spec.new do |s|
'src/core/lib/surface/init.h',
'src/core/lib/surface/init_internally.h',
'src/core/lib/surface/lame_client.h',
'src/core/lib/surface/legacy_channel.h',
'src/core/lib/surface/server.h',
'src/core/lib/surface/server_interface.h',
'src/core/lib/surface/validate_metadata.h',
'src/core/lib/surface/wait_for_cq_end_op.h',
'src/core/lib/transport/batch_builder.h',

13
gRPC-Core.podspec generated

@ -231,7 +231,6 @@ Pod::Spec.new do |s|
ss.source_files = 'src/core/client_channel/backup_poller.cc',
'src/core/client_channel/backup_poller.h',
'src/core/client_channel/channel_connectivity.cc',
'src/core/client_channel/client_channel_channelz.cc',
'src/core/client_channel/client_channel_channelz.h',
'src/core/client_channel/client_channel_factory.cc',
@ -1870,8 +1869,6 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/builtins.cc',
'src/core/lib/surface/builtins.h',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',
'src/core/lib/surface/call.cc',
@ -1882,9 +1879,10 @@ Pod::Spec.new do |s|
'src/core/lib/surface/call_trace.h',
'src/core/lib/surface/channel.cc',
'src/core/lib/surface/channel.h',
'src/core/lib/surface/channel_create.cc',
'src/core/lib/surface/channel_create.h',
'src/core/lib/surface/channel_init.cc',
'src/core/lib/surface/channel_init.h',
'src/core/lib/surface/channel_ping.cc',
'src/core/lib/surface/channel_stack_type.cc',
'src/core/lib/surface/channel_stack_type.h',
'src/core/lib/surface/completion_queue.cc',
@ -1899,9 +1897,12 @@ Pod::Spec.new do |s|
'src/core/lib/surface/init_internally.h',
'src/core/lib/surface/lame_client.cc',
'src/core/lib/surface/lame_client.h',
'src/core/lib/surface/legacy_channel.cc',
'src/core/lib/surface/legacy_channel.h',
'src/core/lib/surface/metadata_array.cc',
'src/core/lib/surface/server.cc',
'src/core/lib/surface/server.h',
'src/core/lib/surface/server_interface.h',
'src/core/lib/surface/validate_metadata.cc',
'src/core/lib/surface/validate_metadata.h',
'src/core/lib/surface/version.cc',
@ -3257,11 +3258,11 @@ Pod::Spec.new do |s|
'src/core/lib/slice/slice_refcount.h',
'src/core/lib/slice/slice_string_helpers.h',
'src/core/lib/surface/api_trace.h',
'src/core/lib/surface/builtins.h',
'src/core/lib/surface/call.h',
'src/core/lib/surface/call_test_only.h',
'src/core/lib/surface/call_trace.h',
'src/core/lib/surface/channel.h',
'src/core/lib/surface/channel_create.h',
'src/core/lib/surface/channel_init.h',
'src/core/lib/surface/channel_stack_type.h',
'src/core/lib/surface/completion_queue.h',
@ -3270,7 +3271,9 @@ Pod::Spec.new do |s|
'src/core/lib/surface/init.h',
'src/core/lib/surface/init_internally.h',
'src/core/lib/surface/lame_client.h',
'src/core/lib/surface/legacy_channel.h',
'src/core/lib/surface/server.h',
'src/core/lib/surface/server_interface.h',
'src/core/lib/surface/validate_metadata.h',
'src/core/lib/surface/wait_for_cq_end_op.h',
'src/core/lib/transport/batch_builder.h',

9
grpc.gemspec generated

@ -123,7 +123,6 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/support/workaround_list.h )
s.files += %w( src/core/client_channel/backup_poller.cc )
s.files += %w( src/core/client_channel/backup_poller.h )
s.files += %w( src/core/client_channel/channel_connectivity.cc )
s.files += %w( src/core/client_channel/client_channel_channelz.cc )
s.files += %w( src/core/client_channel/client_channel_channelz.h )
s.files += %w( src/core/client_channel/client_channel_factory.cc )
@ -1762,8 +1761,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/slice/slice_string_helpers.h )
s.files += %w( src/core/lib/surface/api_trace.cc )
s.files += %w( src/core/lib/surface/api_trace.h )
s.files += %w( src/core/lib/surface/builtins.cc )
s.files += %w( src/core/lib/surface/builtins.h )
s.files += %w( src/core/lib/surface/byte_buffer.cc )
s.files += %w( src/core/lib/surface/byte_buffer_reader.cc )
s.files += %w( src/core/lib/surface/call.cc )
@ -1774,9 +1771,10 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/surface/call_trace.h )
s.files += %w( src/core/lib/surface/channel.cc )
s.files += %w( src/core/lib/surface/channel.h )
s.files += %w( src/core/lib/surface/channel_create.cc )
s.files += %w( src/core/lib/surface/channel_create.h )
s.files += %w( src/core/lib/surface/channel_init.cc )
s.files += %w( src/core/lib/surface/channel_init.h )
s.files += %w( src/core/lib/surface/channel_ping.cc )
s.files += %w( src/core/lib/surface/channel_stack_type.cc )
s.files += %w( src/core/lib/surface/channel_stack_type.h )
s.files += %w( src/core/lib/surface/completion_queue.cc )
@ -1791,9 +1789,12 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/surface/init_internally.h )
s.files += %w( src/core/lib/surface/lame_client.cc )
s.files += %w( src/core/lib/surface/lame_client.h )
s.files += %w( src/core/lib/surface/legacy_channel.cc )
s.files += %w( src/core/lib/surface/legacy_channel.h )
s.files += %w( src/core/lib/surface/metadata_array.cc )
s.files += %w( src/core/lib/surface/server.cc )
s.files += %w( src/core/lib/surface/server.h )
s.files += %w( src/core/lib/surface/server_interface.h )
s.files += %w( src/core/lib/surface/validate_metadata.cc )
s.files += %w( src/core/lib/surface/validate_metadata.h )
s.files += %w( src/core/lib/surface/version.cc )

14
grpc.gyp generated

@ -274,7 +274,6 @@
],
'sources': [
'src/core/client_channel/backup_poller.cc',
'src/core/client_channel/channel_connectivity.cc',
'src/core/client_channel/client_channel_channelz.cc',
'src/core/client_channel/client_channel_factory.cc',
'src/core/client_channel/client_channel_filter.cc',
@ -949,15 +948,14 @@
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/builtins.cc',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',
'src/core/lib/surface/call.cc',
'src/core/lib/surface/call_details.cc',
'src/core/lib/surface/call_log_batch.cc',
'src/core/lib/surface/channel.cc',
'src/core/lib/surface/channel_create.cc',
'src/core/lib/surface/channel_init.cc',
'src/core/lib/surface/channel_ping.cc',
'src/core/lib/surface/channel_stack_type.cc',
'src/core/lib/surface/completion_queue.cc',
'src/core/lib/surface/completion_queue_factory.cc',
@ -965,6 +963,7 @@
'src/core/lib/surface/init.cc',
'src/core/lib/surface/init_internally.cc',
'src/core/lib/surface/lame_client.cc',
'src/core/lib/surface/legacy_channel.cc',
'src/core/lib/surface/metadata_array.cc',
'src/core/lib/surface/server.cc',
'src/core/lib/surface/validate_metadata.cc',
@ -1149,7 +1148,6 @@
],
'sources': [
'src/core/client_channel/backup_poller.cc',
'src/core/client_channel/channel_connectivity.cc',
'src/core/client_channel/client_channel_channelz.cc',
'src/core/client_channel/client_channel_factory.cc',
'src/core/client_channel/client_channel_filter.cc',
@ -1454,15 +1452,14 @@
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/builtins.cc',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',
'src/core/lib/surface/call.cc',
'src/core/lib/surface/call_details.cc',
'src/core/lib/surface/call_log_batch.cc',
'src/core/lib/surface/channel.cc',
'src/core/lib/surface/channel_create.cc',
'src/core/lib/surface/channel_init.cc',
'src/core/lib/surface/channel_ping.cc',
'src/core/lib/surface/channel_stack_type.cc',
'src/core/lib/surface/completion_queue.cc',
'src/core/lib/surface/completion_queue_factory.cc',
@ -1470,6 +1467,7 @@
'src/core/lib/surface/init.cc',
'src/core/lib/surface/init_internally.cc',
'src/core/lib/surface/lame_client.cc',
'src/core/lib/surface/legacy_channel.cc',
'src/core/lib/surface/metadata_array.cc',
'src/core/lib/surface/server.cc',
'src/core/lib/surface/validate_metadata.cc',
@ -2063,7 +2061,6 @@
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/metrics.cc',
'src/core/lib/channel/promise_based_filter.cc',
'src/core/lib/channel/server_call_tracer_filter.cc',
'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
'src/core/lib/compression/compression_internal.cc',
@ -2264,7 +2261,6 @@
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/builtins.cc',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',
'src/core/lib/surface/call.cc',
@ -2272,7 +2268,6 @@
'src/core/lib/surface/call_log_batch.cc',
'src/core/lib/surface/channel.cc',
'src/core/lib/surface/channel_init.cc',
'src/core/lib/surface/channel_ping.cc',
'src/core/lib/surface/channel_stack_type.cc',
'src/core/lib/surface/completion_queue.cc',
'src/core/lib/surface/completion_queue_factory.cc',
@ -2280,7 +2275,6 @@
'src/core/lib/surface/init_internally.cc',
'src/core/lib/surface/lame_client.cc',
'src/core/lib/surface/metadata_array.cc',
'src/core/lib/surface/server.cc',
'src/core/lib/surface/validate_metadata.cc',
'src/core/lib/surface/version.cc',
'src/core/lib/surface/wait_for_cq_end_op.cc',

9
package.xml generated

@ -105,7 +105,6 @@
<file baseinstalldir="/" name="include/grpc/support/workaround_list.h" role="src" />
<file baseinstalldir="/" name="src/core/client_channel/backup_poller.cc" role="src" />
<file baseinstalldir="/" name="src/core/client_channel/backup_poller.h" role="src" />
<file baseinstalldir="/" name="src/core/client_channel/channel_connectivity.cc" role="src" />
<file baseinstalldir="/" name="src/core/client_channel/client_channel_channelz.cc" role="src" />
<file baseinstalldir="/" name="src/core/client_channel/client_channel_channelz.h" role="src" />
<file baseinstalldir="/" name="src/core/client_channel/client_channel_factory.cc" role="src" />
@ -1744,8 +1743,6 @@
<file baseinstalldir="/" name="src/core/lib/slice/slice_string_helpers.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/api_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/builtins.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/builtins.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/byte_buffer.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/byte_buffer_reader.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/call.cc" role="src" />
@ -1756,9 +1753,10 @@
<file baseinstalldir="/" name="src/core/lib/surface/call_trace.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel_create.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel_create.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel_init.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel_init.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel_ping.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel_stack_type.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/channel_stack_type.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/completion_queue.cc" role="src" />
@ -1773,9 +1771,12 @@
<file baseinstalldir="/" name="src/core/lib/surface/init_internally.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/lame_client.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/lame_client.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/legacy_channel.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/legacy_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/metadata_array.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/server.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/server.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/server_interface.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/validate_metadata.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/validate_metadata.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/version.cc" role="src" />

@ -113,6 +113,35 @@ grpc_cc_library(
language = "c++",
)
grpc_cc_library(
name = "server_call_tracer_filter",
srcs = [
"lib/channel/server_call_tracer_filter.cc",
],
external_deps = [
"absl/status",
"absl/status:statusor",
],
language = "c++",
visibility = ["@grpc:alt_grpc_base_legacy"],
deps = [
"arena_promise",
"call_finalization",
"cancel_callback",
"channel_args",
"channel_fwd",
"channel_stack_type",
"context",
"map",
"pipe",
"//:call_tracer",
"//:config",
"//:gpr_platform",
"//:grpc_base",
"//:legacy_context",
],
)
grpc_cc_library(
name = "atomic_utils",
language = "c++",
@ -137,6 +166,7 @@ grpc_cc_library(
"hpack_constants",
"metadata_batch",
"slice",
"//:call_tracer",
"//:gpr_platform",
"//:grpc_base",
],
@ -2526,10 +2556,10 @@ grpc_cc_library(
grpc_cc_library(
name = "channel_args_endpoint_config",
srcs = [
"//src/core:lib/event_engine/channel_args_endpoint_config.cc",
"lib/event_engine/channel_args_endpoint_config.cc",
],
hdrs = [
"//src/core:lib/event_engine/channel_args_endpoint_config.h",
"lib/event_engine/channel_args_endpoint_config.h",
],
external_deps = [
"absl/strings",
@ -2889,6 +2919,19 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "server_interface",
hdrs = [
"lib/surface/server_interface.h",
],
language = "c++",
deps = [
"channel_args",
"//:channelz",
"//:gpr_platform",
],
)
grpc_cc_library(
name = "single_set_ptr",
hdrs = [
@ -3005,6 +3048,7 @@ grpc_cc_library(
"grpc_service_config",
"lb_policy",
"unique_type_name",
"//:call_tracer",
"//:gpr_public_hdrs",
"//:grpc_base",
"//:legacy_context",
@ -3827,6 +3871,7 @@ grpc_cc_library(
"iomgr_fwd",
"unique_type_name",
"useful",
"//:api_trace",
"//:channel_arg_names",
"//:debug_location",
"//:exec_ctx",
@ -3882,6 +3927,7 @@ grpc_cc_library(
"unique_type_name",
"useful",
"//:alts_util",
"//:api_trace",
"//:channel_arg_names",
"//:exec_ctx",
"//:gpr",
@ -3955,6 +4001,7 @@ grpc_cc_library(
"status_helper",
"unique_type_name",
"useful",
"//:api_trace",
"//:channel_arg_names",
"//:debug_location",
"//:exec_ctx",
@ -3995,6 +4042,7 @@ grpc_cc_library(
"slice",
"unique_type_name",
"useful",
"//:api_trace",
"//:exec_ctx",
"//:gpr",
"//:grpc_base",
@ -4042,6 +4090,7 @@ grpc_cc_library(
"time",
"unique_type_name",
"useful",
"//:api_trace",
"//:gpr",
"//:grpc_base",
"//:grpc_credentials_util",
@ -4687,7 +4736,9 @@ grpc_cc_library(
"useful",
"validation_errors",
"//:backoff",
"//:channel",
"//:channel_arg_names",
"//:channel_create",
"//:channelz",
"//:config",
"//:debug_location",
@ -4786,7 +4837,9 @@ grpc_cc_library(
"time",
"validation_errors",
"//:backoff",
"//:channel",
"//:channel_arg_names",
"//:channel_create",
"//:channelz",
"//:config",
"//:debug_location",
@ -5003,7 +5056,9 @@ grpc_cc_library(
"validation_errors",
"xds_type_upb",
"xds_type_upbdefs",
"//:channel",
"//:channel_arg_names",
"//:channel_create",
"//:config",
"//:debug_location",
"//:endpoint_addresses",
@ -5084,6 +5139,7 @@ grpc_cc_library(
"resolved_address",
"slice_refcount",
"unique_type_name",
"//:api_trace",
"//:config",
"//:debug_location",
"//:exec_ctx",
@ -5096,6 +5152,7 @@ grpc_cc_library(
"//:iomgr",
"//:parse_address",
"//:ref_counted_ptr",
"//:server",
"//:sockaddr_utils",
"//:uri_parser",
"//:xds_client",
@ -5969,6 +6026,7 @@ grpc_cc_library(
language = "c++",
deps = [
"arena_promise",
"call_finalization",
"channel_args",
"channel_fwd",
"channel_stack_type",
@ -6636,7 +6694,10 @@ grpc_cc_library(
"tcp_connect_handshaker",
"time",
"unique_type_name",
"//:api_trace",
"//:channel",
"//:channel_arg_names",
"//:channel_create",
"//:channelz",
"//:config",
"//:debug_location",
@ -6690,6 +6751,7 @@ grpc_cc_library(
"status_helper",
"time",
"unique_type_name",
"//:api_trace",
"//:channel_arg_names",
"//:channelz",
"//:chttp2_legacy_frame",
@ -6705,6 +6767,7 @@ grpc_cc_library(
"//:iomgr",
"//:orphanable",
"//:ref_counted_ptr",
"//:server",
"//:sockaddr_utils",
"//:uri_parser",
],
@ -6744,7 +6807,10 @@ grpc_cc_library(
"status_helper",
"time",
"try_seq",
"//:api_trace",
"//:channel",
"//:channel_arg_names",
"//:channel_create",
"//:channelz",
"//:config",
"//:debug_location",
@ -6756,6 +6822,7 @@ grpc_cc_library(
"//:iomgr",
"//:promise",
"//:ref_counted_ptr",
"//:server",
],
)
@ -6916,6 +6983,7 @@ grpc_cc_library(
"slice",
"slice_buffer",
"time",
"//:call_tracer",
"//:channel_arg_names",
"//:config",
"//:gpr",
@ -7112,6 +7180,21 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "call_finalization",
hdrs = [
"lib/channel/call_finalization.h",
],
language = "c++",
visibility = ["@grpc:alt_grpc_base_legacy"],
deps = [
"arena",
"call_final_info",
"context",
"//:gpr_platform",
],
)
grpc_cc_library(
name = "call_filters",
srcs = [
@ -7266,7 +7349,7 @@ grpc_cc_library(
deps = [
"arena",
"chunked_vector",
"compression_internal",
"compression",
"experiments",
"if_list",
"metadata_compression_traits",
@ -7313,8 +7396,9 @@ grpc_cc_library(
)
grpc_cc_library(
name = "compression_internal",
name = "compression",
srcs = [
"lib/compression/compression.cc",
"lib/compression/compression_internal.cc",
],
hdrs = [
@ -7331,6 +7415,8 @@ grpc_cc_library(
"channel_args",
"ref_counted_string",
"slice",
"useful",
"//:api_trace",
"//:gpr",
"//:grpc_public_hdrs",
"//:grpc_trace",
@ -7397,6 +7483,7 @@ grpc_cc_library(
"//:iomgr",
"//:orphanable",
"//:ref_counted_ptr",
"//:server",
],
)
@ -7446,6 +7533,9 @@ grpc_cc_library(
"time",
"try_seq",
"wait_for_callback",
"//:api_trace",
"//:channel",
"//:channel_create",
"//:debug_location",
"//:exec_ctx",
"//:gpr",

@ -1,250 +0,0 @@
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <grpc/support/port_platform.h>
#include <inttypes.h>
#include "absl/base/thread_annotations.h"
#include "absl/status/status.h"
#include "absl/types/optional.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h>
#include <grpc/impl/connectivity_state.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/client_channel/client_channel_filter.h"
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/dual_ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/lame_client.h"
namespace grpc_core {
namespace {
bool IsLameChannel(Channel* channel) {
grpc_channel_element* elem =
grpc_channel_stack_last_element(channel->channel_stack());
return elem->filter == &LameClientFilter::kFilter;
}
} // namespace
} // namespace grpc_core
grpc_connectivity_state grpc_channel_check_connectivity_state(
grpc_channel* c_channel, int try_to_connect) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_channel_check_connectivity_state(channel=%p, try_to_connect=%d)", 2,
(c_channel, try_to_connect));
grpc_core::Channel* channel = grpc_core::Channel::FromC(c_channel);
// Forward through to the underlying client channel.
grpc_core::ClientChannelFilter* client_channel =
grpc_core::ClientChannelFilter::GetFromChannel(channel);
if (GPR_UNLIKELY(client_channel == nullptr)) {
if (grpc_core::IsLameChannel(channel)) {
return GRPC_CHANNEL_TRANSIENT_FAILURE;
}
gpr_log(GPR_ERROR,
"grpc_channel_check_connectivity_state called on something that is "
"not a client channel");
return GRPC_CHANNEL_SHUTDOWN;
}
return client_channel->CheckConnectivityState(try_to_connect);
}
int grpc_channel_support_connectivity_watcher(grpc_channel* channel) {
return grpc_core::ClientChannelFilter::GetFromChannel(
grpc_core::Channel::FromC(channel)) != nullptr;
}
namespace grpc_core {
namespace {
class StateWatcher : public DualRefCounted<StateWatcher> {
public:
StateWatcher(grpc_channel* c_channel, grpc_completion_queue* cq, void* tag,
grpc_connectivity_state last_observed_state,
gpr_timespec deadline)
: channel_(Channel::FromC(c_channel)->Ref()),
cq_(cq),
tag_(tag),
state_(last_observed_state) {
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
GRPC_CLOSURE_INIT(&on_complete_, WatchComplete, this, nullptr);
ClientChannelFilter* client_channel =
ClientChannelFilter::GetFromChannel(channel_.get());
if (client_channel == nullptr) {
// If the target URI used to create the channel was invalid, channel
// stack initialization failed, and that caused us to create a lame
// channel. In that case, connectivity state will never change (it
// will always be TRANSIENT_FAILURE), so we don't actually start a
// watch, but we are hiding that fact from the application.
if (IsLameChannel(channel_.get())) {
// A ref is held by the timer callback.
StartTimer(Timestamp::FromTimespecRoundUp(deadline));
// Ref from object creation needs to be freed here since lame channel
// does not have a watcher.
Unref();
return;
}
Crash(
"grpc_channel_watch_connectivity_state called on something that is "
"not a client channel");
}
// Ref from object creation is held by the watcher callback.
auto* watcher_timer_init_state = new WatcherTimerInitState(
this, Timestamp::FromTimespecRoundUp(deadline));
client_channel->AddExternalConnectivityWatcher(
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq)), &state_,
&on_complete_, watcher_timer_init_state->closure());
}
private:
// A fire-and-forget object used to delay starting the timer until the
// ClientChannelFilter actually starts the watch.
class WatcherTimerInitState {
public:
WatcherTimerInitState(StateWatcher* state_watcher, Timestamp deadline)
: state_watcher_(state_watcher), deadline_(deadline) {
GRPC_CLOSURE_INIT(&closure_, WatcherTimerInit, this, nullptr);
}
grpc_closure* closure() { return &closure_; }
private:
static void WatcherTimerInit(void* arg, grpc_error_handle /*error*/) {
auto* self = static_cast<WatcherTimerInitState*>(arg);
self->state_watcher_->StartTimer(self->deadline_);
delete self;
}
StateWatcher* state_watcher_;
Timestamp deadline_;
grpc_closure closure_;
};
void StartTimer(Timestamp deadline) {
const Duration timeout = deadline - Timestamp::Now();
MutexLock lock(&mu_);
timer_handle_ = channel_->channel_stack()->EventEngine()->RunAfter(
timeout, [self = Ref()]() mutable {
ApplicationCallbackExecCtx callback_exec_ctx;
ExecCtx exec_ctx;
self->TimeoutComplete();
// StateWatcher deletion might require an active ExecCtx.
self.reset();
});
}
static void WatchComplete(void* arg, grpc_error_handle error) {
auto* self = static_cast<StateWatcher*>(arg);
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures)) {
GRPC_LOG_IF_ERROR("watch_completion_error", error);
}
{
MutexLock lock(&self->mu_);
if (self->timer_handle_.has_value()) {
self->channel_->channel_stack()->EventEngine()->Cancel(
*self->timer_handle_);
}
}
// Watcher fired when either notified or cancelled, either way the state of
// this watcher has been cleared from the client channel. Thus there is no
// need to cancel the watch again.
self->Unref();
}
void TimeoutComplete() {
timer_fired_ = true;
// If this is a client channel (not a lame channel), cancel the watch.
ClientChannelFilter* client_channel =
ClientChannelFilter::GetFromChannel(channel_.get());
if (client_channel != nullptr) {
client_channel->CancelExternalConnectivityWatcher(&on_complete_);
}
}
// Invoked when both strong refs are released.
void Orphan() override {
WeakRef().release(); // Take a weak ref until completion is finished.
grpc_error_handle error =
timer_fired_
? GRPC_ERROR_CREATE("Timed out waiting for connection state change")
: absl::OkStatus();
grpc_cq_end_op(cq_, tag_, error, FinishedCompletion, this,
&completion_storage_);
}
// Called when the completion is returned to the CQ.
static void FinishedCompletion(void* arg, grpc_cq_completion* /*ignored*/) {
auto* self = static_cast<StateWatcher*>(arg);
self->WeakUnref();
}
RefCountedPtr<Channel> channel_;
grpc_completion_queue* cq_;
void* tag_;
grpc_connectivity_state state_;
grpc_cq_completion completion_storage_;
grpc_closure on_complete_;
// timer_handle_ might be accessed in parallel from multiple threads, e.g.
// timer callback fired immediately on an EventEngine thread before
// RunAfter() returns.
Mutex mu_;
absl::optional<grpc_event_engine::experimental::EventEngine::TaskHandle>
timer_handle_ ABSL_GUARDED_BY(mu_);
bool timer_fired_ = false;
};
} // namespace
} // namespace grpc_core
void grpc_channel_watch_connectivity_state(
grpc_channel* channel, grpc_connectivity_state last_observed_state,
gpr_timespec deadline, grpc_completion_queue* cq, void* tag) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_channel_watch_connectivity_state("
"channel=%p, last_observed_state=%d, "
"deadline=gpr_timespec { tv_sec: %" PRId64
", tv_nsec: %d, clock_type: %d }, "
"cq=%p, tag=%p)",
7,
(channel, (int)last_observed_state, deadline.tv_sec, deadline.tv_nsec,
(int)deadline.clock_type, cq, tag));
new grpc_core::StateWatcher(channel, cq, tag, last_observed_state, deadline);
}

@ -94,7 +94,6 @@
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/metadata_batch.h"
@ -1197,16 +1196,6 @@ class ClientChannelFilter::ClientChannelControlHelper
// ClientChannelFilter implementation
//
ClientChannelFilter* ClientChannelFilter::GetFromChannel(Channel* channel) {
grpc_channel_element* elem =
grpc_channel_stack_last_element(channel->channel_stack());
if (elem->filter != &kFilterVtableWithPromises &&
elem->filter != &kFilterVtableWithoutPromises) {
return nullptr;
}
return static_cast<ClientChannelFilter*>(elem->channel_data);
}
grpc_error_handle ClientChannelFilter::Init(grpc_channel_element* elem,
grpc_channel_element_args* args) {
GPR_ASSERT(args->is_last);

@ -65,7 +65,6 @@
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/service_config/service_config.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
@ -115,10 +114,6 @@ class ClientChannelFilter {
struct RawPointerChannelArgTag {};
static absl::string_view ChannelArgName() { return GRPC_ARG_CLIENT_CHANNEL; }
// Returns the ClientChannelFilter object from channel, or null if channel
// is not a client channel.
static ClientChannelFilter* GetFromChannel(Channel* channel);
static ArenaPromise<ServerMetadataHandle> MakeCallPromise(
grpc_channel_element* elem, CallArgs call_args,
NextPromiseFactory next_promise_factory);

@ -28,6 +28,7 @@
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
namespace {
@ -56,8 +57,8 @@ grpc_channel* CreateDirectBinderChannelImplForTesting(
.PreconditionChannelArgs(args)
.Set(GRPC_ARG_DEFAULT_AUTHORITY, "binder.authority");
auto channel =
grpc_core::Channel::Create("binder_target_placeholder", channel_args,
GRPC_CLIENT_DIRECT_CHANNEL, transport);
grpc_core::ChannelCreate("binder_target_placeholder", channel_args,
GRPC_CLIENT_DIRECT_CHANNEL, transport);
// TODO(mingcl): Handle error properly
GPR_ASSERT(channel.ok());
grpc_channel_args_destroy(args);
@ -75,8 +76,8 @@ grpc_channel* CreateClientBinderChannelImpl(const grpc_channel_args* args) {
.SetObject(g_factory);
auto channel =
grpc_core::Channel::Create("binder_channel_target_placeholder",
channel_args, GRPC_CLIENT_CHANNEL, nullptr);
grpc_core::ChannelCreate("binder_channel_target_placeholder",
channel_args, GRPC_CLIENT_CHANNEL, nullptr);
if (!channel.ok()) {
return grpc_lame_client_channel_create(

@ -58,6 +58,7 @@
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/lib/transport/promise_endpoint.h"
@ -355,7 +356,7 @@ grpc_channel* grpc_chaotic_good_channel_create(const char* target,
std::string canonical_target = grpc_core::CoreConfiguration::Get()
.resolver_registry()
.AddDefaultPrefixIfNeeded(target);
auto r = grpc_core::Channel::Create(
auto r = grpc_core::ChannelCreate(
target,
grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()

@ -64,6 +64,7 @@
#include "src/core/lib/security/security_connector/security_connector.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/handshaker.h"
@ -307,7 +308,7 @@ class Chttp2SecureClientChannelFactory : public ClientChannelFactory {
}
};
absl::StatusOr<RefCountedPtr<Channel>> CreateChannel(const char* target,
absl::StatusOr<OrphanablePtr<Channel>> CreateChannel(const char* target,
const ChannelArgs& args) {
if (target == nullptr) {
gpr_log(GPR_ERROR, "cannot create channel with NULL target name");
@ -317,9 +318,8 @@ absl::StatusOr<RefCountedPtr<Channel>> CreateChannel(const char* target,
std::string canonical_target =
CoreConfiguration::Get().resolver_registry().AddDefaultPrefixIfNeeded(
target);
return Channel::Create(target,
args.Set(GRPC_ARG_SERVER_URI, canonical_target),
GRPC_CLIENT_CHANNEL, nullptr);
return ChannelCreate(target, args.Set(GRPC_ARG_SERVER_URI, canonical_target),
GRPC_CLIENT_CHANNEL, nullptr);
}
} // namespace
@ -410,7 +410,7 @@ grpc_channel* grpc_channel_create_from_fd(const char* target, int fd,
grpc_core::Transport* transport =
grpc_create_chttp2_transport(final_args, client, true);
GPR_ASSERT(transport);
auto channel = grpc_core::Channel::Create(
auto channel = grpc_core::ChannelCreate(
target, final_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
if (channel.ok()) {
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr);

@ -47,6 +47,8 @@ grpc_cc_library(
"client/secure/cronet_channel_create.h",
],
deps = [
"//:channel",
"//:channel_create",
"//:grpc_base",
"//:grpc_transport_chttp2",
"//src/core:channel_args",

@ -32,6 +32,7 @@
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/transport.h"
@ -52,7 +53,7 @@ GRPCAPI grpc_channel* grpc_cronet_secure_channel_create(
engine, target, channel_args.ToC().get(), reserved);
grpc_core::ExecCtx exec_ctx;
auto channel = grpc_core::Channel::Create(target, channel_args,
GRPC_CLIENT_DIRECT_CHANNEL, ct);
auto channel = grpc_core::ChannelCreate(target, channel_args,
GRPC_CLIENT_DIRECT_CHANNEL, ct);
return channel.ok() ? channel->release()->c_ptr() : nullptr;
}

@ -26,6 +26,7 @@
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/promise/promise.h"
#include "src/core/lib/promise/try_seq.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/transport.h"
@ -155,7 +156,7 @@ bool UsePromiseBasedTransport() {
return true;
}
RefCountedPtr<Channel> MakeLameChannel(absl::string_view why,
OrphanablePtr<Channel> MakeLameChannel(absl::string_view why,
absl::Status error) {
gpr_log(GPR_ERROR, "%s: %s", std::string(why).c_str(),
std::string(error.message()).c_str());
@ -164,11 +165,11 @@ RefCountedPtr<Channel> MakeLameChannel(absl::string_view why,
if (grpc_error_get_int(error, StatusIntProperty::kRpcStatus, &integer)) {
status = static_cast<grpc_status_code>(integer);
}
return RefCountedPtr<Channel>(Channel::FromC(grpc_lame_client_channel_create(
return OrphanablePtr<Channel>(Channel::FromC(grpc_lame_client_channel_create(
nullptr, status, std::string(why).c_str())));
}
RefCountedPtr<Channel> MakeInprocChannel(Server* server,
OrphanablePtr<Channel> MakeInprocChannel(Server* server,
ChannelArgs client_channel_args) {
auto transports = MakeInProcessTransportPair();
auto client_transport = std::move(transports.first);
@ -183,7 +184,7 @@ RefCountedPtr<Channel> MakeInprocChannel(Server* server,
return MakeLameChannel("Failed to create server channel", std::move(error));
}
std::ignore = server_transport.release(); // consumed by SetupTransport
auto channel = Channel::Create(
auto channel = ChannelCreate(
"inproc",
client_channel_args.Set(GRPC_ARG_DEFAULT_AUTHORITY, "inproc.authority"),
GRPC_CLIENT_DIRECT_CHANNEL, client_transport.release());

@ -61,6 +61,7 @@
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/connectivity_state.h"
@ -1264,7 +1265,7 @@ grpc_channel* grpc_legacy_inproc_channel_create(grpc_server* server,
server_transport, nullptr, server_args, nullptr);
grpc_channel* channel = nullptr;
if (error.ok()) {
auto new_channel = grpc_core::Channel::Create(
auto new_channel = grpc_core::ChannelCreate(
"inproc", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
if (!new_channel.ok()) {
GPR_ASSERT(!channel);

@ -69,15 +69,16 @@ namespace grpc_core {
//
GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::GrpcStreamingCall(
RefCountedPtr<GrpcXdsTransportFactory> factory, grpc_channel* channel,
RefCountedPtr<GrpcXdsTransportFactory> factory, Channel* channel,
const char* method,
std::unique_ptr<StreamingCall::EventHandler> event_handler)
: factory_(std::move(factory)), event_handler_(std::move(event_handler)) {
// Create call.
call_ = grpc_channel_create_pollset_set_call(
channel, nullptr, GRPC_PROPAGATE_DEFAULTS, factory_->interested_parties(),
StaticSlice::FromStaticString(method).c_slice(), nullptr,
Timestamp::InfFuture(), nullptr);
call_ = channel->CreateCall(
/*parent_call=*/nullptr, GRPC_PROPAGATE_DEFAULTS, /*cq=*/nullptr,
factory_->interested_parties(), Slice::FromStaticString(method),
/*authority=*/absl::nullopt, Timestamp::InfFuture(),
/*registered_method=*/true);
GPR_ASSERT(call_ != nullptr);
// Init data associated with the call.
grpc_metadata_array_init(&initial_metadata_recv_);
@ -252,19 +253,13 @@ class GrpcXdsTransportFactory::GrpcXdsTransport::StateWatcher
namespace {
grpc_channel* CreateXdsChannel(const ChannelArgs& args,
const GrpcXdsBootstrap::GrpcXdsServer& server) {
OrphanablePtr<Channel> CreateXdsChannel(
const ChannelArgs& args, const GrpcXdsBootstrap::GrpcXdsServer& server) {
RefCountedPtr<grpc_channel_credentials> channel_creds =
CoreConfiguration::Get().channel_creds_registry().CreateChannelCreds(
server.channel_creds_config());
return grpc_channel_create(server.server_uri().c_str(), channel_creds.get(),
args.ToC().get());
}
bool IsLameChannel(grpc_channel* channel) {
grpc_channel_element* elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel));
return elem->filter == &LameClientFilter::kFilter;
return OrphanablePtr<Channel>(Channel::FromC(grpc_channel_create(
server.server_uri().c_str(), channel_creds.get(), args.ToC().get())));
}
} // namespace
@ -278,29 +273,19 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcXdsTransport(
factory->args_,
static_cast<const GrpcXdsBootstrap::GrpcXdsServer&>(server));
GPR_ASSERT(channel_ != nullptr);
if (IsLameChannel(channel_)) {
if (channel_->IsLame()) {
*status = absl::UnavailableError("xds client has a lame channel");
} else {
ClientChannelFilter* client_channel =
ClientChannelFilter::GetFromChannel(Channel::FromC(channel_));
GPR_ASSERT(client_channel != nullptr);
watcher_ = new StateWatcher(std::move(on_connectivity_failure));
client_channel->AddConnectivityWatcher(
channel_->AddConnectivityWatcher(
GRPC_CHANNEL_IDLE,
OrphanablePtr<AsyncConnectivityStateWatcherInterface>(watcher_));
}
}
GrpcXdsTransportFactory::GrpcXdsTransport::~GrpcXdsTransport() {
grpc_channel_destroy_internal(channel_);
}
void GrpcXdsTransportFactory::GrpcXdsTransport::Orphan() {
if (!IsLameChannel(channel_)) {
ClientChannelFilter* client_channel =
ClientChannelFilter::GetFromChannel(Channel::FromC(channel_));
GPR_ASSERT(client_channel != nullptr);
client_channel->RemoveConnectivityWatcher(watcher_);
if (!channel_->IsLame()) {
channel_->RemoveConnectivityWatcher(watcher_);
}
// Do an async hop before unreffing. This avoids a deadlock upon
// shutdown in the case where the xDS channel is itself an xDS channel
@ -319,11 +304,11 @@ GrpcXdsTransportFactory::GrpcXdsTransport::CreateStreamingCall(
return MakeOrphanable<GrpcStreamingCall>(
factory_->RefAsSubclass<GrpcXdsTransportFactory>(DEBUG_LOCATION,
"StreamingCall"),
channel_, method, std::move(event_handler));
channel_.get(), method, std::move(event_handler));
}
void GrpcXdsTransportFactory::GrpcXdsTransport::ResetBackoff() {
grpc_channel_reset_connect_backoff(channel_);
channel_->ResetConnectionBackoff();
}
//

@ -37,6 +37,7 @@
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/iomgr_fwd.h"
#include "src/core/lib/surface/channel.h"
namespace grpc_core {
@ -70,7 +71,6 @@ class GrpcXdsTransportFactory::GrpcXdsTransport
const XdsBootstrap::XdsServer& server,
std::function<void(absl::Status)> on_connectivity_failure,
absl::Status* status);
~GrpcXdsTransport() override;
void Orphan() override;
@ -84,7 +84,7 @@ class GrpcXdsTransportFactory::GrpcXdsTransport
class StateWatcher;
GrpcXdsTransportFactory* factory_; // Not owned.
grpc_channel* channel_;
OrphanablePtr<Channel> channel_;
StateWatcher* watcher_;
};
@ -92,7 +92,7 @@ class GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall
: public XdsTransportFactory::XdsTransport::StreamingCall {
public:
GrpcStreamingCall(RefCountedPtr<GrpcXdsTransportFactory> factory,
grpc_channel* channel, const char* method,
Channel* channel, const char* method,
std::unique_ptr<StreamingCall::EventHandler> event_handler);
~GrpcStreamingCall() override;

@ -19,9 +19,9 @@
#include <utility>
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/promise/context.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/transport/call_final_info.h"
namespace grpc_core {

@ -36,8 +36,8 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/slice_buffer.h"
#include "src/core/lib/transport/call_final_info.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
namespace grpc_core {

@ -191,6 +191,9 @@ class ChannelNode : public BaseNode {
static absl::string_view ChannelArgName() {
return GRPC_ARG_CHANNELZ_CHANNEL_NODE;
}
static int ChannelArgsCompare(const ChannelNode* a, const ChannelNode* b) {
return QsortCompare(a, b);
}
// Returns the string description of the given connectivity state.
static const char* GetChannelConnectivityStateChangeString(

@ -29,6 +29,7 @@
#include "absl/strings/str_format.h"
#include "absl/strings/str_split.h"
#include <grpc/compression.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
@ -239,4 +240,36 @@ DefaultCompressionAlgorithmFromChannelArgs(const ChannelArgs& args) {
return absl::nullopt;
}
grpc_compression_options CompressionOptionsFromChannelArgs(
const ChannelArgs& args) {
// Set compression options.
grpc_compression_options compression_options;
grpc_compression_options_init(&compression_options);
auto default_level = args.GetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL);
if (default_level.has_value()) {
compression_options.default_level.is_set = true;
compression_options.default_level.level = Clamp(
static_cast<grpc_compression_level>(*default_level),
GRPC_COMPRESS_LEVEL_NONE,
static_cast<grpc_compression_level>(GRPC_COMPRESS_LEVEL_COUNT - 1));
}
auto default_algorithm =
args.GetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM);
if (default_algorithm.has_value()) {
compression_options.default_algorithm.is_set = true;
compression_options.default_algorithm.algorithm =
Clamp(static_cast<grpc_compression_algorithm>(*default_algorithm),
GRPC_COMPRESS_NONE,
static_cast<grpc_compression_algorithm>(
GRPC_COMPRESS_ALGORITHMS_COUNT - 1));
}
auto enabled_algorithms_bitset =
args.GetInt(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET);
if (enabled_algorithms_bitset.has_value()) {
compression_options.enabled_algorithms_bitset =
*enabled_algorithms_bitset | 1 /* always support no compression */;
}
return compression_options;
}
} // namespace grpc_core

@ -88,6 +88,9 @@ class CompressionAlgorithmSet {
BitSet<GRPC_COMPRESS_ALGORITHMS_COUNT> set_;
};
grpc_compression_options CompressionOptionsFromChannelArgs(
const ChannelArgs& args);
} // namespace grpc_core
#endif // GRPC_SRC_CORE_LIB_COMPRESSION_COMPRESSION_INTERNAL_H

@ -1,26 +0,0 @@
// Copyright 2021 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef GRPC_SRC_CORE_LIB_SURFACE_BUILTINS_H
#define GRPC_SRC_CORE_LIB_SURFACE_BUILTINS_H
#include <grpc/support/port_platform.h>
#include "src/core/lib/config/core_configuration.h"
namespace grpc_core {
void RegisterBuiltins(CoreConfiguration::Builder* builder);
} // namespace grpc_core
#endif // GRPC_SRC_CORE_LIB_SURFACE_BUILTINS_H

@ -98,7 +98,7 @@
#include "src/core/lib/surface/call_test_only.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/surface/server_interface.h"
#include "src/core/lib/surface/validate_metadata.h"
#include "src/core/lib/surface/wait_for_cq_end_op.h"
#include "src/core/lib/transport/batch_builder.h"
@ -757,7 +757,7 @@ class FilterStackCall final : public Call {
struct {
int* cancelled;
// backpointer to owning server if this is a server side call.
Server* core_server;
ServerInterface* core_server;
} server;
} final_op_;
AtomicError status_error_;
@ -3368,7 +3368,7 @@ class ServerPromiseBasedCall final : public PromiseBasedCall,
const Completion& completion);
void Finish(ServerMetadataHandle result);
Server* const server_;
ServerInterface* const server_;
const void* const server_transport_data_;
PipeSender<ServerMetadataHandle>* server_initial_metadata_ = nullptr;
PipeSender<MessageHandle>* server_to_client_messages_ = nullptr;
@ -3684,7 +3684,7 @@ class ServerCallSpine final : public CallSpineInterface,
public ServerCallContext,
public BasicPromiseBasedCall {
public:
ServerCallSpine(Server* server, Channel* channel, Arena* arena);
ServerCallSpine(ServerInterface* server, Channel* channel, Arena* arena);
// CallSpineInterface
Pipe<ClientMetadataHandle>& client_initial_metadata() override {
@ -3771,7 +3771,8 @@ class ServerCallSpine final : public CallSpineInterface,
ClientMetadataHandle client_initial_metadata_stored_;
};
ServerCallSpine::ServerCallSpine(Server* server, Channel* channel, Arena* arena)
ServerCallSpine::ServerCallSpine(ServerInterface* server, Channel* channel,
Arena* arena)
: BasicPromiseBasedCall(arena, 0, 1,
[channel, server]() -> grpc_call_create_args {
grpc_call_create_args args;
@ -4119,14 +4120,15 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops,
}
}
RefCountedPtr<CallSpineInterface> MakeServerCall(Server* server,
RefCountedPtr<CallSpineInterface> MakeServerCall(ServerInterface* server,
Channel* channel,
Arena* arena) {
return RefCountedPtr<ServerCallSpine>(
arena->New<ServerCallSpine>(server, channel, arena));
}
#else
RefCountedPtr<CallSpineInterface> MakeServerCall(Server*, Channel*, Arena*) {
RefCountedPtr<CallSpineInterface> MakeServerCall(ServerInterface*, Channel*,
Arena*) {
Crash("not implemented");
}
#endif

@ -50,7 +50,7 @@
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/surface/server_interface.h"
#include "src/core/lib/transport/transport.h"
typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success,
@ -58,7 +58,7 @@ typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success,
typedef struct grpc_call_create_args {
grpc_core::RefCountedPtr<grpc_core::Channel> channel;
grpc_core::Server* server;
grpc_core::ServerInterface* server;
grpc_call* parent;
uint32_t propagation_mask;
@ -159,7 +159,7 @@ class CallContext {
template <>
struct ContextType<CallContext> {};
RefCountedPtr<CallSpineInterface> MakeServerCall(Server* server,
RefCountedPtr<CallSpineInterface> MakeServerCall(ServerInterface* server,
Channel* channel,
Arena* arena);

@ -1,5 +1,4 @@
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@ -14,294 +13,84 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include <grpc/support/port_platform.h>
#include "src/core/lib/surface/channel.h"
#include <inttypes.h>
#include <string.h>
#include <algorithm>
#include <atomic>
#include <functional>
#include <memory>
#include "absl/status/status.h"
#include <grpc/compression.h>
#include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_stack_builder_impl.h"
#include "src/core/lib/channel/channel_trace.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/channel/metrics.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/compression/compression_internal.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/resource_quota/memory_quota.h"
#include "src/core/lib/resource_quota/resource_quota.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/surface/init_internally.h"
#include "src/core/lib/transport/call_factory.h"
#include "src/core/lib/transport/transport.h"
// IWYU pragma: no_include <type_traits>
namespace grpc_core {
namespace {
//
// Channel::RegisteredCall
//
class NotReallyACallFactory final : public CallFactory {
public:
using CallFactory::CallFactory;
CallInitiator CreateCall(ClientMetadataHandle, Arena*) override {
Crash("NotReallyACallFactory::CreateCall should never be called");
Channel::RegisteredCall::RegisteredCall(const char* method_arg,
const char* host_arg) {
path = Slice::FromCopiedString(method_arg);
if (host_arg != nullptr && host_arg[0] != 0) {
authority = Slice::FromCopiedString(host_arg);
}
};
} // namespace
Channel::Channel(bool is_client, bool is_promising, std::string target,
const ChannelArgs& channel_args,
grpc_compression_options compression_options,
RefCountedPtr<grpc_channel_stack> channel_stack)
: is_client_(is_client),
is_promising_(is_promising),
compression_options_(compression_options),
channelz_node_(channel_args.GetObjectRef<channelz::ChannelNode>()),
target_(std::move(target)),
channel_stack_(std::move(channel_stack)),
call_factory_(MakeRefCounted<NotReallyACallFactory>(channel_args)) {
// We need to make sure that grpc_shutdown() does not shut things down
// until after the channel is destroyed. However, the channel may not
// actually be destroyed by the time grpc_channel_destroy() returns,
// since there may be other existing refs to the channel. If those
// refs are held by things that are visible to the wrapped language
// (such as outstanding calls on the channel), then the wrapped
// language can be responsible for making sure that grpc_shutdown()
// does not run until after those refs are released. However, the
// channel may also have refs to itself held internally for various
// things that need to be cleaned up at channel destruction (e.g.,
// LB policies, subchannels, etc), and because these refs are not
// visible to the wrapped language, it cannot be responsible for
// deferring grpc_shutdown() until after they are released. To
// accommodate that, we call grpc_init() here and then call
// grpc_shutdown() when the channel is actually destroyed, thus
// ensuring that shutdown is deferred until that point.
InitInternally();
auto channelz_node = channelz_node_;
*channel_stack_->on_destroy = [channelz_node]() {
if (channelz_node != nullptr) {
channelz_node->AddTraceEvent(
channelz::ChannelTrace::Severity::Info,
grpc_slice_from_static_string("Channel destroyed"));
}
ShutdownInternally();
};
}
absl::StatusOr<RefCountedPtr<Channel>> Channel::CreateWithBuilder(
ChannelStackBuilder* builder) {
auto channel_args = builder->channel_args();
if (builder->channel_stack_type() == GRPC_SERVER_CHANNEL) {
global_stats().IncrementServerChannelsCreated();
} else {
global_stats().IncrementClientChannelsCreated();
}
absl::StatusOr<RefCountedPtr<grpc_channel_stack>> r = builder->Build();
if (!r.ok()) {
auto status = r.status();
gpr_log(GPR_ERROR, "channel stack builder failed: %s",
status.ToString().c_str());
return status;
}
grpc_compression_options compression_options;
grpc_compression_options_init(&compression_options);
auto default_level =
channel_args.GetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_LEVEL);
if (default_level.has_value()) {
compression_options.default_level.is_set = true;
compression_options.default_level.level = Clamp(
static_cast<grpc_compression_level>(*default_level),
GRPC_COMPRESS_LEVEL_NONE,
static_cast<grpc_compression_level>(GRPC_COMPRESS_LEVEL_COUNT - 1));
}
auto default_algorithm =
channel_args.GetInt(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM);
if (default_algorithm.has_value()) {
compression_options.default_algorithm.is_set = true;
compression_options.default_algorithm.algorithm =
Clamp(static_cast<grpc_compression_algorithm>(*default_algorithm),
GRPC_COMPRESS_NONE,
static_cast<grpc_compression_algorithm>(
GRPC_COMPRESS_ALGORITHMS_COUNT - 1));
}
auto enabled_algorithms_bitset =
channel_args.GetInt(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET);
if (enabled_algorithms_bitset.has_value()) {
compression_options.enabled_algorithms_bitset =
*enabled_algorithms_bitset | 1 /* always support no compression */;
Channel::RegisteredCall::RegisteredCall(const RegisteredCall& other)
: path(other.path.Ref()) {
if (other.authority.has_value()) {
authority = other.authority->Ref();
}
// TODO(roth): Populate authority after merging
// https://github.com/grpc/grpc/pull/35924.
StatsPlugin::ChannelScope scope(builder->target(), "");
*(*r)->stats_plugin_group =
GlobalStatsPluginRegistry::GetStatsPluginsForChannel(scope);
return RefCountedPtr<Channel>(new Channel(
grpc_channel_stack_type_is_client(builder->channel_stack_type()),
builder->IsPromising(), std::string(builder->target()), channel_args,
compression_options, std::move(*r)));
}
namespace {
Channel::RegisteredCall::~RegisteredCall() {}
void* channelz_node_copy(void* p) {
channelz::ChannelNode* node = static_cast<channelz::ChannelNode*>(p);
node->Ref().release();
return p;
}
void channelz_node_destroy(void* p) {
channelz::ChannelNode* node = static_cast<channelz::ChannelNode*>(p);
node->Unref();
}
int channelz_node_cmp(void* p1, void* p2) { return QsortCompare(p1, p2); }
const grpc_arg_pointer_vtable channelz_node_arg_vtable = {
channelz_node_copy, channelz_node_destroy, channelz_node_cmp};
} // namespace
//
// Channel
//
absl::StatusOr<RefCountedPtr<Channel>> Channel::Create(
const char* target, ChannelArgs args,
grpc_channel_stack_type channel_stack_type, Transport* optional_transport) {
if (!args.GetString(GRPC_ARG_DEFAULT_AUTHORITY).has_value()) {
auto ssl_override = args.GetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
if (ssl_override.has_value()) {
args = args.Set(GRPC_ARG_DEFAULT_AUTHORITY,
std::string(ssl_override.value()));
}
}
if (grpc_channel_stack_type_is_client(channel_stack_type)) {
auto channel_args_mutator =
grpc_channel_args_get_client_channel_creation_mutator();
if (channel_args_mutator != nullptr) {
args = channel_args_mutator(target, args, channel_stack_type);
}
}
// We only need to do this for clients here. For servers, this will be
// done in src/core/lib/surface/server.cc.
if (grpc_channel_stack_type_is_client(channel_stack_type)) {
// Check whether channelz is enabled.
if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ)
.value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) {
// Get parameters needed to create the channelz node.
const size_t channel_tracer_max_memory = std::max(
0,
args.GetInt(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE)
.value_or(GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT));
const bool is_internal_channel =
args.GetBool(GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL).value_or(false);
// Create the channelz node.
std::string channelz_node_target{target == nullptr ? "unknown" : target};
RefCountedPtr<channelz::ChannelNode> channelz_node =
MakeRefCounted<channelz::ChannelNode>(channelz_node_target,
channel_tracer_max_memory,
is_internal_channel);
channelz_node->AddTraceEvent(
channelz::ChannelTrace::Severity::Info,
grpc_slice_from_static_string("Channel created"));
// Add channelz node to channel args.
// We remove the is_internal_channel arg, since we no longer need it.
args = args.Remove(GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL)
.Set(GRPC_ARG_CHANNELZ_CHANNEL_NODE,
ChannelArgs::Pointer(channelz_node.release(),
&channelz_node_arg_vtable));
}
}
ChannelStackBuilderImpl builder(
grpc_channel_stack_type_string(channel_stack_type), channel_stack_type,
args.SetObject(optional_transport));
builder.SetTarget(target);
if (!CoreConfiguration::Get().channel_init().CreateStack(&builder)) {
return nullptr;
Channel::Channel(std::string target, const ChannelArgs& channel_args)
: target_(std::move(target)),
channelz_node_(channel_args.GetObjectRef<channelz::ChannelNode>()),
compression_options_(CompressionOptionsFromChannelArgs(channel_args)) {}
Channel::RegisteredCall* Channel::RegisterCall(const char* method,
const char* host) {
MutexLock lock(&mu_);
auto key = std::make_pair(std::string(host != nullptr ? host : ""),
std::string(method != nullptr ? method : ""));
auto rc_posn = registration_table_.find(key);
if (rc_posn != registration_table_.end()) {
return &rc_posn->second;
}
return CreateWithBuilder(&builder);
auto insertion_result = registration_table_.insert(
{std::move(key), RegisteredCall(method, host)});
return &insertion_result.first->second;
}
} // namespace grpc_core
char* grpc_channel_get_target(grpc_channel* channel) {
GRPC_API_TRACE("grpc_channel_get_target(channel=%p)", 1, (channel));
auto target = grpc_core::Channel::FromC(channel)->target();
char* buffer = static_cast<char*>(gpr_zalloc(target.size() + 1));
memcpy(buffer, target.data(), target.size());
return buffer;
}
void grpc_channel_get_info(grpc_channel* channel,
const grpc_channel_info* channel_info) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_channel_element* elem = grpc_channel_stack_element(
grpc_core::Channel::FromC(channel)->channel_stack(), 0);
elem->filter->get_channel_info(elem, channel_info);
}
//
// C-core API
//
void grpc_channel_reset_connect_backoff(grpc_channel* channel) {
void grpc_channel_destroy(grpc_channel* channel) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_channel_reset_connect_backoff(channel=%p)", 1,
(channel));
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->reset_connect_backoff = true;
grpc_channel_element* elem = grpc_channel_stack_element(
grpc_core::Channel::FromC(channel)->channel_stack(), 0);
elem->filter->start_transport_op(elem, op);
}
static grpc_call* grpc_channel_create_call_internal(
grpc_channel* c_channel, grpc_call* parent_call, uint32_t propagation_mask,
grpc_completion_queue* cq, grpc_pollset_set* pollset_set_alternative,
grpc_core::Slice path, absl::optional<grpc_core::Slice> authority,
grpc_core::Timestamp deadline, bool registered_method) {
auto channel = grpc_core::Channel::FromC(c_channel)->Ref();
GPR_ASSERT(channel->is_client());
GPR_ASSERT(!(cq != nullptr && pollset_set_alternative != nullptr));
grpc_call_create_args args;
args.channel = std::move(channel);
args.server = nullptr;
args.parent = parent_call;
args.propagation_mask = propagation_mask;
args.cq = cq;
args.pollset_set_alternative = pollset_set_alternative;
args.server_transport_data = nullptr;
args.path = std::move(path);
args.authority = std::move(authority);
args.send_deadline = deadline;
args.registered_method = registered_method;
grpc_call* call;
GRPC_LOG_IF_ERROR("call_create", grpc_call_create(&args, &call));
return call;
GRPC_API_TRACE("grpc_channel_destroy(channel=%p)", 1, (channel));
grpc_channel_destroy_internal(channel);
}
grpc_call* grpc_channel_create_call(grpc_channel* channel,
@ -313,52 +102,16 @@ grpc_call* grpc_channel_create_call(grpc_channel* channel,
GPR_ASSERT(!reserved);
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_call* call = grpc_channel_create_call_internal(
channel, parent_call, propagation_mask, completion_queue, nullptr,
return grpc_core::Channel::FromC(channel)->CreateCall(
parent_call, propagation_mask, completion_queue, nullptr,
grpc_core::Slice(grpc_core::CSliceRef(method)),
host != nullptr
? absl::optional<grpc_core::Slice>(grpc_core::CSliceRef(*host))
: absl::nullopt,
grpc_core::Timestamp::FromTimespecRoundUp(deadline),
/*registered_method=*/false);
return call;
}
grpc_call* grpc_channel_create_pollset_set_call(
grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
grpc_pollset_set* pollset_set, const grpc_slice& method,
const grpc_slice* host, grpc_core::Timestamp deadline, void* reserved) {
GPR_ASSERT(!reserved);
return grpc_channel_create_call_internal(
channel, parent_call, propagation_mask, nullptr, pollset_set,
grpc_core::Slice(method),
host != nullptr
? absl::optional<grpc_core::Slice>(grpc_core::CSliceRef(*host))
: absl::nullopt,
deadline, /*registered_method=*/true);
}
namespace grpc_core {
RegisteredCall::RegisteredCall(const char* method_arg, const char* host_arg) {
path = Slice::FromCopiedString(method_arg);
if (host_arg != nullptr && host_arg[0] != 0) {
authority = Slice::FromCopiedString(host_arg);
}
}
RegisteredCall::RegisteredCall(const RegisteredCall& other)
: path(other.path.Ref()) {
if (other.authority.has_value()) {
authority = other.authority->Ref();
}
}
RegisteredCall::~RegisteredCall() {}
} // namespace grpc_core
void* grpc_channel_register_call(grpc_channel* channel, const char* method,
const char* host, void* reserved) {
GRPC_API_TRACE(
@ -370,29 +123,12 @@ void* grpc_channel_register_call(grpc_channel* channel, const char* method,
return grpc_core::Channel::FromC(channel)->RegisterCall(method, host);
}
namespace grpc_core {
RegisteredCall* Channel::RegisterCall(const char* method, const char* host) {
MutexLock lock(&registration_table_.mu);
auto key = std::make_pair(std::string(host != nullptr ? host : ""),
std::string(method != nullptr ? method : ""));
auto rc_posn = registration_table_.map.find(key);
if (rc_posn != registration_table_.map.end()) {
return &rc_posn->second;
}
auto insertion_result = registration_table_.map.insert(
{std::move(key), RegisteredCall(method, host)});
return &insertion_result.first->second;
}
} // namespace grpc_core
grpc_call* grpc_channel_create_registered_call(
grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
grpc_completion_queue* completion_queue, void* registered_call_handle,
gpr_timespec deadline, void* reserved) {
grpc_core::RegisteredCall* rc =
static_cast<grpc_core::RegisteredCall*>(registered_call_handle);
auto* rc =
static_cast<grpc_core::Channel::RegisteredCall*>(registered_call_handle);
GRPC_API_TRACE(
"grpc_channel_create_registered_call("
"channel=%p, parent_call=%p, propagation_mask=%x, completion_queue=%p, "
@ -407,31 +143,77 @@ grpc_call* grpc_channel_create_registered_call(
GPR_ASSERT(!reserved);
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_call* call = grpc_channel_create_call_internal(
channel, parent_call, propagation_mask, completion_queue, nullptr,
rc->path.Ref(),
return grpc_core::Channel::FromC(channel)->CreateCall(
parent_call, propagation_mask, completion_queue, nullptr, rc->path.Ref(),
rc->authority.has_value()
? absl::optional<grpc_core::Slice>(rc->authority->Ref())
: absl::nullopt,
grpc_core::Timestamp::FromTimespecRoundUp(deadline),
/*registered_method=*/true);
}
return call;
char* grpc_channel_get_target(grpc_channel* channel) {
GRPC_API_TRACE("grpc_channel_get_target(channel=%p)", 1, (channel));
auto target = grpc_core::Channel::FromC(channel)->target();
char* buffer = static_cast<char*>(gpr_zalloc(target.size() + 1));
memcpy(buffer, target.data(), target.size());
return buffer;
}
void grpc_channel_destroy_internal(grpc_channel* c_channel) {
grpc_core::RefCountedPtr<grpc_core::Channel> channel(
grpc_core::Channel::FromC(c_channel));
grpc_transport_op* op = grpc_make_transport_op(nullptr);
grpc_channel_element* elem;
GRPC_API_TRACE("grpc_channel_destroy(channel=%p)", 1, (c_channel));
op->disconnect_with_error = GRPC_ERROR_CREATE("Channel Destroyed");
elem = grpc_channel_stack_element(channel->channel_stack(), 0);
elem->filter->start_transport_op(elem, op);
void grpc_channel_get_info(grpc_channel* channel,
const grpc_channel_info* channel_info) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_core::Channel::FromC(channel)->GetInfo(channel_info);
}
void grpc_channel_destroy(grpc_channel* channel) {
void grpc_channel_reset_connect_backoff(grpc_channel* channel) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
grpc_channel_destroy_internal(channel);
GRPC_API_TRACE("grpc_channel_reset_connect_backoff(channel=%p)", 1,
(channel));
grpc_core::Channel::FromC(channel)->ResetConnectionBackoff();
}
int grpc_channel_support_connectivity_watcher(grpc_channel* channel) {
return grpc_core::Channel::FromC(channel)->SupportsConnectivityWatcher();
}
grpc_connectivity_state grpc_channel_check_connectivity_state(
grpc_channel* channel, int try_to_connect) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_channel_check_connectivity_state(channel=%p, try_to_connect=%d)", 2,
(channel, try_to_connect));
return grpc_core::Channel::FromC(channel)->CheckConnectivityState(
try_to_connect);
}
void grpc_channel_watch_connectivity_state(
grpc_channel* channel, grpc_connectivity_state last_observed_state,
gpr_timespec deadline, grpc_completion_queue* cq, void* tag) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_channel_watch_connectivity_state("
"channel=%p, last_observed_state=%d, "
"deadline=gpr_timespec { tv_sec: %" PRId64
", tv_nsec: %d, clock_type: %d }, "
"cq=%p, tag=%p)",
7,
(channel, (int)last_observed_state, deadline.tv_sec, deadline.tv_nsec,
(int)deadline.clock_type, cq, tag));
return grpc_core::Channel::FromC(channel)->WatchConnectivityState(
last_observed_state, grpc_core::Timestamp::FromTimespecRoundUp(deadline),
cq, tag);
}
void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
void* tag, void* reserved) {
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE("grpc_channel_ping(channel=%p, cq=%p, tag=%p, reserved=%p)", 4,
(channel, cq, tag, reserved));
GPR_ASSERT(reserved == nullptr);
grpc_core::Channel::FromC(channel)->Ping(cq, tag);
}

@ -1,6 +1,5 @@
//
//
// Copyright 2015 gRPC authors.
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -14,20 +13,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#ifndef GRPC_SRC_CORE_LIB_SURFACE_CHANNEL_H
#define GRPC_SRC_CORE_LIB_SURFACE_CHANNEL_H
#include <grpc/support/port_platform.h>
#include <stddef.h>
#include <stdint.h>
#include <atomic>
#include <map>
#include <string>
#include <utility>
#include "absl/base/thread_annotations.h"
#include "absl/status/statusor.h"
@ -35,155 +28,143 @@
#include "absl/types/optional.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/event_engine/memory_allocator.h>
#include <grpc/grpc.h>
#include <grpc/impl/compression_types.h>
#include <grpc/slice.h>
#include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h" // IWYU pragma: keep
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/gprpp/cpp_impl_of.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/iomgr_fwd.h"
#include "src/core/lib/resource_quota/arena.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/call_factory.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/lib/transport/connectivity_state.h"
/// The same as grpc_channel_destroy, but doesn't create an ExecCtx, and so
/// is safe to use from within core.
void grpc_channel_destroy_internal(grpc_channel* channel);
/// Create a call given a grpc_channel, in order to call \a method.
/// Progress is tied to activity on \a pollset_set. The returned call object is
/// meant to be used with \a grpc_call_start_batch_and_execute, which relies on
/// callbacks to signal completions. \a method and \a host need
/// only live through the invocation of this function. If \a parent_call is
/// non-NULL, it must be a server-side call. It will be used to propagate
/// properties from the server call to this new client call, depending on the
/// value of \a propagation_mask (see propagation_bits.h for possible values)
grpc_call* grpc_channel_create_pollset_set_call(
grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
grpc_pollset_set* pollset_set, const grpc_slice& method,
const grpc_slice* host, grpc_core::Timestamp deadline, void* reserved);
/// Get a (borrowed) pointer to this channels underlying channel stack
grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel);
grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node(
grpc_channel* channel);
// Forward declaration to avoid dependency loop.
struct grpc_channel_stack;
namespace grpc_core {
struct RegisteredCall {
Slice path;
absl::optional<Slice> authority;
explicit RegisteredCall(const char* method_arg, const char* host_arg);
RegisteredCall(const RegisteredCall& other);
RegisteredCall& operator=(const RegisteredCall&) = delete;
~RegisteredCall();
};
struct CallRegistrationTable {
Mutex mu;
// The map key should be owned strings rather than unowned char*'s to
// guarantee that it outlives calls on the core channel (which may outlast the
// C++ or other wrapped language Channel that registered these calls).
std::map<std::pair<std::string, std::string>, RegisteredCall> map
ABSL_GUARDED_BY(mu);
};
// Forward declaration to avoid dependency loop.
class Transport;
class Channel : public RefCounted<Channel>,
public CppImplOf<Channel, grpc_channel> {
public:
static absl::StatusOr<RefCountedPtr<Channel>> Create(
const char* target, ChannelArgs args,
grpc_channel_stack_type channel_stack_type,
Transport* optional_transport);
struct RegisteredCall {
Slice path;
absl::optional<Slice> authority;
static absl::StatusOr<RefCountedPtr<Channel>> CreateWithBuilder(
ChannelStackBuilder* builder);
explicit RegisteredCall(const char* method_arg, const char* host_arg);
RegisteredCall(const RegisteredCall& other);
RegisteredCall& operator=(const RegisteredCall&) = delete;
grpc_channel_stack* channel_stack() const { return channel_stack_.get(); }
~RegisteredCall();
};
grpc_compression_options compression_options() const {
return compression_options_;
}
virtual void Orphan() = 0;
channelz::ChannelNode* channelz_node() const { return channelz_node_.get(); }
virtual Arena* CreateArena() = 0;
virtual void DestroyArena(Arena* arena) = 0;
virtual bool IsLame() const = 0;
// TODO(roth): This should return a C++ type.
virtual grpc_call* CreateCall(grpc_call* parent_call,
uint32_t propagation_mask,
grpc_completion_queue* cq,
grpc_pollset_set* pollset_set_alternative,
Slice path, absl::optional<Slice> authority,
Timestamp deadline, bool registered_method) = 0;
virtual grpc_event_engine::experimental::EventEngine* event_engine()
const = 0;
virtual bool SupportsConnectivityWatcher() const = 0;
Arena* CreateArena() { return call_factory_->CreateArena(); }
void DestroyArena(Arena* arena) { return call_factory_->DestroyArena(arena); }
virtual grpc_connectivity_state CheckConnectivityState(
bool try_to_connect) = 0;
// For external watched via the C-core API.
virtual void WatchConnectivityState(
grpc_connectivity_state last_observed_state, Timestamp deadline,
grpc_completion_queue* cq, void* tag) = 0;
// For internal watches.
virtual void AddConnectivityWatcher(
grpc_connectivity_state initial_state,
OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher) = 0;
virtual void RemoveConnectivityWatcher(
AsyncConnectivityStateWatcherInterface* watcher) = 0;
virtual void GetInfo(const grpc_channel_info* channel_info) = 0;
virtual void ResetConnectionBackoff() = 0;
absl::string_view target() const { return target_; }
bool is_client() const { return is_client_; }
bool is_promising() const { return is_promising_; }
channelz::ChannelNode* channelz_node() const { return channelz_node_.get(); }
grpc_compression_options compression_options() const {
return compression_options_;
}
RegisteredCall* RegisterCall(const char* method, const char* host);
int TestOnlyRegisteredCalls() {
MutexLock lock(&registration_table_.mu);
return registration_table_.map.size();
MutexLock lock(&mu_);
return registration_table_.size();
}
grpc_event_engine::experimental::EventEngine* event_engine() const {
return channel_stack_->EventEngine();
}
// For tests only.
// Pings the channel's peer. Load-balanced channels will select one
// subchannel to ping. If the channel is not connected, posts a
// failure to the CQ.
virtual void Ping(grpc_completion_queue* cq, void* tag) = 0;
private:
Channel(bool is_client, bool is_promising, std::string target,
const ChannelArgs& channel_args,
grpc_compression_options compression_options,
RefCountedPtr<grpc_channel_stack> channel_stack);
// TODO(roth): Remove these methods when LegacyChannel goes away.
virtual grpc_channel_stack* channel_stack() const { return nullptr; }
virtual bool is_client() const { return true; }
virtual bool is_promising() const { return true; }
const bool is_client_;
const bool is_promising_;
protected:
Channel(std::string target, const ChannelArgs& channel_args);
private:
const std::string target_;
const RefCountedPtr<channelz::ChannelNode> channelz_node_;
const grpc_compression_options compression_options_;
CallRegistrationTable registration_table_;
RefCountedPtr<channelz::ChannelNode> channelz_node_;
std::string target_;
const RefCountedPtr<grpc_channel_stack> channel_stack_;
const RefCountedPtr<CallFactory> call_factory_;
Mutex mu_;
// The map key needs to be owned strings rather than unowned char*'s to
// guarantee that it outlives calls on the core channel (which may outlast
// the C++ or other wrapped language Channel that registered these calls).
std::map<std::pair<std::string, std::string>, RegisteredCall>
registration_table_ ABSL_GUARDED_BY(mu_);
};
} // namespace grpc_core
/// The same as grpc_channel_destroy, but doesn't create an ExecCtx, and so
/// is safe to use from within core.
inline void grpc_channel_destroy_internal(grpc_channel* channel) {
grpc_core::Channel::FromC(channel)->Orphan();
}
// Return the channel's compression options.
inline grpc_compression_options grpc_channel_compression_options(
const grpc_channel* channel) {
return grpc_core::Channel::FromC(channel)->compression_options();
}
inline grpc_channel_stack* grpc_channel_get_channel_stack(
grpc_channel* channel) {
return grpc_core::Channel::FromC(channel)->channel_stack();
}
inline grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node(
grpc_channel* channel) {
return grpc_core::Channel::FromC(channel)->channelz_node();
}
inline void grpc_channel_internal_ref(grpc_channel* channel,
const char* reason) {
grpc_core::Channel::FromC(channel)->Ref(DEBUG_LOCATION, reason).release();
}
inline void grpc_channel_internal_unref(grpc_channel* channel,
const char* reason) {
grpc_core::Channel::FromC(channel)->Unref(DEBUG_LOCATION, reason);
}
// Return the channel's compression options.
grpc_compression_options grpc_channel_compression_options(
const grpc_channel* channel);
// Ping the channels peer (load balanced channels will select one sub-channel to
// ping); if the channel is not connected, posts a failed.
void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,

@ -0,0 +1,100 @@
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#include <grpc/support/port_platform.h>
#include <grpc/grpc.h>
#include <grpc/impl/channel_arg_names.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/lame_client.h"
#include "src/core/lib/surface/legacy_channel.h"
namespace grpc_core {
absl::StatusOr<OrphanablePtr<Channel>> ChannelCreate(
std::string target, ChannelArgs args,
grpc_channel_stack_type channel_stack_type, Transport* optional_transport) {
global_stats().IncrementClientChannelsCreated();
// Set default authority if needed.
if (!args.GetString(GRPC_ARG_DEFAULT_AUTHORITY).has_value()) {
auto ssl_override = args.GetString(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG);
if (ssl_override.has_value()) {
args = args.Set(GRPC_ARG_DEFAULT_AUTHORITY,
std::string(ssl_override.value()));
}
}
// Check whether channelz is enabled.
if (args.GetBool(GRPC_ARG_ENABLE_CHANNELZ)
.value_or(GRPC_ENABLE_CHANNELZ_DEFAULT)) {
// Get parameters needed to create the channelz node.
const size_t channel_tracer_max_memory = std::max(
0, args.GetInt(GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE)
.value_or(GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT));
const bool is_internal_channel =
args.GetBool(GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL).value_or(false);
// Create the channelz node.
std::string channelz_node_target{target.empty() ? "unknown" : target};
auto channelz_node = MakeRefCounted<channelz::ChannelNode>(
channelz_node_target, channel_tracer_max_memory, is_internal_channel);
channelz_node->AddTraceEvent(
channelz::ChannelTrace::Severity::Info,
grpc_slice_from_static_string("Channel created"));
// Add channelz node to channel args.
// We remove the is_internal_channel arg, since we no longer need it.
args = args.Remove(GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL)
.SetObject(std::move(channelz_node));
}
// Add transport to args.
if (optional_transport != nullptr) {
args = args.SetObject(optional_transport);
}
// Delegate to legacy channel impl.
return LegacyChannel::Create(std::move(target), std::move(args),
channel_stack_type);
}
} // namespace grpc_core
grpc_channel* grpc_lame_client_channel_create(const char* target,
grpc_status_code error_code,
const char* error_message) {
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_lame_client_channel_create(target=%s, error_code=%d, "
"error_message=%s)",
3, (target, (int)error_code, error_message));
if (error_code == GRPC_STATUS_OK) error_code = GRPC_STATUS_UNKNOWN;
grpc_core::ChannelArgs args =
grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr)
.Set(GRPC_ARG_LAME_FILTER_ERROR,
grpc_core::ChannelArgs::Pointer(
new absl::Status(static_cast<absl::StatusCode>(error_code),
error_message),
&grpc_core::kLameFilterErrorArgVtable));
auto channel =
grpc_core::ChannelCreate(target == nullptr ? "" : target, std::move(args),
GRPC_CLIENT_LAME_CHANNEL, nullptr);
GPR_ASSERT(channel.ok());
return channel->release()->c_ptr();
}

@ -1,4 +1,5 @@
// Copyright 2021 gRPC authors.
//
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -11,27 +12,31 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef GRPC_SRC_CORE_LIB_SURFACE_CHANNEL_CREATE_H
#define GRPC_SRC_CORE_LIB_SURFACE_CHANNEL_CREATE_H
#include <grpc/support/port_platform.h>
#include "src/core/lib/surface/builtins.h"
#include <string>
#include "src/core/lib/channel/call_tracer.h"
#include "src/core/lib/config/core_configuration.h"
#include "absl/status/statusor.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/surface/lame_client.h"
#include "src/core/lib/surface/server.h"
namespace grpc_core {
void RegisterBuiltins(CoreConfiguration::Builder* builder) {
RegisterServerCallTracerFilter(builder);
builder->channel_init()
->RegisterFilter<LameClientFilter>(GRPC_CLIENT_LAME_CHANNEL)
.Terminal();
builder->channel_init()
->RegisterFilter(GRPC_SERVER_CHANNEL, &Server::kServerTopFilter)
.BeforeAll();
}
class Transport;
// Creates a client channel.
absl::StatusOr<OrphanablePtr<Channel>> ChannelCreate(
std::string target, ChannelArgs args,
grpc_channel_stack_type channel_stack_type, Transport* optional_transport);
} // namespace grpc_core
#endif // GRPC_SRC_CORE_LIB_SURFACE_CHANNEL_CREATE_H

@ -1,69 +0,0 @@
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include <grpc/support/port_platform.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/transport/transport.h"
struct ping_result {
grpc_closure closure;
void* tag;
grpc_completion_queue* cq;
grpc_cq_completion completion_storage;
};
static void ping_destroy(void* arg, grpc_cq_completion* /*storage*/) {
gpr_free(arg);
}
static void ping_done(void* arg, grpc_error_handle error) {
ping_result* pr = static_cast<ping_result*>(arg);
grpc_cq_end_op(pr->cq, pr->tag, error, ping_destroy, pr,
&pr->completion_storage);
}
void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq,
void* tag, void* reserved) {
GRPC_API_TRACE("grpc_channel_ping(channel=%p, cq=%p, tag=%p, reserved=%p)", 4,
(channel, cq, tag, reserved));
grpc_transport_op* op = grpc_make_transport_op(nullptr);
ping_result* pr = static_cast<ping_result*>(gpr_malloc(sizeof(*pr)));
grpc_channel_element* top_elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(reserved == nullptr);
pr->tag = tag;
pr->cq = cq;
GRPC_CLOSURE_INIT(&pr->closure, ping_done, pr, grpc_schedule_on_exec_ctx);
op->send_ping.on_ack = &pr->closure;
op->bind_pollset = grpc_cq_pollset(cq);
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
top_elem->filter->start_transport_op(top_elem, op);
}

@ -23,6 +23,7 @@
#include <memory>
#include <utility>
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include <grpc/grpc.h>
@ -53,8 +54,6 @@
// Avoid some IWYU confusion:
// IWYU pragma: no_include "src/core/lib/gprpp/orphanable.h"
#define GRPC_ARG_LAME_FILTER_ERROR "grpc.lame_filter_error"
namespace grpc_core {
const grpc_channel_filter LameClientFilter::kFilter =
@ -126,11 +125,11 @@ void* ErrorCopy(void* p) {
void ErrorDestroy(void* p) { delete static_cast<absl::Status*>(p); }
int ErrorCompare(void* p, void* q) { return QsortCompare(p, q); }
} // namespace
const grpc_arg_pointer_vtable kLameFilterErrorArgVtable = {
ErrorCopy, ErrorDestroy, ErrorCompare};
} // namespace
grpc_arg MakeLameClientErrorArg(grpc_error_handle* error) {
return grpc_channel_arg_pointer_create(
const_cast<char*>(GRPC_ARG_LAME_FILTER_ERROR), error,
@ -138,27 +137,3 @@ grpc_arg MakeLameClientErrorArg(grpc_error_handle* error) {
}
} // namespace grpc_core
grpc_channel* grpc_lame_client_channel_create(const char* target,
grpc_status_code error_code,
const char* error_message) {
grpc_core::ExecCtx exec_ctx;
GRPC_API_TRACE(
"grpc_lame_client_channel_create(target=%s, error_code=%d, "
"error_message=%s)",
3, (target, (int)error_code, error_message));
if (error_code == GRPC_STATUS_OK) error_code = GRPC_STATUS_UNKNOWN;
grpc_core::ChannelArgs args =
grpc_core::CoreConfiguration::Get()
.channel_args_preconditioning()
.PreconditionChannelArgs(nullptr)
.Set(GRPC_ARG_LAME_FILTER_ERROR,
grpc_core::ChannelArgs::Pointer(
new absl::Status(static_cast<absl::StatusCode>(error_code),
error_message),
&grpc_core::kLameFilterErrorArgVtable));
auto channel = grpc_core::Channel::Create(target, std::move(args),
GRPC_CLIENT_LAME_CHANNEL, nullptr);
GPR_ASSERT(channel.ok());
return channel->release()->c_ptr();
}

@ -38,9 +38,9 @@
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/transport.h"
#define GRPC_ARG_LAME_FILTER_ERROR "grpc.lame_filter_error"
namespace grpc_core {
// Does NOT take ownership of error.
grpc_arg MakeLameClientErrorArg(grpc_error_handle* error);
// This filter becomes the entire channel stack for a channel that fails to be
// created. Every call returns failure.
@ -66,6 +66,11 @@ class LameClientFilter : public ChannelFilter {
};
std::unique_ptr<State> state_;
};
extern const grpc_arg_pointer_vtable kLameFilterErrorArgVtable;
grpc_arg MakeLameClientErrorArg(grpc_error_handle* error);
} // namespace grpc_core
#endif // GRPC_SRC_CORE_LIB_SURFACE_LAME_CLIENT_H

@ -0,0 +1,418 @@
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include <grpc/support/port_platform.h>
#include "src/core/lib/surface/legacy_channel.h"
#include "absl/base/thread_annotations.h"
#include "absl/status/status.h"
#include "absl/types/optional.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h>
#include <grpc/impl/connectivity_state.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/client_channel/client_channel_filter.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/channel_stack_builder_impl.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/channel/metrics.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/debug/stats_data.h"
#include "src/core/lib/gprpp/crash.h"
#include "src/core/lib/gprpp/dual_ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/init_internally.h"
#include "src/core/lib/surface/lame_client.h"
#include "src/core/lib/transport/call_factory.h"
#include "src/core/lib/transport/transport.h"
namespace grpc_core {
absl::StatusOr<OrphanablePtr<Channel>> LegacyChannel::Create(
std::string target, ChannelArgs args,
grpc_channel_stack_type channel_stack_type) {
if (grpc_channel_stack_type_is_client(channel_stack_type)) {
auto channel_args_mutator =
grpc_channel_args_get_client_channel_creation_mutator();
if (channel_args_mutator != nullptr) {
args = channel_args_mutator(target.c_str(), args, channel_stack_type);
}
}
ChannelStackBuilderImpl builder(
grpc_channel_stack_type_string(channel_stack_type), channel_stack_type,
args);
builder.SetTarget(target.c_str());
if (!CoreConfiguration::Get().channel_init().CreateStack(&builder)) {
return nullptr;
}
// Only need to update stats for server channels here. Stats for client
// channels are handled in our base class.
if (builder.channel_stack_type() == GRPC_SERVER_CHANNEL) {
global_stats().IncrementServerChannelsCreated();
}
absl::StatusOr<RefCountedPtr<grpc_channel_stack>> r = builder.Build();
if (!r.ok()) {
auto status = r.status();
gpr_log(GPR_ERROR, "channel stack builder failed: %s",
status.ToString().c_str());
return status;
}
// TODO(roth): Figure out how to populate authority here.
// Or maybe just don't worry about this if no one needs it until after
// the call v3 stack lands.
StatsPlugin::ChannelScope scope(builder.target(), "");
*(*r)->stats_plugin_group =
GlobalStatsPluginRegistry::GetStatsPluginsForChannel(scope);
return MakeOrphanable<LegacyChannel>(
grpc_channel_stack_type_is_client(builder.channel_stack_type()),
builder.IsPromising(), std::move(target), args, std::move(*r));
}
namespace {
class NotReallyACallFactory final : public CallFactory {
public:
using CallFactory::CallFactory;
CallInitiator CreateCall(ClientMetadataHandle, Arena*) override {
Crash("NotReallyACallFactory::CreateCall should never be called");
}
};
} // namespace
LegacyChannel::LegacyChannel(bool is_client, bool is_promising,
std::string target,
const ChannelArgs& channel_args,
RefCountedPtr<grpc_channel_stack> channel_stack)
: Channel(std::move(target), channel_args),
is_client_(is_client),
is_promising_(is_promising),
channel_stack_(std::move(channel_stack)),
call_factory_(MakeRefCounted<NotReallyACallFactory>(channel_args)) {
// We need to make sure that grpc_shutdown() does not shut things down
// until after the channel is destroyed. However, the channel may not
// actually be destroyed by the time grpc_channel_destroy() returns,
// since there may be other existing refs to the channel. If those
// refs are held by things that are visible to the wrapped language
// (such as outstanding calls on the channel), then the wrapped
// language can be responsible for making sure that grpc_shutdown()
// does not run until after those refs are released. However, the
// channel may also have refs to itself held internally for various
// things that need to be cleaned up at channel destruction (e.g.,
// LB policies, subchannels, etc), and because these refs are not
// visible to the wrapped language, it cannot be responsible for
// deferring grpc_shutdown() until after they are released. To
// accommodate that, we call grpc_init() here and then call
// grpc_shutdown() when the channel is actually destroyed, thus
// ensuring that shutdown is deferred until that point.
InitInternally();
RefCountedPtr<channelz::ChannelNode> node;
if (channelz_node() != nullptr) {
node = channelz_node()->RefAsSubclass<channelz::ChannelNode>();
}
*channel_stack_->on_destroy = [node = std::move(node)]() {
if (node != nullptr) {
node->AddTraceEvent(channelz::ChannelTrace::Severity::Info,
grpc_slice_from_static_string("Channel destroyed"));
}
ShutdownInternally();
};
}
void LegacyChannel::Orphan() {
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->disconnect_with_error = GRPC_ERROR_CREATE("Channel Destroyed");
grpc_channel_element* elem =
grpc_channel_stack_element(channel_stack_.get(), 0);
elem->filter->start_transport_op(elem, op);
Unref();
}
bool LegacyChannel::IsLame() const {
grpc_channel_element* elem =
grpc_channel_stack_last_element(channel_stack_.get());
return elem->filter == &LameClientFilter::kFilter;
}
grpc_call* LegacyChannel::CreateCall(
grpc_call* parent_call, uint32_t propagation_mask,
grpc_completion_queue* cq, grpc_pollset_set* pollset_set_alternative,
Slice path, absl::optional<Slice> authority, Timestamp deadline,
bool registered_method) {
GPR_ASSERT(is_client_);
GPR_ASSERT(!(cq != nullptr && pollset_set_alternative != nullptr));
grpc_call_create_args args;
args.channel = Ref();
args.server = nullptr;
args.parent = parent_call;
args.propagation_mask = propagation_mask;
args.cq = cq;
args.pollset_set_alternative = pollset_set_alternative;
args.server_transport_data = nullptr;
args.path = std::move(path);
args.authority = std::move(authority);
args.send_deadline = deadline;
args.registered_method = registered_method;
grpc_call* call;
GRPC_LOG_IF_ERROR("call_create", grpc_call_create(&args, &call));
return call;
}
grpc_connectivity_state LegacyChannel::CheckConnectivityState(
bool try_to_connect) {
// Forward through to the underlying client channel.
ClientChannelFilter* client_channel = GetClientChannelFilter();
if (GPR_UNLIKELY(client_channel == nullptr)) {
if (IsLame()) return GRPC_CHANNEL_TRANSIENT_FAILURE;
gpr_log(GPR_ERROR,
"grpc_channel_check_connectivity_state called on something that is "
"not a client channel");
return GRPC_CHANNEL_SHUTDOWN;
}
return client_channel->CheckConnectivityState(try_to_connect);
}
bool LegacyChannel::SupportsConnectivityWatcher() const {
return GetClientChannelFilter() != nullptr;
}
// A fire-and-forget object to handle external connectivity state watches.
class LegacyChannel::StateWatcher : public DualRefCounted<StateWatcher> {
public:
StateWatcher(RefCountedPtr<LegacyChannel> channel, grpc_completion_queue* cq,
void* tag, grpc_connectivity_state last_observed_state,
Timestamp deadline)
: channel_(std::move(channel)),
cq_(cq),
tag_(tag),
state_(last_observed_state) {
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
GRPC_CLOSURE_INIT(&on_complete_, WatchComplete, this, nullptr);
ClientChannelFilter* client_channel = channel_->GetClientChannelFilter();
if (client_channel == nullptr) {
// If the target URI used to create the channel was invalid, channel
// stack initialization failed, and that caused us to create a lame
// channel. In that case, connectivity state will never change (it
// will always be TRANSIENT_FAILURE), so we don't actually start a
// watch, but we are hiding that fact from the application.
if (channel_->IsLame()) {
// A ref is held by the timer callback.
StartTimer(deadline);
// Ref from object creation needs to be freed here since lame channel
// does not have a watcher.
Unref();
return;
}
Crash(
"grpc_channel_watch_connectivity_state called on something that is "
"not a client channel");
}
// Ref from object creation is held by the watcher callback.
auto* watcher_timer_init_state = new WatcherTimerInitState(this, deadline);
client_channel->AddExternalConnectivityWatcher(
grpc_polling_entity_create_from_pollset(grpc_cq_pollset(cq)), &state_,
&on_complete_, watcher_timer_init_state->closure());
}
private:
// A fire-and-forget object used to delay starting the timer until the
// ClientChannelFilter actually starts the watch.
class WatcherTimerInitState {
public:
WatcherTimerInitState(StateWatcher* state_watcher, Timestamp deadline)
: state_watcher_(state_watcher), deadline_(deadline) {
GRPC_CLOSURE_INIT(&closure_, WatcherTimerInit, this, nullptr);
}
grpc_closure* closure() { return &closure_; }
private:
static void WatcherTimerInit(void* arg, grpc_error_handle /*error*/) {
auto* self = static_cast<WatcherTimerInitState*>(arg);
self->state_watcher_->StartTimer(self->deadline_);
delete self;
}
StateWatcher* state_watcher_;
Timestamp deadline_;
grpc_closure closure_;
};
void StartTimer(Timestamp deadline) {
const Duration timeout = deadline - Timestamp::Now();
MutexLock lock(&mu_);
timer_handle_ =
channel_->event_engine()->RunAfter(timeout, [self = Ref()]() mutable {
ApplicationCallbackExecCtx callback_exec_ctx;
ExecCtx exec_ctx;
self->TimeoutComplete();
// StateWatcher deletion might require an active ExecCtx.
self.reset();
});
}
void TimeoutComplete() {
timer_fired_ = true;
// If this is a client channel (not a lame channel), cancel the watch.
ClientChannelFilter* client_channel = channel_->GetClientChannelFilter();
if (client_channel != nullptr) {
client_channel->CancelExternalConnectivityWatcher(&on_complete_);
}
}
static void WatchComplete(void* arg, grpc_error_handle error) {
RefCountedPtr<StateWatcher> self(static_cast<StateWatcher*>(arg));
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_operation_failures)) {
GRPC_LOG_IF_ERROR("watch_completion_error", error);
}
MutexLock lock(&self->mu_);
if (self->timer_handle_.has_value()) {
self->channel_->event_engine()->Cancel(*self->timer_handle_);
}
}
// Invoked when both strong refs are released.
void Orphan() override {
WeakRef().release(); // Take a weak ref until completion is finished.
grpc_error_handle error =
timer_fired_
? GRPC_ERROR_CREATE("Timed out waiting for connection state change")
: absl::OkStatus();
grpc_cq_end_op(cq_, tag_, error, FinishedCompletion, this,
&completion_storage_);
}
// Called when the completion is returned to the CQ.
static void FinishedCompletion(void* arg, grpc_cq_completion* /*ignored*/) {
auto* self = static_cast<StateWatcher*>(arg);
self->WeakUnref();
}
RefCountedPtr<LegacyChannel> channel_;
grpc_completion_queue* cq_;
void* tag_;
grpc_connectivity_state state_;
grpc_cq_completion completion_storage_;
grpc_closure on_complete_;
// timer_handle_ might be accessed in parallel from multiple threads, e.g.
// timer callback fired immediately on an EventEngine thread before
// RunAfter() returns.
Mutex mu_;
absl::optional<grpc_event_engine::experimental::EventEngine::TaskHandle>
timer_handle_ ABSL_GUARDED_BY(mu_);
bool timer_fired_ = false;
};
void LegacyChannel::WatchConnectivityState(
grpc_connectivity_state last_observed_state, Timestamp deadline,
grpc_completion_queue* cq, void* tag) {
new StateWatcher(RefAsSubclass<LegacyChannel>(), cq, tag, last_observed_state,
deadline);
}
void LegacyChannel::AddConnectivityWatcher(
grpc_connectivity_state initial_state,
OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher) {
auto* client_channel = GetClientChannelFilter();
GPR_ASSERT(client_channel != nullptr);
client_channel->AddConnectivityWatcher(initial_state, std::move(watcher));
}
void LegacyChannel::RemoveConnectivityWatcher(
AsyncConnectivityStateWatcherInterface* watcher) {
auto* client_channel = GetClientChannelFilter();
GPR_ASSERT(client_channel != nullptr);
client_channel->RemoveConnectivityWatcher(watcher);
}
void LegacyChannel::GetInfo(const grpc_channel_info* channel_info) {
grpc_channel_element* elem =
grpc_channel_stack_element(channel_stack_.get(), 0);
elem->filter->get_channel_info(elem, channel_info);
}
void LegacyChannel::ResetConnectionBackoff() {
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->reset_connect_backoff = true;
grpc_channel_element* elem =
grpc_channel_stack_element(channel_stack_.get(), 0);
elem->filter->start_transport_op(elem, op);
}
namespace {
struct ping_result {
grpc_closure closure;
void* tag;
grpc_completion_queue* cq;
grpc_cq_completion completion_storage;
};
void ping_destroy(void* arg, grpc_cq_completion* /*storage*/) { gpr_free(arg); }
void ping_done(void* arg, grpc_error_handle error) {
ping_result* pr = static_cast<ping_result*>(arg);
grpc_cq_end_op(pr->cq, pr->tag, error, ping_destroy, pr,
&pr->completion_storage);
}
} // namespace
void LegacyChannel::Ping(grpc_completion_queue* cq, void* tag) {
ping_result* pr = static_cast<ping_result*>(gpr_malloc(sizeof(*pr)));
pr->tag = tag;
pr->cq = cq;
GRPC_CLOSURE_INIT(&pr->closure, ping_done, pr, grpc_schedule_on_exec_ctx);
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->send_ping.on_ack = &pr->closure;
op->bind_pollset = grpc_cq_pollset(cq);
GPR_ASSERT(grpc_cq_begin_op(cq, tag));
grpc_channel_element* top_elem =
grpc_channel_stack_element(channel_stack_.get(), 0);
top_elem->filter->start_transport_op(top_elem, op);
}
ClientChannelFilter* LegacyChannel::GetClientChannelFilter() const {
grpc_channel_element* elem =
grpc_channel_stack_last_element(channel_stack_.get());
if (elem->filter != &ClientChannelFilter::kFilterVtableWithPromises &&
elem->filter != &ClientChannelFilter::kFilterVtableWithoutPromises) {
return nullptr;
}
return static_cast<ClientChannelFilter*>(elem->channel_data);
}
} // namespace grpc_core

@ -0,0 +1,118 @@
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#ifndef GRPC_SRC_CORE_LIB_SURFACE_LEGACY_CHANNEL_H
#define GRPC_SRC_CORE_LIB_SURFACE_LEGACY_CHANNEL_H
#include <grpc/support/port_platform.h>
#include <string>
#include "absl/status/statusor.h"
#include "absl/types/optional.h"
#include <grpc/event_engine/event_engine.h>
#include <grpc/grpc.h>
#include "src/core/client_channel/client_channel_filter.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_fwd.h"
#include "src/core/lib/channel/channel_stack.h" // IWYU pragma: keep
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/iomgr_fwd.h"
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/call_factory.h"
#include "src/core/lib/transport/transport.h"
namespace grpc_core {
class LegacyChannel : public Channel {
public:
static absl::StatusOr<OrphanablePtr<Channel>> Create(
std::string target, ChannelArgs args,
grpc_channel_stack_type channel_stack_type);
// Do not instantiate directly -- use Create() instead.
LegacyChannel(bool is_client, bool is_promising, std::string target,
const ChannelArgs& channel_args,
RefCountedPtr<grpc_channel_stack> channel_stack);
void Orphan() override;
Arena* CreateArena() override { return call_factory_->CreateArena(); }
void DestroyArena(Arena* arena) override {
return call_factory_->DestroyArena(arena);
}
bool IsLame() const override;
grpc_call* CreateCall(grpc_call* parent_call, uint32_t propagation_mask,
grpc_completion_queue* cq,
grpc_pollset_set* pollset_set_alternative, Slice path,
absl::optional<Slice> authority, Timestamp deadline,
bool registered_method) override;
grpc_event_engine::experimental::EventEngine* event_engine() const override {
return channel_stack_->EventEngine();
}
bool SupportsConnectivityWatcher() const override;
grpc_connectivity_state CheckConnectivityState(bool try_to_connect) override;
void WatchConnectivityState(grpc_connectivity_state last_observed_state,
Timestamp deadline, grpc_completion_queue* cq,
void* tag) override;
void AddConnectivityWatcher(
grpc_connectivity_state initial_state,
OrphanablePtr<AsyncConnectivityStateWatcherInterface> watcher) override;
void RemoveConnectivityWatcher(
AsyncConnectivityStateWatcherInterface* watcher) override;
void GetInfo(const grpc_channel_info* channel_info) override;
void ResetConnectionBackoff() override;
void Ping(grpc_completion_queue* cq, void* tag) override;
bool is_client() const override { return is_client_; }
bool is_promising() const override { return is_promising_; }
grpc_channel_stack* channel_stack() const override {
return channel_stack_.get();
}
private:
class StateWatcher;
// Returns the client channel filter if this is a client channel,
// otherwise null.
ClientChannelFilter* GetClientChannelFilter() const;
const bool is_client_;
const bool is_promising_;
RefCountedPtr<grpc_channel_stack> channel_stack_;
const RefCountedPtr<CallFactory> call_factory_;
};
} // namespace grpc_core
#endif // GRPC_SRC_CORE_LIB_SURFACE_LEGACY_CHANNEL_H

@ -77,6 +77,7 @@
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/legacy_channel.h"
#include "src/core/lib/surface/wait_for_cq_end_op.h"
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/error_utils.h"
@ -742,7 +743,7 @@ class ChannelBroadcaster {
// Broadcasts a shutdown on each channel.
void BroadcastShutdown(bool send_goaway, grpc_error_handle force_disconnect) {
for (const RefCountedPtr<Channel>& channel : channels_) {
SendShutdown(channel->c_ptr(), send_goaway, force_disconnect);
SendShutdown(channel.get(), send_goaway, force_disconnect);
}
channels_.clear(); // just for safety against double broadcast
}
@ -759,7 +760,7 @@ class ChannelBroadcaster {
delete a;
}
static void SendShutdown(grpc_channel* channel, bool send_goaway,
static void SendShutdown(Channel* channel, bool send_goaway,
grpc_error_handle send_disconnect) {
ShutdownCleanupArgs* sc = new ShutdownCleanupArgs;
GRPC_CLOSURE_INIT(&sc->closure, ShutdownCleanup, sc,
@ -773,8 +774,7 @@ class ChannelBroadcaster {
: absl::OkStatus();
sc->slice = grpc_slice_from_copied_string("Server shutdown");
op->disconnect_with_error = send_disconnect;
elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
elem = grpc_channel_stack_element(channel->channel_stack(), 0);
elem->filter->start_transport_op(elem, op);
}
@ -911,8 +911,9 @@ grpc_error_handle Server::SetupTransport(
const ChannelArgs& args,
const RefCountedPtr<channelz::SocketNode>& socket_node) {
// Create channel.
absl::StatusOr<RefCountedPtr<Channel>> channel =
Channel::Create(nullptr, args, GRPC_SERVER_CHANNEL, transport);
global_stats().IncrementServerChannelsCreated();
absl::StatusOr<OrphanablePtr<Channel>> channel =
LegacyChannel::Create("", args.SetObject(transport), GRPC_SERVER_CHANNEL);
if (!channel.ok()) {
return absl_status_to_grpc_error(channel.status());
}
@ -1309,11 +1310,11 @@ absl::StatusOr<CallInitiator> Server::ChannelData::CreateCall(
}
void Server::ChannelData::InitTransport(RefCountedPtr<Server> server,
RefCountedPtr<Channel> channel,
OrphanablePtr<Channel> channel,
size_t cq_idx, Transport* transport,
intptr_t channelz_socket_uuid) {
server_ = std::move(server);
channel_ = channel;
channel_ = std::move(channel);
cq_idx_ = cq_idx;
channelz_socket_uuid_ = channelz_socket_uuid;
// Publish channel.
@ -1392,7 +1393,7 @@ void Server::ChannelData::AcceptStream(void* arg, Transport* /*transport*/,
auto* chand = static_cast<Server::ChannelData*>(arg);
// create a call
grpc_call_create_args args;
args.channel = chand->channel_;
args.channel = chand->channel_->Ref();
args.server = chand->server_.get();
args.parent = nullptr;
args.propagation_mask = 0;

@ -66,6 +66,7 @@
#include "src/core/lib/slice/slice.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server_interface.h"
#include "src/core/lib/transport/metadata_batch.h"
#include "src/core/lib/transport/transport.h"
@ -77,7 +78,8 @@ namespace grpc_core {
extern TraceFlag grpc_server_channel_trace;
class Server : public InternallyRefCounted<Server>,
class Server : public ServerInterface,
public InternallyRefCounted<Server>,
public CppImplOf<Server, grpc_server> {
public:
// Filter vtable.
@ -134,8 +136,10 @@ class Server : public InternallyRefCounted<Server>,
void Orphan() ABSL_LOCKS_EXCLUDED(mu_global_) override;
const ChannelArgs& channel_args() const { return channel_args_; }
channelz::ServerNode* channelz_node() const { return channelz_node_.get(); }
const ChannelArgs& channel_args() const override { return channel_args_; }
channelz::ServerNode* channelz_node() const override {
return channelz_node_.get();
}
// Do not call this before Start(). Returns the pollsets. The
// vector itself is immutable, but the pollsets inside are mutable. The
@ -146,7 +150,7 @@ class Server : public InternallyRefCounted<Server>,
return config_fetcher_.get();
}
ServerCallTracerFactory* server_call_tracer_factory() const {
ServerCallTracerFactory* server_call_tracer_factory() const override {
return server_call_tracer_factory_;
}
@ -224,7 +228,7 @@ class Server : public InternallyRefCounted<Server>,
~ChannelData();
void InitTransport(RefCountedPtr<Server> server,
RefCountedPtr<Channel> channel, size_t cq_idx,
OrphanablePtr<Channel> channel, size_t cq_idx,
Transport* transport, intptr_t channelz_socket_uuid);
RefCountedPtr<Server> server() const { return server_; }
@ -257,7 +261,7 @@ class Server : public InternallyRefCounted<Server>,
static void FinishDestroy(void* arg, grpc_error_handle error);
RefCountedPtr<Server> server_;
RefCountedPtr<Channel> channel_;
OrphanablePtr<Channel> channel_;
// The index into Server::cqs_ of the CQ used as a starting point for
// where to publish new incoming calls.
size_t cq_idx_;

@ -0,0 +1,43 @@
//
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef GRPC_SRC_CORE_LIB_SURFACE_SERVER_INTERFACE_H
#define GRPC_SRC_CORE_LIB_SURFACE_SERVER_INTERFACE_H
#include <grpc/support/port_platform.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channelz.h"
namespace grpc_core {
class ServerCallTracerFactory;
// This class is a hack to avoid a circular dependency that would be
// caused by the code in call.cc depending directly on the server code.
// TODO(roth): After the call v3 migration, find a cleaner way to do this.
class ServerInterface {
public:
virtual ~ServerInterface() = default;
virtual const ChannelArgs& channel_args() const = 0;
virtual channelz::ServerNode* channelz_node() const = 0;
virtual ServerCallTracerFactory* server_call_tracer_factory() const = 0;
};
} // namespace grpc_core
#endif // GRPC_SRC_CORE_LIB_SURFACE_SERVER_INTERFACE_H

@ -547,7 +547,7 @@ class GrpcLb : public LoadBalancingPolicy {
bool shutting_down_ = false;
// The channel for communicating with the LB server.
grpc_channel* lb_channel_ = nullptr;
OrphanablePtr<Channel> lb_channel_;
StateWatcher* watcher_ = nullptr;
// Response generator to inject address updates into lb_channel_.
RefCountedPtr<FakeResolverResponseGenerator> response_generator_;
@ -898,11 +898,11 @@ GrpcLb::BalancerCallState::BalancerCallState(
grpclb_policy()->lb_call_timeout_ == Duration::Zero()
? Timestamp::InfFuture()
: Timestamp::Now() + grpclb_policy()->lb_call_timeout_;
lb_call_ = grpc_channel_create_pollset_set_call(
grpclb_policy()->lb_channel_, nullptr, GRPC_PROPAGATE_DEFAULTS,
grpclb_policy_->interested_parties(),
Slice::FromStaticString("/grpc.lb.v1.LoadBalancer/BalanceLoad").c_slice(),
nullptr, deadline, nullptr);
lb_call_ = grpclb_policy()->lb_channel_->CreateCall(
/*parent_call=*/nullptr, GRPC_PROPAGATE_DEFAULTS,
/*cq=*/nullptr, grpclb_policy_->interested_parties(),
Slice::FromStaticString("/grpc.lb.v1.LoadBalancer/BalanceLoad"),
/*authority=*/absl::nullopt, deadline, /*registered_method=*/true);
// Init the LB call request payload.
upb::Arena arena;
grpc_slice request_payload_slice = GrpcLbRequestCreate(
@ -1504,13 +1504,11 @@ void GrpcLb::ShutdownLocked() {
// alive when that callback is invoked.
if (lb_channel_ != nullptr) {
if (parent_channelz_node_ != nullptr) {
channelz::ChannelNode* child_channelz_node =
grpc_channel_get_channelz_node(lb_channel_);
channelz::ChannelNode* child_channelz_node = lb_channel_->channelz_node();
GPR_ASSERT(child_channelz_node != nullptr);
parent_channelz_node_->RemoveChildChannel(child_channelz_node->uuid());
}
grpc_channel_destroy_internal(lb_channel_);
lb_channel_ = nullptr;
lb_channel_.reset();
}
}
@ -1520,7 +1518,7 @@ void GrpcLb::ShutdownLocked() {
void GrpcLb::ResetBackoffLocked() {
if (lb_channel_ != nullptr) {
grpc_channel_reset_connect_backoff(lb_channel_);
lb_channel_->ResetConnectionBackoff();
}
if (child_policy_ != nullptr) {
child_policy_->ResetBackoffLocked();
@ -1592,13 +1590,9 @@ absl::Status GrpcLb::UpdateLocked(UpdateArgs args) {
// Start watching the channel's connectivity state. If the channel
// goes into state TRANSIENT_FAILURE before the timer fires, we go into
// fallback mode even if the fallback timeout has not elapsed.
ClientChannelFilter* client_channel =
ClientChannelFilter::GetFromChannel(Channel::FromC(lb_channel_));
GPR_ASSERT(client_channel != nullptr);
// Ref held by callback.
watcher_ =
new StateWatcher(RefAsSubclass<GrpcLb>(DEBUG_LOCATION, "StateWatcher"));
client_channel->AddConnectivityWatcher(
lb_channel_->AddConnectivityWatcher(
GRPC_CHANNEL_IDLE,
OrphanablePtr<AsyncConnectivityStateWatcherInterface>(watcher_));
// Start balancer call.
@ -1633,13 +1627,13 @@ absl::Status GrpcLb::UpdateBalancerChannelLocked() {
if (lb_channel_ == nullptr) {
std::string uri_str =
absl::StrCat("fake:///", channel_control_helper()->GetAuthority());
lb_channel_ =
grpc_channel_create(uri_str.c_str(), channel_credentials.get(),
lb_channel_args.ToC().get());
lb_channel_.reset(
Channel::FromC(
grpc_channel_create(uri_str.c_str(), channel_credentials.get(),
lb_channel_args.ToC().get())));
GPR_ASSERT(lb_channel_ != nullptr);
// Set up channelz linkage.
channelz::ChannelNode* child_channelz_node =
grpc_channel_get_channelz_node(lb_channel_);
channelz::ChannelNode* child_channelz_node = lb_channel_->channelz_node();
auto parent_channelz_node = args_.GetObjectRef<channelz::ChannelNode>();
if (child_channelz_node != nullptr && parent_channelz_node != nullptr) {
parent_channelz_node->AddChildChannel(child_channelz_node->uuid());
@ -1659,10 +1653,7 @@ absl::Status GrpcLb::UpdateBalancerChannelLocked() {
}
void GrpcLb::CancelBalancerChannelConnectivityWatchLocked() {
ClientChannelFilter* client_channel =
ClientChannelFilter::GetFromChannel(Channel::FromC(lb_channel_));
GPR_ASSERT(client_channel != nullptr);
client_channel->RemoveConnectivityWatcher(watcher_);
lb_channel_->RemoveConnectivityWatcher(watcher_);
}
//
@ -1678,7 +1669,7 @@ void GrpcLb::StartBalancerCallLocked() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_glb_trace)) {
gpr_log(GPR_INFO,
"[grpclb %p] Query for backends (lb_channel: %p, lb_calld: %p)",
this, lb_channel_, lb_calld_.get());
this, lb_channel_.get(), lb_calld_.get());
}
lb_calld_->StartQuery();
}

@ -568,7 +568,7 @@ class RlsLb : public LoadBalancingPolicy {
// Resets the channel's backoff.
void ResetBackoff();
grpc_channel* channel() const { return channel_; }
Channel* channel() const { return channel_.get(); }
private:
// Watches the state of the RLS channel. Notifies the LB policy when
@ -620,7 +620,7 @@ class RlsLb : public LoadBalancingPolicy {
RefCountedPtr<RlsLb> lb_policy_;
bool is_shutdown_ = false;
grpc_channel* channel_ = nullptr;
OrphanablePtr<Channel> channel_;
RefCountedPtr<channelz::ChannelNode> parent_channelz_node_;
StateWatcher* watcher_ = nullptr;
Throttle throttle_ ABSL_GUARDED_BY(&RlsLb::mu_);
@ -1539,17 +1539,18 @@ RlsLb::RlsChannel::RlsChannel(RefCountedPtr<RlsLb> lb_policy)
args = args.Set(GRPC_ARG_SERVICE_CONFIG, service_config)
.Set(GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION, 1);
}
channel_ = grpc_channel_create(lb_policy_->config_->lookup_service().c_str(),
creds.get(), args.ToC().get());
channel_.reset(
Channel::FromC(
grpc_channel_create(lb_policy_->config_->lookup_service().c_str(),
creds.get(), args.ToC().get())));
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) {
gpr_log(GPR_INFO, "[rlslb %p] RlsChannel=%p: created channel %p for %s",
lb_policy_.get(), this, channel_,
lb_policy_.get(), this, channel_.get(),
lb_policy_->config_->lookup_service().c_str());
}
if (channel_ != nullptr) {
// Set up channelz linkage.
channelz::ChannelNode* child_channelz_node =
grpc_channel_get_channelz_node(channel_);
channelz::ChannelNode* child_channelz_node = channel_->channelz_node();
auto parent_channelz_node =
lb_policy_->channel_args_.GetObjectRef<channelz::ChannelNode>();
if (child_channelz_node != nullptr && parent_channelz_node != nullptr) {
@ -1557,11 +1558,8 @@ RlsLb::RlsChannel::RlsChannel(RefCountedPtr<RlsLb> lb_policy)
parent_channelz_node_ = std::move(parent_channelz_node);
}
// Start connectivity watch.
ClientChannelFilter* client_channel =
ClientChannelFilter::GetFromChannel(Channel::FromC(channel_));
GPR_ASSERT(client_channel != nullptr);
watcher_ = new StateWatcher(Ref(DEBUG_LOCATION, "StateWatcher"));
client_channel->AddConnectivityWatcher(
channel_->AddConnectivityWatcher(
GRPC_CHANNEL_IDLE,
OrphanablePtr<AsyncConnectivityStateWatcherInterface>(watcher_));
}
@ -1570,26 +1568,22 @@ RlsLb::RlsChannel::RlsChannel(RefCountedPtr<RlsLb> lb_policy)
void RlsLb::RlsChannel::Orphan() {
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_rls_trace)) {
gpr_log(GPR_INFO, "[rlslb %p] RlsChannel=%p, channel=%p: shutdown",
lb_policy_.get(), this, channel_);
lb_policy_.get(), this, channel_.get());
}
is_shutdown_ = true;
if (channel_ != nullptr) {
// Remove channelz linkage.
if (parent_channelz_node_ != nullptr) {
channelz::ChannelNode* child_channelz_node =
grpc_channel_get_channelz_node(channel_);
channelz::ChannelNode* child_channelz_node = channel_->channelz_node();
GPR_ASSERT(child_channelz_node != nullptr);
parent_channelz_node_->RemoveChildChannel(child_channelz_node->uuid());
}
// Stop connectivity watch.
if (watcher_ != nullptr) {
ClientChannelFilter* client_channel =
ClientChannelFilter::GetFromChannel(Channel::FromC(channel_));
GPR_ASSERT(client_channel != nullptr);
client_channel->RemoveConnectivityWatcher(watcher_);
channel_->RemoveConnectivityWatcher(watcher_);
watcher_ = nullptr;
}
grpc_channel_destroy_internal(channel_);
channel_.reset();
}
Unref(DEBUG_LOCATION, "Orphan");
}
@ -1618,7 +1612,7 @@ void RlsLb::RlsChannel::ReportResponseLocked(bool response_succeeded) {
void RlsLb::RlsChannel::ResetBackoff() {
GPR_DEBUG_ASSERT(channel_ != nullptr);
grpc_channel_reset_connect_backoff(channel_);
channel_->ResetConnectionBackoff();
}
//
@ -1683,11 +1677,11 @@ void RlsLb::RlsRequest::StartCallLocked() {
deadline_ = now + lb_policy_->config_->lookup_service_timeout();
grpc_metadata_array_init(&recv_initial_metadata_);
grpc_metadata_array_init(&recv_trailing_metadata_);
call_ = grpc_channel_create_pollset_set_call(
rls_channel_->channel(), nullptr, GRPC_PROPAGATE_DEFAULTS,
call_ = rls_channel_->channel()->CreateCall(
/*parent_call=*/nullptr, GRPC_PROPAGATE_DEFAULTS, /*cq=*/nullptr,
lb_policy_->interested_parties(),
grpc_slice_from_static_string(kRlsRequestPath), nullptr, deadline_,
nullptr);
Slice::FromStaticString(kRlsRequestPath), /*authority=*/absl::nullopt,
deadline_, /*registered_method=*/true);
grpc_op ops[6];
memset(ops, 0, sizeof(ops));
grpc_op* op = ops;

@ -21,10 +21,13 @@
#include <grpc/grpc.h>
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/surface/builtins.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/surface/lame_client.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/http_connect_handshaker.h"
#include "src/core/lib/transport/tcp_connect_handshaker.h"
namespace grpc_event_engine {
namespace experimental {
extern void RegisterEventEngineChannelArgPreconditioning(
@ -73,6 +76,20 @@ extern void RegisterRlsLbPolicy(CoreConfiguration::Builder* builder);
extern void RegisterBinderResolver(CoreConfiguration::Builder* builder);
#endif
namespace {
void RegisterBuiltins(CoreConfiguration::Builder* builder) {
RegisterServerCallTracerFilter(builder);
builder->channel_init()
->RegisterFilter<LameClientFilter>(GRPC_CLIENT_LAME_CHANNEL)
.Terminal();
builder->channel_init()
->RegisterFilter(GRPC_SERVER_CHANNEL, &Server::kServerTopFilter)
.BeforeAll();
}
} // namespace
void BuildCoreConfiguration(CoreConfiguration::Builder* builder) {
grpc_event_engine::experimental::RegisterEventEngineChannelArgPreconditioning(
builder);

@ -19,7 +19,6 @@
#include <grpc/grpc.h>
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/surface/builtins.h"
namespace grpc_core {
#ifndef GRPC_NO_XDS

@ -19,7 +19,6 @@
#include <grpc/grpc.h>
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/surface/builtins.h"
namespace grpc_core {
void RegisterExtraFilters(CoreConfiguration::Builder* /* builder */) {}

@ -742,10 +742,12 @@ alts_handshaker_client* alts_grpc_handshaker_client_create(
strcmp(handshaker_service_url, ALTS_HANDSHAKER_SERVICE_URL_FOR_TESTING) ==
0
? nullptr
: grpc_channel_create_pollset_set_call(
channel, nullptr, GRPC_PROPAGATE_DEFAULTS, interested_parties,
grpc_slice_from_static_string(ALTS_SERVICE_METHOD), nullptr,
grpc_core::Timestamp::InfFuture(), nullptr);
: grpc_core::Channel::FromC(channel)->CreateCall(
/*parent_call=*/nullptr, GRPC_PROPAGATE_DEFAULTS,
/*cq=*/nullptr, interested_parties,
grpc_core::Slice::FromStaticString(ALTS_SERVICE_METHOD),
/*authority=*/absl::nullopt, grpc_core::Timestamp::InfFuture(),
/*registered_method=*/true);
GRPC_CLOSURE_INIT(&client->on_handshaker_service_resp_recv, grpc_cb, client,
grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&client->on_status_received, on_status_received, client,

@ -36,6 +36,7 @@
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/iomgr/closure.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/tsi/alts/frame_protector/alts_frame_protector.h"
#include "src/core/tsi/alts/handshaker/alts_handshaker_client.h"

@ -55,6 +55,7 @@ grpc_cc_library(
language = "c++",
visibility = ["//:__subpackages__"],
deps = [
"//:call_tracer",
"//:gpr",
"//:gpr_platform",
"//:grpc_base",

@ -59,6 +59,7 @@ grpc_cc_library(
language = "c++",
visibility = ["//:__subpackages__"],
deps = [
"//:call_tracer",
"//:config",
"//:gpr",
"//:gpr_platform",

@ -16,7 +16,6 @@
CORE_SOURCE_FILES = [
'src/core/client_channel/backup_poller.cc',
'src/core/client_channel/channel_connectivity.cc',
'src/core/client_channel/client_channel_channelz.cc',
'src/core/client_channel/client_channel_factory.cc',
'src/core/client_channel/client_channel_filter.cc',
@ -736,15 +735,14 @@ CORE_SOURCE_FILES = [
'src/core/lib/slice/slice_refcount.cc',
'src/core/lib/slice/slice_string_helpers.cc',
'src/core/lib/surface/api_trace.cc',
'src/core/lib/surface/builtins.cc',
'src/core/lib/surface/byte_buffer.cc',
'src/core/lib/surface/byte_buffer_reader.cc',
'src/core/lib/surface/call.cc',
'src/core/lib/surface/call_details.cc',
'src/core/lib/surface/call_log_batch.cc',
'src/core/lib/surface/channel.cc',
'src/core/lib/surface/channel_create.cc',
'src/core/lib/surface/channel_init.cc',
'src/core/lib/surface/channel_ping.cc',
'src/core/lib/surface/channel_stack_type.cc',
'src/core/lib/surface/completion_queue.cc',
'src/core/lib/surface/completion_queue_factory.cc',
@ -752,6 +750,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/surface/init.cc',
'src/core/lib/surface/init_internally.cc',
'src/core/lib/surface/lame_client.cc',
'src/core/lib/surface/legacy_channel.cc',
'src/core/lib/surface/metadata_array.cc',
'src/core/lib/surface/server.cc',
'src/core/lib/surface/validate_metadata.cc',

@ -28,6 +28,7 @@ grpc_cc_binary(
deps = [
"//:gpr",
"//:grpc",
"//:server",
"//src/core:channel_args",
"//test/core/util:grpc_test_util",
],

@ -39,6 +39,7 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/transport.h"
@ -108,9 +109,10 @@ static void client_setup_transport(grpc_core::Transport* transport) {
grpc_channel_args_copy_and_add(nullptr, &authority_arg, 1);
// TODO (pjaikumar): use GRPC_CLIENT_CHANNEL instead of
// GRPC_CLIENT_DIRECT_CHANNEL
g_ctx.client = (*grpc_core::Channel::Create(
g_ctx.client = (*grpc_core::ChannelCreate(
"socketpair-target", grpc_core::ChannelArgs::FromC(args),
GRPC_CLIENT_DIRECT_CHANNEL, transport))
.release()
->c_ptr();
grpc_channel_args_destroy(args);
}

@ -38,6 +38,7 @@
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
@ -108,8 +109,8 @@ class SockpairFixture : public CoreTestFixture {
auto* client_endpoint = std::exchange(ep_.client, nullptr);
EXPECT_NE(client_endpoint, nullptr);
transport = grpc_create_chttp2_transport(args, client_endpoint, true);
auto channel = Channel::Create("socketpair-target", args,
GRPC_CLIENT_DIRECT_CHANNEL, transport);
auto channel = ChannelCreate("socketpair-target", args,
GRPC_CLIENT_DIRECT_CHANNEL, transport);
grpc_channel* client;
if (channel.ok()) {
client = channel->release()->c_ptr();

@ -32,6 +32,7 @@
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/transport.h"
#include "src/libfuzzer/libfuzzer_macro.h"
@ -66,8 +67,8 @@ class ClientFuzzer final : public BasicFuzzer {
.SetIfUnset(GRPC_ARG_DEFAULT_AUTHORITY, "test-authority");
Transport* transport =
grpc_create_chttp2_transport(args, mock_endpoint_, true);
channel_ = Channel::Create("test-target", args, GRPC_CLIENT_DIRECT_CHANNEL,
transport)
channel_ = ChannelCreate("test-target", args, GRPC_CLIENT_DIRECT_CHANNEL,
transport)
->release()
->c_ptr();
}

@ -58,8 +58,8 @@ void test_transport_op(grpc_channel* channel) {
grpc_core::ExecCtx exec_ctx;
grpc_transport_op* op = grpc_make_transport_op(nullptr);
op->start_connectivity_watch = grpc_core::MakeOrphanable<Watcher>();
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
grpc_channel_element* elem = grpc_channel_stack_element(
grpc_core::Channel::FromC(channel)->channel_stack(), 0);
elem->filter->start_transport_op(elem, op);
GRPC_CLOSURE_INIT(&transport_op_cb, do_nothing, nullptr,

@ -1,5 +1,4 @@
//
//
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
@ -36,8 +35,8 @@ void test_unknown_scheme_target(void) {
grpc_channel_credentials* creds =
grpc_fake_transport_security_credentials_create();
grpc_channel* chan = grpc_channel_create("blah://blah", creds, nullptr);
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
grpc_channel_element* elem = grpc_channel_stack_element(
grpc_core::Channel::FromC(chan)->channel_stack(), 0);
ASSERT_STREQ(elem->filter->name, "lame-client");
grpc_core::ExecCtx exec_ctx;
grpc_core::Channel::FromC(chan)->Unref();
@ -50,8 +49,8 @@ void test_security_connector_already_in_arg(void) {
args.num_args = 1;
args.args = &arg;
grpc_channel* chan = grpc_channel_create(nullptr, nullptr, &args);
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
grpc_channel_element* elem = grpc_channel_stack_element(
grpc_core::Channel::FromC(chan)->channel_stack(), 0);
ASSERT_STREQ(elem->filter->name, "lame-client");
grpc_core::ExecCtx exec_ctx;
grpc_core::Channel::FromC(chan)->Unref();
@ -59,8 +58,8 @@ void test_security_connector_already_in_arg(void) {
void test_null_creds(void) {
grpc_channel* chan = grpc_channel_create(nullptr, nullptr, nullptr);
grpc_channel_element* elem =
grpc_channel_stack_element(grpc_channel_get_channel_stack(chan), 0);
grpc_channel_element* elem = grpc_channel_stack_element(
grpc_core::Channel::FromC(chan)->channel_stack(), 0);
ASSERT_STREQ(elem->filter->name, "lame-client");
grpc_core::ExecCtx exec_ctx;
grpc_core::Channel::FromC(chan)->Unref();

@ -24,6 +24,7 @@
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/libfuzzer/libfuzzer_macro.h"
#include "test/core/transport/binder/end2end/fuzzers/binder_transport_fuzzer.pb.h"
#include "test/core/transport/binder/end2end/fuzzers/fuzzer_utils.h"
@ -59,8 +60,8 @@ DEFINE_PROTO_FUZZER(const binder_transport_fuzzer::Input& input) {
.channel_args_preconditioning()
.PreconditionChannelArgs(args);
auto channel =
grpc_core::Channel::Create("test-target", channel_args,
GRPC_CLIENT_DIRECT_CHANNEL, client_transport)
grpc_core::ChannelCreate("test-target", channel_args,
GRPC_CLIENT_DIRECT_CHANNEL, client_transport)
->release()
->c_ptr();
grpc_channel_args_destroy(args);

@ -23,6 +23,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/transport/error_utils.h"
namespace grpc_binder {
@ -124,7 +125,7 @@ grpc_channel* grpc_binder_channel_create_for_testing(
grpc_error_handle error = grpc_core::Server::FromC(server)->SetupTransport(
server_transport, nullptr, server_args, nullptr);
GPR_ASSERT(error.ok());
auto channel = grpc_core::Channel::Create(
auto channel = grpc_core::ChannelCreate(
"binder", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport);
GPR_ASSERT(channel.ok());
return channel->release()->c_ptr();

@ -82,7 +82,10 @@ grpc_cc_test(
"absl/status:statusor",
"gtest",
],
deps = ["//src/core:chaotic_good_frame"],
deps = [
"//:channel_create",
"//src/core:chaotic_good_frame",
],
)
grpc_proto_fuzzer(

@ -37,6 +37,7 @@
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/tcp_posix.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/server.h"
#include "src/cpp/client/create_channel_internal.h"
@ -206,8 +207,8 @@ class EndpointPairFixture : public BaseFixture {
grpc_create_chttp2_transport(c_args, endpoints.client, true);
GPR_ASSERT(client_transport_);
grpc_channel* channel =
grpc_core::Channel::Create(
"target", c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_)
grpc_core::ChannelCreate("target", c_args, GRPC_CLIENT_DIRECT_CHANNEL,
client_transport_)
->release()
->c_ptr();
grpc_chttp2_transport_start_reading(client_transport_, nullptr, nullptr,

@ -29,6 +29,7 @@ grpc_cc_test(
"//:gpr",
"//:grpc",
"//:grpc++",
"//:server",
"//src/core:channel_args",
"//src/proto/grpc/testing:echo_proto",
"//test/core/event_engine:event_engine_test_utils",

@ -41,6 +41,7 @@
#include "src/core/lib/iomgr/event_engine_shims/endpoint.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_create.h"
#include "src/core/lib/surface/server.h"
#include "src/cpp/client/create_channel_internal.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h"
@ -144,8 +145,8 @@ class InProcessCHTTP2 {
/*is_client=*/true);
GPR_ASSERT(transport);
grpc_channel* channel =
grpc_core::Channel::Create("target", args, GRPC_CLIENT_DIRECT_CHANNEL,
transport)
grpc_core::ChannelCreate("target", args, GRPC_CLIENT_DIRECT_CHANNEL,
transport)
->release()
->c_ptr();
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr);

@ -1083,7 +1083,6 @@ include/grpcpp/version_info.h \
include/grpcpp/xds_server_builder.h \
src/core/client_channel/backup_poller.cc \
src/core/client_channel/backup_poller.h \
src/core/client_channel/channel_connectivity.cc \
src/core/client_channel/client_channel_channelz.cc \
src/core/client_channel/client_channel_channelz.h \
src/core/client_channel/client_channel_factory.cc \
@ -2761,8 +2760,6 @@ src/core/lib/slice/slice_string_helpers.cc \
src/core/lib/slice/slice_string_helpers.h \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/api_trace.h \
src/core/lib/surface/builtins.cc \
src/core/lib/surface/builtins.h \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \
src/core/lib/surface/call.cc \
@ -2773,9 +2770,10 @@ src/core/lib/surface/call_test_only.h \
src/core/lib/surface/call_trace.h \
src/core/lib/surface/channel.cc \
src/core/lib/surface/channel.h \
src/core/lib/surface/channel_create.cc \
src/core/lib/surface/channel_create.h \
src/core/lib/surface/channel_init.cc \
src/core/lib/surface/channel_init.h \
src/core/lib/surface/channel_ping.cc \
src/core/lib/surface/channel_stack_type.cc \
src/core/lib/surface/channel_stack_type.h \
src/core/lib/surface/completion_queue.cc \
@ -2790,9 +2788,12 @@ src/core/lib/surface/init_internally.cc \
src/core/lib/surface/init_internally.h \
src/core/lib/surface/lame_client.cc \
src/core/lib/surface/lame_client.h \
src/core/lib/surface/legacy_channel.cc \
src/core/lib/surface/legacy_channel.h \
src/core/lib/surface/metadata_array.cc \
src/core/lib/surface/server.cc \
src/core/lib/surface/server.h \
src/core/lib/surface/server_interface.h \
src/core/lib/surface/validate_metadata.cc \
src/core/lib/surface/validate_metadata.h \
src/core/lib/surface/version.cc \

@ -887,7 +887,6 @@ src/core/README.md \
src/core/client_channel/README.md \
src/core/client_channel/backup_poller.cc \
src/core/client_channel/backup_poller.h \
src/core/client_channel/channel_connectivity.cc \
src/core/client_channel/client_channel_channelz.cc \
src/core/client_channel/client_channel_channelz.h \
src/core/client_channel/client_channel_factory.cc \
@ -2537,8 +2536,6 @@ src/core/lib/slice/slice_string_helpers.h \
src/core/lib/surface/README.md \
src/core/lib/surface/api_trace.cc \
src/core/lib/surface/api_trace.h \
src/core/lib/surface/builtins.cc \
src/core/lib/surface/builtins.h \
src/core/lib/surface/byte_buffer.cc \
src/core/lib/surface/byte_buffer_reader.cc \
src/core/lib/surface/call.cc \
@ -2549,9 +2546,10 @@ src/core/lib/surface/call_test_only.h \
src/core/lib/surface/call_trace.h \
src/core/lib/surface/channel.cc \
src/core/lib/surface/channel.h \
src/core/lib/surface/channel_create.cc \
src/core/lib/surface/channel_create.h \
src/core/lib/surface/channel_init.cc \
src/core/lib/surface/channel_init.h \
src/core/lib/surface/channel_ping.cc \
src/core/lib/surface/channel_stack_type.cc \
src/core/lib/surface/channel_stack_type.h \
src/core/lib/surface/completion_queue.cc \
@ -2566,9 +2564,12 @@ src/core/lib/surface/init_internally.cc \
src/core/lib/surface/init_internally.h \
src/core/lib/surface/lame_client.cc \
src/core/lib/surface/lame_client.h \
src/core/lib/surface/legacy_channel.cc \
src/core/lib/surface/legacy_channel.h \
src/core/lib/surface/metadata_array.cc \
src/core/lib/surface/server.cc \
src/core/lib/surface/server.h \
src/core/lib/surface/server_interface.h \
src/core/lib/surface/validate_metadata.cc \
src/core/lib/surface/validate_metadata.h \
src/core/lib/surface/version.cc \

@ -55,6 +55,7 @@ BANNED_EXCEPT = {
"grpc_call_cancel(": ["src/core/lib/surface/call.cc"],
"grpc_channel_destroy(": [
"src/core/lib/surface/channel.cc",
"src/core/lib/surface/legacy_channel.cc",
"src/core/tsi/alts/handshaker/alts_shared_resource.cc",
],
"grpc_closure_create(": [

Loading…
Cancel
Save