diff --git a/.github/workflows/pr-auto-fix.yaml b/.github/workflows/pr-auto-fix.yaml index 13511d3c86c..7566c2776aa 100644 --- a/.github/workflows/pr-auto-fix.yaml +++ b/.github/workflows/pr-auto-fix.yaml @@ -29,7 +29,7 @@ jobs: path: ~/.cache/bazel # formattedTime here is like 2021323 - the year concatenated with the week then # the day of that week. - # As this changes every day, we cycle to a new cache once per day, with lookup + # As this changes every day, we cycle to a new cache once per day, with lookup # across the week (and then the year). key: ${{ runner.os }}-${{ steps.current-time-with-day.outputs.formattedTime }} restore-keys: | @@ -48,13 +48,13 @@ jobs: with: script: | // If you'd like not to run this code on your commits, add your github user id here: - NO_AUTOFIX_USERS = ["copybara-service[bot]"] - const { owner, repo } = context.repo + const NO_AUTOFIX_USERS = ["copybara-service[bot]"]; + const { owner, repo } = context.repo; console.log("Actor: " + context.actor); if (NO_AUTOFIX_USERS.includes(context.actor)) { console.log('Cancelling'); const run_id = "${{ github.run_id }}"; - await github.actions.cancelWorkflowRun({ owner, repo, run_id }); + await github.rest.actions.cancelWorkflowRun({ owner, repo, run_id }); return 'go'; } else { return 'stay'; diff --git a/BUILD b/BUILD index aa1a4e5333e..3b207877927 100644 --- a/BUILD +++ b/BUILD @@ -1868,10 +1868,10 @@ grpc_cc_library( grpc_cc_library( name = "server", srcs = [ - "//src/core:lib/surface/server.cc", + "//src/core:server/server.cc", ], hdrs = [ - "//src/core:lib/surface/server.h", + "//src/core:server/server.h", ], external_deps = [ "absl/base:core_headers", @@ -2270,6 +2270,7 @@ grpc_cc_library( external_deps = [ "absl/base:core_headers", "absl/container:inlined_vector", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", @@ -2995,7 +2996,6 @@ grpc_cc_library( deps = [ "gpr_platform", "//src/core:env", - "//src/core:gpr_log_internal", ], ) @@ -3112,6 +3112,7 @@ grpc_cc_library( external_deps = [ "absl/base:core_headers", "absl/container:inlined_vector", + "absl/log:check", "absl/status", "absl/strings:str_format", ], @@ -3961,6 +3962,7 @@ grpc_cc_library( "//src/core:lib/security/credentials/jwt/jwt_verifier.h", ], external_deps = [ + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cf1a5066e8..83a0769f131 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1540,6 +1540,7 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx xds_audit_logger_registry_test) add_dependencies(buildtests_cxx xds_bootstrap_test) add_dependencies(buildtests_cxx xds_certificate_provider_test) + add_dependencies(buildtests_cxx xds_channel_stack_modifier_test) add_dependencies(buildtests_cxx xds_client_test) if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_cxx xds_cluster_end2end_test) @@ -1857,7 +1858,6 @@ add_library(grpc src/core/ext/filters/message_size/message_size_filter.cc src/core/ext/filters/rbac/rbac_filter.cc src/core/ext/filters/rbac/rbac_service_config_parser.cc - src/core/ext/filters/server_config_selector/server_config_selector_filter.cc src/core/ext/filters/stateful_session/stateful_session_filter.cc src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc src/core/ext/gcp/metadata_query.cc @@ -2220,7 +2220,6 @@ add_library(grpc src/core/ext/xds/xds_bootstrap.cc src/core/ext/xds/xds_bootstrap_grpc.cc src/core/ext/xds/xds_certificate_provider.cc - src/core/ext/xds/xds_channel_stack_modifier.cc src/core/ext/xds/xds_client.cc src/core/ext/xds/xds_client_grpc.cc src/core/ext/xds/xds_client_stats.cc @@ -2237,7 +2236,6 @@ add_library(grpc src/core/ext/xds/xds_listener.cc src/core/ext/xds/xds_route_config.cc src/core/ext/xds/xds_routing.cc - src/core/ext/xds/xds_server_config_fetcher.cc src/core/ext/xds/xds_transport_grpc.cc src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc src/core/handshaker/handshaker.cc @@ -2263,7 +2261,6 @@ add_library(grpc 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 @@ -2517,7 +2514,6 @@ add_library(grpc 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 src/core/lib/surface/version.cc src/core/lib/surface/wait_for_cq_end_op.cc @@ -2589,6 +2585,11 @@ add_library(grpc src/core/resolver/xds/xds_dependency_manager.cc src/core/resolver/xds/xds_resolver.cc src/core/resolver/xds/xds_resolver_trace.cc + src/core/server/server.cc + src/core/server/server_call_tracer_filter.cc + src/core/server/server_config_selector_filter.cc + src/core/server/xds_channel_stack_modifier.cc + src/core/server/xds_server_config_fetcher.cc src/core/service_config/service_config_channel_arg_filter.cc src/core/service_config/service_config_impl.cc src/core/service_config/service_config_parser.cc @@ -3027,7 +3028,6 @@ add_library(grpc_unsecure 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 @@ -3242,7 +3242,6 @@ add_library(grpc_unsecure 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 src/core/lib/surface/version.cc src/core/lib/surface/wait_for_cq_end_op.cc @@ -3304,6 +3303,8 @@ add_library(grpc_unsecure src/core/resolver/resolver.cc src/core/resolver/resolver_registry.cc src/core/resolver/sockaddr/sockaddr_resolver.cc + src/core/server/server.cc + src/core/server/server_call_tracer_filter.cc src/core/service_config/service_config_channel_arg_filter.cc src/core/service_config/service_config_impl.cc src/core/service_config/service_config_parser.cc @@ -27040,7 +27041,7 @@ endif() if(gRPC_BUILD_TESTS) add_executable(server_config_selector_test - test/core/server_config_selector/server_config_selector_test.cc + test/core/server/server_config_selector_test.cc ) if(WIN32 AND MSVC) if(BUILD_SHARED_LIBS) @@ -33190,6 +33191,105 @@ target_link_libraries(xds_certificate_provider_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(xds_channel_stack_modifier_test + src/core/ext/filters/logging/logging_filter.cc + src/cpp/client/call_credentials.cc + src/cpp/client/channel_cc.cc + src/cpp/client/channel_credentials.cc + src/cpp/client/client_callback.cc + src/cpp/client/client_context.cc + src/cpp/client/client_interceptor.cc + src/cpp/client/client_stats_interceptor.cc + src/cpp/client/create_channel.cc + src/cpp/client/create_channel_internal.cc + src/cpp/client/create_channel_posix.cc + src/cpp/client/insecure_credentials.cc + src/cpp/client/secure_credentials.cc + src/cpp/common/alarm.cc + src/cpp/common/auth_property_iterator.cc + src/cpp/common/channel_arguments.cc + src/cpp/common/completion_queue_cc.cc + src/cpp/common/resource_quota_cc.cc + src/cpp/common/rpc_method.cc + src/cpp/common/secure_auth_context.cc + src/cpp/common/secure_create_auth_context.cc + src/cpp/common/tls_certificate_provider.cc + src/cpp/common/tls_certificate_verifier.cc + src/cpp/common/tls_credentials_options.cc + src/cpp/common/validate_service_config.cc + src/cpp/common/version_cc.cc + src/cpp/ext/filters/census/client_filter.cc + src/cpp/ext/filters/census/context.cc + src/cpp/ext/filters/census/grpc_plugin.cc + src/cpp/ext/filters/census/measures.cc + src/cpp/ext/filters/census/rpc_encoding.cc + src/cpp/ext/filters/census/server_call_tracer.cc + src/cpp/ext/filters/census/views.cc + src/cpp/server/async_generic_service.cc + src/cpp/server/backend_metric_recorder.cc + src/cpp/server/channel_argument_option.cc + src/cpp/server/create_default_thread_pool.cc + src/cpp/server/external_connection_acceptor_impl.cc + src/cpp/server/health/default_health_check_service.cc + src/cpp/server/health/health_check_service.cc + src/cpp/server/health/health_check_service_server_builder_option.cc + src/cpp/server/insecure_server_credentials.cc + src/cpp/server/secure_server_credentials.cc + src/cpp/server/server_builder.cc + src/cpp/server/server_callback.cc + src/cpp/server/server_cc.cc + src/cpp/server/server_context.cc + src/cpp/server/server_credentials.cc + src/cpp/server/server_posix.cc + src/cpp/thread_manager/thread_manager.cc + src/cpp/util/byte_buffer_cc.cc + src/cpp/util/status.cc + src/cpp/util/string_ref.cc + src/cpp/util/time_cc.cc + test/core/server/xds_channel_stack_modifier_test.cc +) +if(WIN32 AND MSVC) + if(BUILD_SHARED_LIBS) + target_compile_definitions(xds_channel_stack_modifier_test + PRIVATE + "GPR_DLL_IMPORTS" + "GRPC_DLL_IMPORTS" + ) + endif() +endif() +target_compile_features(xds_channel_stack_modifier_test PUBLIC cxx_std_14) +target_include_directories(xds_channel_stack_modifier_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(xds_channel_stack_modifier_test + ${_gRPC_ALLTARGETS_LIBRARIES} + gtest + absl::endian + absl::int128 + ${_gRPC_PROTOBUF_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index c397bcad2cd..26446a07d48 100644 --- a/Makefile +++ b/Makefile @@ -699,7 +699,6 @@ LIBGRPC_SRC = \ src/core/ext/filters/message_size/message_size_filter.cc \ src/core/ext/filters/rbac/rbac_filter.cc \ src/core/ext/filters/rbac/rbac_service_config_parser.cc \ - src/core/ext/filters/server_config_selector/server_config_selector_filter.cc \ src/core/ext/filters/stateful_session/stateful_session_filter.cc \ src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc \ src/core/ext/gcp/metadata_query.cc \ @@ -1062,7 +1061,6 @@ LIBGRPC_SRC = \ src/core/ext/xds/xds_bootstrap.cc \ src/core/ext/xds/xds_bootstrap_grpc.cc \ src/core/ext/xds/xds_certificate_provider.cc \ - src/core/ext/xds/xds_channel_stack_modifier.cc \ src/core/ext/xds/xds_client.cc \ src/core/ext/xds/xds_client_grpc.cc \ src/core/ext/xds/xds_client_stats.cc \ @@ -1079,7 +1077,6 @@ LIBGRPC_SRC = \ src/core/ext/xds/xds_listener.cc \ src/core/ext/xds/xds_route_config.cc \ src/core/ext/xds/xds_routing.cc \ - src/core/ext/xds/xds_server_config_fetcher.cc \ src/core/ext/xds/xds_transport_grpc.cc \ src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc \ src/core/handshaker/handshaker.cc \ @@ -1105,7 +1102,6 @@ LIBGRPC_SRC = \ 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 \ @@ -1404,7 +1400,6 @@ LIBGRPC_SRC = \ 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 \ src/core/lib/surface/version.cc \ src/core/lib/surface/wait_for_cq_end_op.cc \ @@ -1476,6 +1471,11 @@ LIBGRPC_SRC = \ src/core/resolver/xds/xds_dependency_manager.cc \ src/core/resolver/xds/xds_resolver.cc \ src/core/resolver/xds/xds_resolver_trace.cc \ + src/core/server/server.cc \ + src/core/server/server_call_tracer_filter.cc \ + src/core/server/server_config_selector_filter.cc \ + src/core/server/xds_channel_stack_modifier.cc \ + src/core/server/xds_server_config_fetcher.cc \ src/core/service_config/service_config_channel_arg_filter.cc \ src/core/service_config/service_config_impl.cc \ src/core/service_config/service_config_parser.cc \ diff --git a/Package.swift b/Package.swift index 756f3643856..9afca3494ca 100644 --- a/Package.swift +++ b/Package.swift @@ -184,9 +184,6 @@ let package = Package( "src/core/ext/filters/rbac/rbac_filter.h", "src/core/ext/filters/rbac/rbac_service_config_parser.cc", "src/core/ext/filters/rbac/rbac_service_config_parser.h", - "src/core/ext/filters/server_config_selector/server_config_selector.h", - "src/core/ext/filters/server_config_selector/server_config_selector_filter.cc", - "src/core/ext/filters/server_config_selector/server_config_selector_filter.h", "src/core/ext/filters/stateful_session/stateful_session_filter.cc", "src/core/ext/filters/stateful_session/stateful_session_filter.h", "src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc", @@ -1078,8 +1075,6 @@ let package = Package( "src/core/ext/xds/xds_certificate_provider.cc", "src/core/ext/xds/xds_certificate_provider.h", "src/core/ext/xds/xds_channel_args.h", - "src/core/ext/xds/xds_channel_stack_modifier.cc", - "src/core/ext/xds/xds_channel_stack_modifier.h", "src/core/ext/xds/xds_client.cc", "src/core/ext/xds/xds_client.h", "src/core/ext/xds/xds_client_grpc.cc", @@ -1115,7 +1110,6 @@ let package = Package( "src/core/ext/xds/xds_route_config.h", "src/core/ext/xds/xds_routing.cc", "src/core/ext/xds/xds_routing.h", - "src/core/ext/xds/xds_server_config_fetcher.cc", "src/core/ext/xds/xds_transport.h", "src/core/ext/xds/xds_transport_grpc.cc", "src/core/ext/xds/xds_transport_grpc.h", @@ -1173,8 +1167,6 @@ let package = Package( "src/core/lib/channel/metrics.h", "src/core/lib/channel/promise_based_filter.cc", "src/core/lib/channel/promise_based_filter.h", - "src/core/lib/channel/server_call_tracer_filter.cc", - "src/core/lib/channel/server_call_tracer_filter.h", "src/core/lib/channel/status_util.cc", "src/core/lib/channel/status_util.h", "src/core/lib/channel/tcp_tracer.h", @@ -1324,7 +1316,6 @@ let package = Package( "src/core/lib/gpr/linux/cpu.cc", "src/core/lib/gpr/linux/log.cc", "src/core/lib/gpr/log.cc", - "src/core/lib/gpr/log_internal.h", "src/core/lib/gpr/msys/tmpfile.cc", "src/core/lib/gpr/posix/cpu.cc", "src/core/lib/gpr/posix/log.cc", @@ -1800,9 +1791,6 @@ let package = Package( "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", @@ -1942,6 +1930,17 @@ let package = Package( "src/core/resolver/xds/xds_resolver_attributes.h", "src/core/resolver/xds/xds_resolver_trace.cc", "src/core/resolver/xds/xds_resolver_trace.h", + "src/core/server/server.cc", + "src/core/server/server.h", + "src/core/server/server_call_tracer_filter.cc", + "src/core/server/server_call_tracer_filter.h", + "src/core/server/server_config_selector.h", + "src/core/server/server_config_selector_filter.cc", + "src/core/server/server_config_selector_filter.h", + "src/core/server/server_interface.h", + "src/core/server/xds_channel_stack_modifier.cc", + "src/core/server/xds_channel_stack_modifier.h", + "src/core/server/xds_server_config_fetcher.cc", "src/core/service_config/service_config.h", "src/core/service_config/service_config_call_data.h", "src/core/service_config/service_config_channel_arg_filter.cc", diff --git a/bazel/experiments.bzl b/bazel/experiments.bzl index 679b754b05d..abd1166647f 100644 --- a/bazel/experiments.bzl +++ b/bazel/experiments.bzl @@ -60,12 +60,16 @@ EXPERIMENTS = { }, "off": { "core_end2end_test": [ + "event_engine_client", "promise_based_server_call", ], "endpoint_test": [ "tcp_frame_size_tuning", "tcp_rcv_lowat", ], + "event_engine_client_test": [ + "event_engine_client", + ], "flow_control_test": [ "multiping", "peer_state_based_framing", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 4e50264e937..bd949a4560a 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -56,7 +56,6 @@ libs: - src/core/lib/config/load_config.h - src/core/lib/event_engine/thread_local.h - src/core/lib/gpr/alloc.h - - src/core/lib/gpr/log_internal.h - src/core/lib/gpr/string.h - src/core/lib/gpr/time_precise.h - src/core/lib/gpr/tmpfile.h @@ -256,8 +255,6 @@ libs: - src/core/ext/filters/message_size/message_size_filter.h - src/core/ext/filters/rbac/rbac_filter.h - src/core/ext/filters/rbac/rbac_service_config_parser.h - - src/core/ext/filters/server_config_selector/server_config_selector.h - - src/core/ext/filters/server_config_selector/server_config_selector_filter.h - src/core/ext/filters/stateful_session/stateful_session_filter.h - src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h - src/core/ext/gcp/metadata_query.h @@ -787,7 +784,6 @@ libs: - src/core/ext/xds/xds_bootstrap_grpc.h - src/core/ext/xds/xds_certificate_provider.h - src/core/ext/xds/xds_channel_args.h - - src/core/ext/xds/xds_channel_stack_modifier.h - src/core/ext/xds/xds_client.h - src/core/ext/xds/xds_client_grpc.h - src/core/ext/xds/xds_client_stats.h @@ -839,7 +835,6 @@ libs: - src/core/lib/channel/context.h - src/core/lib/channel/metrics.h - src/core/lib/channel/promise_based_filter.h - - src/core/lib/channel/server_call_tracer_filter.h - src/core/lib/channel/status_util.h - src/core/lib/channel/tcp_tracer.h - src/core/lib/compression/compression_internal.h @@ -1138,8 +1133,6 @@ libs: - 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 @@ -1208,6 +1201,12 @@ libs: - src/core/resolver/xds/xds_dependency_manager.h - src/core/resolver/xds/xds_resolver_attributes.h - src/core/resolver/xds/xds_resolver_trace.h + - src/core/server/server.h + - src/core/server/server_call_tracer_filter.h + - src/core/server/server_config_selector.h + - src/core/server/server_config_selector_filter.h + - src/core/server/server_interface.h + - src/core/server/xds_channel_stack_modifier.h - src/core/service_config/service_config.h - src/core/service_config/service_config_call_data.h - src/core/service_config/service_config_impl.h @@ -1277,7 +1276,6 @@ libs: - src/core/ext/filters/message_size/message_size_filter.cc - src/core/ext/filters/rbac/rbac_filter.cc - src/core/ext/filters/rbac/rbac_service_config_parser.cc - - src/core/ext/filters/server_config_selector/server_config_selector_filter.cc - src/core/ext/filters/stateful_session/stateful_session_filter.cc - src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc - src/core/ext/gcp/metadata_query.cc @@ -1640,7 +1638,6 @@ libs: - src/core/ext/xds/xds_bootstrap.cc - src/core/ext/xds/xds_bootstrap_grpc.cc - src/core/ext/xds/xds_certificate_provider.cc - - src/core/ext/xds/xds_channel_stack_modifier.cc - src/core/ext/xds/xds_client.cc - src/core/ext/xds/xds_client_grpc.cc - src/core/ext/xds/xds_client_stats.cc @@ -1657,7 +1654,6 @@ libs: - src/core/ext/xds/xds_listener.cc - src/core/ext/xds/xds_route_config.cc - src/core/ext/xds/xds_routing.cc - - src/core/ext/xds/xds_server_config_fetcher.cc - src/core/ext/xds/xds_transport_grpc.cc - src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc - src/core/handshaker/handshaker.cc @@ -1683,7 +1679,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 @@ -1937,7 +1932,6 @@ libs: - 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 - src/core/lib/surface/version.cc - src/core/lib/surface/wait_for_cq_end_op.cc @@ -2009,6 +2003,11 @@ libs: - src/core/resolver/xds/xds_dependency_manager.cc - src/core/resolver/xds/xds_resolver.cc - src/core/resolver/xds/xds_resolver_trace.cc + - src/core/server/server.cc + - src/core/server/server_call_tracer_filter.cc + - src/core/server/server_config_selector_filter.cc + - src/core/server/xds_channel_stack_modifier.cc + - src/core/server/xds_server_config_fetcher.cc - src/core/service_config/service_config_channel_arg_filter.cc - src/core/service_config/service_config_impl.cc - src/core/service_config/service_config_parser.cc @@ -2340,7 +2339,6 @@ libs: - src/core/lib/channel/context.h - src/core/lib/channel/metrics.h - src/core/lib/channel/promise_based_filter.h - - src/core/lib/channel/server_call_tracer_filter.h - src/core/lib/channel/status_util.h - src/core/lib/channel/tcp_tracer.h - src/core/lib/compression/compression_internal.h @@ -2603,8 +2601,6 @@ libs: - 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 @@ -2667,6 +2663,9 @@ libs: - src/core/resolver/resolver_factory.h - src/core/resolver/resolver_registry.h - src/core/resolver/server_address.h + - src/core/server/server.h + - src/core/server/server_call_tracer_filter.h + - src/core/server/server_interface.h - src/core/service_config/service_config.h - src/core/service_config/service_config_call_data.h - src/core/service_config/service_config_impl.h @@ -2805,7 +2804,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 @@ -3020,7 +3018,6 @@ libs: - 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 - src/core/lib/surface/version.cc - src/core/lib/surface/wait_for_cq_end_op.cc @@ -3082,6 +3079,8 @@ libs: - src/core/resolver/resolver.cc - src/core/resolver/resolver_registry.cc - src/core/resolver/sockaddr/sockaddr_resolver.cc + - src/core/server/server.cc + - src/core/server/server_call_tracer_filter.cc - src/core/service_config/service_config_channel_arg_filter.cc - src/core/service_config/service_config_impl.cc - src/core/service_config/service_config_parser.cc @@ -4679,7 +4678,6 @@ 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_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 @@ -4712,6 +4710,7 @@ libs: - src/core/resolver/resolver_factory.h - src/core/resolver/resolver_registry.h - src/core/resolver/server_address.h + - src/core/server/server_interface.h - src/core/service_config/service_config.h - src/core/service_config/service_config_call_data.h - src/core/service_config/service_config_parser.h @@ -11834,7 +11833,6 @@ targets: - 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_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 @@ -11869,6 +11867,7 @@ targets: - src/core/resolver/resolver_factory.h - src/core/resolver/resolver_registry.h - src/core/resolver/server_address.h + - src/core/server/server_interface.h - src/core/service_config/service_config.h - src/core/service_config/service_config_call_data.h - src/core/service_config/service_config_parser.h @@ -17938,7 +17937,7 @@ targets: language: c++ headers: [] src: - - test/core/server_config_selector/server_config_selector_test.cc + - test/core/server/server_config_selector_test.cc deps: - gtest - grpc_test_util @@ -20950,6 +20949,94 @@ targets: - gtest - grpc_test_util uses_polling: false +- name: xds_channel_stack_modifier_test + gtest: true + build: test + language: c++ + headers: + - src/core/ext/filters/logging/logging_filter.h + - src/core/ext/filters/logging/logging_sink.h + - src/cpp/client/client_stats_interceptor.h + - src/cpp/client/create_channel_internal.h + - src/cpp/client/secure_credentials.h + - src/cpp/common/secure_auth_context.h + - src/cpp/ext/filters/census/client_filter.h + - src/cpp/ext/filters/census/context.h + - src/cpp/ext/filters/census/grpc_plugin.h + - src/cpp/ext/filters/census/measures.h + - src/cpp/ext/filters/census/open_census_call_tracer.h + - src/cpp/ext/filters/census/rpc_encoding.h + - src/cpp/ext/filters/census/server_call_tracer.h + - src/cpp/server/backend_metric_recorder.h + - src/cpp/server/dynamic_thread_pool.h + - src/cpp/server/external_connection_acceptor_impl.h + - src/cpp/server/health/default_health_check_service.h + - src/cpp/server/secure_server_credentials.h + - src/cpp/server/thread_pool_interface.h + - src/cpp/thread_manager/thread_manager.h + src: + - src/core/ext/filters/logging/logging_filter.cc + - src/cpp/client/call_credentials.cc + - src/cpp/client/channel_cc.cc + - src/cpp/client/channel_credentials.cc + - src/cpp/client/client_callback.cc + - src/cpp/client/client_context.cc + - src/cpp/client/client_interceptor.cc + - src/cpp/client/client_stats_interceptor.cc + - src/cpp/client/create_channel.cc + - src/cpp/client/create_channel_internal.cc + - src/cpp/client/create_channel_posix.cc + - src/cpp/client/insecure_credentials.cc + - src/cpp/client/secure_credentials.cc + - src/cpp/common/alarm.cc + - src/cpp/common/auth_property_iterator.cc + - src/cpp/common/channel_arguments.cc + - src/cpp/common/completion_queue_cc.cc + - src/cpp/common/resource_quota_cc.cc + - src/cpp/common/rpc_method.cc + - src/cpp/common/secure_auth_context.cc + - src/cpp/common/secure_create_auth_context.cc + - src/cpp/common/tls_certificate_provider.cc + - src/cpp/common/tls_certificate_verifier.cc + - src/cpp/common/tls_credentials_options.cc + - src/cpp/common/validate_service_config.cc + - src/cpp/common/version_cc.cc + - src/cpp/ext/filters/census/client_filter.cc + - src/cpp/ext/filters/census/context.cc + - src/cpp/ext/filters/census/grpc_plugin.cc + - src/cpp/ext/filters/census/measures.cc + - src/cpp/ext/filters/census/rpc_encoding.cc + - src/cpp/ext/filters/census/server_call_tracer.cc + - src/cpp/ext/filters/census/views.cc + - src/cpp/server/async_generic_service.cc + - src/cpp/server/backend_metric_recorder.cc + - src/cpp/server/channel_argument_option.cc + - src/cpp/server/create_default_thread_pool.cc + - src/cpp/server/external_connection_acceptor_impl.cc + - src/cpp/server/health/default_health_check_service.cc + - src/cpp/server/health/health_check_service.cc + - src/cpp/server/health/health_check_service_server_builder_option.cc + - src/cpp/server/insecure_server_credentials.cc + - src/cpp/server/secure_server_credentials.cc + - src/cpp/server/server_builder.cc + - src/cpp/server/server_callback.cc + - src/cpp/server/server_cc.cc + - src/cpp/server/server_context.cc + - src/cpp/server/server_credentials.cc + - src/cpp/server/server_posix.cc + - src/cpp/thread_manager/thread_manager.cc + - src/cpp/util/byte_buffer_cc.cc + - src/cpp/util/status.cc + - src/cpp/util/string_ref.cc + - src/cpp/util/time_cc.cc + - test/core/server/xds_channel_stack_modifier_test.cc + deps: + - gtest + - absl/base:endian + - absl/numeric:int128 + - protobuf + - grpc_test_util + uses_polling: false - name: xds_client_test gtest: true build: test diff --git a/config.m4 b/config.m4 index f2b4c4817e5..125cc7f8c1e 100644 --- a/config.m4 +++ b/config.m4 @@ -74,7 +74,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/message_size/message_size_filter.cc \ src/core/ext/filters/rbac/rbac_filter.cc \ src/core/ext/filters/rbac/rbac_service_config_parser.cc \ - src/core/ext/filters/server_config_selector/server_config_selector_filter.cc \ src/core/ext/filters/stateful_session/stateful_session_filter.cc \ src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc \ src/core/ext/gcp/metadata_query.cc \ @@ -437,7 +436,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/xds/xds_bootstrap.cc \ src/core/ext/xds/xds_bootstrap_grpc.cc \ src/core/ext/xds/xds_certificate_provider.cc \ - src/core/ext/xds/xds_channel_stack_modifier.cc \ src/core/ext/xds/xds_client.cc \ src/core/ext/xds/xds_client_grpc.cc \ src/core/ext/xds/xds_client_stats.cc \ @@ -454,7 +452,6 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/xds/xds_listener.cc \ src/core/ext/xds/xds_route_config.cc \ src/core/ext/xds/xds_routing.cc \ - src/core/ext/xds/xds_server_config_fetcher.cc \ src/core/ext/xds/xds_transport_grpc.cc \ src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc \ src/core/handshaker/handshaker.cc \ @@ -480,7 +477,6 @@ if test "$PHP_GRPC" != "no"; then 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 \ @@ -779,7 +775,6 @@ if test "$PHP_GRPC" != "no"; then 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 \ src/core/lib/surface/version.cc \ src/core/lib/surface/wait_for_cq_end_op.cc \ @@ -851,6 +846,11 @@ if test "$PHP_GRPC" != "no"; then src/core/resolver/xds/xds_dependency_manager.cc \ src/core/resolver/xds/xds_resolver.cc \ src/core/resolver/xds/xds_resolver_trace.cc \ + src/core/server/server.cc \ + src/core/server/server_call_tracer_filter.cc \ + src/core/server/server_config_selector_filter.cc \ + src/core/server/xds_channel_stack_modifier.cc \ + src/core/server/xds_server_config_fetcher.cc \ src/core/service_config/service_config_channel_arg_filter.cc \ src/core/service_config/service_config_impl.cc \ src/core/service_config/service_config_parser.cc \ @@ -1397,7 +1397,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/server) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/message_size) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/rbac) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/server_config_selector) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/stateful_session) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/gcp) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/alpn) @@ -1598,6 +1597,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/resolver/google_c2p) PHP_ADD_BUILD_DIR($ext_builddir/src/core/resolver/sockaddr) PHP_ADD_BUILD_DIR($ext_builddir/src/core/resolver/xds) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/server) PHP_ADD_BUILD_DIR($ext_builddir/src/core/service_config) PHP_ADD_BUILD_DIR($ext_builddir/src/core/tsi) PHP_ADD_BUILD_DIR($ext_builddir/src/core/tsi/alts/crypt) diff --git a/config.w32 b/config.w32 index 4643bbfedd6..a0cc2a6ee58 100644 --- a/config.w32 +++ b/config.w32 @@ -39,7 +39,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\message_size\\message_size_filter.cc " + "src\\core\\ext\\filters\\rbac\\rbac_filter.cc " + "src\\core\\ext\\filters\\rbac\\rbac_service_config_parser.cc " + - "src\\core\\ext\\filters\\server_config_selector\\server_config_selector_filter.cc " + "src\\core\\ext\\filters\\stateful_session\\stateful_session_filter.cc " + "src\\core\\ext\\filters\\stateful_session\\stateful_session_service_config_parser.cc " + "src\\core\\ext\\gcp\\metadata_query.cc " + @@ -402,7 +401,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\xds\\xds_bootstrap.cc " + "src\\core\\ext\\xds\\xds_bootstrap_grpc.cc " + "src\\core\\ext\\xds\\xds_certificate_provider.cc " + - "src\\core\\ext\\xds\\xds_channel_stack_modifier.cc " + "src\\core\\ext\\xds\\xds_client.cc " + "src\\core\\ext\\xds\\xds_client_grpc.cc " + "src\\core\\ext\\xds\\xds_client_stats.cc " + @@ -419,7 +417,6 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\xds\\xds_listener.cc " + "src\\core\\ext\\xds\\xds_route_config.cc " + "src\\core\\ext\\xds\\xds_routing.cc " + - "src\\core\\ext\\xds\\xds_server_config_fetcher.cc " + "src\\core\\ext\\xds\\xds_transport_grpc.cc " + "src\\core\\handshaker\\endpoint_info\\endpoint_info_handshaker.cc " + "src\\core\\handshaker\\handshaker.cc " + @@ -445,7 +442,6 @@ if (PHP_GRPC != "no") { "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 " + @@ -744,7 +740,6 @@ if (PHP_GRPC != "no") { "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 " + "src\\core\\lib\\surface\\version.cc " + "src\\core\\lib\\surface\\wait_for_cq_end_op.cc " + @@ -816,6 +811,11 @@ if (PHP_GRPC != "no") { "src\\core\\resolver\\xds\\xds_dependency_manager.cc " + "src\\core\\resolver\\xds\\xds_resolver.cc " + "src\\core\\resolver\\xds\\xds_resolver_trace.cc " + + "src\\core\\server\\server.cc " + + "src\\core\\server\\server_call_tracer_filter.cc " + + "src\\core\\server\\server_config_selector_filter.cc " + + "src\\core\\server\\xds_channel_stack_modifier.cc " + + "src\\core\\server\\xds_server_config_fetcher.cc " + "src\\core\\service_config\\service_config_channel_arg_filter.cc " + "src\\core\\service_config\\service_config_impl.cc " + "src\\core\\service_config\\service_config_parser.cc " + @@ -1391,7 +1391,6 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\http\\server"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\message_size"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\rbac"); - FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\server_config_selector"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\filters\\stateful_session"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\gcp"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport"); @@ -1736,6 +1735,7 @@ if (PHP_GRPC != "no") { FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\resolver\\google_c2p"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\resolver\\sockaddr"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\resolver\\xds"); + FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\server"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\service_config"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\tsi"); FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\tsi\\alts"); diff --git a/examples/python/helloworld/helloworld_pb2.py b/examples/python/helloworld/helloworld_pb2.py index 0e202a09116..88f8715f997 100644 --- a/examples/python/helloworld/helloworld_pb2.py +++ b/examples/python/helloworld/helloworld_pb2.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: helloworld.proto -# Protobuf Python Version: 4.25.1 +# Protobuf Python Version: 5.26.1 """Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool @@ -19,8 +19,8 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10helloworld.pro _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'helloworld_pb2', _globals) -if _descriptor._USE_C_DESCRIPTORS == False: - _globals['DESCRIPTOR']._options = None +if not _descriptor._USE_C_DESCRIPTORS: + _globals['DESCRIPTOR']._loaded_options = None _globals['DESCRIPTOR']._serialized_options = b'\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW' _globals['_HELLOREQUEST']._serialized_start=32 _globals['_HELLOREQUEST']._serialized_end=60 diff --git a/examples/python/helloworld/helloworld_pb2_grpc.py b/examples/python/helloworld/helloworld_pb2_grpc.py index 48ad1004f9b..a991c8fd3f3 100644 --- a/examples/python/helloworld/helloworld_pb2_grpc.py +++ b/examples/python/helloworld/helloworld_pb2_grpc.py @@ -5,7 +5,7 @@ import warnings import helloworld_pb2 as helloworld__pb2 -GRPC_GENERATED_VERSION = '1.63.0.dev0' +GRPC_GENERATED_VERSION = '1.64.0.dev0' GRPC_VERSION = grpc.__version__ EXPECTED_ERROR_RELEASE = '1.65.0' SCHEDULED_RELEASE_DATE = 'June 25, 2024' @@ -102,6 +102,7 @@ def add_GreeterServicer_to_server(servicer, server): generic_handler = grpc.method_handlers_generic_handler( 'helloworld.Greeter', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) + server.add_registered_method_handlers('helloworld.Greeter', rpc_method_handlers) # This class is part of an EXPERIMENTAL API. diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 91edbbe6cb0..57179a085a3 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -295,8 +295,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/rbac/rbac_filter.h', 'src/core/ext/filters/rbac/rbac_service_config_parser.h', - 'src/core/ext/filters/server_config_selector/server_config_selector.h', - 'src/core/ext/filters/server_config_selector/server_config_selector_filter.h', 'src/core/ext/filters/stateful_session/stateful_session_filter.h', 'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h', 'src/core/ext/gcp/metadata_query.h', @@ -864,7 +862,6 @@ Pod::Spec.new do |s| 'src/core/ext/xds/xds_bootstrap_grpc.h', 'src/core/ext/xds/xds_certificate_provider.h', 'src/core/ext/xds/xds_channel_args.h', - 'src/core/ext/xds/xds_channel_stack_modifier.h', 'src/core/ext/xds/xds_client.h', 'src/core/ext/xds/xds_client_grpc.h', 'src/core/ext/xds/xds_client_stats.h', @@ -917,7 +914,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/context.h', 'src/core/lib/channel/metrics.h', 'src/core/lib/channel/promise_based_filter.h', - 'src/core/lib/channel/server_call_tracer_filter.h', 'src/core/lib/channel/status_util.h', 'src/core/lib/channel/tcp_tracer.h', 'src/core/lib/compression/compression_internal.h', @@ -997,7 +993,6 @@ Pod::Spec.new do |s| 'src/core/lib/experiments/config.h', 'src/core/lib/experiments/experiments.h', 'src/core/lib/gpr/alloc.h', - 'src/core/lib/gpr/log_internal.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', 'src/core/lib/gpr/time_precise.h', @@ -1241,8 +1236,6 @@ Pod::Spec.new do |s| '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', @@ -1311,6 +1304,12 @@ Pod::Spec.new do |s| 'src/core/resolver/xds/xds_dependency_manager.h', 'src/core/resolver/xds/xds_resolver_attributes.h', 'src/core/resolver/xds/xds_resolver_trace.h', + 'src/core/server/server.h', + 'src/core/server/server_call_tracer_filter.h', + 'src/core/server/server_config_selector.h', + 'src/core/server/server_config_selector_filter.h', + 'src/core/server/server_interface.h', + 'src/core/server/xds_channel_stack_modifier.h', 'src/core/service_config/service_config.h', 'src/core/service_config/service_config_call_data.h', 'src/core/service_config/service_config_impl.h', @@ -1583,8 +1582,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/rbac/rbac_filter.h', 'src/core/ext/filters/rbac/rbac_service_config_parser.h', - 'src/core/ext/filters/server_config_selector/server_config_selector.h', - 'src/core/ext/filters/server_config_selector/server_config_selector_filter.h', 'src/core/ext/filters/stateful_session/stateful_session_filter.h', 'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h', 'src/core/ext/gcp/metadata_query.h', @@ -2134,7 +2131,6 @@ Pod::Spec.new do |s| 'src/core/ext/xds/xds_bootstrap_grpc.h', 'src/core/ext/xds/xds_certificate_provider.h', 'src/core/ext/xds/xds_channel_args.h', - 'src/core/ext/xds/xds_channel_stack_modifier.h', 'src/core/ext/xds/xds_client.h', 'src/core/ext/xds/xds_client_grpc.h', 'src/core/ext/xds/xds_client_stats.h', @@ -2187,7 +2183,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/context.h', 'src/core/lib/channel/metrics.h', 'src/core/lib/channel/promise_based_filter.h', - 'src/core/lib/channel/server_call_tracer_filter.h', 'src/core/lib/channel/status_util.h', 'src/core/lib/channel/tcp_tracer.h', 'src/core/lib/compression/compression_internal.h', @@ -2267,7 +2262,6 @@ Pod::Spec.new do |s| 'src/core/lib/experiments/config.h', 'src/core/lib/experiments/experiments.h', 'src/core/lib/gpr/alloc.h', - 'src/core/lib/gpr/log_internal.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', 'src/core/lib/gpr/time_precise.h', @@ -2511,8 +2505,6 @@ Pod::Spec.new do |s| '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', @@ -2581,6 +2573,12 @@ Pod::Spec.new do |s| 'src/core/resolver/xds/xds_dependency_manager.h', 'src/core/resolver/xds/xds_resolver_attributes.h', 'src/core/resolver/xds/xds_resolver_trace.h', + 'src/core/server/server.h', + 'src/core/server/server_call_tracer_filter.h', + 'src/core/server/server_config_selector.h', + 'src/core/server/server_config_selector_filter.h', + 'src/core/server/server_interface.h', + 'src/core/server/xds_channel_stack_modifier.h', 'src/core/service_config/service_config.h', 'src/core/service_config/service_config_call_data.h', 'src/core/service_config/service_config_impl.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index fe5a8f48f84..154ea290e80 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -301,9 +301,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/rbac/rbac_filter.h', 'src/core/ext/filters/rbac/rbac_service_config_parser.cc', 'src/core/ext/filters/rbac/rbac_service_config_parser.h', - 'src/core/ext/filters/server_config_selector/server_config_selector.h', - 'src/core/ext/filters/server_config_selector/server_config_selector_filter.cc', - 'src/core/ext/filters/server_config_selector/server_config_selector_filter.h', 'src/core/ext/filters/stateful_session/stateful_session_filter.cc', 'src/core/ext/filters/stateful_session/stateful_session_filter.h', 'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc', @@ -1195,8 +1192,6 @@ Pod::Spec.new do |s| 'src/core/ext/xds/xds_certificate_provider.cc', 'src/core/ext/xds/xds_certificate_provider.h', 'src/core/ext/xds/xds_channel_args.h', - 'src/core/ext/xds/xds_channel_stack_modifier.cc', - 'src/core/ext/xds/xds_channel_stack_modifier.h', 'src/core/ext/xds/xds_client.cc', 'src/core/ext/xds/xds_client.h', 'src/core/ext/xds/xds_client_grpc.cc', @@ -1232,7 +1227,6 @@ Pod::Spec.new do |s| 'src/core/ext/xds/xds_route_config.h', 'src/core/ext/xds/xds_routing.cc', 'src/core/ext/xds/xds_routing.h', - 'src/core/ext/xds/xds_server_config_fetcher.cc', 'src/core/ext/xds/xds_transport.h', 'src/core/ext/xds/xds_transport_grpc.cc', 'src/core/ext/xds/xds_transport_grpc.h', @@ -1290,8 +1284,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/metrics.h', 'src/core/lib/channel/promise_based_filter.cc', 'src/core/lib/channel/promise_based_filter.h', - 'src/core/lib/channel/server_call_tracer_filter.cc', - 'src/core/lib/channel/server_call_tracer_filter.h', 'src/core/lib/channel/status_util.cc', 'src/core/lib/channel/status_util.h', 'src/core/lib/channel/tcp_tracer.h', @@ -1441,7 +1433,6 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/linux/cpu.cc', 'src/core/lib/gpr/linux/log.cc', 'src/core/lib/gpr/log.cc', - 'src/core/lib/gpr/log_internal.h', 'src/core/lib/gpr/msys/tmpfile.cc', 'src/core/lib/gpr/posix/cpu.cc', 'src/core/lib/gpr/posix/log.cc', @@ -1913,9 +1904,6 @@ Pod::Spec.new do |s| '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', @@ -2055,6 +2043,17 @@ Pod::Spec.new do |s| 'src/core/resolver/xds/xds_resolver_attributes.h', 'src/core/resolver/xds/xds_resolver_trace.cc', 'src/core/resolver/xds/xds_resolver_trace.h', + 'src/core/server/server.cc', + 'src/core/server/server.h', + 'src/core/server/server_call_tracer_filter.cc', + 'src/core/server/server_call_tracer_filter.h', + 'src/core/server/server_config_selector.h', + 'src/core/server/server_config_selector_filter.cc', + 'src/core/server/server_config_selector_filter.h', + 'src/core/server/server_interface.h', + 'src/core/server/xds_channel_stack_modifier.cc', + 'src/core/server/xds_channel_stack_modifier.h', + 'src/core/server/xds_server_config_fetcher.cc', 'src/core/service_config/service_config.h', 'src/core/service_config/service_config_call_data.h', 'src/core/service_config/service_config_channel_arg_filter.cc', @@ -2382,8 +2381,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/rbac/rbac_filter.h', 'src/core/ext/filters/rbac/rbac_service_config_parser.h', - 'src/core/ext/filters/server_config_selector/server_config_selector.h', - 'src/core/ext/filters/server_config_selector/server_config_selector_filter.h', 'src/core/ext/filters/stateful_session/stateful_session_filter.h', 'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.h', 'src/core/ext/gcp/metadata_query.h', @@ -2913,7 +2910,6 @@ Pod::Spec.new do |s| 'src/core/ext/xds/xds_bootstrap_grpc.h', 'src/core/ext/xds/xds_certificate_provider.h', 'src/core/ext/xds/xds_channel_args.h', - 'src/core/ext/xds/xds_channel_stack_modifier.h', 'src/core/ext/xds/xds_client.h', 'src/core/ext/xds/xds_client_grpc.h', 'src/core/ext/xds/xds_client_stats.h', @@ -2965,7 +2961,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/context.h', 'src/core/lib/channel/metrics.h', 'src/core/lib/channel/promise_based_filter.h', - 'src/core/lib/channel/server_call_tracer_filter.h', 'src/core/lib/channel/status_util.h', 'src/core/lib/channel/tcp_tracer.h', 'src/core/lib/compression/compression_internal.h', @@ -3045,7 +3040,6 @@ Pod::Spec.new do |s| 'src/core/lib/experiments/config.h', 'src/core/lib/experiments/experiments.h', 'src/core/lib/gpr/alloc.h', - 'src/core/lib/gpr/log_internal.h', 'src/core/lib/gpr/spinlock.h', 'src/core/lib/gpr/string.h', 'src/core/lib/gpr/time_precise.h', @@ -3289,8 +3283,6 @@ Pod::Spec.new do |s| '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', @@ -3359,6 +3351,12 @@ Pod::Spec.new do |s| 'src/core/resolver/xds/xds_dependency_manager.h', 'src/core/resolver/xds/xds_resolver_attributes.h', 'src/core/resolver/xds/xds_resolver_trace.h', + 'src/core/server/server.h', + 'src/core/server/server_call_tracer_filter.h', + 'src/core/server/server_config_selector.h', + 'src/core/server/server_config_selector_filter.h', + 'src/core/server/server_interface.h', + 'src/core/server/xds_channel_stack_modifier.h', 'src/core/service_config/service_config.h', 'src/core/service_config/service_config_call_data.h', 'src/core/service_config/service_config_impl.h', diff --git a/grpc.gemspec b/grpc.gemspec index f803c2aa549..1247adbae75 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -190,9 +190,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/rbac/rbac_filter.h ) s.files += %w( src/core/ext/filters/rbac/rbac_service_config_parser.cc ) s.files += %w( src/core/ext/filters/rbac/rbac_service_config_parser.h ) - s.files += %w( src/core/ext/filters/server_config_selector/server_config_selector.h ) - s.files += %w( src/core/ext/filters/server_config_selector/server_config_selector_filter.cc ) - s.files += %w( src/core/ext/filters/server_config_selector/server_config_selector_filter.h ) s.files += %w( src/core/ext/filters/stateful_session/stateful_session_filter.cc ) s.files += %w( src/core/ext/filters/stateful_session/stateful_session_filter.h ) s.files += %w( src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc ) @@ -1084,8 +1081,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/xds/xds_certificate_provider.cc ) s.files += %w( src/core/ext/xds/xds_certificate_provider.h ) s.files += %w( src/core/ext/xds/xds_channel_args.h ) - s.files += %w( src/core/ext/xds/xds_channel_stack_modifier.cc ) - s.files += %w( src/core/ext/xds/xds_channel_stack_modifier.h ) s.files += %w( src/core/ext/xds/xds_client.cc ) s.files += %w( src/core/ext/xds/xds_client.h ) s.files += %w( src/core/ext/xds/xds_client_grpc.cc ) @@ -1121,7 +1116,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/xds/xds_route_config.h ) s.files += %w( src/core/ext/xds/xds_routing.cc ) s.files += %w( src/core/ext/xds/xds_routing.h ) - s.files += %w( src/core/ext/xds/xds_server_config_fetcher.cc ) s.files += %w( src/core/ext/xds/xds_transport.h ) s.files += %w( src/core/ext/xds/xds_transport_grpc.cc ) s.files += %w( src/core/ext/xds/xds_transport_grpc.h ) @@ -1179,8 +1173,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/metrics.h ) s.files += %w( src/core/lib/channel/promise_based_filter.cc ) s.files += %w( src/core/lib/channel/promise_based_filter.h ) - s.files += %w( src/core/lib/channel/server_call_tracer_filter.cc ) - s.files += %w( src/core/lib/channel/server_call_tracer_filter.h ) s.files += %w( src/core/lib/channel/status_util.cc ) s.files += %w( src/core/lib/channel/status_util.h ) s.files += %w( src/core/lib/channel/tcp_tracer.h ) @@ -1330,7 +1322,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/linux/cpu.cc ) s.files += %w( src/core/lib/gpr/linux/log.cc ) s.files += %w( src/core/lib/gpr/log.cc ) - s.files += %w( src/core/lib/gpr/log_internal.h ) s.files += %w( src/core/lib/gpr/msys/tmpfile.cc ) s.files += %w( src/core/lib/gpr/posix/cpu.cc ) s.files += %w( src/core/lib/gpr/posix/log.cc ) @@ -1802,9 +1793,6 @@ Gem::Specification.new do |s| 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 ) @@ -1944,6 +1932,17 @@ Gem::Specification.new do |s| s.files += %w( src/core/resolver/xds/xds_resolver_attributes.h ) s.files += %w( src/core/resolver/xds/xds_resolver_trace.cc ) s.files += %w( src/core/resolver/xds/xds_resolver_trace.h ) + s.files += %w( src/core/server/server.cc ) + s.files += %w( src/core/server/server.h ) + s.files += %w( src/core/server/server_call_tracer_filter.cc ) + s.files += %w( src/core/server/server_call_tracer_filter.h ) + s.files += %w( src/core/server/server_config_selector.h ) + s.files += %w( src/core/server/server_config_selector_filter.cc ) + s.files += %w( src/core/server/server_config_selector_filter.h ) + s.files += %w( src/core/server/server_interface.h ) + s.files += %w( src/core/server/xds_channel_stack_modifier.cc ) + s.files += %w( src/core/server/xds_channel_stack_modifier.h ) + s.files += %w( src/core/server/xds_server_config_fetcher.cc ) s.files += %w( src/core/service_config/service_config.h ) s.files += %w( src/core/service_config/service_config_call_data.h ) s.files += %w( src/core/service_config/service_config_channel_arg_filter.cc ) diff --git a/package.xml b/package.xml index 62b2b535a98..f95df49ac37 100644 --- a/package.xml +++ b/package.xml @@ -172,9 +172,6 @@ - - - @@ -1066,8 +1063,6 @@ - - @@ -1103,7 +1098,6 @@ - @@ -1161,8 +1155,6 @@ - - @@ -1312,7 +1304,6 @@ - @@ -1784,9 +1775,6 @@ - - - @@ -1926,6 +1914,17 @@ + + + + + + + + + + + diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index e968fedcbad..bb3b0ab84aa 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -574,6 +574,9 @@ bool PrivateGenerator::PrintAddServicerToServer( "'$PackageQualifiedServiceName$', rpc_method_handlers)\n"); } out->Print("server.add_generic_rpc_handlers((generic_handler,))\n"); + out->Print(method_dict, + "server.add_registered_method_handlers('$" + "PackageQualifiedServiceName$', rpc_method_handlers)\n"); } return true; } diff --git a/src/core/BUILD b/src/core/BUILD index 26bdbd93ded..b28f3b72064 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -119,10 +119,10 @@ grpc_cc_library( grpc_cc_library( name = "server_call_tracer_filter", srcs = [ - "lib/channel/server_call_tracer_filter.cc", + "server/server_call_tracer_filter.cc", ], hdrs = [ - "lib/channel/server_call_tracer_filter.h", + "server/server_call_tracer_filter.h", ], external_deps = [ "absl/status", @@ -288,15 +288,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "gpr_log_internal", - hdrs = [ - "lib/gpr/log_internal.h", - ], - language = "c++", - deps = ["//:gpr_platform"], -) - grpc_cc_library( name = "env", srcs = [ @@ -483,6 +474,7 @@ grpc_cc_library( grpc_cc_library( name = "poll", + external_deps = ["absl/log:check"], language = "c++", public_hdrs = [ "lib/promise/poll.h", @@ -497,6 +489,7 @@ grpc_cc_library( grpc_cc_library( name = "status_flag", external_deps = [ + "absl/log:check", "absl/status", "absl/status:statusor", "absl/types:optional", @@ -542,6 +535,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/strings", "absl/strings:str_format", ], @@ -564,7 +558,10 @@ grpc_cc_library( grpc_cc_library( name = "context", - external_deps = ["absl/meta:type_traits"], + external_deps = [ + "absl/log:check", + "absl/meta:type_traits", + ], language = "c++", public_hdrs = [ "lib/promise/context.h", @@ -705,6 +702,7 @@ grpc_cc_library( grpc_cc_library( name = "promise_status", external_deps = [ + "absl/log:check", "absl/status", "absl/status:statusor", ], @@ -750,6 +748,9 @@ grpc_cc_library( grpc_cc_library( name = "join_state", + external_deps = [ + "absl/log:check", + ], language = "c++", public_hdrs = [ "lib/promise/detail/join_state.h", @@ -782,6 +783,7 @@ grpc_cc_library( grpc_cc_library( name = "try_join", external_deps = [ + "absl/log:check", "absl/meta:type_traits", "absl/status", "absl/status:statusor", @@ -836,6 +838,7 @@ grpc_cc_library( name = "seq_state", external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/strings", ], language = "c++", @@ -872,6 +875,7 @@ grpc_cc_library( grpc_cc_library( name = "try_seq", external_deps = [ + "absl/log:check", "absl/meta:type_traits", "absl/status", "absl/status:statusor", @@ -899,6 +903,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status", "absl/strings", "absl/strings:str_format", @@ -943,6 +948,7 @@ grpc_cc_library( hdrs = [ "lib/promise/event_engine_wakeup_scheduler.h", ], + external_deps = ["absl/log:check"], language = "c++", deps = [ "//:event_engine_base_hdrs", @@ -970,7 +976,10 @@ grpc_cc_library( grpc_cc_library( name = "latch", - external_deps = ["absl/strings"], + external_deps = [ + "absl/log:check", + "absl/strings", + ], language = "c++", public_hdrs = [ "lib/promise/latch.h", @@ -1008,6 +1017,7 @@ grpc_cc_library( "lib/promise/interceptor_list.h", ], external_deps = [ + "absl/log:check", "absl/strings", "absl/strings:str_format", "absl/types:optional", @@ -1030,6 +1040,7 @@ grpc_cc_library( "lib/promise/pipe.h", ], external_deps = [ + "absl/log:check", "absl/strings", "absl/types:optional", "absl/types:variant", @@ -1056,6 +1067,7 @@ grpc_cc_library( hdrs = [ "lib/promise/promise_mutex.h", ], + external_deps = ["absl/log:check"], language = "c++", deps = [ "activity", @@ -1103,7 +1115,10 @@ grpc_cc_library( hdrs = [ "lib/promise/mpsc.h", ], - external_deps = ["absl/base:core_headers"], + external_deps = [ + "absl/base:core_headers", + "absl/log:check", + ], language = "c++", deps = [ "activity", @@ -1123,6 +1138,7 @@ grpc_cc_library( external_deps = [ "absl/container:flat_hash_set", "absl/functional:any_invocable", + "absl/log:check", ], language = "c++", deps = [ @@ -1135,6 +1151,7 @@ grpc_cc_library( grpc_cc_library( name = "for_each", external_deps = [ + "absl/log:check", "absl/status", "absl/strings", ], @@ -1250,6 +1267,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/types:optional", @@ -2839,7 +2857,10 @@ grpc_cc_library( "lib/transport/bdp_estimator.cc", ], hdrs = ["lib/transport/bdp_estimator.h"], - external_deps = ["absl/strings"], + external_deps = [ + "absl/log:check", + "absl/strings", + ], deps = [ "time", "//:gpr", @@ -3040,7 +3061,7 @@ grpc_cc_library( grpc_cc_library( name = "server_interface", hdrs = [ - "lib/surface/server_interface.h", + "server/server_interface.h", ], language = "c++", deps = [ @@ -3591,7 +3612,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_server_config_selector", hdrs = [ - "ext/filters/server_config_selector/server_config_selector.h", + "server/server_config_selector.h", ], external_deps = [ "absl/status:statusor", @@ -3614,10 +3635,10 @@ grpc_cc_library( grpc_cc_library( name = "grpc_server_config_selector_filter", srcs = [ - "ext/filters/server_config_selector/server_config_selector_filter.cc", + "server/server_config_selector_filter.cc", ], hdrs = [ - "ext/filters/server_config_selector/server_config_selector_filter.h", + "server/server_config_selector_filter.h", ], external_deps = [ "absl/base:core_headers", @@ -3964,6 +3985,7 @@ grpc_cc_library( "lib/security/security_connector/ssl/ssl_security_connector.h", ], external_deps = [ + "absl/log:check", "absl/status", "absl/strings", "absl/strings:str_format", @@ -4008,6 +4030,7 @@ grpc_cc_library( "load_balancing/grpclb/grpclb.h", ], external_deps = [ + "absl/log:check", "absl/status:statusor", "absl/strings", "absl/types:optional", @@ -4089,6 +4112,7 @@ grpc_cc_library( "absl/base:core_headers", "absl/container:inlined_vector", "absl/functional:bind_front", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", @@ -4140,6 +4164,7 @@ grpc_cc_library( "lib/security/credentials/iam/iam_credentials.h", ], external_deps = [ + "absl/log:check", "absl/status:statusor", "absl/strings", "absl/strings:str_format", @@ -4173,6 +4198,7 @@ grpc_cc_library( "lib/security/credentials/oauth2/oauth2_credentials.h", ], external_deps = [ + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", @@ -4234,6 +4260,7 @@ grpc_cc_library( "lib/security/credentials/external/url_external_account_credentials.h", ], external_deps = [ + "absl/log:check", "absl/status", "absl/status:statusor", "absl/strings", @@ -5173,10 +5200,10 @@ grpc_cc_library( grpc_cc_library( name = "grpc_xds_channel_stack_modifier", srcs = [ - "ext/xds/xds_channel_stack_modifier.cc", + "server/xds_channel_stack_modifier.cc", ], hdrs = [ - "ext/xds/xds_channel_stack_modifier.h", + "server/xds_channel_stack_modifier.h", ], external_deps = ["absl/strings"], language = "c++", @@ -5198,7 +5225,7 @@ grpc_cc_library( grpc_cc_library( name = "grpc_xds_server_config_fetcher", srcs = [ - "ext/xds/xds_server_config_fetcher.cc", + "server/xds_server_config_fetcher.cc", ], external_deps = [ "absl/base:core_headers", @@ -7065,6 +7092,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status", "absl/status:statusor", "absl/types:optional", @@ -7266,6 +7294,9 @@ grpc_cc_library( hdrs = [ "lib/transport/call_filters.h", ], + external_deps = [ + "absl/log:check", + ], deps = [ "call_final_info", "latch", @@ -7373,6 +7404,9 @@ grpc_cc_library( hdrs = [ "lib/transport/call_spine.h", ], + external_deps = [ + "absl/log:check", + ], deps = [ "1999", "call_arena_allocator", @@ -7407,6 +7441,7 @@ grpc_cc_library( "absl/container:flat_hash_set", "absl/container:inlined_vector", "absl/functional:function_ref", + "absl/log:check", "absl/meta:type_traits", "absl/strings", "absl/strings:str_format", @@ -7441,6 +7476,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/types:optional", ], deps = [ diff --git a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc index d189d4080a7..fd48d034d38 100644 --- a/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +++ b/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc @@ -307,13 +307,15 @@ void RegisterLegacyChannelIdleFilters(CoreConfiguration::Builder* builder) { .If([](const ChannelArgs& channel_args) { return GetClientIdleTimeout(channel_args) != Duration::Infinity(); }); - builder->channel_init() - ->RegisterV2Filter(GRPC_SERVER_CHANNEL) - .ExcludeFromMinimalStack() - .If([](const ChannelArgs& channel_args) { - return LegacyMaxAgeFilter::Config::FromChannelArgs(channel_args) - .enable(); - }); + if (!IsChaoticGoodEnabled()) { + builder->channel_init() + ->RegisterV2Filter(GRPC_SERVER_CHANNEL) + .ExcludeFromMinimalStack() + .If([](const ChannelArgs& channel_args) { + return LegacyMaxAgeFilter::Config::FromChannelArgs(channel_args) + .enable(); + }); + } } LegacyMaxAgeFilter::LegacyMaxAgeFilter(grpc_channel_stack* channel_stack, diff --git a/src/core/ext/transport/binder/server/binder_server.cc b/src/core/ext/transport/binder/server/binder_server.cc index 3afbd2ef615..dd47707fe5b 100644 --- a/src/core/ext/transport/binder/server/binder_server.cc +++ b/src/core/ext/transport/binder/server/binder_server.cc @@ -30,8 +30,8 @@ #include "src/core/ext/transport/binder/utils/ndk_binder.h" #include "src/core/ext/transport/binder/wire_format/binder_android.h" #include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/error_utils.h" +#include "src/core/server/server.h" #ifdef GPR_SUPPORT_BINDER_TRANSPORT diff --git a/src/core/ext/transport/binder/server/binder_server.h b/src/core/ext/transport/binder/server/binder_server.h index 0a1a36e8ba3..34f25090c59 100644 --- a/src/core/ext/transport/binder/server/binder_server.h +++ b/src/core/ext/transport/binder/server/binder_server.h @@ -26,8 +26,8 @@ #include "src/core/ext/transport/binder/transport/binder_transport.h" #include "src/core/ext/transport/binder/wire_format/binder.h" #include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/error_utils.h" +#include "src/core/server/server.h" // TODO(waynetu): This is part of the public API and should be moved to the // include/ folder. diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc index 7449a52d2ed..b84e0e1d147 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc @@ -62,11 +62,11 @@ #include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_buffer.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/error_utils.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/promise_endpoint.h" +#include "src/core/server/server.h" namespace grpc_core { namespace chaotic_good { diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h index 0d547f1f634..404bbbf946d 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.h @@ -44,8 +44,8 @@ #include "src/core/lib/resource_quota/memory_quota.h" #include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/slice/slice.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/promise_endpoint.h" +#include "src/core/server/server.h" namespace grpc_core { namespace chaotic_good { diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index af853c75977..239a03db478 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -80,10 +80,10 @@ #include "src/core/lib/security/credentials/insecure/insecure_credentials.h" #include "src/core/lib/security/security_connector/security_connector.h" #include "src/core/lib/surface/api_trace.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/error_utils.h" #include "src/core/lib/transport/transport.h" #include "src/core/lib/uri/uri_parser.h" +#include "src/core/server/server.h" #ifdef GPR_SUPPORT_CHANNELS_FROM_FD #include "src/core/lib/iomgr/ev_posix.h" diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.h b/src/core/ext/transport/chttp2/server/chttp2_server.h index f7eb7a23c66..26c178be917 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -25,7 +25,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/iomgr/error.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" namespace grpc_core { diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index 6069283efb4..ffcc7469c6a 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -27,8 +27,8 @@ #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" +#include "src/core/server/server.h" namespace grpc_core { diff --git a/src/core/ext/transport/inproc/legacy_inproc_transport.cc b/src/core/ext/transport/inproc/legacy_inproc_transport.cc index b6f9a0517a8..cf91abab6c5 100644 --- a/src/core/ext/transport/inproc/legacy_inproc_transport.cc +++ b/src/core/ext/transport/inproc/legacy_inproc_transport.cc @@ -62,10 +62,10 @@ #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" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" +#include "src/core/server/server.h" #define INPROC_LOG(...) \ do { \ diff --git a/src/core/handshaker/handshaker.cc b/src/core/handshaker/handshaker.cc index efd73de2de0..9be4fd4383f 100644 --- a/src/core/handshaker/handshaker.cc +++ b/src/core/handshaker/handshaker.cc @@ -23,6 +23,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_format.h" @@ -100,7 +101,7 @@ bool HandshakeManager::CallNextHandshakerLocked(grpc_error_handle error) { this, StatusToString(error).c_str(), is_shutdown_, index_, HandshakerArgsString(&args_).c_str()); } - GPR_ASSERT(index_ <= handshakers_.size()); + CHECK(index_ <= handshakers_.size()); // If we got an error or we've been shut down or we're exiting early or // we've finished the last handshaker, invoke the on_handshake_done // callback. Otherwise, call the next handshaker. @@ -177,7 +178,7 @@ void HandshakeManager::DoHandshake(grpc_endpoint* endpoint, bool done; { MutexLock lock(&mu_); - GPR_ASSERT(index_ == 0); + CHECK_EQ(index_, 0u); // Construct handshaker args. These will be passed through all // handshakers and eventually be freed by the on_handshake_done callback. args_.endpoint = endpoint; diff --git a/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc b/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc index 9db2cb81bd8..fa10c544d05 100644 --- a/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc +++ b/src/core/handshaker/tcp_connect/tcp_connect_handshaker.cc @@ -21,6 +21,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/types/optional.h" @@ -124,7 +125,7 @@ void TCPConnectHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/, MutexLock lock(&mu_); on_handshake_done_ = on_handshake_done; } - GPR_ASSERT(args->endpoint == nullptr); + CHECK_EQ(args->endpoint, nullptr); args_ = args; absl::StatusOr uri = URI::Parse( args->args.GetString(GRPC_ARG_TCP_HANDSHAKER_RESOLVED_ADDRESS).value()); @@ -179,7 +180,7 @@ void TCPConnectHandshaker::Connected(void* arg, grpc_error_handle error) { } return; } - GPR_ASSERT(self->endpoint_to_destroy_ != nullptr); + CHECK_NE(self->endpoint_to_destroy_, nullptr); self->args_->endpoint = self->endpoint_to_destroy_; self->endpoint_to_destroy_ = nullptr; if (self->bind_endpoint_to_pollset_) { diff --git a/src/core/lib/config/load_config.cc b/src/core/lib/config/load_config.cc index a961a24a81d..1e9c3170a74 100644 --- a/src/core/lib/config/load_config.cc +++ b/src/core/lib/config/load_config.cc @@ -24,7 +24,6 @@ #include -#include "src/core/lib/gpr/log_internal.h" #include "src/core/lib/gprpp/env.h" namespace grpc_core { diff --git a/src/core/lib/event_engine/windows/windows_endpoint.cc b/src/core/lib/event_engine/windows/windows_endpoint.cc index dc7193fd397..c3edbebaa47 100644 --- a/src/core/lib/event_engine/windows/windows_endpoint.cc +++ b/src/core/lib/event_engine/windows/windows_endpoint.cc @@ -81,7 +81,7 @@ void WindowsEndpoint::AsyncIOState::DoTcpRead(SliceBuffer* buffer) { GRPC_EVENT_ENGINE_ENDPOINT_TRACE("WindowsEndpoint::%p reading", endpoint); if (socket->IsShutdown()) { socket->read_info()->SetErrorStatus( - absl::UnavailableError("Socket is shutting down.")); + absl::InternalError("Socket is shutting down.")); thread_pool->Run(&handle_read_event); return; } @@ -131,7 +131,7 @@ bool WindowsEndpoint::Read(absl::AnyInvocable on_read, SliceBuffer* buffer, const ReadArgs* /* args */) { if (io_state_->socket->IsShutdown()) { io_state_->thread_pool->Run([on_read = std::move(on_read)]() mutable { - on_read(absl::UnavailableError("Socket is shutting down.")); + on_read(absl::InternalError("Socket is shutting down.")); }); return false; } @@ -154,7 +154,7 @@ bool WindowsEndpoint::Write(absl::AnyInvocable on_writable, if (io_state_->socket->IsShutdown()) { io_state_->thread_pool->Run( [on_writable = std::move(on_writable)]() mutable { - on_writable(absl::UnavailableError("Socket is shutting down.")); + on_writable(absl::InternalError("Socket is shutting down.")); }); return false; } @@ -300,7 +300,7 @@ void WindowsEndpoint::HandleReadClosure::Run() { DumpSliceBuffer(buffer_, absl::StrFormat("WindowsEndpoint::%p READ", io_state->endpoint)); } - status = absl::UnavailableError("End of TCP stream"); + status = absl::InternalError("End of TCP stream"); grpc_core::StatusSetInt(&status, grpc_core::StatusIntProperty::kRpcStatus, GRPC_STATUS_UNAVAILABLE); buffer_->Swap(last_read_buffer_); diff --git a/src/core/lib/experiments/rollouts.yaml b/src/core/lib/experiments/rollouts.yaml index ce9cf80c114..6f4e84827f0 100644 --- a/src/core/lib/experiments/rollouts.yaml +++ b/src/core/lib/experiments/rollouts.yaml @@ -60,7 +60,7 @@ posix: false # TODO(hork): resolve when the client end2end test flake rate reduces to # a tolerable amount. - windows: broken + windows: false - name: event_engine_dns default: # not tested on iOS at all diff --git a/src/core/lib/gpr/log_internal.h b/src/core/lib/gpr/log_internal.h deleted file mode 100644 index 0d7c9108880..00000000000 --- a/src/core/lib/gpr/log_internal.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2022 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_GPR_LOG_INTERNAL_H -#define GRPC_SRC_CORE_LIB_GPR_LOG_INTERNAL_H - -#include - -#include -#include - -#include - -/// abort() the process if x is zero, with rudimentary logging to prevent -/// circular dependencies with gpr_log. - -/// Intended for internal invariants. If the error can be recovered from, -/// without the possibility of corruption, or might best be reflected via -/// an exception in a higher-level language, consider returning error code. -#define GPR_ASSERT_INTERNAL(x) \ - do { \ - if (GPR_UNLIKELY(!(x))) { \ - fprintf(stderr, "assertion failed: %s", #x); \ - abort(); \ - } \ - } while (0) - -#ifndef NDEBUG -#define GPR_DEBUG_ASSERT_INTERNAL(x) GPR_ASSERT_INTERNAL(x) -#else -#define GPR_DEBUG_ASSERT_INTERNAL(x) -#endif - -#define GPR_LOG_ERROR_INTERNAL(format, ...) \ - do { \ - char f[] = __FILE__; \ - char* display_file = f; \ - char* slash_pos = strrchr(f, '/'); \ - if (slash_pos != nullptr) display_file = slash_pos + 1; \ - char prefix[60]; \ - sprintf(prefix, "INTERNAL %37s:%d]", display_file, __LINE__); \ - fprintf(stderr, "%-60s " format "\n", prefix, __VA_ARGS__); \ - } while (0) - -#endif // GRPC_SRC_CORE_LIB_GPR_LOG_INTERNAL_H diff --git a/src/core/lib/promise/activity.cc b/src/core/lib/promise/activity.cc index b229e5e3a29..614e343bc8f 100644 --- a/src/core/lib/promise/activity.cc +++ b/src/core/lib/promise/activity.cc @@ -18,6 +18,7 @@ #include +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" @@ -54,7 +55,7 @@ class FreestandingActivity::Handle final : public Wakeable { // Activity is going away... drop its reference and sever the connection back. void DropActivity() ABSL_LOCKS_EXCLUDED(mu_) { mu_.Lock(); - GPR_ASSERT(activity_ != nullptr); + CHECK_NE(activity_, nullptr); activity_ = nullptr; mu_.Unlock(); Unref(); diff --git a/src/core/lib/promise/activity.h b/src/core/lib/promise/activity.h index d8bf6ed7bd2..daf3e76a6c2 100644 --- a/src/core/lib/promise/activity.h +++ b/src/core/lib/promise/activity.h @@ -24,6 +24,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/types/optional.h" @@ -467,11 +468,11 @@ class PromiseActivity final // We shouldn't destruct without calling Cancel() first, and that must get // us to be done_, so we assume that and have no logic to destruct the // promise here. - GPR_ASSERT(done_); + CHECK(done_); } void RunScheduledWakeup() { - GPR_ASSERT(wakeup_scheduled_.exchange(false, std::memory_order_acq_rel)); + CHECK(wakeup_scheduled_.exchange(false, std::memory_order_acq_rel)); Step(); WakeupComplete(); } @@ -535,7 +536,7 @@ class PromiseActivity final // Notification that we're no longer executing - it's ok to destruct the // promise. void MarkDone() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) { - GPR_ASSERT(!std::exchange(done_, true)); + CHECK(!std::exchange(done_, true)); ScopedContext contexts(this); Destruct(&promise_holder_.promise); } @@ -580,10 +581,10 @@ class PromiseActivity final // Until there are no wakeups from within and the promise is incomplete: // poll the promise. absl::optional StepLoop() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu()) { - GPR_ASSERT(is_current()); + CHECK(is_current()); while (true) { // Run the promise. - GPR_ASSERT(!done_); + CHECK(!done_); auto r = promise_holder_.promise(); if (auto* status = r.value_if_ready()) { // If complete, destroy the promise, flag done, and exit this loop. diff --git a/src/core/lib/promise/context.h b/src/core/lib/promise/context.h index a69effe7a1d..4b1f9ef6369 100644 --- a/src/core/lib/promise/context.h +++ b/src/core/lib/promise/context.h @@ -17,6 +17,7 @@ #include +#include "absl/log/check.h" #include "absl/meta/type_traits.h" #include @@ -114,7 +115,7 @@ bool HasContext() { template T* GetContext() { auto* p = promise_detail::Context::get(); - GPR_ASSERT(p != nullptr); + CHECK_NE(p, nullptr); return p; } diff --git a/src/core/lib/promise/detail/join_state.h b/src/core/lib/promise/detail/join_state.h index 32d87e66296..e930ba53f36 100644 --- a/src/core/lib/promise/detail/join_state.h +++ b/src/core/lib/promise/detail/join_state.h @@ -21,6 +21,8 @@ #include #include +#include "absl/log/check.h" + #include #include @@ -57,7 +59,7 @@ struct JoinState { Construct(&promise1, std::forward(p1)); } JoinState(const JoinState& other) { - GPR_ASSERT(other.ready.none()); + CHECK(other.ready.none()); Construct(&promise0, other.promise0); Construct(&promise1, other.promise1); } @@ -172,7 +174,7 @@ struct JoinState { Construct(&promise2, std::forward(p2)); } JoinState(const JoinState& other) { - GPR_ASSERT(other.ready.none()); + CHECK(other.ready.none()); Construct(&promise0, other.promise0); Construct(&promise1, other.promise1); Construct(&promise2, other.promise2); @@ -329,7 +331,7 @@ struct JoinState { Construct(&promise3, std::forward(p3)); } JoinState(const JoinState& other) { - GPR_ASSERT(other.ready.none()); + CHECK(other.ready.none()); Construct(&promise0, other.promise0); Construct(&promise1, other.promise1); Construct(&promise2, other.promise2); @@ -528,7 +530,7 @@ struct JoinState { Construct(&promise4, std::forward(p4)); } JoinState(const JoinState& other) { - GPR_ASSERT(other.ready.none()); + CHECK(other.ready.none()); Construct(&promise0, other.promise0); Construct(&promise1, other.promise1); Construct(&promise2, other.promise2); @@ -769,7 +771,7 @@ struct JoinState { Construct(&promise5, std::forward(p5)); } JoinState(const JoinState& other) { - GPR_ASSERT(other.ready.none()); + CHECK(other.ready.none()); Construct(&promise0, other.promise0); Construct(&promise1, other.promise1); Construct(&promise2, other.promise2); @@ -1051,7 +1053,7 @@ struct JoinState { Construct(&promise6, std::forward(p6)); } JoinState(const JoinState& other) { - GPR_ASSERT(other.ready.none()); + CHECK(other.ready.none()); Construct(&promise0, other.promise0); Construct(&promise1, other.promise1); Construct(&promise2, other.promise2); @@ -1376,7 +1378,7 @@ struct JoinState { Construct(&promise7, std::forward(p7)); } JoinState(const JoinState& other) { - GPR_ASSERT(other.ready.none()); + CHECK(other.ready.none()); Construct(&promise0, other.promise0); Construct(&promise1, other.promise1); Construct(&promise2, other.promise2); @@ -1742,7 +1744,7 @@ struct JoinState { Construct(&promise8, std::forward(p8)); } JoinState(const JoinState& other) { - GPR_ASSERT(other.ready.none()); + CHECK(other.ready.none()); Construct(&promise0, other.promise0); Construct(&promise1, other.promise1); Construct(&promise2, other.promise2); diff --git a/src/core/lib/promise/detail/seq_state.h b/src/core/lib/promise/detail/seq_state.h index f22b312aba4..3e69e60b741 100644 --- a/src/core/lib/promise/detail/seq_state.h +++ b/src/core/lib/promise/detail/seq_state.h @@ -22,6 +22,7 @@ #include #include "absl/base/attributes.h" +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include @@ -119,7 +120,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.next_factory, other.prior.next_factory); } @@ -254,7 +255,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.next_factory, other.prior.prior.next_factory); Construct(&prior.next_factory, other.prior.next_factory); @@ -447,7 +448,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.prior.next_factory, other.prior.prior.prior.next_factory); @@ -700,7 +701,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.prior.prior.next_factory, other.prior.prior.prior.prior.next_factory); @@ -1021,7 +1022,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.prior.prior.prior.next_factory, other.prior.prior.prior.prior.prior.next_factory); @@ -1405,7 +1406,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.prior.prior.prior.prior.next_factory, other.prior.prior.prior.prior.prior.prior.next_factory); @@ -1855,7 +1856,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory, other.prior.prior.prior.prior.prior.prior.prior.next_factory); @@ -2373,7 +2374,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct( &prior.prior.prior.prior.prior.prior.prior.prior.next_factory, @@ -2964,7 +2965,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct( &prior.prior.prior.prior.prior.prior.prior.prior.prior.next_factory, @@ -3631,7 +3632,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior .next_factory, @@ -4375,7 +4376,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior .next_factory, @@ -5198,7 +5199,7 @@ struct SeqState { } SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - GPR_ASSERT(state == State::kState0); + CHECK(state == State::kState0); Construct(&prior.current_promise, other.prior.current_promise); Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior .prior.next_factory, diff --git a/src/core/lib/promise/detail/status.h b/src/core/lib/promise/detail/status.h index 987fddfb99f..f1c2aa03d8c 100644 --- a/src/core/lib/promise/detail/status.h +++ b/src/core/lib/promise/detail/status.h @@ -17,6 +17,7 @@ #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -106,7 +107,7 @@ struct FailureStatusCastImpl, const absl::Status&> { template To FailureStatusCast(From&& from) { - GPR_DEBUG_ASSERT(!IsStatusOk(from)); + DCHECK(!IsStatusOk(from)); return FailureStatusCastImpl::Cast(std::forward(from)); } diff --git a/src/core/lib/promise/event_engine_wakeup_scheduler.h b/src/core/lib/promise/event_engine_wakeup_scheduler.h index b2ba6586a50..eedd48357c3 100644 --- a/src/core/lib/promise/event_engine_wakeup_scheduler.h +++ b/src/core/lib/promise/event_engine_wakeup_scheduler.h @@ -18,6 +18,8 @@ #include #include +#include "absl/log/check.h" + #include #include @@ -33,7 +35,7 @@ class EventEngineWakeupScheduler { std::shared_ptr event_engine) : event_engine_(std::move(event_engine)) { - GPR_ASSERT(event_engine_ != nullptr); + CHECK_NE(event_engine_, nullptr); } template diff --git a/src/core/lib/promise/for_each.h b/src/core/lib/promise/for_each.h index 529dde62256..80d066a18dc 100644 --- a/src/core/lib/promise/for_each.h +++ b/src/core/lib/promise/for_each.h @@ -20,6 +20,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" @@ -129,13 +130,13 @@ class ForEach { : reader_(std::move(other.reader_)), action_factory_(std::move(other.action_factory_)), whence_(other.whence_) { - GPR_DEBUG_ASSERT(reading_next_); - GPR_DEBUG_ASSERT(other.reading_next_); + DCHECK(reading_next_); + DCHECK(other.reading_next_); Construct(&reader_next_, std::move(other.reader_next_)); } ForEach& operator=(ForEach&& other) noexcept { - GPR_DEBUG_ASSERT(reading_next_); - GPR_DEBUG_ASSERT(other.reading_next_); + DCHECK(reading_next_); + DCHECK(other.reading_next_); reader_ = std::move(other.reader_); action_factory_ = std::move(other.action_factory_); reader_next_ = std::move(other.reader_next_); diff --git a/src/core/lib/promise/interceptor_list.h b/src/core/lib/promise/interceptor_list.h index be12ed0cfdf..da44df51b71 100644 --- a/src/core/lib/promise/interceptor_list.h +++ b/src/core/lib/promise/interceptor_list.h @@ -22,6 +22,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include "absl/types/optional.h" @@ -66,7 +67,7 @@ class InterceptorList { // Update the next pointer stored with this map. // This is only valid to call once, and only before the map is used. void SetNext(Map* next) { - GPR_DEBUG_ASSERT(next_ == nullptr); + DCHECK_EQ(next_, nullptr); next_ = next; } diff --git a/src/core/lib/promise/latch.h b/src/core/lib/promise/latch.h index 63a6846dfab..221793e7cd0 100644 --- a/src/core/lib/promise/latch.h +++ b/src/core/lib/promise/latch.h @@ -21,6 +21,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include @@ -47,12 +48,12 @@ class Latch { Latch(Latch&& other) noexcept : value_(std::move(other.value_)), has_value_(other.has_value_) { #ifndef NDEBUG - GPR_DEBUG_ASSERT(!other.has_had_waiters_); + DCHECK(!other.has_had_waiters_); #endif } Latch& operator=(Latch&& other) noexcept { #ifndef NDEBUG - GPR_DEBUG_ASSERT(!other.has_had_waiters_); + DCHECK(!other.has_had_waiters_); #endif value_ = std::move(other.value_); has_value_ = other.has_value_; @@ -102,7 +103,7 @@ class Latch { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_INFO, "%sSet %s", DebugTag().c_str(), StateString().c_str()); } - GPR_DEBUG_ASSERT(!has_value_); + DCHECK(!has_value_); value_ = std::move(value); has_value_ = true; waiter_.Wake(); @@ -145,12 +146,12 @@ class Latch { Latch& operator=(const Latch&) = delete; Latch(Latch&& other) noexcept : is_set_(other.is_set_) { #ifndef NDEBUG - GPR_DEBUG_ASSERT(!other.has_had_waiters_); + DCHECK(!other.has_had_waiters_); #endif } Latch& operator=(Latch&& other) noexcept { #ifndef NDEBUG - GPR_DEBUG_ASSERT(!other.has_had_waiters_); + DCHECK(!other.has_had_waiters_); #endif is_set_ = other.is_set_; return *this; @@ -179,7 +180,7 @@ class Latch { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_INFO, "%sSet %s", DebugTag().c_str(), StateString().c_str()); } - GPR_DEBUG_ASSERT(!is_set_); + DCHECK(!is_set_); is_set_ = true; waiter_.Wake(); } diff --git a/src/core/lib/promise/mpsc.h b/src/core/lib/promise/mpsc.h index 2362de390cd..ec8132e843a 100644 --- a/src/core/lib/promise/mpsc.h +++ b/src/core/lib/promise/mpsc.h @@ -22,6 +22,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include #include @@ -179,10 +180,10 @@ class MpscReceiver { // a non-empty buffer during a legal move! MpscReceiver(MpscReceiver&& other) noexcept : center_(std::move(other.center_)) { - GPR_DEBUG_ASSERT(other.buffer_.empty()); + DCHECK(other.buffer_.empty()); } MpscReceiver& operator=(MpscReceiver&& other) noexcept { - GPR_DEBUG_ASSERT(other.buffer_.empty()); + DCHECK(other.buffer_.empty()); center_ = std::move(other.center_); return *this; } diff --git a/src/core/lib/promise/observable.h b/src/core/lib/promise/observable.h index 37437d9cc16..edf7a37515a 100644 --- a/src/core/lib/promise/observable.h +++ b/src/core/lib/promise/observable.h @@ -17,6 +17,7 @@ #include "absl/container/flat_hash_set.h" #include "absl/functional/any_invocable.h" +#include "absl/log/check.h" #include @@ -123,8 +124,8 @@ class Observable { Observer(const Observer&) = delete; Observer& operator=(const Observer&) = delete; Observer(Observer&& other) noexcept : state_(std::move(other.state_)) { - GPR_ASSERT(other.waker_.is_unwakeable()); - GPR_ASSERT(!other.saw_pending_); + CHECK(other.waker_.is_unwakeable()); + CHECK(!other.saw_pending_); } Observer& operator=(Observer&& other) noexcept = delete; diff --git a/src/core/lib/promise/party.cc b/src/core/lib/promise/party.cc index 5d967a658e0..c030f43c4e0 100644 --- a/src/core/lib/promise/party.cc +++ b/src/core/lib/promise/party.cc @@ -17,6 +17,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/strings/str_format.h" #include @@ -102,7 +103,7 @@ class Party::Handle final : public Wakeable { // Activity is going away... drop its reference and sever the connection back. void DropActivity() ABSL_LOCKS_EXCLUDED(mu_) { mu_.Lock(); - GPR_ASSERT(party_ != nullptr); + CHECK_NE(party_, nullptr); party_ = nullptr; mu_.Unlock(); Unref(); @@ -194,13 +195,13 @@ std::string Party::ActivityDebugTag(WakeupMask wakeup_mask) const { } Waker Party::MakeOwningWaker() { - GPR_DEBUG_ASSERT(currently_polling_ != kNotPolling); + DCHECK(currently_polling_ != kNotPolling); IncrementRefCount(); return Waker(this, 1u << currently_polling_); } Waker Party::MakeNonOwningWaker() { - GPR_DEBUG_ASSERT(currently_polling_ != kNotPolling); + DCHECK(currently_polling_ != kNotPolling); return Waker(participants_[currently_polling_] .load(std::memory_order_relaxed) ->MakeNonOwningWakeable(this), @@ -208,7 +209,7 @@ Waker Party::MakeNonOwningWaker() { } void Party::ForceImmediateRepoll(WakeupMask mask) { - GPR_DEBUG_ASSERT(is_current()); + DCHECK(is_current()); sync_.ForceImmediateRepoll(mask); } @@ -232,11 +233,11 @@ void Party::RunLocked() { return; } auto body = [this]() { - GPR_DEBUG_ASSERT(g_current_party_run_next == nullptr); + DCHECK_EQ(g_current_party_run_next, nullptr); Party* run_next = nullptr; g_current_party_run_next = &run_next; const bool done = RunParty(); - GPR_DEBUG_ASSERT(g_current_party_run_next == &run_next); + DCHECK(g_current_party_run_next == &run_next); g_current_party_run_next = nullptr; if (done) { ScopedActivity activity(this); diff --git a/src/core/lib/promise/party.h b/src/core/lib/promise/party.h index 44f890fa208..214c36a588f 100644 --- a/src/core/lib/promise/party.h +++ b/src/core/lib/promise/party.h @@ -24,6 +24,7 @@ #include "absl/base/attributes.h" #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -115,7 +116,7 @@ class PartySyncUsingAtomics { std::memory_order_acquire); LogStateChange("Run", prev_state, prev_state & (kRefMask | kLocked | kAllocatedMask)); - GPR_ASSERT(prev_state & kLocked); + CHECK(prev_state & kLocked); if (prev_state & kDestroying) return true; // From the previous state, extract which participants we're to wakeup. uint64_t wakeups = prev_state & kWakeupMask; @@ -195,7 +196,7 @@ class PartySyncUsingAtomics { slots[n++] = bit; allocated |= 1 << bit; } - GPR_ASSERT(n == count); + CHECK(n == count); // Try to allocate this slot and take a ref (atomically). // Ref needs to be taken because once we store the participant it could be // spuriously woken up and unref the party. @@ -293,7 +294,7 @@ class PartySyncUsingMutex { WakeupMask freed = 0; while (true) { ReleasableMutexLock lock(&mu_); - GPR_ASSERT(locked_); + CHECK(locked_); allocated_ &= ~std::exchange(freed, 0); auto wakeup = std::exchange(wakeups_, 0); if (wakeup == 0) { @@ -322,7 +323,7 @@ class PartySyncUsingMutex { wakeup_mask |= 1 << bit; allocated_ |= 1 << bit; } - GPR_ASSERT(n == count); + CHECK(n == count); store(slots); wakeups_ |= wakeup_mask; return !std::exchange(locked_, true); @@ -390,7 +391,7 @@ class Party : public Activity, private Wakeable { // Activity implementation: not allowed to be overridden by derived types. void ForceImmediateRepoll(WakeupMask mask) final; WakeupMask CurrentParticipant() const final { - GPR_DEBUG_ASSERT(currently_polling_ != kNotPolling); + DCHECK(currently_polling_ != kNotPolling); return 1u << currently_polling_; } Waker MakeOwningWaker() final; @@ -411,10 +412,10 @@ class Party : public Activity, private Wakeable { // This is useful for implementing batching and the like: we can hold some // action until the rest of the party resolves itself. auto AfterCurrentPoll() { - GPR_DEBUG_ASSERT(GetContext() == this); + DCHECK(GetContext() == this); sync_.WakeAfterPoll(CurrentParticipant()); return [this, iteration = sync_.iteration()]() -> Poll { - GPR_DEBUG_ASSERT(GetContext() == this); + DCHECK(GetContext() == this); if (iteration == sync_.iteration()) return Pending{}; return Empty{}; }; diff --git a/src/core/lib/promise/pipe.h b/src/core/lib/promise/pipe.h index f56567e6cf2..c77919f697c 100644 --- a/src/core/lib/promise/pipe.h +++ b/src/core/lib/promise/pipe.h @@ -22,6 +22,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/types/optional.h" #include "absl/types/variant.h" @@ -63,7 +64,7 @@ class NextResult final { NextResult() : center_(nullptr) {} explicit NextResult(RefCountedPtr> center) : center_(std::move(center)) { - GPR_ASSERT(center_ != nullptr); + CHECK(center_ != nullptr); } explicit NextResult(bool cancelled) : center_(nullptr), cancelled_(cancelled) {} @@ -79,11 +80,11 @@ class NextResult final { bool has_value() const; // Only valid if has_value() const T& value() const { - GPR_ASSERT(has_value()); + CHECK(has_value()); return **this; } T& value() { - GPR_ASSERT(has_value()); + CHECK(has_value()); return **this; } const T& operator*() const; @@ -121,7 +122,7 @@ class Center : public InterceptorList { gpr_log(GPR_DEBUG, "%s", DebugOpString("IncrementRefCount").c_str()); } refs_++; - GPR_DEBUG_ASSERT(refs_ != 0); + DCHECK_NE(refs_, 0); } RefCountedPtr
Ref() { @@ -135,7 +136,7 @@ class Center : public InterceptorList { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_DEBUG, "%s", DebugOpString("Unref").c_str()); } - GPR_DEBUG_ASSERT(refs_ > 0); + DCHECK_GT(refs_, 0); refs_--; if (0 == refs_) { this->~Center(); @@ -150,7 +151,7 @@ class Center : public InterceptorList { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_INFO, "%s", DebugOpString("Push").c_str()); } - GPR_DEBUG_ASSERT(refs_ != 0); + DCHECK_NE(refs_, 0); switch (value_state_) { case ValueState::kClosed: case ValueState::kReadyClosed: @@ -174,7 +175,7 @@ class Center : public InterceptorList { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_INFO, "%s", DebugOpString("PollAck").c_str()); } - GPR_DEBUG_ASSERT(refs_ != 0); + DCHECK_NE(refs_, 0); switch (value_state_) { case ValueState::kClosed: return true; @@ -202,7 +203,7 @@ class Center : public InterceptorList { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_INFO, "%s", DebugOpString("Next").c_str()); } - GPR_DEBUG_ASSERT(refs_ != 0); + DCHECK_NE(refs_, 0); switch (value_state_) { case ValueState::kEmpty: case ValueState::kAcked: @@ -228,7 +229,7 @@ class Center : public InterceptorList { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_INFO, "%s", DebugOpString("PollClosedForSender").c_str()); } - GPR_DEBUG_ASSERT(refs_ != 0); + DCHECK_NE(refs_, 0); switch (value_state_) { case ValueState::kEmpty: case ValueState::kAcked: @@ -251,7 +252,7 @@ class Center : public InterceptorList { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_INFO, "%s", DebugOpString("PollClosedForReceiver").c_str()); } - GPR_DEBUG_ASSERT(refs_ != 0); + DCHECK_NE(refs_, 0); switch (value_state_) { case ValueState::kEmpty: case ValueState::kAcked: @@ -272,7 +273,7 @@ class Center : public InterceptorList { if (grpc_trace_promise_primitives.enabled()) { gpr_log(GPR_INFO, "%s", DebugOpString("PollEmpty").c_str()); } - GPR_DEBUG_ASSERT(refs_ != 0); + DCHECK_NE(refs_, 0); switch (value_state_) { case ValueState::kReady: case ValueState::kReadyClosed: @@ -668,7 +669,7 @@ class Push { return Pending{}; } } - GPR_DEBUG_ASSERT(absl::holds_alternative(state_)); + DCHECK(absl::holds_alternative(state_)); return center_->PollAck(); } diff --git a/src/core/lib/promise/poll.h b/src/core/lib/promise/poll.h index 53604c2c89d..57a4a65e83a 100644 --- a/src/core/lib/promise/poll.h +++ b/src/core/lib/promise/poll.h @@ -18,6 +18,8 @@ #include #include +#include "absl/log/check.h" + #include #include @@ -95,12 +97,12 @@ class Poll { bool ready() const { return ready_; } T& value() { - GPR_DEBUG_ASSERT(ready()); + DCHECK(ready()); return value_; } const T& value() const { - GPR_DEBUG_ASSERT(ready()); + DCHECK(ready()); return value_; } @@ -154,7 +156,7 @@ class Poll { bool ready() const { return ready_; } Empty value() const { - GPR_DEBUG_ASSERT(ready()); + DCHECK(ready()); return Empty{}; } diff --git a/src/core/lib/promise/promise_mutex.h b/src/core/lib/promise/promise_mutex.h index 218919db1e9..d1e01f22319 100644 --- a/src/core/lib/promise/promise_mutex.h +++ b/src/core/lib/promise/promise_mutex.h @@ -17,6 +17,8 @@ #include +#include "absl/log/check.h" + #include #include @@ -35,7 +37,7 @@ class PromiseMutex { Lock() {} ~Lock() { if (mutex_ != nullptr) { - GPR_ASSERT(mutex_->locked_); + CHECK(mutex_->locked_); mutex_->locked_ = false; mutex_->waiter_.Wake(); } @@ -52,18 +54,18 @@ class PromiseMutex { Lock& operator=(const Lock&) noexcept = delete; T* operator->() { - GPR_DEBUG_ASSERT(mutex_ != nullptr); + DCHECK_NE(mutex_, nullptr); return &mutex_->value_; } T& operator*() { - GPR_DEBUG_ASSERT(mutex_ != nullptr); + DCHECK_NE(mutex_, nullptr); return mutex_->value_; } private: friend class PromiseMutex; explicit Lock(PromiseMutex* mutex) : mutex_(mutex) { - GPR_DEBUG_ASSERT(!mutex_->locked_); + DCHECK(!mutex_->locked_); mutex_->locked_ = true; } PromiseMutex* mutex_ = nullptr; @@ -71,7 +73,7 @@ class PromiseMutex { PromiseMutex() = default; explicit PromiseMutex(T value) : value_(std::move(value)) {} - ~PromiseMutex() { GPR_DEBUG_ASSERT(!locked_); } + ~PromiseMutex() { DCHECK(!locked_); } auto Acquire() { return [this]() -> Poll { diff --git a/src/core/lib/promise/status_flag.h b/src/core/lib/promise/status_flag.h index 3626c251fb0..38d4cf5b720 100644 --- a/src/core/lib/promise/status_flag.h +++ b/src/core/lib/promise/status_flag.h @@ -15,6 +15,7 @@ #ifndef GRPC_SRC_CORE_LIB_PROMISE_STATUS_FLAG_H #define GRPC_SRC_CORE_LIB_PROMISE_STATUS_FLAG_H +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/types/optional.h" @@ -127,7 +128,7 @@ struct StatusCastImpl { template struct FailureStatusCastImpl, StatusFlag> { static absl::StatusOr Cast(StatusFlag flag) { - GPR_DEBUG_ASSERT(!flag.ok()); + DCHECK(!flag.ok()); return absl::CancelledError(); } }; @@ -135,7 +136,7 @@ struct FailureStatusCastImpl, StatusFlag> { template struct FailureStatusCastImpl, StatusFlag&> { static absl::StatusOr Cast(StatusFlag flag) { - GPR_DEBUG_ASSERT(!flag.ok()); + DCHECK(!flag.ok()); return absl::CancelledError(); } }; @@ -143,7 +144,7 @@ struct FailureStatusCastImpl, StatusFlag&> { template struct FailureStatusCastImpl, const StatusFlag&> { static absl::StatusOr Cast(StatusFlag flag) { - GPR_DEBUG_ASSERT(!flag.ok()); + DCHECK(!flag.ok()); return absl::CancelledError(); } }; @@ -157,7 +158,7 @@ class ValueOrFailure { // NOLINTNEXTLINE(google-explicit-constructor) ValueOrFailure(Failure) {} // NOLINTNEXTLINE(google-explicit-constructor) - ValueOrFailure(StatusFlag status) { GPR_ASSERT(!status.ok()); } + ValueOrFailure(StatusFlag status) { CHECK(!status.ok()); } static ValueOrFailure FromOptional(absl::optional value) { return ValueOrFailure{std::move(value)}; @@ -215,7 +216,7 @@ struct StatusCastImpl, Failure> { template struct StatusCastImpl, StatusFlag&> { static ValueOrFailure Cast(StatusFlag f) { - GPR_ASSERT(!f.ok()); + CHECK(!f.ok()); return ValueOrFailure(Failure{}); } }; @@ -223,7 +224,7 @@ struct StatusCastImpl, StatusFlag&> { template struct StatusCastImpl, StatusFlag> { static ValueOrFailure Cast(StatusFlag f) { - GPR_ASSERT(!f.ok()); + CHECK(!f.ok()); return ValueOrFailure(Failure{}); } }; diff --git a/src/core/lib/promise/try_join.h b/src/core/lib/promise/try_join.h index b984d880190..77b0496792b 100644 --- a/src/core/lib/promise/try_join.h +++ b/src/core/lib/promise/try_join.h @@ -18,6 +18,7 @@ #include #include +#include "absl/log/check.h" #include "absl/meta/type_traits.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -83,7 +84,7 @@ struct TryJoinTraits { } template static R EarlyReturn(const ValueOrFailure& x) { - GPR_ASSERT(!x.ok()); + CHECK(!x.ok()); return FailureStatusCast(Failure{}); } template diff --git a/src/core/lib/promise/try_seq.h b/src/core/lib/promise/try_seq.h index aaecff002b0..36f2c9639f0 100644 --- a/src/core/lib/promise/try_seq.h +++ b/src/core/lib/promise/try_seq.h @@ -20,6 +20,7 @@ #include #include +#include "absl/log/check.h" #include "absl/meta/type_traits.h" #include "absl/status/status.h" #include "absl/status/statusor.h" @@ -162,7 +163,7 @@ struct TrySeqTraitsWithSfinae< } template static R ReturnValue(T&& status) { - GPR_DEBUG_ASSERT(!IsStatusOk(status)); + DCHECK(!IsStatusOk(status)); return FailureStatusCast(status.status()); } template diff --git a/src/core/lib/security/credentials/composite/composite_credentials.cc b/src/core/lib/security/credentials/composite/composite_credentials.cc index a9273162eb6..0684012e796 100644 --- a/src/core/lib/security/credentials/composite/composite_credentials.cc +++ b/src/core/lib/security/credentials/composite/composite_credentials.cc @@ -22,6 +22,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" @@ -130,9 +131,9 @@ grpc_call_credentials* grpc_composite_call_credentials_create( "grpc_composite_call_credentials_create(creds1=%p, creds2=%p, " "reserved=%p)", 3, (creds1, creds2, reserved)); - GPR_ASSERT(reserved == nullptr); - GPR_ASSERT(creds1 != nullptr); - GPR_ASSERT(creds2 != nullptr); + CHECK_EQ(reserved, nullptr); + CHECK_NE(creds1, nullptr); + CHECK_NE(creds2, nullptr); return composite_call_credentials_create(creds1->Ref(), creds2->Ref()) .release(); @@ -144,7 +145,8 @@ grpc_core::RefCountedPtr grpc_composite_channel_credentials::create_security_connector( grpc_core::RefCountedPtr call_creds, const char* target, grpc_core::ChannelArgs* args) { - GPR_ASSERT(inner_creds_ != nullptr && call_creds_ != nullptr); + CHECK(inner_creds_ != nullptr); + CHECK(call_creds_ != nullptr); // If we are passed a call_creds, create a call composite to pass it // downstream. if (call_creds != nullptr) { @@ -159,8 +161,8 @@ grpc_composite_channel_credentials::create_security_connector( grpc_channel_credentials* grpc_composite_channel_credentials_create( grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, void* reserved) { - GPR_ASSERT(channel_creds != nullptr && call_creds != nullptr && - reserved == nullptr); + CHECK(channel_creds != nullptr && call_creds != nullptr && + reserved == nullptr); GRPC_API_TRACE( "grpc_composite_channel_credentials_create(channel_creds=%p, " "call_creds=%p, reserved=%p)", diff --git a/src/core/lib/security/credentials/credentials.cc b/src/core/lib/security/credentials/credentials.cc index e3c4f097aa1..dc58615e26a 100644 --- a/src/core/lib/security/credentials/credentials.cc +++ b/src/core/lib/security/credentials/credentials.cc @@ -21,6 +21,8 @@ #include #include +#include "absl/log/check.h" + #include #include @@ -111,7 +113,7 @@ void grpc_server_credentials::set_auth_metadata_processor( void grpc_server_credentials_set_auth_metadata_processor( grpc_server_credentials* creds, grpc_auth_metadata_processor processor) { - GPR_DEBUG_ASSERT(creds != nullptr); + DCHECK_NE(creds, nullptr); creds->set_auth_metadata_processor(processor); } diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index 6a9661c05a6..24e384e8d71 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -23,6 +23,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" @@ -137,7 +138,7 @@ struct grpc_channel_credentials // two different `grpc_channel_credentials` objects are used but they compare // as equal (assuming other channel args match). int cmp(const grpc_channel_credentials* other) const { - GPR_ASSERT(other != nullptr); + CHECK_NE(other, nullptr); int r = type().Compare(other->type()); if (r != 0) return r; return cmp_impl(other); @@ -218,7 +219,7 @@ struct grpc_call_credentials // If this method returns 0, it means that gRPC can treat the two call // credentials as effectively the same.. int cmp(const grpc_call_credentials* other) const { - GPR_ASSERT(other != nullptr); + CHECK_NE(other, nullptr); int r = type().Compare(other->type()); if (r != 0) return r; return cmp_impl(other); diff --git a/src/core/lib/security/credentials/external/aws_external_account_credentials.cc b/src/core/lib/security/credentials/external/aws_external_account_credentials.cc index 754fd4b3ed0..5bdb1f1aad6 100644 --- a/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/aws_external_account_credentials.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -228,8 +229,8 @@ void AwsExternalAccountCredentials::OnRetrieveImdsV2SessionTokenInternal( void AwsExternalAccountCredentials::AddMetadataRequestHeaders( grpc_http_request* request) { if (!imdsv2_session_token_.empty()) { - GPR_ASSERT(request->hdr_count == 0); - GPR_ASSERT(request->hdrs == nullptr); + CHECK_EQ(request->hdr_count, 0u); + CHECK_EQ(request->hdrs, nullptr); grpc_http_header* headers = static_cast(gpr_malloc(sizeof(grpc_http_header))); headers[0].key = gpr_strdup("x-aws-ec2-metadata-token"); diff --git a/src/core/lib/security/credentials/external/external_account_credentials.cc b/src/core/lib/security/credentials/external/external_account_credentials.cc index ae3f80e5986..a5d7add62b9 100644 --- a/src/core/lib/security/credentials/external/external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/external_account_credentials.cc @@ -22,6 +22,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/escaping.h" @@ -110,7 +111,7 @@ bool MatchWorkforcePoolAudience(absl::string_view audience) { RefCountedPtr ExternalAccountCredentials::Create( const Json& json, std::vector scopes, grpc_error_handle* error) { - GPR_ASSERT(error->ok()); + CHECK(error->ok()); Options options; options.type = GRPC_AUTH_JSON_TYPE_INVALID; if (json.type() != Json::Type::kObject) { @@ -301,7 +302,7 @@ void ExternalAccountCredentials::fetch_oauth2( grpc_credentials_metadata_request* metadata_req, grpc_polling_entity* pollent, grpc_iomgr_cb_func response_cb, Timestamp deadline) { - GPR_ASSERT(ctx_ == nullptr); + CHECK_EQ(ctx_, nullptr); ctx_ = new HTTPRequestContext(pollent, deadline); metadata_req_ = metadata_req; response_cb_ = response_cb; @@ -381,7 +382,7 @@ void ExternalAccountCredentials::ExchangeToken( grpc_http_response_destroy(&ctx_->response); ctx_->response = {}; GRPC_CLOSURE_INIT(&ctx_->closure, OnExchangeToken, this, nullptr); - GPR_ASSERT(http_request_ == nullptr); + CHECK(http_request_ == nullptr); RefCountedPtr http_request_creds; if (uri->scheme() == "http") { http_request_creds = RefCountedPtr( @@ -483,7 +484,7 @@ void ExternalAccountCredentials::ImpersenateServiceAccount() { ctx_->response = {}; GRPC_CLOSURE_INIT(&ctx_->closure, OnImpersenateServiceAccount, this, nullptr); // TODO(ctiller): Use the callers resource quota. - GPR_ASSERT(http_request_ == nullptr); + CHECK(http_request_ == nullptr); RefCountedPtr http_request_creds; if (uri->scheme() == "http") { http_request_creds = RefCountedPtr( diff --git a/src/core/lib/security/credentials/external/url_external_account_credentials.cc b/src/core/lib/security/credentials/external/url_external_account_credentials.cc index 310c7e40170..c73f84d498c 100644 --- a/src/core/lib/security/credentials/external/url_external_account_credentials.cc +++ b/src/core/lib/security/credentials/external/url_external_account_credentials.cc @@ -20,6 +20,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/str_cat.h" @@ -167,7 +168,7 @@ void UrlExternalAccountCredentials::RetrieveSubjectToken( grpc_http_response_destroy(&ctx_->response); ctx_->response = {}; GRPC_CLOSURE_INIT(&ctx_->closure, OnRetrieveSubjectToken, this, nullptr); - GPR_ASSERT(http_request_ == nullptr); + CHECK(http_request_ == nullptr); RefCountedPtr http_request_creds; if (url_.scheme() == "http") { http_request_creds = RefCountedPtr( diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index 4291bdf5e62..b3515b33f11 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -23,6 +23,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/statusor.h" #include "absl/strings/match.h" #include "absl/strings/string_view.h" @@ -215,7 +216,7 @@ static int is_metadata_server_reachable() { auto uri = grpc_core::URI::Create("http", GRPC_COMPUTE_ENGINE_DETECTION_HOST, "/", {} /* query params */, "" /* fragment */); - GPR_ASSERT(uri.ok()); // params are hardcoded + CHECK(uri.ok()); // params are hardcoded auto http_request = grpc_core::HttpRequest::Get( std::move(*uri), nullptr /* channel args */, &detector.pollent, &request, grpc_core::Timestamp::Now() + max_detection_delay, @@ -317,7 +318,7 @@ static grpc_error_handle create_default_creds_from_path( result = grpc_core::ExternalAccountCredentials::Create(json, {}, &error); end: - GPR_ASSERT((result == nullptr) + (error.ok()) == 1); + CHECK((result == nullptr) + (error.ok()) == 1); *creds = result; return error; } @@ -395,7 +396,7 @@ grpc_channel_credentials* grpc_google_default_credentials_create( // Create google default credentials. grpc_channel_credentials* ssl_creds = grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr); - GPR_ASSERT(ssl_creds != nullptr); + CHECK_NE(ssl_creds, nullptr); grpc_alts_credentials_options* options = grpc_alts_credentials_client_options_create(); grpc_channel_credentials* alts_creds = @@ -407,7 +408,7 @@ grpc_channel_credentials* grpc_google_default_credentials_create( grpc_core::RefCountedPtr(ssl_creds)); result = grpc_composite_channel_credentials_create( creds.get(), call_creds.get(), nullptr); - GPR_ASSERT(result != nullptr); + CHECK_NE(result, nullptr); } else { gpr_log(GPR_ERROR, "Could not create google default credentials: %s", grpc_core::StatusToString(error).c_str()); diff --git a/src/core/lib/security/credentials/iam/iam_credentials.cc b/src/core/lib/security/credentials/iam/iam_credentials.cc index a29624ac0ad..c6be5fe8865 100644 --- a/src/core/lib/security/credentials/iam/iam_credentials.cc +++ b/src/core/lib/security/credentials/iam/iam_credentials.cc @@ -23,6 +23,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/str_format.h" #include "absl/strings/string_view.h" @@ -73,9 +74,9 @@ grpc_call_credentials* grpc_google_iam_credentials_create( "grpc_iam_credentials_create(token=%s, authority_selector=%s, " "reserved=%p)", 3, (token, authority_selector, reserved)); - GPR_ASSERT(reserved == nullptr); - GPR_ASSERT(token != nullptr); - GPR_ASSERT(authority_selector != nullptr); + CHECK_EQ(reserved, nullptr); + CHECK_NE(token, nullptr); + CHECK_NE(authority_selector, nullptr); return grpc_core::MakeRefCounted( token, authority_selector) .release(); diff --git a/src/core/lib/security/credentials/jwt/json_token.cc b/src/core/lib/security/credentials/jwt/json_token.cc index ba81ab8dac3..21bd06fd61b 100644 --- a/src/core/lib/security/credentials/jwt/json_token.cc +++ b/src/core/lib/security/credentials/jwt/json_token.cc @@ -29,6 +29,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/escaping.h" @@ -224,8 +225,8 @@ static char* dot_concat_and_free_strings(char* str1, char* str2) { *(current++) = '.'; memcpy(current, str2, str2_len); current += str2_len; - GPR_ASSERT(current >= result); - GPR_ASSERT((uintptr_t)(current - result) == result_len); + CHECK(current >= result); + CHECK((uintptr_t)(current - result) == result_len); *current = '\0'; gpr_free(str1); gpr_free(str2); diff --git a/src/core/lib/security/credentials/jwt/jwt_credentials.cc b/src/core/lib/security/credentials/jwt/jwt_credentials.cc index 98c80150e94..bb69678b8f0 100644 --- a/src/core/lib/security/credentials/jwt/jwt_credentials.cc +++ b/src/core/lib/security/credentials/jwt/jwt_credentials.cc @@ -24,6 +24,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" @@ -167,7 +168,7 @@ grpc_call_credentials* grpc_service_account_jwt_access_credentials_create( static_cast(token_lifetime.clock_type), reserved); gpr_free(clean_json); } - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ExecCtx exec_ctx; return grpc_service_account_jwt_access_credentials_create_from_auth_json_key( diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.cc b/src/core/lib/security/credentials/jwt/jwt_verifier.cc index 064f75d4278..0e927aa075d 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.cc +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.cc @@ -41,6 +41,7 @@ #include #endif +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/strings/escaping.h" @@ -313,7 +314,7 @@ grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims, gpr_timespec skewed_now; int audience_ok; - GPR_ASSERT(claims != nullptr); + CHECK_NE(claims, nullptr); skewed_now = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), grpc_jwt_verifier_clock_skew); @@ -459,7 +460,7 @@ static EVP_PKEY* extract_pkey_from_x509(const char* x509_str) { EVP_PKEY* result = nullptr; BIO* bio = BIO_new(BIO_s_mem()); size_t len = strlen(x509_str); - GPR_ASSERT(len < INT_MAX); + CHECK_LT(len, static_cast(INT_MAX)); BIO_write(bio, x509_str, static_cast(len)); x509 = PEM_read_bio_X509(bio, nullptr, nullptr, nullptr); if (x509 == nullptr) { @@ -530,8 +531,8 @@ static EVP_PKEY* pkey_from_jwk(const Json& json, const char* kty) { BIGNUM* tmp_e = nullptr; Json::Object::const_iterator it; - GPR_ASSERT(json.type() == Json::Type::kObject); - GPR_ASSERT(kty != nullptr); + CHECK(json.type() == Json::Type::kObject); + CHECK_NE(kty, nullptr); if (strcmp(kty, "RSA") != 0) { gpr_log(GPR_ERROR, "Unsupported key type %s.", kty); goto end; @@ -658,7 +659,7 @@ static int verify_jwt_signature(EVP_PKEY* key, const char* alg, const EVP_MD* md = evp_md_from_alg(alg); int result = 0; - GPR_ASSERT(md != nullptr); // Checked before. + CHECK_NE(md, nullptr); // Checked before. if (md_ctx == nullptr) { gpr_log(GPR_ERROR, "Could not create EVP_MD_CTX."); goto end; @@ -797,7 +798,7 @@ static email_key_mapping* verifier_get_mapping(grpc_jwt_verifier* v, static void verifier_put_mapping(grpc_jwt_verifier* v, const char* email_domain, const char* key_url_prefix) { email_key_mapping* mapping = verifier_get_mapping(v, email_domain); - GPR_ASSERT(v->num_mappings < v->allocated_mappings); + CHECK(v->num_mappings < v->allocated_mappings); if (mapping != nullptr) { gpr_free(mapping->key_url_prefix); mapping->key_url_prefix = gpr_strdup(key_url_prefix); @@ -806,7 +807,7 @@ static void verifier_put_mapping(grpc_jwt_verifier* v, const char* email_domain, v->mappings[v->num_mappings].email_domain = gpr_strdup(email_domain); v->mappings[v->num_mappings].key_url_prefix = gpr_strdup(key_url_prefix); v->num_mappings++; - GPR_ASSERT(v->num_mappings <= v->allocated_mappings); + CHECK(v->num_mappings <= v->allocated_mappings); } // Very non-sophisticated way to detect an email address. Should be good @@ -818,7 +819,7 @@ const char* grpc_jwt_issuer_email_domain(const char* issuer) { if (*email_domain == '\0') return nullptr; const char* dot = strrchr(email_domain, '.'); if (dot == nullptr || dot == email_domain) return email_domain; - GPR_ASSERT(dot > email_domain); + CHECK(dot > email_domain); // There may be a subdomain, we just want the domain. dot = static_cast( gpr_memrchr(email_domain, '.', static_cast(dot - email_domain))); @@ -839,8 +840,7 @@ static void retrieve_key_and_verify(verifier_cb_ctx* ctx) { char* path; absl::StatusOr uri; - GPR_ASSERT(ctx != nullptr && ctx->header != nullptr && - ctx->claims != nullptr); + CHECK(ctx != nullptr && ctx->header != nullptr && ctx->claims != nullptr); iss = ctx->claims->iss; if (ctx->header->kid == nullptr) { gpr_log(GPR_ERROR, "Missing kid in jose header."); @@ -859,7 +859,7 @@ static void retrieve_key_and_verify(verifier_cb_ctx* ctx) { email_domain = grpc_jwt_issuer_email_domain(iss); if (email_domain != nullptr) { email_key_mapping* mapping; - GPR_ASSERT(ctx->verifier != nullptr); + CHECK_NE(ctx->verifier, nullptr); mapping = verifier_get_mapping(ctx->verifier, email_domain); if (mapping == nullptr) { gpr_log(GPR_ERROR, "Missing mapping for issuer email."); @@ -926,8 +926,8 @@ void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier, Json json; std::string signature_str; - GPR_ASSERT(verifier != nullptr && jwt != nullptr && audience != nullptr && - cb != nullptr); + CHECK(verifier != nullptr && jwt != nullptr && audience != nullptr && + cb != nullptr); dot = strchr(cur, '.'); if (dot == nullptr) goto error; json = parse_json_part_from_jwt(cur, static_cast(dot - cur)); diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc index 842b3f70f08..0c2862940db 100644 --- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc @@ -27,6 +27,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" @@ -395,7 +396,7 @@ class grpc_compute_engine_token_fetcher_credentials auto uri = grpc_core::URI::Create("http", GRPC_COMPUTE_ENGINE_METADATA_HOST, GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH, {} /* query params */, "" /* fragment */); - GPR_ASSERT(uri.ok()); // params are hardcoded + CHECK(uri.ok()); // params are hardcoded http_request_ = grpc_core::HttpRequest::Get( std::move(*uri), nullptr /* channel args */, pollent, &request, deadline, @@ -424,7 +425,7 @@ grpc_call_credentials* grpc_google_compute_engine_credentials_create( void* reserved) { GRPC_API_TRACE("grpc_compute_engine_credentials_create(reserved=%p)", 1, (reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); return grpc_core::MakeRefCounted< grpc_compute_engine_token_fetcher_credentials>() .release(); @@ -461,7 +462,7 @@ void grpc_google_refresh_token_credentials::fetch_oauth2( auto uri = grpc_core::URI::Create("https", GRPC_GOOGLE_OAUTH2_SERVICE_HOST, GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH, {} /* query params */, "" /* fragment */); - GPR_ASSERT(uri.ok()); // params are hardcoded + CHECK(uri.ok()); // params are hardcoded http_request_ = grpc_core::HttpRequest::Post( std::move(*uri), nullptr /* channel args */, pollent, &request, deadline, GRPC_CLOSURE_INIT(&http_post_cb_closure_, response_cb, metadata_req, @@ -517,7 +518,7 @@ grpc_call_credentials* grpc_google_refresh_token_credentials_create( "reserved=%p)", create_loggable_refresh_token(&token).c_str(), reserved); } - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); return grpc_refresh_token_credentials_create_from_auth_refresh_token(token) .release(); } @@ -700,7 +701,7 @@ absl::StatusOr ValidateStsCredentialsOptions( grpc_call_credentials* grpc_sts_credentials_create( const grpc_sts_credentials_options* options, void* reserved) { - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); absl::StatusOr sts_url = grpc_core::ValidateStsCredentialsOptions(options); if (!sts_url.ok()) { @@ -747,7 +748,7 @@ grpc_call_credentials* grpc_access_token_credentials_create( "grpc_access_token_credentials_create(access_token=, " "reserved=%p)", 1, (reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); return grpc_core::MakeRefCounted(access_token) .release(); } diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.cc b/src/core/lib/security/credentials/plugin/plugin_credentials.cc index 36a9ca80621..be6ea721dee 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.cc +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" @@ -209,6 +210,6 @@ grpc_call_credentials* grpc_metadata_credentials_create_from_plugin( grpc_security_level min_security_level, void* reserved) { GRPC_API_TRACE("grpc_metadata_credentials_create_from_plugin(reserved=%p)", 1, (reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); return new grpc_plugin_credentials(plugin, min_security_level); } diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc index ef11a680737..1d178a35a22 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc @@ -23,6 +23,7 @@ #include #include +#include "absl/log/check.h" #include "absl/types/optional.h" #include @@ -149,8 +150,8 @@ void grpc_ssl_credentials::build_config( const grpc_ssl_verify_peer_options* verify_options) { config_.pem_root_certs = gpr_strdup(pem_root_certs); if (pem_key_cert_pair != nullptr) { - GPR_ASSERT(pem_key_cert_pair->private_key != nullptr); - GPR_ASSERT(pem_key_cert_pair->cert_chain != nullptr); + CHECK_NE(pem_key_cert_pair->private_key, nullptr); + CHECK_NE(pem_key_cert_pair->cert_chain, nullptr); config_.pem_key_cert_pair = static_cast( gpr_zalloc(sizeof(tsi_ssl_pem_key_cert_pair))); config_.pem_key_cert_pair->cert_chain = @@ -234,7 +235,7 @@ grpc_channel_credentials* grpc_ssl_credentials_create( "verify_options=%p, " "reserved=%p)", 4, (pem_root_certs, pem_key_cert_pair, verify_options, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); return new grpc_ssl_credentials( pem_root_certs, pem_key_cert_pair, @@ -250,7 +251,7 @@ grpc_channel_credentials* grpc_ssl_credentials_create_ex( "verify_options=%p, " "reserved=%p)", 4, (pem_root_certs, pem_key_cert_pair, verify_options, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); return new grpc_ssl_credentials(pem_root_certs, pem_key_cert_pair, verify_options); @@ -300,13 +301,13 @@ tsi_ssl_pem_key_cert_pair* grpc_convert_grpc_to_tsi_cert_pairs( size_t num_key_cert_pairs) { tsi_ssl_pem_key_cert_pair* tsi_pairs = nullptr; if (num_key_cert_pairs > 0) { - GPR_ASSERT(pem_key_cert_pairs != nullptr); + CHECK_NE(pem_key_cert_pairs, nullptr); tsi_pairs = static_cast( gpr_zalloc(num_key_cert_pairs * sizeof(tsi_ssl_pem_key_cert_pair))); } for (size_t i = 0; i < num_key_cert_pairs; i++) { - GPR_ASSERT(pem_key_cert_pairs[i].private_key != nullptr); - GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != nullptr); + CHECK_NE(pem_key_cert_pairs[i].private_key, nullptr); + CHECK_NE(pem_key_cert_pairs[i].cert_chain, nullptr); tsi_pairs[i].cert_chain = gpr_strdup(pem_key_cert_pairs[i].cert_chain); tsi_pairs[i].private_key = gpr_strdup(pem_key_cert_pairs[i].private_key); } @@ -343,14 +344,14 @@ grpc_ssl_server_certificate_config* grpc_ssl_server_certificate_config_create( gpr_zalloc(sizeof(grpc_ssl_server_certificate_config))); config->pem_root_certs = gpr_strdup(pem_root_certs); if (num_key_cert_pairs > 0) { - GPR_ASSERT(pem_key_cert_pairs != nullptr); + CHECK_NE(pem_key_cert_pairs, nullptr); config->pem_key_cert_pairs = static_cast( gpr_zalloc(num_key_cert_pairs * sizeof(grpc_ssl_pem_key_cert_pair))); } config->num_key_cert_pairs = num_key_cert_pairs; for (size_t i = 0; i < num_key_cert_pairs; i++) { - GPR_ASSERT(pem_key_cert_pairs[i].private_key != nullptr); - GPR_ASSERT(pem_key_cert_pairs[i].cert_chain != nullptr); + CHECK_NE(pem_key_cert_pairs[i].private_key, nullptr); + CHECK_NE(pem_key_cert_pairs[i].cert_chain, nullptr); config->pem_key_cert_pairs[i].cert_chain = gpr_strdup(pem_key_cert_pairs[i].cert_chain); config->pem_key_cert_pairs[i].private_key = @@ -435,7 +436,7 @@ grpc_server_credentials* grpc_ssl_server_credentials_create_ex( 5, (pem_root_certs, pem_key_cert_pairs, (unsigned long)num_key_cert_pairs, client_certificate_request, reserved)); - GPR_ASSERT(reserved == nullptr); + CHECK_EQ(reserved, nullptr); grpc_ssl_server_certificate_config* cert_config = grpc_ssl_server_certificate_config_create( diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.h b/src/core/lib/security/credentials/ssl/ssl_credentials.h index d76009f0666..dea04657f23 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.h +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.h @@ -20,6 +20,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -116,7 +118,7 @@ class grpc_ssl_server_credentials final : public grpc_server_credentials { grpc_ssl_certificate_config_reload_status FetchCertConfig( grpc_ssl_server_certificate_config** config) { - GPR_DEBUG_ASSERT(has_cert_config_fetcher()); + DCHECK(has_cert_config_fetcher()); return certificate_config_fetcher_.cb(certificate_config_fetcher_.user_data, config); } diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc b/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc index dbe28e1cf98..8b02a5a4446 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc @@ -16,6 +16,7 @@ #include "src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include @@ -26,17 +27,17 @@ void grpc_tls_certificate_distributor::SetKeyMaterials( const std::string& cert_name, absl::optional pem_root_certs, absl::optional pem_key_cert_pairs) { - GPR_ASSERT(pem_root_certs.has_value() || pem_key_cert_pairs.has_value()); + CHECK(pem_root_certs.has_value() || pem_key_cert_pairs.has_value()); grpc_core::MutexLock lock(&mu_); auto& cert_info = certificate_info_map_[cert_name]; if (pem_root_certs.has_value()) { // Successful credential updates will clear any pre-existing error. cert_info.SetRootError(absl::OkStatus()); for (auto* watcher_ptr : cert_info.root_cert_watchers) { - GPR_ASSERT(watcher_ptr != nullptr); + CHECK_NE(watcher_ptr, nullptr); const auto watcher_it = watchers_.find(watcher_ptr); - GPR_ASSERT(watcher_it != watchers_.end()); - GPR_ASSERT(watcher_it->second.root_cert_name.has_value()); + CHECK(watcher_it != watchers_.end()); + CHECK(watcher_it->second.root_cert_name.has_value()); absl::optional pem_key_cert_pairs_to_report; if (pem_key_cert_pairs.has_value() && @@ -58,10 +59,10 @@ void grpc_tls_certificate_distributor::SetKeyMaterials( // Successful credential updates will clear any pre-existing error. cert_info.SetIdentityError(absl::OkStatus()); for (const auto watcher_ptr : cert_info.identity_cert_watchers) { - GPR_ASSERT(watcher_ptr != nullptr); + CHECK_NE(watcher_ptr, nullptr); const auto watcher_it = watchers_.find(watcher_ptr); - GPR_ASSERT(watcher_it != watchers_.end()); - GPR_ASSERT(watcher_it->second.identity_cert_name.has_value()); + CHECK(watcher_it != watchers_.end()); + CHECK(watcher_it->second.identity_cert_name.has_value()); absl::optional pem_root_certs_to_report; if (pem_root_certs.has_value() && watcher_it->second.root_cert_name == cert_name) { @@ -102,14 +103,14 @@ void grpc_tls_certificate_distributor::SetErrorForCert( const std::string& cert_name, absl::optional root_cert_error, absl::optional identity_cert_error) { - GPR_ASSERT(root_cert_error.has_value() || identity_cert_error.has_value()); + CHECK(root_cert_error.has_value() || identity_cert_error.has_value()); grpc_core::MutexLock lock(&mu_); CertificateInfo& cert_info = certificate_info_map_[cert_name]; if (root_cert_error.has_value()) { for (auto* watcher_ptr : cert_info.root_cert_watchers) { - GPR_ASSERT(watcher_ptr != nullptr); + CHECK_NE(watcher_ptr, nullptr); const auto watcher_it = watchers_.find(watcher_ptr); - GPR_ASSERT(watcher_it != watchers_.end()); + CHECK(watcher_it != watchers_.end()); // identity_cert_error_to_report is the error of the identity cert this // watcher is watching, if there is any. grpc_error_handle identity_cert_error_to_report; @@ -127,9 +128,9 @@ void grpc_tls_certificate_distributor::SetErrorForCert( } if (identity_cert_error.has_value()) { for (auto* watcher_ptr : cert_info.identity_cert_watchers) { - GPR_ASSERT(watcher_ptr != nullptr); + CHECK_NE(watcher_ptr, nullptr); const auto watcher_it = watchers_.find(watcher_ptr); - GPR_ASSERT(watcher_it != watchers_.end()); + CHECK(watcher_it != watchers_.end()); // root_cert_error_to_report is the error of the root cert this watcher is // watching, if there is any. grpc_error_handle root_cert_error_to_report; @@ -150,11 +151,11 @@ void grpc_tls_certificate_distributor::SetErrorForCert( }; void grpc_tls_certificate_distributor::SetError(grpc_error_handle error) { - GPR_ASSERT(!error.ok()); + CHECK(!error.ok()); grpc_core::MutexLock lock(&mu_); for (const auto& watcher : watchers_) { const auto watcher_ptr = watcher.first; - GPR_ASSERT(watcher_ptr != nullptr); + CHECK_NE(watcher_ptr, nullptr); const auto& watcher_info = watcher.second; watcher_ptr->OnError( watcher_info.root_cert_name.has_value() ? error : absl::OkStatus(), @@ -175,16 +176,16 @@ void grpc_tls_certificate_distributor::WatchTlsCertificates( bool already_watching_identity_for_root_cert = false; bool start_watching_identity_cert = false; bool already_watching_root_for_identity_cert = false; - GPR_ASSERT(root_cert_name.has_value() || identity_cert_name.has_value()); + CHECK(root_cert_name.has_value() || identity_cert_name.has_value()); TlsCertificatesWatcherInterface* watcher_ptr = watcher.get(); - GPR_ASSERT(watcher_ptr != nullptr); + CHECK_NE(watcher_ptr, nullptr); // Update watchers_ and certificate_info_map_. { grpc_core::MutexLock lock(&mu_); const auto watcher_it = watchers_.find(watcher_ptr); // The caller needs to cancel the watcher first if it wants to re-register // the watcher. - GPR_ASSERT(watcher_it == watchers_.end()); + CHECK(watcher_it == watchers_.end()); watchers_[watcher_ptr] = {std::move(watcher), root_cert_name, identity_cert_name}; absl::optional updated_root_certs; @@ -270,7 +271,7 @@ void grpc_tls_certificate_distributor::CancelTlsCertificatesWatch( watchers_.erase(it); if (root_cert_name.has_value()) { auto it = certificate_info_map_.find(*root_cert_name); - GPR_ASSERT(it != certificate_info_map_.end()); + CHECK(it != certificate_info_map_.end()); CertificateInfo& cert_info = it->second; cert_info.root_cert_watchers.erase(watcher); stop_watching_root_cert = cert_info.root_cert_watchers.empty(); @@ -282,7 +283,7 @@ void grpc_tls_certificate_distributor::CancelTlsCertificatesWatch( } if (identity_cert_name.has_value()) { auto it = certificate_info_map_.find(*identity_cert_name); - GPR_ASSERT(it != certificate_info_map_.end()); + CHECK(it != certificate_info_map_.end()); CertificateInfo& cert_info = it->second; cert_info.identity_cert_watchers.erase(watcher); stop_watching_identity_cert = cert_info.identity_cert_watchers.empty(); @@ -326,13 +327,13 @@ grpc_tls_identity_pairs* grpc_tls_identity_pairs_create() { void grpc_tls_identity_pairs_add_pair(grpc_tls_identity_pairs* pairs, const char* private_key, const char* cert_chain) { - GPR_ASSERT(pairs != nullptr); - GPR_ASSERT(private_key != nullptr); - GPR_ASSERT(cert_chain != nullptr); + CHECK_NE(pairs, nullptr); + CHECK_NE(private_key, nullptr); + CHECK_NE(cert_chain, nullptr); pairs->pem_key_cert_pairs.emplace_back(private_key, cert_chain); } void grpc_tls_identity_pairs_destroy(grpc_tls_identity_pairs* pairs) { - GPR_ASSERT(pairs != nullptr); + CHECK_NE(pairs, nullptr); delete pairs; } diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc b/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc index 03921c540aa..aa1dc975a5d 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc @@ -23,6 +23,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include @@ -128,15 +129,15 @@ FileWatcherCertificateProvider::FileWatcherCertificateProvider( refresh_interval_sec_ = kMinimumFileWatcherRefreshIntervalSeconds; } // Private key and identity cert files must be both set or both unset. - GPR_ASSERT(private_key_path_.empty() == identity_certificate_path_.empty()); + CHECK(private_key_path_.empty() == identity_certificate_path_.empty()); // Must be watching either root or identity certs. - GPR_ASSERT(!private_key_path_.empty() || !root_cert_path_.empty()); + CHECK(!private_key_path_.empty() || !root_cert_path_.empty()); gpr_event_init(&shutdown_event_); ForceUpdate(); auto thread_lambda = [](void* arg) { FileWatcherCertificateProvider* provider = static_cast(arg); - GPR_ASSERT(provider != nullptr); + CHECK_NE(provider, nullptr); while (true) { void* value = gpr_event_wait( &provider->shutdown_event_, @@ -386,7 +387,7 @@ int64_t FileWatcherCertificateProvider::TestOnlyGetRefreshIntervalSecond() grpc_tls_certificate_provider* grpc_tls_certificate_provider_static_data_create( const char* root_certificate, grpc_tls_identity_pairs* pem_key_cert_pairs) { - GPR_ASSERT(root_certificate != nullptr || pem_key_cert_pairs != nullptr); + CHECK(root_certificate != nullptr || pem_key_cert_pairs != nullptr); grpc_core::ExecCtx exec_ctx; grpc_core::PemKeyCertPairList identity_pairs_core; if (pem_key_cert_pairs != nullptr) { diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h b/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h index f0775320191..fb5eaffaa38 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h @@ -23,6 +23,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" @@ -65,7 +66,7 @@ struct grpc_tls_certificate_provider // be reused when two different `grpc_tls_certificate_provider` objects are // used but they compare as equal (assuming other channel args match). int Compare(const grpc_tls_certificate_provider* other) const { - GPR_ASSERT(other != nullptr); + CHECK_NE(other, nullptr); int r = type().Compare(other->type()); if (r != 0) return r; return CompareImpl(other); diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc b/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc index 48e31b7dac0..b34005d0a89 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.cc @@ -21,6 +21,7 @@ #include #include +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -111,7 +112,7 @@ UniqueTypeName NoOpCertificateVerifier::type() const { bool HostNameCertificateVerifier::Verify( grpc_tls_custom_verification_check_request* request, std::function, absl::Status* sync_status) { - GPR_ASSERT(request != nullptr); + CHECK_NE(request, nullptr); // Extract the target name, and remove its port. const char* target_name = request->target_name; if (target_name == nullptr) { diff --git a/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h b/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h index 69a9861df22..507464e3fe3 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h +++ b/src/core/lib/security/credentials/tls/grpc_tls_certificate_verifier.h @@ -21,6 +21,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include @@ -58,7 +59,7 @@ struct grpc_tls_certificate_verifier // If this method returns 0, it means that gRPC can treat the two certificate // verifiers as effectively the same. int Compare(const grpc_tls_certificate_verifier* other) const { - GPR_ASSERT(other != nullptr); + CHECK_NE(other, nullptr); int r = type().Compare(other->type()); if (r != 0) return r; return CompareImpl(other); diff --git a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc index 3d159c5a306..0b95cc01264 100644 --- a/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +++ b/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc @@ -20,6 +20,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -39,7 +41,7 @@ grpc_tls_credentials_options* grpc_tls_credentials_options_create() { grpc_tls_credentials_options* grpc_tls_credentials_options_copy( grpc_tls_credentials_options* options) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); return new grpc_tls_credentials_options(*options); } @@ -51,21 +53,21 @@ void grpc_tls_credentials_options_destroy( void grpc_tls_credentials_options_set_cert_request_type( grpc_tls_credentials_options* options, grpc_ssl_client_certificate_request_type type) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_cert_request_type(type); } void grpc_tls_credentials_options_set_verify_server_cert( grpc_tls_credentials_options* options, int verify_server_cert) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_verify_server_cert(verify_server_cert); } void grpc_tls_credentials_options_set_certificate_provider( grpc_tls_credentials_options* options, grpc_tls_certificate_provider* provider) { - GPR_ASSERT(options != nullptr); - GPR_ASSERT(provider != nullptr); + CHECK_NE(options, nullptr); + CHECK_NE(provider, nullptr); grpc_core::ExecCtx exec_ctx; options->set_certificate_provider( provider->Ref(DEBUG_LOCATION, "set_certificate_provider")); @@ -73,45 +75,45 @@ void grpc_tls_credentials_options_set_certificate_provider( void grpc_tls_credentials_options_watch_root_certs( grpc_tls_credentials_options* options) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_watch_root_cert(true); } void grpc_tls_credentials_options_set_root_cert_name( grpc_tls_credentials_options* options, const char* root_cert_name) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_root_cert_name(root_cert_name); } void grpc_tls_credentials_options_watch_identity_key_cert_pairs( grpc_tls_credentials_options* options) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_watch_identity_pair(true); } void grpc_tls_credentials_options_set_identity_cert_name( grpc_tls_credentials_options* options, const char* identity_cert_name) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_identity_cert_name(identity_cert_name); } void grpc_tls_credentials_options_set_certificate_verifier( grpc_tls_credentials_options* options, grpc_tls_certificate_verifier* verifier) { - GPR_ASSERT(options != nullptr); - GPR_ASSERT(verifier != nullptr); + CHECK_NE(options, nullptr); + CHECK_NE(verifier, nullptr); options->set_certificate_verifier(verifier->Ref()); } void grpc_tls_credentials_options_set_crl_directory( grpc_tls_credentials_options* options, const char* crl_directory) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_crl_directory(crl_directory); } void grpc_tls_credentials_options_set_check_call_host( grpc_tls_credentials_options* options, int check_call_host) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_check_call_host(check_call_host); } @@ -145,18 +147,18 @@ void grpc_tls_credentials_options_set_send_client_ca_list( void grpc_tls_credentials_options_set_crl_provider( grpc_tls_credentials_options* options, std::shared_ptr provider) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_crl_provider(provider); } void grpc_tls_credentials_options_set_min_tls_version( grpc_tls_credentials_options* options, grpc_tls_version min_tls_version) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_min_tls_version(min_tls_version); } void grpc_tls_credentials_options_set_max_tls_version( grpc_tls_credentials_options* options, grpc_tls_version max_tls_version) { - GPR_ASSERT(options != nullptr); + CHECK_NE(options, nullptr); options->set_max_tls_version(max_tls_version); } diff --git a/src/core/lib/security/credentials/xds/xds_credentials.cc b/src/core/lib/security/credentials/xds/xds_credentials.cc index cfe1a1136fd..c170b218632 100644 --- a/src/core/lib/security/credentials/xds/xds_credentials.cc +++ b/src/core/lib/security/credentials/xds/xds_credentials.cc @@ -18,6 +18,7 @@ #include "src/core/lib/security/credentials/xds/xds_credentials.h" +#include "absl/log/check.h" #include "absl/types/optional.h" #include @@ -79,7 +80,7 @@ XdsCertificateVerifier::XdsCertificateVerifier( bool XdsCertificateVerifier::Verify( grpc_tls_custom_verification_check_request* request, std::function, absl::Status* sync_status) { - GPR_ASSERT(request != nullptr); + CHECK_NE(request, nullptr); if (!XdsVerifySubjectAlternativeNames( request->peer_info.san_names.uri_names, request->peer_info.san_names.uri_names_size, @@ -165,7 +166,7 @@ XdsCredentials::create_security_connector( target_name, args); } } - GPR_ASSERT(fallback_credentials_ != nullptr); + CHECK(fallback_credentials_ != nullptr); return fallback_credentials_->create_security_connector(std::move(call_creds), target_name, args); } @@ -216,12 +217,12 @@ UniqueTypeName XdsServerCredentials::Type() { grpc_channel_credentials* grpc_xds_credentials_create( grpc_channel_credentials* fallback_credentials) { - GPR_ASSERT(fallback_credentials != nullptr); + CHECK_NE(fallback_credentials, nullptr); return new grpc_core::XdsCredentials(fallback_credentials->Ref()); } grpc_server_credentials* grpc_xds_server_credentials_create( grpc_server_credentials* fallback_credentials) { - GPR_ASSERT(fallback_credentials != nullptr); + CHECK_NE(fallback_credentials, nullptr); return new grpc_core::XdsServerCredentials(fallback_credentials->Ref()); } diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index 1f104385d93..a8eabbd9496 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -98,13 +98,13 @@ #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_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" #include "src/core/lib/transport/error_utils.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" +#include "src/core/server/server_interface.h" grpc_core::TraceFlag grpc_call_error_trace(false, "call_error"); grpc_core::TraceFlag grpc_compression_trace(false, "compression"); diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index efb377ede34..2f0dce7ad62 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -49,8 +49,8 @@ #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_interface.h" #include "src/core/lib/transport/transport.h" +#include "src/core/server/server_interface.h" typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success, void* user_data); diff --git a/src/core/lib/transport/batch_builder.cc b/src/core/lib/transport/batch_builder.cc index 81c0b2fa5e9..a16f5a164df 100644 --- a/src/core/lib/transport/batch_builder.cc +++ b/src/core/lib/transport/batch_builder.cc @@ -16,6 +16,8 @@ #include +#include "absl/log/check.h" + #include #include "src/core/lib/promise/poll.h" @@ -96,13 +98,13 @@ BatchBuilder::Batch* BatchBuilder::GetBatch(Target target) { batch_ = GetContext()->NewPooled(payload_, target_->stream_refcount); } - GPR_ASSERT(batch_ != nullptr); + CHECK_NE(batch_, nullptr); return batch_; } void BatchBuilder::FlushBatch() { - GPR_ASSERT(batch_ != nullptr); - GPR_ASSERT(target_.has_value()); + CHECK_NE(batch_, nullptr); + CHECK(target_.has_value()); if (grpc_call_trace.enabled()) { gpr_log( GPR_DEBUG, "%sPerform transport stream op batch: %p %s", diff --git a/src/core/lib/transport/bdp_estimator.cc b/src/core/lib/transport/bdp_estimator.cc index cb5fc537754..d81e047cbc0 100644 --- a/src/core/lib/transport/bdp_estimator.cc +++ b/src/core/lib/transport/bdp_estimator.cc @@ -23,6 +23,8 @@ #include +#include "absl/log/check.h" + #include grpc_core::TraceFlag grpc_bdp_estimator_trace(false, "bdp_estimator"); @@ -53,7 +55,7 @@ Timestamp BdpEstimator::CompletePing() { std::string(name_).c_str(), accumulator_, estimate_, dt, bw / 125000.0, bw_est_ / 125000.0); } - GPR_ASSERT(ping_state_ == PingState::STARTED); + CHECK(ping_state_ == PingState::STARTED); if (accumulator_ > 2 * estimate_ / 3 && bw > bw_est_) { estimate_ = std::max(accumulator_, estimate_ * 2); bw_est_ = bw; diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 571cee0028d..6c953bd4054 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -23,6 +23,7 @@ #include +#include "absl/log/check.h" #include "absl/strings/string_view.h" #include @@ -54,7 +55,7 @@ class BdpEstimator { gpr_log(GPR_INFO, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, std::string(name_).c_str(), accumulator_, estimate_); } - GPR_ASSERT(ping_state_ == PingState::UNSCHEDULED); + CHECK(ping_state_ == PingState::UNSCHEDULED); ping_state_ = PingState::SCHEDULED; accumulator_ = 0; } @@ -67,7 +68,7 @@ class BdpEstimator { gpr_log(GPR_INFO, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, std::string(name_).c_str(), accumulator_, estimate_); } - GPR_ASSERT(ping_state_ == PingState::SCHEDULED); + CHECK(ping_state_ == PingState::SCHEDULED); ping_state_ = PingState::STARTED; ping_start_time_ = gpr_now(GPR_CLOCK_MONOTONIC); } diff --git a/src/core/lib/transport/call_destination.h b/src/core/lib/transport/call_destination.h index 2cf0f446d24..77683e230f5 100644 --- a/src/core/lib/transport/call_destination.h +++ b/src/core/lib/transport/call_destination.h @@ -36,7 +36,7 @@ class UnstartedCallDestination // and started. // Must be called from the party owned by the call, eg the following must // hold: - // GPR_ASSERT(GetContext() == unstarted_call_handler.party()); + // CHECK(GetContext() == unstarted_call_handler.party()); virtual void StartCall(UnstartedCallHandler unstarted_call_handler) = 0; }; diff --git a/src/core/lib/transport/call_filters.cc b/src/core/lib/transport/call_filters.cc index c40ca8609e8..d4792c02bfe 100644 --- a/src/core/lib/transport/call_filters.cc +++ b/src/core/lib/transport/call_filters.cc @@ -14,6 +14,8 @@ #include "src/core/lib/transport/call_filters.h" +#include "absl/log/check.h" + #include #include "src/core/lib/gprpp/crash.h" @@ -43,7 +45,7 @@ Poll> OperationExecutor::Start( if (layout->promise_size == 0) { // No call state ==> instantaneously ready auto r = InitStep(std::move(input), call_data); - GPR_ASSERT(r.ready()); + CHECK(r.ready()); return r; } promise_data_ = @@ -53,7 +55,7 @@ Poll> OperationExecutor::Start( template Poll> OperationExecutor::InitStep(T input, void* call_data) { - GPR_ASSERT(input != nullptr); + CHECK(input != nullptr); while (true) { if (ops_ == end_ops_) { return ResultOr{std::move(input), nullptr}; @@ -73,7 +75,7 @@ Poll> OperationExecutor::InitStep(T input, void* call_data) { template Poll> OperationExecutor::Step(void* call_data) { - GPR_DEBUG_ASSERT(promise_data_ != nullptr); + DCHECK_NE(promise_data_, nullptr); auto p = ContinueStep(call_data); if (p.ready()) { gpr_free_aligned(promise_data_); @@ -109,7 +111,7 @@ Poll InfallibleOperationExecutor::Start( if (layout->promise_size == 0) { // No call state ==> instantaneously ready auto r = InitStep(std::move(input), call_data); - GPR_ASSERT(r.ready()); + CHECK(r.ready()); return r; } promise_data_ = @@ -137,7 +139,7 @@ Poll InfallibleOperationExecutor::InitStep(T input, void* call_data) { template Poll InfallibleOperationExecutor::Step(void* call_data) { - GPR_DEBUG_ASSERT(promise_data_ != nullptr); + DCHECK_NE(promise_data_, nullptr); auto p = ContinueStep(call_data); if (p.ready()) { gpr_free_aligned(promise_data_); @@ -182,7 +184,7 @@ CallFilters::~CallFilters() { } void CallFilters::SetStack(RefCountedPtr stack) { - GPR_ASSERT(call_data_ == nullptr); + CHECK_EQ(call_data_, nullptr); stack_ = std::move(stack); call_data_ = gpr_malloc_aligned(stack_->data_.call_data_size, stack_->data_.call_data_alignment); @@ -217,13 +219,13 @@ void CallFilters::CancelDueToFailedPipeOperation(SourceLocation but_where) { } void CallFilters::PushServerTrailingMetadata(ServerMetadataHandle md) { - GPR_ASSERT(md != nullptr); + CHECK(md != nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_promise_primitives)) { gpr_log(GPR_INFO, "%s PushServerTrailingMetadata[%p]: %s into %s", GetContext()->DebugTag().c_str(), this, md->DebugString().c_str(), DebugString().c_str()); } - GPR_ASSERT(md != nullptr); + CHECK(md != nullptr); if (server_trailing_metadata_ != nullptr) return; server_trailing_metadata_ = std::move(md); client_initial_metadata_state_.CloseWithError(); @@ -286,7 +288,7 @@ RefCountedPtr CallFilters::StackBuilder::Build() { // CallFilters::PipeState void filters_detail::PipeState::Start() { - GPR_DEBUG_ASSERT(!started_); + DCHECK(!started_); started_ = true; wait_recv_.Wake(); } diff --git a/src/core/lib/transport/call_filters.h b/src/core/lib/transport/call_filters.h index 043bf6434da..a9e3a1c5b98 100644 --- a/src/core/lib/transport/call_filters.h +++ b/src/core/lib/transport/call_filters.h @@ -19,6 +19,8 @@ #include #include +#include "absl/log/check.h" + #include #include "src/core/lib/gprpp/ref_counted.h" @@ -157,7 +159,7 @@ template struct ResultOr { ResultOr(T ok, ServerMetadataHandle error) : ok(std::move(ok)), error(std::move(error)) { - GPR_ASSERT((this->ok == nullptr) ^ (this->error == nullptr)); + CHECK((this->ok == nullptr) ^ (this->error == nullptr)); } T ok; ServerMetadataHandle error; @@ -990,13 +992,13 @@ struct StackData { template void AddFinalizer(FilterType*, size_t, const NoInterceptor* p) { - GPR_DEBUG_ASSERT(p == &FilterType::Call::OnFinalize); + DCHECK(p == &FilterType::Call::OnFinalize); } template void AddFinalizer(FilterType* channel_data, size_t call_offset, void (FilterType::Call::*p)(const grpc_call_final_info*)) { - GPR_DEBUG_ASSERT(p == &FilterType::Call::OnFinalize); + DCHECK(p == &FilterType::Call::OnFinalize); finalizers.push_back(Finalizer{ channel_data, call_offset, @@ -1011,7 +1013,7 @@ struct StackData { void AddFinalizer(FilterType* channel_data, size_t call_offset, void (FilterType::Call::*p)(const grpc_call_final_info*, FilterType*)) { - GPR_DEBUG_ASSERT(p == &FilterType::Call::OnFinalize); + DCHECK(p == &FilterType::Call::OnFinalize); finalizers.push_back(Finalizer{ channel_data, call_offset, @@ -1041,11 +1043,11 @@ class OperationExecutor { OperationExecutor(OperationExecutor&& other) noexcept : ops_(other.ops_), end_ops_(other.end_ops_) { // Movable iff we're not running. - GPR_DEBUG_ASSERT(other.promise_data_ == nullptr); + DCHECK_EQ(other.promise_data_, nullptr); } OperationExecutor& operator=(OperationExecutor&& other) noexcept { - GPR_DEBUG_ASSERT(other.promise_data_ == nullptr); - GPR_DEBUG_ASSERT(promise_data_ == nullptr); + DCHECK_EQ(other.promise_data_, nullptr); + DCHECK_EQ(promise_data_, nullptr); ops_ = other.ops_; end_ops_ = other.end_ops_; return *this; @@ -1094,12 +1096,12 @@ class InfallibleOperationExecutor { InfallibleOperationExecutor(InfallibleOperationExecutor&& other) noexcept : ops_(other.ops_), end_ops_(other.end_ops_) { // Movable iff we're not running. - GPR_DEBUG_ASSERT(other.promise_data_ == nullptr); + DCHECK_EQ(other.promise_data_, nullptr); } InfallibleOperationExecutor& operator=( InfallibleOperationExecutor&& other) noexcept { - GPR_DEBUG_ASSERT(other.promise_data_ == nullptr); - GPR_DEBUG_ASSERT(promise_data_ == nullptr); + DCHECK_EQ(other.promise_data_, nullptr); + DCHECK_EQ(promise_data_, nullptr); ops_ = other.ops_; end_ops_ = other.end_ops_; return *this; @@ -1388,12 +1390,12 @@ class CallFilters { public: Push(CallFilters* filters, T x) : filters_(filters), value_(std::move(x)) { - GPR_ASSERT(value_ != nullptr); + CHECK(value_ != nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_promise_primitives)) { gpr_log(GPR_INFO, "BeginPush[%p|%p]: %s", &state(), this, state().DebugString().c_str()); } - GPR_ASSERT(push_slot() == nullptr); + CHECK_EQ(push_slot(), nullptr); state().BeginPush(); push_slot() = this; } @@ -1402,7 +1404,7 @@ class CallFilters { if (value_ != nullptr) { state().DropPush(); } - GPR_ASSERT(push_slot() == this); + CHECK(push_slot() == this); push_slot() = nullptr; } } @@ -1413,7 +1415,7 @@ class CallFilters { : filters_(std::exchange(other.filters_, nullptr)), value_(std::move(other.value_)) { if (filters_ != nullptr) { - GPR_DEBUG_ASSERT(push_slot() == &other); + DCHECK(push_slot() == &other); push_slot() = this; } } @@ -1422,7 +1424,7 @@ class CallFilters { Poll operator()() { if (value_ == nullptr) { - GPR_ASSERT(filters_ == nullptr); + CHECK_EQ(filters_, nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_promise_primitives)) { gpr_log(GPR_INFO, "Push[|%p]: already done", this); } @@ -1457,8 +1459,8 @@ class CallFilters { gpr_log(GPR_INFO, "Push[%p|%p]: take value; %s", &state(), this, state().DebugString().c_str()); } - GPR_ASSERT(value_ != nullptr); - GPR_ASSERT(filters_ != nullptr); + CHECK(value_ != nullptr); + CHECK(filters_ != nullptr); push_slot() = nullptr; filters_ = nullptr; return std::move(value_); @@ -1536,7 +1538,7 @@ class CallFilters { Poll> p) { auto* r = p.value_if_ready(); if (r == nullptr) return Pending{}; - GPR_DEBUG_ASSERT(!executor_.IsRunning()); + DCHECK(!executor_.IsRunning()); state().AckPull(); if (r->ok != nullptr) return std::move(r->ok); filters_->PushServerTrailingMetadata(std::move(r->error)); @@ -1564,7 +1566,7 @@ class CallFilters { PullMessage& operator=(PullMessage&&) = delete; Poll>> operator()() { - GPR_ASSERT(filters_ != nullptr); + CHECK(filters_ != nullptr); if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_promise_primitives)) { gpr_log(GPR_INFO, "PullMessage[%p|%p]: %s executor:%d", &state(), this, state().DebugString().c_str(), executor_.IsRunning()); @@ -1592,7 +1594,7 @@ class CallFilters { return Failure{}; } if (!**r) return absl::nullopt; - GPR_ASSERT(filters_ != nullptr); + CHECK(filters_ != nullptr); return FinishOperationExecutor(executor_.Start( layout(), push()->TakeValue(), filters_->call_data_)); } @@ -1609,7 +1611,7 @@ class CallFilters { FinishOperationExecutor(Poll> p) { auto* r = p.value_if_ready(); if (r == nullptr) return Pending{}; - GPR_DEBUG_ASSERT(!executor_.IsRunning()); + DCHECK(!executor_.IsRunning()); if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_promise_primitives)) { gpr_log(GPR_INFO, "PullMessage[%p|%p] executor done: %s", &state(), this, state().DebugString().c_str()); @@ -1658,7 +1660,7 @@ class CallFilters { filters_->CancelDueToFailedPipeOperation(); return Failure{}; } - GPR_ASSERT(filters_->client_initial_metadata_ != nullptr); + CHECK(filters_->client_initial_metadata_ != nullptr); return FinishOperationExecutor(executor_.Start( &filters_->stack_->data_.client_initial_metadata, std::move(filters_->client_initial_metadata_), filters_->call_data_)); @@ -1673,7 +1675,7 @@ class CallFilters { Poll> p) { auto* r = p.value_if_ready(); if (r == nullptr) return Pending{}; - GPR_DEBUG_ASSERT(!executor_.IsRunning()); + DCHECK(!executor_.IsRunning()); state().AckPull(); if (r->ok != nullptr) return std::move(r->ok); filters_->PushServerTrailingMetadata(std::move(r->error)); @@ -1803,7 +1805,7 @@ inline auto CallFilters::PullClientInitialMetadata() { } inline auto CallFilters::PushServerInitialMetadata(ServerMetadataHandle md) { - GPR_ASSERT(md != nullptr); + CHECK(md != nullptr); return [p = ServerInitialMetadataPromises::Push{ this, std::move(md)}]() mutable { return p(); }; } @@ -1813,7 +1815,7 @@ inline auto CallFilters::PullServerInitialMetadata() { } inline auto CallFilters::PushClientToServerMessage(MessageHandle message) { - GPR_ASSERT(message != nullptr); + CHECK(message != nullptr); return [p = ClientToServerMessagePromises::Push{ this, std::move(message)}]() mutable { return p(); }; } @@ -1823,7 +1825,7 @@ inline auto CallFilters::PullClientToServerMessage() { } inline auto CallFilters::PushServerToClientMessage(MessageHandle message) { - GPR_ASSERT(message != nullptr); + CHECK(message != nullptr); return [p = ServerToClientMessagePromises::Push{ this, std::move(message)}]() mutable { return p(); }; } diff --git a/src/core/lib/transport/call_spine.h b/src/core/lib/transport/call_spine.h index 2c81c2ff927..8593e47e9c8 100644 --- a/src/core/lib/transport/call_spine.h +++ b/src/core/lib/transport/call_spine.h @@ -15,6 +15,8 @@ #ifndef GRPC_SRC_CORE_LIB_TRANSPORT_CALL_SPINE_H #define GRPC_SRC_CORE_LIB_TRANSPORT_CALL_SPINE_H +#include "absl/log/check.h" + #include #include @@ -88,7 +90,7 @@ class CallSpineInterface { // The resulting (returned) promise will resolve to Empty. template auto CancelIfFails(Promise promise) { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); using P = promise_detail::PromiseLike; using ResultType = typename P::Result; return Map(std::move(promise), [this](ResultType r) { @@ -151,7 +153,7 @@ class PipeBasedCallSpine : public CallSpineInterface { Promise>> PullServerInitialMetadata() final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return Map(server_initial_metadata().receiver.Next(), [](NextResult md) -> ValueOrFailure> { @@ -164,41 +166,41 @@ class PipeBasedCallSpine : public CallSpineInterface { } Promise PullServerTrailingMetadata() final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return cancel_latch().Wait(); } Promise>> PullServerToClientMessage() final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return Map(server_to_client_messages().receiver.Next(), MapNextMessage); } Promise PushClientToServerMessage(MessageHandle message) final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return Map(client_to_server_messages().sender.Push(std::move(message)), [](bool r) { return StatusFlag(r); }); } Promise>> PullClientToServerMessage() final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return Map(client_to_server_messages().receiver.Next(), MapNextMessage); } Promise PushServerToClientMessage(MessageHandle message) final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return Map(server_to_client_messages().sender.Push(std::move(message)), [](bool r) { return StatusFlag(r); }); } void FinishSends() final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); client_to_server_messages().sender.Close(); } void PushServerTrailingMetadata(ServerMetadataHandle metadata) final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); auto& c = cancel_latch(); if (c.is_set()) return; const bool was_cancelled = @@ -213,13 +215,13 @@ class PipeBasedCallSpine : public CallSpineInterface { } Promise WasCancelled() final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return was_cancelled_latch().Wait(); } Promise> PullClientInitialMetadata() final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return Map(client_initial_metadata().receiver.Next(), [](NextResult md) -> ValueOrFailure { @@ -230,7 +232,7 @@ class PipeBasedCallSpine : public CallSpineInterface { Promise PushServerInitialMetadata( absl::optional md) final { - GPR_DEBUG_ASSERT(GetContext() == &party()); + DCHECK(GetContext() == &party()); return If( md.has_value(), [&md, this]() { diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index d7d0185a66e..7df578396bc 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -28,6 +28,7 @@ #include "absl/container/inlined_vector.h" #include "absl/functional/function_ref.h" +#include "absl/log/check.h" #include "absl/meta/type_traits.h" #include "absl/strings/numbers.h" #include "absl/strings/string_view.h" @@ -107,7 +108,7 @@ struct TeMetadata { MetadataParseErrorFn on_error); static ValueType MementoToValue(MementoType te) { return te; } static StaticSlice Encode(ValueType x) { - GPR_ASSERT(x == kTrailers); + CHECK(x == kTrailers); return StaticSlice::FromStaticString("trailers"); } static const char* DisplayValue(ValueType te); @@ -210,7 +211,7 @@ struct CompressionAlgorithmBasedMetadata { MetadataParseErrorFn on_error); static ValueType MementoToValue(MementoType x) { return x; } static Slice Encode(ValueType x) { - GPR_ASSERT(x != GRPC_COMPRESS_ALGORITHMS_COUNT); + CHECK(x != GRPC_COMPRESS_ALGORITHMS_COUNT); return Slice::FromStaticString(CompressionAlgorithmAsString(x)); } static const char* DisplayValue(ValueType x) { diff --git a/src/core/lib/transport/promise_endpoint.cc b/src/core/lib/transport/promise_endpoint.cc index 9f8ced08ef8..031f5194e02 100644 --- a/src/core/lib/transport/promise_endpoint.cc +++ b/src/core/lib/transport/promise_endpoint.cc @@ -19,6 +19,7 @@ #include #include +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/types/optional.h" @@ -38,7 +39,7 @@ PromiseEndpoint::PromiseEndpoint( endpoint, SliceBuffer already_received) : endpoint_(std::move(endpoint)) { - GPR_ASSERT(endpoint_ != nullptr); + CHECK_NE(endpoint_, nullptr); read_state_->endpoint = endpoint_; // TODO(ladynana): Replace this with `SliceBufferCast<>` when it is // available. @@ -72,7 +73,7 @@ void PromiseEndpoint::ReadState::Complete(absl::Status status, // Appends `pending_buffer` to `buffer`. pending_buffer.MoveFirstNBytesIntoSliceBuffer(pending_buffer.Length(), buffer); - GPR_DEBUG_ASSERT(pending_buffer.Count() == 0u); + DCHECK(pending_buffer.Count() == 0u); if (buffer.Length() < num_bytes_requested) { // A further read is needed. // Set read args with number of bytes needed as hint. diff --git a/src/core/lib/transport/promise_endpoint.h b/src/core/lib/transport/promise_endpoint.h index be49a1fccb0..12659aff583 100644 --- a/src/core/lib/transport/promise_endpoint.h +++ b/src/core/lib/transport/promise_endpoint.h @@ -25,6 +25,7 @@ #include #include "absl/base/thread_annotations.h" +#include "absl/log/check.h" #include "absl/status/status.h" #include "absl/status/statusor.h" #include "absl/types/optional.h" @@ -75,7 +76,7 @@ class PromiseEndpoint { // Start write and assert previous write finishes. auto prev = write_state_->state.exchange(WriteState::kWriting, std::memory_order_relaxed); - GPR_ASSERT(prev == WriteState::kIdle); + CHECK(prev == WriteState::kIdle); bool completed; if (data.Length() == 0) { completed = true; @@ -102,7 +103,7 @@ class PromiseEndpoint { return [write_state = write_state_]() { auto prev = write_state->state.exchange(WriteState::kIdle, std::memory_order_relaxed); - GPR_ASSERT(prev == WriteState::kWriting); + CHECK(prev == WriteState::kWriting); return absl::OkStatus(); }; }, @@ -120,7 +121,7 @@ class PromiseEndpoint { } // State was not Written; since we're polling it must be // Writing. Assert that and return Pending. - GPR_ASSERT(expected == WriteState::kWriting); + CHECK(expected == WriteState::kWriting); return Pending(); }; }); @@ -134,9 +135,9 @@ class PromiseEndpoint { // undefined behavior. auto Read(size_t num_bytes) { // Assert previous read finishes. - GPR_ASSERT(!read_state_->complete.load(std::memory_order_relaxed)); + CHECK(!read_state_->complete.load(std::memory_order_relaxed)); // Should not have pending reads. - GPR_ASSERT(read_state_->pending_buffer.Count() == 0u); + CHECK(read_state_->pending_buffer.Count() == 0u); bool complete = true; while (read_state_->buffer.Length() < num_bytes) { // Set read args with hinted bytes. @@ -156,7 +157,7 @@ class PromiseEndpoint { read_state_->waker = Waker(); read_state_->pending_buffer.MoveFirstNBytesIntoSliceBuffer( read_state_->pending_buffer.Length(), read_state_->buffer); - GPR_DEBUG_ASSERT(read_state_->pending_buffer.Count() == 0u); + DCHECK(read_state_->pending_buffer.Count() == 0u); } else { complete = false; break; @@ -233,8 +234,7 @@ class PromiseEndpoint { // Copy everything from read_state_->buffer into a single slice and // replace the contents of read_state_->buffer with that slice. grpc_slice slice = grpc_slice_malloc_large(read_state_->buffer.Length()); - GPR_ASSERT( - reinterpret_cast(GRPC_SLICE_START_PTR(slice)) % 64 == 0); + CHECK(reinterpret_cast(GRPC_SLICE_START_PTR(slice)) % 64 == 0); size_t ofs = 0; for (size_t i = 0; i < read_state_->buffer.Count(); i++) { memcpy( @@ -249,7 +249,7 @@ class PromiseEndpoint { read_state_->buffer.Clear(); read_state_->buffer.AppendIndexed( grpc_event_engine::experimental::Slice(slice)); - GPR_DEBUG_ASSERT(read_state_->buffer.Length() == ofs); + DCHECK(read_state_->buffer.Length() == ofs); } } @@ -305,7 +305,7 @@ class PromiseEndpoint { auto prev = state.exchange(kWritten, std::memory_order_release); // Previous state should be Writing. If we got anything else we've entered // the callback path twice. - GPR_ASSERT(prev == kWriting); + CHECK(prev == kWriting); w.Wakeup(); } }; diff --git a/src/core/lib/transport/timeout_encoding.cc b/src/core/lib/transport/timeout_encoding.cc index 265081aac34..deb82cb2cdc 100644 --- a/src/core/lib/transport/timeout_encoding.cc +++ b/src/core/lib/transport/timeout_encoding.cc @@ -21,6 +21,7 @@ #include #include "absl/base/attributes.h" +#include "absl/log/check.h" #include #include @@ -182,7 +183,7 @@ Timeout Timeout::FromMillis(int64_t millis) { } Timeout Timeout::FromSeconds(int64_t seconds) { - GPR_DEBUG_ASSERT(seconds != 0); + DCHECK_NE(seconds, 0); if (seconds < 1000) { if (seconds % kSecondsPerMinute != 0) { return Timeout(seconds, Unit::kSeconds); @@ -202,7 +203,7 @@ Timeout Timeout::FromSeconds(int64_t seconds) { } Timeout Timeout::FromMinutes(int64_t minutes) { - GPR_DEBUG_ASSERT(minutes != 0); + DCHECK_NE(minutes, 0); if (minutes < 1000) { if (minutes % kMinutesPerHour != 0) { return Timeout(minutes, Unit::kMinutes); @@ -222,7 +223,7 @@ Timeout Timeout::FromMinutes(int64_t minutes) { } Timeout Timeout::FromHours(int64_t hours) { - GPR_DEBUG_ASSERT(hours != 0); + DCHECK_NE(hours, 0); if (hours < kMaxHours) { return Timeout(hours, Unit::kHours); } diff --git a/src/core/load_balancing/endpoint_list.cc b/src/core/load_balancing/endpoint_list.cc index f86d5af16ff..5b952490740 100644 --- a/src/core/load_balancing/endpoint_list.cc +++ b/src/core/load_balancing/endpoint_list.cc @@ -87,7 +87,7 @@ class EndpointList::Endpoint::Helper final // EndpointList::Endpoint // -void EndpointList::Endpoint::Init( +absl::Status EndpointList::Endpoint::Init( const EndpointAddresses& addresses, const ChannelArgs& args, std::shared_ptr work_serializer) { ChannelArgs child_args = @@ -123,9 +123,7 @@ void EndpointList::Endpoint::Init( update_args.addresses = std::make_shared(addresses); update_args.args = child_args; update_args.config = std::move(*config); - // TODO(roth): If the child reports a non-OK status with the update, - // we need to propagate that back to the resolver somehow. - (void)child_policy_->UpdateLocked(std::move(update_args)); + return child_policy_->UpdateLocked(std::move(update_args)); } void EndpointList::Endpoint::Orphan() { diff --git a/src/core/load_balancing/endpoint_list.h b/src/core/load_balancing/endpoint_list.h index daf4f1fe366..cd8276bf51a 100644 --- a/src/core/load_balancing/endpoint_list.h +++ b/src/core/load_balancing/endpoint_list.h @@ -53,7 +53,8 @@ class MyEndpointList : public EndpointList { public: MyEndpointList(RefCountedPtr lb_policy, EndpointAddressesIterator* endpoints, - const ChannelArgs& args) + const ChannelArgs& args, + std::vector* errors) : EndpointList(std::move(lb_policy), GRPC_TRACE_FLAG_ENABLED(grpc_my_tracer) ? "MyEndpointList" @@ -63,7 +64,7 @@ class MyEndpointList : public EndpointList { const EndpointAddresses& addresses, const ChannelArgs& args) { return MakeOrphanable( std::move(endpoint_list), addresses, args, - policy()->work_serializer()); + policy()->work_serializer(), errors); }); } @@ -71,10 +72,15 @@ class MyEndpointList : public EndpointList { class MyEndpoint : public Endpoint { public: MyEndpoint(RefCountedPtr endpoint_list, - const EndpointAddresses& address, const ChannelArgs& args, - std::shared_ptr work_serializer) + const EndpointAddresses& addresses, const ChannelArgs& args, + std::shared_ptr work_serializer, + std::vector* errors) : Endpoint(std::move(endpoint_list)) { - Init(addresses, args, std::move(work_serializer)); + absl::Status status = Init(addresses, args, std::move(work_serializer)); + if (!status.ok()) { + errors->emplace_back(absl::StrCat( + "endpoint ", addresses.ToString(), ": ", status.ToString())); + } } private: @@ -120,8 +126,9 @@ class EndpointList : public InternallyRefCounted { explicit Endpoint(RefCountedPtr endpoint_list) : endpoint_list_(std::move(endpoint_list)) {} - void Init(const EndpointAddresses& addresses, const ChannelArgs& args, - std::shared_ptr work_serializer); + absl::Status Init(const EndpointAddresses& addresses, + const ChannelArgs& args, + std::shared_ptr work_serializer); // Templated for convenience, to provide a short-hand for // down-casting in the caller. diff --git a/src/core/load_balancing/priority/priority.cc b/src/core/load_balancing/priority/priority.cc index ac3eea9c371..0ccfe20c953 100644 --- a/src/core/load_balancing/priority/priority.cc +++ b/src/core/load_balancing/priority/priority.cc @@ -415,11 +415,16 @@ void PriorityLb::ChoosePriorityLocked() { child_name); auto child_config = config_->children().find(child_name); GPR_DEBUG_ASSERT(child_config != config_->children().end()); - // TODO(roth): If the child reports a non-OK status with the - // update, we need to propagate that back to the resolver somehow. - (void)child->UpdateLocked( + // If the child policy returns a non-OK status, request re-resolution. + // Note that this will initially cause fixed backoff delay in the + // resolver instead of exponential delay. However, once the + // resolver returns the initial re-resolution, we will be able to + // return non-OK from UpdateLocked(), which will trigger + // exponential backoff instead. + absl::Status status = child->UpdateLocked( child_config->second.config, child_config->second.ignore_reresolution_requests); + if (!status.ok()) channel_control_helper()->RequestReresolution(); } else { // The child already exists. Reactivate if needed. child->MaybeReactivateLocked(); diff --git a/src/core/load_balancing/ring_hash/ring_hash.cc b/src/core/load_balancing/ring_hash/ring_hash.cc index 41782c70655..667b23440cc 100644 --- a/src/core/load_balancing/ring_hash/ring_hash.cc +++ b/src/core/load_balancing/ring_hash/ring_hash.cc @@ -169,7 +169,7 @@ class RingHash final : public LoadBalancingPolicy { size_t index() const { return index_; } - void UpdateLocked(size_t index); + absl::Status UpdateLocked(size_t index); grpc_connectivity_state connectivity_state() const { return connectivity_state_; @@ -196,7 +196,7 @@ class RingHash final : public LoadBalancingPolicy { class Helper; void CreateChildPolicy(); - void UpdateChildPolicyLocked(); + absl::Status UpdateChildPolicyLocked(); // Called when the child policy reports a connectivity state update. void OnStateUpdate(grpc_connectivity_state new_state, @@ -498,9 +498,10 @@ void RingHash::RingHashEndpoint::Orphan() { Unref(); } -void RingHash::RingHashEndpoint::UpdateLocked(size_t index) { +absl::Status RingHash::RingHashEndpoint::UpdateLocked(size_t index) { index_ = index; - if (child_policy_ != nullptr) UpdateChildPolicyLocked(); + if (child_policy_ == nullptr) return absl::OkStatus(); + return UpdateChildPolicyLocked(); } void RingHash::RingHashEndpoint::ResetBackoffLocked() { @@ -541,10 +542,19 @@ void RingHash::RingHashEndpoint::CreateChildPolicy() { // this policy, which in turn is tied to the application's call. grpc_pollset_set_add_pollset_set(child_policy_->interested_parties(), ring_hash_->interested_parties()); - UpdateChildPolicyLocked(); + // If the child policy returns a non-OK status, request re-resolution. + // Note that this will initially cause fixed backoff delay in the + // resolver instead of exponential delay. However, once the + // resolver returns the initial re-resolution, we will be able to + // return non-OK from UpdateLocked(), which will trigger + // exponential backoff instead. + absl::Status status = UpdateChildPolicyLocked(); + if (!status.ok()) { + ring_hash_->channel_control_helper()->RequestReresolution(); + } } -void RingHash::RingHashEndpoint::UpdateChildPolicyLocked() { +absl::Status RingHash::RingHashEndpoint::UpdateChildPolicyLocked() { // Construct pick_first config. auto config = CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig( @@ -557,9 +567,7 @@ void RingHash::RingHashEndpoint::UpdateChildPolicyLocked() { std::make_shared(ring_hash_->endpoints_[index_]); update_args.args = ring_hash_->args_; update_args.config = std::move(*config); - // TODO(roth): If the child reports a non-OK status with the update, - // we need to propagate that back to the resolver somehow. - (void)child_policy_->UpdateLocked(std::move(update_args)); + return child_policy_->UpdateLocked(std::move(update_args)); } void RingHash::RingHashEndpoint::OnStateUpdate( @@ -667,13 +675,18 @@ absl::Status RingHash::UpdateLocked(UpdateArgs args) { this, static_cast(args.config.get())); // Update endpoint map. std::map> endpoint_map; + std::vector errors; for (size_t i = 0; i < endpoints_.size(); ++i) { const EndpointAddresses& addresses = endpoints_[i]; const EndpointAddressSet address_set(addresses.addresses()); // If present in old map, retain it; otherwise, create a new one. auto it = endpoint_map_.find(address_set); if (it != endpoint_map_.end()) { - it->second->UpdateLocked(i); + absl::Status status = it->second->UpdateLocked(i); + if (!status.ok()) { + errors.emplace_back(absl::StrCat("endpoint ", address_set.ToString(), + ": ", status.ToString())); + } endpoint_map.emplace(address_set, std::move(it->second)); } else { endpoint_map.emplace(address_set, MakeOrphanable( @@ -695,6 +708,10 @@ absl::Status RingHash::UpdateLocked(UpdateArgs args) { // Return a new picker. UpdateAggregatedConnectivityStateLocked(/*entered_transient_failure=*/false, absl::OkStatus()); + if (!errors.empty()) { + return absl::UnavailableError(absl::StrCat( + "errors from children: [", absl::StrJoin(errors, "; "), "]")); + } return absl::OkStatus(); } diff --git a/src/core/load_balancing/rls/rls.cc b/src/core/load_balancing/rls/rls.cc index 93de1b7ae9f..1207daac8c3 100644 --- a/src/core/load_balancing/rls/rls.cc +++ b/src/core/load_balancing/rls/rls.cc @@ -1860,9 +1860,16 @@ void RlsLb::RlsRequest::OnRlsCallCompleteLocked(grpc_error_handle error) { // Now that we've released the lock, finish the update on any newly // created child policies. for (ChildPolicyWrapper* child : child_policies_to_finish_update) { - // TODO(roth): If the child reports an error with the update, we - // need to propagate that back to the resolver somehow. - (void)child->MaybeFinishUpdate(); + // If the child policy returns a non-OK status, request re-resolution. + // Note that this will initially cause fixed backoff delay in the + // resolver instead of exponential delay. However, once the + // resolver returns the initial re-resolution, we will be able to + // return non-OK from UpdateLocked(), which will trigger + // exponential backoff instead. + absl::Status status = child->MaybeFinishUpdate(); + if (!status.ok()) { + lb_policy_->channel_control_helper()->RequestReresolution(); + } } } diff --git a/src/core/load_balancing/round_robin/round_robin.cc b/src/core/load_balancing/round_robin/round_robin.cc index 85d524e10f3..a232b3fdc17 100644 --- a/src/core/load_balancing/round_robin/round_robin.cc +++ b/src/core/load_balancing/round_robin/round_robin.cc @@ -72,7 +72,8 @@ class RoundRobin final : public LoadBalancingPolicy { public: RoundRobinEndpointList(RefCountedPtr round_robin, EndpointAddressesIterator* endpoints, - const ChannelArgs& args) + const ChannelArgs& args, + std::vector* errors) : EndpointList(std::move(round_robin), GRPC_TRACE_FLAG_ENABLED(grpc_lb_round_robin_trace) ? "RoundRobinEndpointList" @@ -82,7 +83,7 @@ class RoundRobin final : public LoadBalancingPolicy { const EndpointAddresses& addresses, const ChannelArgs& args) { return MakeOrphanable( std::move(endpoint_list), addresses, args, - policy()->work_serializer()); + policy()->work_serializer(), errors); }); } @@ -92,9 +93,14 @@ class RoundRobin final : public LoadBalancingPolicy { RoundRobinEndpoint(RefCountedPtr endpoint_list, const EndpointAddresses& addresses, const ChannelArgs& args, - std::shared_ptr work_serializer) + std::shared_ptr work_serializer, + std::vector* errors) : Endpoint(std::move(endpoint_list)) { - Init(addresses, args, std::move(work_serializer)); + absl::Status status = Init(addresses, args, std::move(work_serializer)); + if (!status.ok()) { + errors->emplace_back(absl::StrCat("endpoint ", addresses.ToString(), + ": ", status.ToString())); + } } private: @@ -255,9 +261,10 @@ absl::Status RoundRobin::UpdateLocked(UpdateArgs args) { gpr_log(GPR_INFO, "[RR %p] replacing previous pending child list %p", this, latest_pending_endpoint_list_.get()); } + std::vector errors; latest_pending_endpoint_list_ = MakeOrphanable( RefAsSubclass(DEBUG_LOCATION, "RoundRobinEndpointList"), - addresses, args.args); + addresses, args.args, &errors); // If the new list is empty, immediately promote it to // endpoint_list_ and report TRANSIENT_FAILURE. if (latest_pending_endpoint_list_->size() == 0) { @@ -281,6 +288,10 @@ absl::Status RoundRobin::UpdateLocked(UpdateArgs args) { if (endpoint_list_ == nullptr) { endpoint_list_ = std::move(latest_pending_endpoint_list_); } + if (!errors.empty()) { + return absl::UnavailableError(absl::StrCat( + "errors from children: [", absl::StrJoin(errors, "; "), "]")); + } return absl::OkStatus(); } diff --git a/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc b/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc index b93f51f410a..73311eb07eb 100644 --- a/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +++ b/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc @@ -221,11 +221,16 @@ class WeightedRoundRobin final : public LoadBalancingPolicy { public: WrrEndpoint(RefCountedPtr endpoint_list, const EndpointAddresses& addresses, const ChannelArgs& args, - std::shared_ptr work_serializer) + std::shared_ptr work_serializer, + std::vector* errors) : Endpoint(std::move(endpoint_list)), weight_(policy()->GetOrCreateWeight( addresses.addresses())) { - Init(addresses, args, std::move(work_serializer)); + absl::Status status = Init(addresses, args, std::move(work_serializer)); + if (!status.ok()) { + errors->emplace_back(absl::StrCat("endpoint ", addresses.ToString(), + ": ", status.ToString())); + } } RefCountedPtr weight() const { return weight_; } @@ -261,7 +266,7 @@ class WeightedRoundRobin final : public LoadBalancingPolicy { WrrEndpointList(RefCountedPtr wrr, EndpointAddressesIterator* endpoints, - const ChannelArgs& args) + const ChannelArgs& args, std::vector* errors) : EndpointList(std::move(wrr), GRPC_TRACE_FLAG_ENABLED(grpc_lb_wrr_trace) ? "WrrEndpointList" @@ -271,7 +276,7 @@ class WeightedRoundRobin final : public LoadBalancingPolicy { const EndpointAddresses& addresses, const ChannelArgs& args) { return MakeOrphanable( std::move(endpoint_list), addresses, args, - policy()->work_serializer()); + policy()->work_serializer(), errors); }); } @@ -767,8 +772,9 @@ absl::Status WeightedRoundRobin::UpdateLocked(UpdateArgs args) { gpr_log(GPR_INFO, "[WRR %p] replacing previous pending endpoint list %p", this, latest_pending_endpoint_list_.get()); } + std::vector errors; latest_pending_endpoint_list_ = MakeOrphanable( - RefAsSubclass(), addresses.get(), args.args); + RefAsSubclass(), addresses.get(), args.args, &errors); // If the new list is empty, immediately promote it to // endpoint_list_ and report TRANSIENT_FAILURE. if (latest_pending_endpoint_list_->size() == 0) { @@ -792,6 +798,10 @@ absl::Status WeightedRoundRobin::UpdateLocked(UpdateArgs args) { if (endpoint_list_.get() == nullptr) { endpoint_list_ = std::move(latest_pending_endpoint_list_); } + if (!errors.empty()) { + return absl::UnavailableError(absl::StrCat( + "errors from children: [", absl::StrJoin(errors, "; "), "]")); + } return absl::OkStatus(); } diff --git a/src/core/plugin_registry/grpc_plugin_registry.cc b/src/core/plugin_registry/grpc_plugin_registry.cc index ef816a1343a..c0205fa8497 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.cc +++ b/src/core/plugin_registry/grpc_plugin_registry.cc @@ -22,11 +22,11 @@ #include "src/core/handshaker/endpoint_info/endpoint_info_handshaker.h" #include "src/core/handshaker/http_connect/http_connect_handshaker.h" #include "src/core/handshaker/tcp_connect/tcp_connect_handshaker.h" -#include "src/core/lib/channel/server_call_tracer_filter.h" #include "src/core/lib/config/core_configuration.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/server/server.h" +#include "src/core/server/server_call_tracer_filter.h" namespace grpc_event_engine { namespace experimental { diff --git a/src/core/lib/surface/server.cc b/src/core/server/server.cc similarity index 99% rename from src/core/lib/surface/server.cc rename to src/core/server/server.cc index 9540684920e..c43792935af 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/server/server.cc @@ -14,7 +14,7 @@ // limitations under the License. // -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include #include diff --git a/src/core/lib/surface/server.h b/src/core/server/server.h similarity index 99% rename from src/core/lib/surface/server.h rename to src/core/server/server.h index 9eca869af44..486892b14d8 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/server/server.h @@ -14,8 +14,8 @@ // limitations under the License. // -#ifndef GRPC_SRC_CORE_LIB_SURFACE_SERVER_H -#define GRPC_SRC_CORE_LIB_SURFACE_SERVER_H +#ifndef GRPC_SRC_CORE_SERVER_SERVER_H +#define GRPC_SRC_CORE_SERVER_SERVER_H #include #include @@ -65,9 +65,9 @@ #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" +#include "src/core/server/server_interface.h" #define GRPC_ARG_SERVER_MAX_PENDING_REQUESTS "grpc.server.max_pending_requests" #define GRPC_ARG_SERVER_MAX_PENDING_REQUESTS_HARD_LIMIT \ @@ -551,4 +551,4 @@ inline void Server::set_config_fetcher( } // namespace grpc_core -#endif // GRPC_SRC_CORE_LIB_SURFACE_SERVER_H +#endif // GRPC_SRC_CORE_SERVER_SERVER_H diff --git a/src/core/lib/channel/server_call_tracer_filter.cc b/src/core/server/server_call_tracer_filter.cc similarity index 98% rename from src/core/lib/channel/server_call_tracer_filter.cc rename to src/core/server/server_call_tracer_filter.cc index 5effe8f8538..6966b4ccc05 100644 --- a/src/core/lib/channel/server_call_tracer_filter.cc +++ b/src/core/server/server_call_tracer_filter.cc @@ -14,7 +14,7 @@ // limitations under the License. // -#include "src/core/lib/channel/server_call_tracer_filter.h" +#include "src/core/server/server_call_tracer_filter.h" #include #include diff --git a/src/core/lib/channel/server_call_tracer_filter.h b/src/core/server/server_call_tracer_filter.h similarity index 81% rename from src/core/lib/channel/server_call_tracer_filter.h rename to src/core/server/server_call_tracer_filter.h index e34fcb416d0..af554b84aff 100644 --- a/src/core/lib/channel/server_call_tracer_filter.h +++ b/src/core/server/server_call_tracer_filter.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef GRPC_SRC_CORE_LIB_CHANNEL_SERVER_CALL_TRACER_FILTER_H -#define GRPC_SRC_CORE_LIB_CHANNEL_SERVER_CALL_TRACER_FILTER_H +#ifndef GRPC_SRC_CORE_SERVER_SERVER_CALL_TRACER_FILTER_H +#define GRPC_SRC_CORE_SERVER_SERVER_CALL_TRACER_FILTER_H #include @@ -25,4 +25,4 @@ void RegisterServerCallTracerFilter(CoreConfiguration::Builder* builder); } // namespace grpc_core -#endif // GRPC_SRC_CORE_LIB_CHANNEL_SERVER_CALL_TRACER_FILTER_H +#endif // GRPC_SRC_CORE_SERVER_SERVER_CALL_TRACER_FILTER_H diff --git a/src/core/ext/filters/server_config_selector/server_config_selector.h b/src/core/server/server_config_selector.h similarity index 91% rename from src/core/ext/filters/server_config_selector/server_config_selector.h rename to src/core/server/server_config_selector.h index 924aed3778d..dbead559c11 100644 --- a/src/core/ext/filters/server_config_selector/server_config_selector.h +++ b/src/core/server/server_config_selector.h @@ -14,16 +14,16 @@ // limitations under the License. // -#ifndef GRPC_SRC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_H -#define GRPC_SRC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_H - -#include +#ifndef GRPC_SRC_CORE_SERVER_SERVER_CONFIG_SELECTOR_H +#define GRPC_SRC_CORE_SERVER_SERVER_CONFIG_SELECTOR_H #include #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include + #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/dual_ref_counted.h" #include "src/core/lib/gprpp/ref_counted.h" @@ -80,4 +80,4 @@ class ServerConfigSelectorProvider } // namespace grpc_core -#endif // GRPC_SRC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_H +#endif // GRPC_SRC_CORE_SERVER_SERVER_CONFIG_SELECTOR_H diff --git a/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc b/src/core/server/server_config_selector_filter.cc similarity index 97% rename from src/core/ext/filters/server_config_selector/server_config_selector_filter.cc rename to src/core/server/server_config_selector_filter.cc index 0d37c5c646c..8a17c035d3a 100644 --- a/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +++ b/src/core/server/server_config_selector_filter.cc @@ -12,9 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include - -#include "src/core/ext/filters/server_config_selector/server_config_selector_filter.h" +#include "src/core/server/server_config_selector_filter.h" #include #include @@ -26,8 +24,8 @@ #include "absl/types/optional.h" #include +#include -#include "src/core/ext/filters/server_config_selector/server_config_selector.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/context.h" #include "src/core/lib/channel/promise_based_filter.h" @@ -41,6 +39,7 @@ #include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" +#include "src/core/server/server_config_selector.h" #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_call_data.h" diff --git a/src/core/ext/filters/server_config_selector/server_config_selector_filter.h b/src/core/server/server_config_selector_filter.h similarity index 75% rename from src/core/ext/filters/server_config_selector/server_config_selector_filter.h rename to src/core/server/server_config_selector_filter.h index 7e1d5b78296..1cc77358836 100644 --- a/src/core/ext/filters/server_config_selector/server_config_selector_filter.h +++ b/src/core/server/server_config_selector_filter.h @@ -16,8 +16,8 @@ // // -#ifndef GRPC_SRC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_FILTER_H -#define GRPC_SRC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_FILTER_H +#ifndef GRPC_SRC_CORE_SERVER_SERVER_CONFIG_SELECTOR_FILTER_H +#define GRPC_SRC_CORE_SERVER_SERVER_CONFIG_SELECTOR_FILTER_H #include @@ -30,4 +30,4 @@ extern const grpc_channel_filter kServerConfigSelectorFilter; } // namespace grpc_core -#endif // GRPC_SRC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_FILTER_H +#endif // GRPC_SRC_CORE_SERVER_SERVER_CONFIG_SELECTOR_FILTER_H diff --git a/src/core/lib/surface/server_interface.h b/src/core/server/server_interface.h similarity index 88% rename from src/core/lib/surface/server_interface.h rename to src/core/server/server_interface.h index 988cc201910..3cb7b1702ff 100644 --- a/src/core/lib/surface/server_interface.h +++ b/src/core/server/server_interface.h @@ -14,8 +14,8 @@ // limitations under the License. // -#ifndef GRPC_SRC_CORE_LIB_SURFACE_SERVER_INTERFACE_H -#define GRPC_SRC_CORE_LIB_SURFACE_SERVER_INTERFACE_H +#ifndef GRPC_SRC_CORE_SERVER_SERVER_INTERFACE_H +#define GRPC_SRC_CORE_SERVER_SERVER_INTERFACE_H #include @@ -40,4 +40,4 @@ class ServerInterface { } // namespace grpc_core -#endif // GRPC_SRC_CORE_LIB_SURFACE_SERVER_INTERFACE_H +#endif // GRPC_SRC_CORE_SERVER_SERVER_INTERFACE_H diff --git a/src/core/ext/xds/xds_channel_stack_modifier.cc b/src/core/server/xds_channel_stack_modifier.cc similarity index 98% rename from src/core/ext/xds/xds_channel_stack_modifier.cc rename to src/core/server/xds_channel_stack_modifier.cc index eeb1f26809d..2dfa03a1ed2 100644 --- a/src/core/ext/xds/xds_channel_stack_modifier.cc +++ b/src/core/server/xds_channel_stack_modifier.cc @@ -16,7 +16,7 @@ // // -#include "src/core/ext/xds/xds_channel_stack_modifier.h" +#include "src/core/server/xds_channel_stack_modifier.h" #include #include diff --git a/src/core/ext/xds/xds_channel_stack_modifier.h b/src/core/server/xds_channel_stack_modifier.h similarity index 91% rename from src/core/ext/xds/xds_channel_stack_modifier.h rename to src/core/server/xds_channel_stack_modifier.h index 740c2aefc5d..78dc1db0b2c 100644 --- a/src/core/ext/xds/xds_channel_stack_modifier.h +++ b/src/core/server/xds_channel_stack_modifier.h @@ -16,8 +16,8 @@ // // -#ifndef GRPC_SRC_CORE_EXT_XDS_XDS_CHANNEL_STACK_MODIFIER_H -#define GRPC_SRC_CORE_EXT_XDS_XDS_CHANNEL_STACK_MODIFIER_H +#ifndef GRPC_SRC_CORE_SERVER_XDS_CHANNEL_STACK_MODIFIER_H +#define GRPC_SRC_CORE_SERVER_XDS_CHANNEL_STACK_MODIFIER_H #include #include @@ -60,4 +60,4 @@ class XdsChannelStackModifier final } // namespace grpc_core -#endif // GRPC_SRC_CORE_EXT_XDS_XDS_CHANNEL_STACK_MODIFIER_H +#endif // GRPC_SRC_CORE_SERVER_XDS_CHANNEL_STACK_MODIFIER_H diff --git a/src/core/ext/xds/xds_server_config_fetcher.cc b/src/core/server/xds_server_config_fetcher.cc similarity index 99% rename from src/core/ext/xds/xds_server_config_fetcher.cc rename to src/core/server/xds_server_config_fetcher.cc index 76b612f987b..edb46e9bd3d 100644 --- a/src/core/ext/xds/xds_server_config_fetcher.cc +++ b/src/core/server/xds_server_config_fetcher.cc @@ -47,12 +47,9 @@ #include #include -#include "src/core/ext/filters/server_config_selector/server_config_selector.h" -#include "src/core/ext/filters/server_config_selector/server_config_selector_filter.h" #include "src/core/ext/xds/certificate_provider_store.h" #include "src/core/ext/xds/xds_bootstrap_grpc.h" #include "src/core/ext/xds/xds_certificate_provider.h" -#include "src/core/ext/xds/xds_channel_stack_modifier.h" #include "src/core/ext/xds/xds_client.h" #include "src/core/ext/xds/xds_client_grpc.h" #include "src/core/ext/xds/xds_common_types.h" @@ -84,9 +81,12 @@ #include "src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h" #include "src/core/lib/security/credentials/xds/xds_credentials.h" #include "src/core/lib/surface/api_trace.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/uri/uri_parser.h" +#include "src/core/server/server.h" +#include "src/core/server/server_config_selector.h" +#include "src/core/server/server_config_selector_filter.h" +#include "src/core/server/xds_channel_stack_modifier.h" #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_impl.h" diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index cd3357fd8a3..ff3c3c7bdb3 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -74,7 +74,7 @@ #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/resource_quota/api.h" #include "src/core/lib/surface/completion_queue.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "src/cpp/client/create_channel_internal.h" #include "src/cpp/server/external_connection_acceptor_impl.h" #include "src/cpp/server/health/default_health_check_service.h" diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py index 273d97c01f6..406f5651516 100644 --- a/src/python/grpcio/grpc/__init__.py +++ b/src/python/grpcio/grpc/__init__.py @@ -1454,6 +1454,22 @@ class Server(abc.ABC): """ raise NotImplementedError() + @abc.abstractmethod + def add_registered_method_handlers(self, service_name, method_handlers): + """Registers GenericRpcHandlers with this Server. + + This method is only safe to call before the server is started. + + If the same method have both generic and registered handler, + registered handler will take precedence. + + Args: + service_name: The service name. + method_handlers: A dictionary that maps method names to corresponding + RpcMethodHandler. + """ + raise NotImplementedError() + @abc.abstractmethod def add_insecure_port(self, address): """Opens an insecure port for accepting RPCs. diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi index 96d03e181b9..86a98b6803a 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pxd.pxi @@ -28,6 +28,7 @@ cdef class _CallState: cdef set due # call_tracer_capsule should have type of grpc._observability.ClientCallTracerCapsule cdef object call_tracer_capsule + cdef void maybe_save_registered_method(self, bytes method_name) except * cdef void maybe_set_client_call_tracer_on_call(self, bytes method_name, bytes target) except * cdef void maybe_delete_call_tracer(self) except * diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi index dde3b166789..564877736c0 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi @@ -77,18 +77,22 @@ cdef class _CallState: return _observability.delete_call_tracer(self.call_tracer_capsule) + cdef void maybe_save_registered_method(self, bytes method_name) except *: + with _observability.get_plugin() as plugin: + if plugin and plugin.observability_enabled: + plugin.save_registered_method(method_name) + cdef void maybe_set_client_call_tracer_on_call(self, bytes method_name, bytes target) except *: # TODO(xuanwn): use channel args to exclude those metrics. for exclude_prefix in _observability._SERVICES_TO_EXCLUDE: if exclude_prefix in method_name: return with _observability.get_plugin() as plugin: - if not (plugin and plugin.observability_enabled): - return - capsule = plugin.create_client_call_tracer(method_name, target) - capsule_ptr = cpython.PyCapsule_GetPointer(capsule, CLIENT_CALL_TRACER) - _set_call_tracer(self.c_call, capsule_ptr) - self.call_tracer_capsule = capsule + if plugin and plugin.observability_enabled: + capsule = plugin.create_client_call_tracer(method_name, target) + capsule_ptr = cpython.PyCapsule_GetPointer(capsule, CLIENT_CALL_TRACER) + _set_call_tracer(self.c_call, capsule_ptr) + self.call_tracer_capsule = capsule cdef class _ChannelState: @@ -268,6 +272,7 @@ cdef void _call( channel_state.c_channel, NULL, flags, c_completion_queue, cpython.PyLong_AsVoidPtr(registered_call_handle), _timespec_from_time(deadline), NULL) + call_state.maybe_save_registered_method(method) else: call_state.c_call = grpc_channel_create_call( channel_state.c_channel, NULL, flags, diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index ce9a1d85e6b..13c7b41ad98 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -457,10 +457,24 @@ cdef extern from "grpc/grpc.h": grpc_metadata_array *request_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new) nogil + grpc_call_error grpc_server_request_registered_call( + grpc_server* server, void* registered_method, grpc_call** call, + gpr_timespec* deadline, grpc_metadata_array* request_metadata, + grpc_byte_buffer** optional_payload, + grpc_completion_queue* cq_bound_to_call, + grpc_completion_queue* cq_for_notification, void* tag_new) nogil void grpc_server_register_completion_queue(grpc_server *server, grpc_completion_queue *cq, void *reserved) nogil + ctypedef enum grpc_server_register_method_payload_handling: + GRPC_SRM_PAYLOAD_NONE + GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER + + void *grpc_server_register_method(grpc_server* server, const char* method, + const char* host, grpc_server_register_method_payload_handling payload_handling, + uint32_t flags) nogil + ctypedef struct grpc_server_config_fetcher: pass diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi index b89ed99d97b..0480bf2b6a3 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi @@ -24,6 +24,21 @@ cdef class Server: # TODO(https://github.com/grpc/grpc/issues/15662): Elide this. cdef list references cdef list registered_completion_queues + cdef dict registered_methods # Mapping[bytes, RegisteredMethod] cdef _c_shutdown(self, CompletionQueue queue, tag) + cdef _c_request_unregistered_call(self, + _RequestCallTag request_call_tag, + CompletionQueue call_queue, + CompletionQueue server_queue) + cdef _c_request_registered_call(self, + _RequestCallTag request_call_tag, + CompletionQueue call_queue, + CompletionQueue server_queue, + bytes method) cdef notify_shutdown_complete(self) + +cdef class RegisteredMethod: + + cdef void *c_registered_method + cdef bytes method diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi index 29dabec61d9..017894b7239 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi @@ -13,6 +13,28 @@ # limitations under the License. +cdef class RegisteredMethod: + + def __cinit__(self, bytes method, uintptr_t server): + self.method = method + cpython.Py_INCREF(self.method) + cdef const char *c_method = self.method + cdef grpc_server *c_server = server + # TODO(xuanwn): Consider use GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER for unary request + # as optimization. + # Note that in stubs method is not bound to any host, thus we set host as NULL. + with nogil: + self.c_registered_method = grpc_server_register_method(c_server, + c_method, NULL, GRPC_SRM_PAYLOAD_NONE, 0) + + def __dealloc__(self): + # c_registered_method should have the same lifetime as Cython Server since the method + # maybe called at any time during the server's lifetime. + # Since all RegisteredMethod belongs to Cython Server, they'll be destructed at the same + # time with Cython Server, at which point it's safe to assume core no longer holds any reference. + cpython.Py_DECREF(self.method) + + cdef class Server: def __cinit__(self, object arguments, bint xds): @@ -23,6 +45,7 @@ cdef class Server: self.is_shutting_down = False self.is_shutdown = False self.c_server = NULL + self.registered_methods = {} # Mapping[bytes, RegisteredMethod] cdef _ChannelArgs channel_args = _ChannelArgs(arguments) self.c_server = grpc_server_create(channel_args.c_args(), NULL) cdef grpc_server_xds_status_notifier notifier @@ -41,14 +64,62 @@ cdef class Server: if server_queue not in self.registered_completion_queues: raise ValueError("server_queue must be a registered completion queue") cdef _RequestCallTag request_call_tag = _RequestCallTag(tag) + return self._c_request_unregistered_call(request_call_tag, call_queue, server_queue) + + def request_registered_call( + self, CompletionQueue call_queue not None, + CompletionQueue server_queue not None, + str method not None, + tag): + if not self.is_started or self.is_shutting_down: + raise ValueError("server must be started and not shutting down") + if server_queue not in self.registered_completion_queues: + raise ValueError("server_queue must be a registered completion queue") + cdef _RequestCallTag request_call_tag = _RequestCallTag(tag) + method_bytes = str_to_bytes(method) + return self._c_request_registered_call(request_call_tag, call_queue, server_queue, method_bytes) + + cdef _c_request_registered_call(self, + _RequestCallTag request_call_tag, + CompletionQueue call_queue, + CompletionQueue server_queue, + bytes method): + request_call_tag.prepare() + cpython.Py_INCREF(request_call_tag) + cdef cpython.PyObject *c_request_call_tag = request_call_tag + cdef RegisteredMethod registered_method = self.registered_methods[method] + # optional_payload is set to NULL because we use GRPC_SRM_PAYLOAD_NONE for all method. + cdef grpc_call_error c_call_error = GRPC_CALL_OK + with nogil: + c_call_error = grpc_server_request_registered_call( + self.c_server, registered_method.c_registered_method, &request_call_tag.call.c_call, + &request_call_tag.call_details.c_details.deadline, + &request_call_tag.c_invocation_metadata, + NULL, + call_queue.c_completion_queue, server_queue.c_completion_queue, + c_request_call_tag) + if c_call_error != GRPC_CALL_OK: + raise InternalError("Error in grpc_server_request_registered_call: %s" % grpc_call_error_to_string(self.c_call_error).decode()) + return c_call_error + + cdef _c_request_unregistered_call(self, + _RequestCallTag request_call_tag, + CompletionQueue call_queue, + CompletionQueue server_queue): request_call_tag.prepare() cpython.Py_INCREF(request_call_tag) - return grpc_server_request_call( - self.c_server, &request_call_tag.call.c_call, - &request_call_tag.call_details.c_details, - &request_call_tag.c_invocation_metadata, - call_queue.c_completion_queue, server_queue.c_completion_queue, - request_call_tag) + cdef cpython.PyObject *c_request_call_tag = request_call_tag + cdef grpc_call_error c_call_error = GRPC_CALL_OK + with nogil: + c_call_error = grpc_server_request_call( + self.c_server, &request_call_tag.call.c_call, + &request_call_tag.call_details.c_details, + &request_call_tag.c_invocation_metadata, + call_queue.c_completion_queue, server_queue.c_completion_queue, + c_request_call_tag) + if c_call_error != GRPC_CALL_OK: + raise InternalError("Error in grpc_server_request_call: %s" % grpc_call_error_to_string(self.c_call_error).decode()) + return c_call_error def register_completion_queue( self, CompletionQueue queue not None): @@ -59,6 +130,14 @@ cdef class Server: self.c_server, queue.c_completion_queue, NULL) self.registered_completion_queues.append(queue) + def register_method(self, str fully_qualified_method): + method_bytes = str_to_bytes(fully_qualified_method) + if method_bytes in self.registered_methods.keys(): + # Ignore already registered method + return + cdef RegisteredMethod registered_method = RegisteredMethod(method_bytes, self.c_server) + self.registered_methods[method_bytes] = registered_method + def start(self, backup_queue=True): """Start the Cython gRPC Server. diff --git a/src/python/grpcio/grpc/_observability.py b/src/python/grpcio/grpc/_observability.py index 3b365481922..e18dbc1dd0f 100644 --- a/src/python/grpcio/grpc/_observability.py +++ b/src/python/grpcio/grpc/_observability.py @@ -55,6 +55,8 @@ class ObservabilityPlugin( Attributes: _stats_enabled: A bool indicates whether tracing is enabled. _tracing_enabled: A bool indicates whether stats(metrics) is enabled. + _registered_methods: A set which stores the registered method names in + bytes. """ _tracing_enabled: bool = False @@ -76,6 +78,7 @@ class ObservabilityPlugin( Args: method_name: The method name of the call in byte format. target: The channel target of the call in byte format. + registered_method: Wether this method is pre-registered. Returns: A PyCapsule which stores a ClientCallTracer object. @@ -174,6 +177,17 @@ class ObservabilityPlugin( """ self._stats_enabled = enable + def save_registered_method(self, method_name: bytes) -> None: + """Saves the method name to registered_method list. + + When exporting metrics, method name for unregistered methods will be replaced + with 'other' by default. + + Args: + method_name: The method name in bytes. + """ + raise NotImplementedError() + @property def tracing_enabled(self) -> bool: return self._tracing_enabled @@ -259,9 +273,8 @@ def delete_call_tracer(client_call_tracer_capsule: Any) -> None: client_call_tracer_capsule: A PyCapsule which stores a ClientCallTracer object. """ with get_plugin() as plugin: - if not (plugin and plugin.observability_enabled): - return - plugin.delete_client_call_tracer(client_call_tracer_capsule) + if plugin and plugin.observability_enabled: + plugin.delete_client_call_tracer(client_call_tracer_capsule) def maybe_record_rpc_latency(state: "_channel._RPCState") -> None: diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 4ea1d5e4597..ade13718091 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -15,6 +15,7 @@ from __future__ import annotations +import abc import collections from concurrent import futures import contextvars @@ -26,6 +27,7 @@ import traceback from typing import ( Any, Callable, + Dict, Iterable, Iterator, List, @@ -121,6 +123,58 @@ class _HandlerCallDetails( pass +class _Method(abc.ABC): + @abc.abstractmethod + def name(self) -> Optional[str]: + raise NotImplementedError() + + @abc.abstractmethod + def handler( + self, handler_call_details: _HandlerCallDetails + ) -> Optional[grpc.RpcMethodHandler]: + raise NotImplementedError() + + +class _RegisteredMethod(_Method): + def __init__( + self, + name: str, + registered_handler: Optional[grpc.RpcMethodHandler], + ): + self._name = name + self._registered_handler = registered_handler + + def name(self) -> Optional[str]: + return self._name + + def handler( + self, handler_call_details: _HandlerCallDetails + ) -> Optional[grpc.RpcMethodHandler]: + return self._registered_handler + + +class _GenericMethod(_Method): + def __init__( + self, + generic_handlers: List[grpc.GenericRpcHandler], + ): + self._generic_handlers = generic_handlers + + def name(self) -> Optional[str]: + return None + + def handler( + self, handler_call_details: _HandlerCallDetails + ) -> Optional[grpc.RpcMethodHandler]: + # If the same method have both generic and registered handler, + # registered handler will take precedence. + for generic_handler in self._generic_handlers: + method_handler = generic_handler.service(handler_call_details) + if method_handler is not None: + return method_handler + return None + + class _RPCState(object): context: contextvars.Context condition: threading.Condition @@ -932,20 +986,20 @@ def _handle_stream_stream( def _find_method_handler( rpc_event: cygrpc.BaseEvent, state: _RPCState, - generic_handlers: List[grpc.GenericRpcHandler], + method_with_handler: _Method, interceptor_pipeline: Optional[_interceptor._ServicePipeline], ) -> Optional[grpc.RpcMethodHandler]: def query_handlers( handler_call_details: _HandlerCallDetails, ) -> Optional[grpc.RpcMethodHandler]: - for generic_handler in generic_handlers: - method_handler = generic_handler.service(handler_call_details) - if method_handler is not None: - return method_handler - return None + return method_with_handler.handler(handler_call_details) + + method_name = method_with_handler.name() + if not method_name: + method_name = _common.decode(rpc_event.call_details.method) handler_call_details = _HandlerCallDetails( - _common.decode(rpc_event.call_details.method), + method_name, rpc_event.invocation_metadata, ) @@ -1013,18 +1067,32 @@ def _handle_with_method_handler( def _handle_call( rpc_event: cygrpc.BaseEvent, - generic_handlers: List[grpc.GenericRpcHandler], + method_with_handler: _Method, interceptor_pipeline: Optional[_interceptor._ServicePipeline], thread_pool: futures.ThreadPoolExecutor, concurrency_exceeded: bool, ) -> Tuple[Optional[_RPCState], Optional[futures.Future]]: + """Handles RPC based on provided handlers. + + When receiving a call event from Core, registered method will have it's + name as tag, we pass the tag as registered_method_name to this method, + then we can find the handler in registered_method_handlers based on + the method name. + + For call event with unregistered method, the method name will be included + in rpc_event.call_details.method and we need to query the generics handlers + to find the actual handler. + """ if not rpc_event.success: return None, None - if rpc_event.call_details.method is not None: + if rpc_event.call_details.method or method_with_handler.name(): rpc_state = _RPCState() try: method_handler = _find_method_handler( - rpc_event, rpc_state, generic_handlers, interceptor_pipeline + rpc_event, + rpc_state, + method_with_handler, + interceptor_pipeline, ) except Exception as exception: # pylint: disable=broad-except details = "Exception servicing handler: {}".format(exception) @@ -1075,6 +1143,7 @@ class _ServerState(object): completion_queue: cygrpc.CompletionQueue server: cygrpc.Server generic_handlers: List[grpc.GenericRpcHandler] + registered_method_handlers: Dict[str, grpc.RpcMethodHandler] interceptor_pipeline: Optional[_interceptor._ServicePipeline] thread_pool: futures.ThreadPoolExecutor stage: _ServerStage @@ -1107,6 +1176,7 @@ class _ServerState(object): self.shutdown_events = [self.termination_event] self.maximum_concurrent_rpcs = maximum_concurrent_rpcs self.active_rpc_count = 0 + self.registered_method_handlers = {} # TODO(https://github.com/grpc/grpc/issues/6597): eliminate these fields. self.rpc_states = set() @@ -1123,6 +1193,13 @@ def _add_generic_handlers( state.generic_handlers.extend(generic_handlers) +def _add_registered_method_handlers( + state: _ServerState, method_handlers: Dict[str, grpc.RpcMethodHandler] +) -> None: + with state.lock: + state.registered_method_handlers.update(method_handlers) + + def _add_insecure_port(state: _ServerState, address: bytes) -> int: with state.lock: return state.server.add_http2_port(address) @@ -1146,6 +1223,17 @@ def _request_call(state: _ServerState) -> None: state.due.add(_REQUEST_CALL_TAG) +def _request_registered_call(state: _ServerState, method: str) -> None: + registered_call_tag = method + state.server.request_registered_call( + state.completion_queue, + state.completion_queue, + method, + registered_call_tag, + ) + state.due.add(registered_call_tag) + + # TODO(https://github.com/grpc/grpc/issues/6597): delete this function. def _stop_serving(state: _ServerState) -> bool: if not state.rpc_states and not state.due: @@ -1163,6 +1251,7 @@ def _on_call_completed(state: _ServerState) -> None: state.active_rpc_count -= 1 +# pylint: disable=too-many-branches def _process_event_and_continue( state: _ServerState, event: cygrpc.BaseEvent ) -> bool: @@ -1172,16 +1261,32 @@ def _process_event_and_continue( state.due.remove(_SHUTDOWN_TAG) if _stop_serving(state): should_continue = False - elif event.tag is _REQUEST_CALL_TAG: + elif ( + event.tag is _REQUEST_CALL_TAG + or event.tag in state.registered_method_handlers.keys() + ): + registered_method_name = None + if event.tag in state.registered_method_handlers.keys(): + registered_method_name = event.tag + method_with_handler = _RegisteredMethod( + registered_method_name, + state.registered_method_handlers.get( + registered_method_name, None + ), + ) + else: + method_with_handler = _GenericMethod( + state.generic_handlers, + ) with state.lock: - state.due.remove(_REQUEST_CALL_TAG) + state.due.remove(event.tag) concurrency_exceeded = ( state.maximum_concurrent_rpcs is not None and state.active_rpc_count >= state.maximum_concurrent_rpcs ) rpc_state, rpc_future = _handle_call( event, - state.generic_handlers, + method_with_handler, state.interceptor_pipeline, state.thread_pool, concurrency_exceeded, @@ -1194,7 +1299,13 @@ def _process_event_and_continue( lambda unused_future: _on_call_completed(state) ) if state.stage is _ServerStage.STARTED: - _request_call(state) + if ( + registered_method_name + in state.registered_method_handlers.keys() + ): + _request_registered_call(state, registered_method_name) + else: + _request_call(state) elif _stop_serving(state): should_continue = False else: @@ -1267,6 +1378,10 @@ def _start(state: _ServerState) -> None: raise ValueError("Cannot start already-started server!") state.server.start() state.stage = _ServerStage.STARTED + # Request a call for each registered method so we can handle any of them. + for method in state.registered_method_handlers.keys(): + _request_registered_call(state, method) + # Also request a call for non-registered method. _request_call(state) thread = threading.Thread(target=_serve, args=(state,)) thread.daemon = True @@ -1318,6 +1433,7 @@ class _Server(grpc.Server): thread_pool, maximum_concurrent_rpcs, ) + self._cy_server = server def add_generic_rpc_handlers( self, generic_rpc_handlers: Iterable[grpc.GenericRpcHandler] @@ -1325,6 +1441,25 @@ class _Server(grpc.Server): _validate_generic_rpc_handlers(generic_rpc_handlers) _add_generic_handlers(self._state, generic_rpc_handlers) + def add_registered_method_handlers( + self, + service_name: str, + method_handlers: Dict[str, grpc.RpcMethodHandler], + ) -> None: + # Can't register method once server started. + with self._state.lock: + if self._state.stage is _ServerStage.STARTED: + return + + # TODO(xuanwn): We should validate method_handlers first. + method_to_handlers = { + _common.fully_qualified_method(service_name, method): method_handler + for method, method_handler in method_handlers.items() + } + for fully_qualified_method in method_to_handlers.keys(): + self._cy_server.register_method(fully_qualified_method) + _add_registered_method_handlers(self._state, method_to_handlers) + def add_insecure_port(self, address: str) -> int: return _common.validate_port_binding_result( address, _add_insecure_port(self._state, _common.encode(address)) diff --git a/src/python/grpcio/grpc/aio/_base_server.py b/src/python/grpcio/grpc/aio/_base_server.py index 07fd84901ff..9563a7875bc 100644 --- a/src/python/grpcio/grpc/aio/_base_server.py +++ b/src/python/grpcio/grpc/aio/_base_server.py @@ -136,6 +136,19 @@ class Server(abc.ABC): A bool indicates if the operation times out. """ + @abc.abstractmethod + def add_registered_method_handlers(self, service_name, method_handlers): + """Registers GenericRpcHandlers with this Server. + + This method is only safe to call before the server is started. + + Args: + service_name: The service name. + method_handlers: A dictionary that maps method names to corresponding + RpcMethodHandler. + """ + raise NotImplementedError() + # pylint: disable=too-many-public-methods class ServicerContext(Generic[RequestType, ResponseType], abc.ABC): diff --git a/src/python/grpcio/grpc/aio/_server.py b/src/python/grpcio/grpc/aio/_server.py index 730b5262fda..0eee6b1470e 100644 --- a/src/python/grpcio/grpc/aio/_server.py +++ b/src/python/grpcio/grpc/aio/_server.py @@ -14,7 +14,7 @@ """Server-side implementation of gRPC Asyncio Python.""" from concurrent.futures import Executor -from typing import Any, Optional, Sequence +from typing import Any, Dict, Optional, Sequence import grpc from grpc import _common @@ -79,6 +79,14 @@ class Server(_base_server.Server): """ self._server.add_generic_rpc_handlers(generic_rpc_handlers) + def add_registered_method_handlers( + self, + service_name: str, + method_handlers: Dict[str, grpc.RpcMethodHandler], + ) -> None: + # TODO(xuanwn): Implement this for AsyncIO. + pass + def add_insecure_port(self, address: str) -> int: """Opens an insecure port for accepting RPCs. diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 06d78ce6bd1..ba757f7cd54 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -48,7 +48,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/message_size/message_size_filter.cc', 'src/core/ext/filters/rbac/rbac_filter.cc', 'src/core/ext/filters/rbac/rbac_service_config_parser.cc', - 'src/core/ext/filters/server_config_selector/server_config_selector_filter.cc', 'src/core/ext/filters/stateful_session/stateful_session_filter.cc', 'src/core/ext/filters/stateful_session/stateful_session_service_config_parser.cc', 'src/core/ext/gcp/metadata_query.cc', @@ -411,7 +410,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/xds/xds_bootstrap.cc', 'src/core/ext/xds/xds_bootstrap_grpc.cc', 'src/core/ext/xds/xds_certificate_provider.cc', - 'src/core/ext/xds/xds_channel_stack_modifier.cc', 'src/core/ext/xds/xds_client.cc', 'src/core/ext/xds/xds_client_grpc.cc', 'src/core/ext/xds/xds_client_stats.cc', @@ -428,7 +426,6 @@ CORE_SOURCE_FILES = [ 'src/core/ext/xds/xds_listener.cc', 'src/core/ext/xds/xds_route_config.cc', 'src/core/ext/xds/xds_routing.cc', - 'src/core/ext/xds/xds_server_config_fetcher.cc', 'src/core/ext/xds/xds_transport_grpc.cc', 'src/core/handshaker/endpoint_info/endpoint_info_handshaker.cc', 'src/core/handshaker/handshaker.cc', @@ -454,7 +451,6 @@ CORE_SOURCE_FILES = [ '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', @@ -753,7 +749,6 @@ CORE_SOURCE_FILES = [ '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', 'src/core/lib/surface/version.cc', 'src/core/lib/surface/wait_for_cq_end_op.cc', @@ -825,6 +820,11 @@ CORE_SOURCE_FILES = [ 'src/core/resolver/xds/xds_dependency_manager.cc', 'src/core/resolver/xds/xds_resolver.cc', 'src/core/resolver/xds/xds_resolver_trace.cc', + 'src/core/server/server.cc', + 'src/core/server/server_call_tracer_filter.cc', + 'src/core/server/server_config_selector_filter.cc', + 'src/core/server/xds_channel_stack_modifier.cc', + 'src/core/server/xds_server_config_fetcher.cc', 'src/core/service_config/service_config_channel_arg_filter.cc', 'src/core/service_config/service_config_impl.cc', 'src/core/service_config/service_config_parser.cc', diff --git a/src/python/grpcio_observability/grpc_observability/BUILD.bazel b/src/python/grpcio_observability/grpc_observability/BUILD.bazel index 0ae6bb46db4..3447bdaf1f2 100644 --- a/src/python/grpcio_observability/grpc_observability/BUILD.bazel +++ b/src/python/grpcio_observability/grpc_observability/BUILD.bazel @@ -22,7 +22,7 @@ cc_library( srcs = [ "client_call_tracer.cc", "observability_util.cc", - "python_census_context.cc", + "python_observability_context.cc", "rpc_encoding.cc", "sampler.cc", "server_call_tracer.cc", @@ -31,7 +31,7 @@ cc_library( "client_call_tracer.h", "constants.h", "observability_util.h", - "python_census_context.h", + "python_observability_context.h", "rpc_encoding.h", "sampler.h", "server_call_tracer.h", diff --git a/src/python/grpcio_observability/grpc_observability/_cyobservability.pxd b/src/python/grpcio_observability/grpc_observability/_cyobservability.pxd index 93a077b8679..c0c2fb25c61 100644 --- a/src/python/grpcio_observability/grpc_observability/_cyobservability.pxd +++ b/src/python/grpcio_observability/grpc_observability/_cyobservability.pxd @@ -38,7 +38,7 @@ cdef extern from "src/core/lib/channel/call_tracer.h" namespace "grpc_core": cdef cppclass ClientCallTracer: pass -cdef extern from "python_census_context.h" namespace "grpc_observability": +cdef extern from "python_observability_context.h" namespace "grpc_observability": cdef void EnablePythonCensusStats(bint enable) nogil cdef void EnablePythonCensusTracing(bint enable) nogil @@ -58,6 +58,7 @@ cdef extern from "python_census_context.h" namespace "grpc_observability": cMetricsName name MeasurementType type MeasurementValue value + bint registered_method ctypedef struct SpanCensusData: string name @@ -78,7 +79,8 @@ cdef extern from "observability_util.h" namespace "grpc_observability": cdef void* CreateClientCallTracer(const char* method, const char* target, const char* trace_id, - const char* parent_span_id) except + + const char* parent_span_id, + bint registered_method) except + cdef void* CreateServerCallTracerFactory() except + cdef queue[NativeCensusData]* g_census_data_buffer cdef void AwaitNextBatchLocked(unique_lock[mutex]&, int) nogil @@ -147,6 +149,7 @@ cdef extern from "constants.h" namespace "grpc_observability": string kClientMethod string kClientTarget string kClientStatus + string kRegisteredMethod cdef extern from "sampler.h" namespace "grpc_observability": cdef cppclass ProbabilitySampler: diff --git a/src/python/grpcio_observability/grpc_observability/_cyobservability.pyx b/src/python/grpcio_observability/grpc_observability/_cyobservability.pyx index 236601770ee..143d24731a7 100644 --- a/src/python/grpcio_observability/grpc_observability/_cyobservability.pyx +++ b/src/python/grpcio_observability/grpc_observability/_cyobservability.pyx @@ -115,7 +115,8 @@ def activate_stats() -> None: EnablePythonCensusStats(True); -def create_client_call_tracer(bytes method_name, bytes target, bytes trace_id, +def create_client_call_tracer(bytes method_name, bytes target, + bytes trace_id, bint registered_method, bytes parent_span_id=b'') -> cpython.PyObject: """Create a ClientCallTracer and save to PyCapsule. @@ -126,7 +127,7 @@ def create_client_call_tracer(bytes method_name, bytes target, bytes trace_id, cdef char* c_trace_id = cpython.PyBytes_AsString(trace_id) cdef char* c_parent_span_id = cpython.PyBytes_AsString(parent_span_id) - cdef void* call_tracer = CreateClientCallTracer(c_method, c_target, c_trace_id, c_parent_span_id) + cdef void* call_tracer = CreateClientCallTracer(c_method, c_target, c_trace_id, c_parent_span_id, registered_method) capsule = cpython.PyCapsule_New(call_tracer, CLIENT_CALL_TRACER, NULL) return capsule @@ -158,7 +159,7 @@ def _c_label_to_labels(vector[Label] c_labels) -> Mapping[str, str]: def _c_measurement_to_measurement(object measurement - ) -> Mapping[str, Union[enum, Mapping[str, Union[float, int]]]]: + ) -> Mapping[str, Union[enum, Mapping[str, Union[float, int], bool]]]: """Convert Cython Measurement to Python measurement. Args: @@ -169,6 +170,7 @@ def _c_measurement_to_measurement(object measurement A mapping object with keys and values as following: name -> cMetricsName type -> MeasurementType + registered_method -> bool value -> {value_double: float | value_int: int} """ measurement: Measurement @@ -176,6 +178,7 @@ def _c_measurement_to_measurement(object measurement py_measurement = {} py_measurement['name'] = measurement['name'] py_measurement['type'] = measurement['type'] + py_measurement['registered_method'] = measurement['registered_method'] if measurement['type'] == kMeasurementDouble: py_measurement['value'] = {'value_double': measurement['value']['value_double']} else: @@ -223,10 +226,12 @@ def _get_stats_data(object measurement, object labels) -> _observability.StatsDa if measurement['type'] == kMeasurementDouble: py_stat = _observability.StatsData(name=metric_name, measure_double=True, value_float=measurement['value']['value_double'], + registered_method=measurement['registered_method'], labels=labels) else: py_stat = _observability.StatsData(name=metric_name, measure_double=False, value_int=measurement['value']['value_int'], + registered_method=measurement['registered_method'], labels=labels) return py_stat @@ -248,13 +253,15 @@ def _get_tracing_data(SpanCensusData span_data, vector[Label] span_labels, span_annotations = py_span_annotations) -def _record_rpc_latency(object exporter, str method, str target, float rpc_latency, str status_code) -> None: +def _record_rpc_latency(object exporter, str method, str target, + float rpc_latency, str status_code, bint registered_method) -> None: exporter: _observability.Exporter measurement = {} measurement['name'] = kRpcClientApiLatencyMeasureName measurement['type'] = kMeasurementDouble measurement['value'] = {'value_double': rpc_latency} + measurement['registered_method'] = registered_method labels = {} labels[_decode(kClientMethod)] = method.strip("/") diff --git a/src/python/grpcio_observability/grpc_observability/_gcp_observability.py b/src/python/grpcio_observability/grpc_observability/_gcp_observability.py index 797c4797d01..5e4b6610e21 100644 --- a/src/python/grpcio_observability/grpc_observability/_gcp_observability.py +++ b/src/python/grpcio_observability/grpc_observability/_gcp_observability.py @@ -15,7 +15,7 @@ from __future__ import annotations import logging import time -from typing import Any +from typing import Any, Set import grpc @@ -69,6 +69,7 @@ class GCPOpenCensusObservability(grpc._observability.ObservabilityPlugin): config: _observability_config.GcpObservabilityConfig exporter: "grpc_observability.Exporter" + _registered_method: Set[bytes] def __init__(self, exporter: "grpc_observability.Exporter" = None): self.exporter = None @@ -122,7 +123,10 @@ class GCPOpenCensusObservability(grpc._observability.ObservabilityPlugin): ) -> ClientCallTracerCapsule: trace_id = b"TRACE_ID" capsule = _cyobservability.create_client_call_tracer( - method_name, target, trace_id + method_name, + target, + trace_id, + method_name in self._registered_methods, ) return capsule @@ -151,5 +155,13 @@ class GCPOpenCensusObservability(grpc._observability.ObservabilityPlugin): ) -> None: status_code = GRPC_STATUS_CODE_TO_STRING.get(status_code, "UNKNOWN") _cyobservability._record_rpc_latency( - self.exporter, method, target, rpc_latency, status_code + self.exporter, + method, + target, + rpc_latency, + status_code, + method in self._registered_methods, ) + + def save_registered_method(self, method_name: bytes) -> None: + self._registered_methods.add(method_name) diff --git a/src/python/grpcio_observability/grpc_observability/_observability.py b/src/python/grpcio_observability/grpc_observability/_observability.py index 1f0ea328f3f..352a25c69d7 100644 --- a/src/python/grpcio_observability/grpc_observability/_observability.py +++ b/src/python/grpcio_observability/grpc_observability/_observability.py @@ -52,6 +52,8 @@ class StatsData: value. value_int: The actual metric value if measure_double is False. value_float: The actual metric value if measure_double is True. + registered_method: Whether the method in this data is a registered method + in stubs. labels: A dictionary that maps label tags associated with this metric to corresponding label value. """ @@ -60,6 +62,7 @@ class StatsData: measure_double: bool value_int: int = 0 value_float: float = 0.0 + registered_method: bool = False labels: Mapping[str, str] = field(default_factory=dict) diff --git a/src/python/grpcio_observability/grpc_observability/_open_telemetry_observability.py b/src/python/grpcio_observability/grpc_observability/_open_telemetry_observability.py index 7846c5568f5..24eee8e062f 100644 --- a/src/python/grpcio_observability/grpc_observability/_open_telemetry_observability.py +++ b/src/python/grpcio_observability/grpc_observability/_open_telemetry_observability.py @@ -15,7 +15,7 @@ import logging import threading import time -from typing import Any, Dict, Iterable, List, Optional, Union +from typing import Any, Dict, Iterable, List, Optional, Set, Union import grpc @@ -224,6 +224,7 @@ class OpenTelemetryObservability(grpc._observability.ObservabilityPlugin): """ exporter: "grpc_observability.Exporter" + _registered_method: Set[bytes] def __init__( self, @@ -231,6 +232,7 @@ class OpenTelemetryObservability(grpc._observability.ObservabilityPlugin): plugins: Optional[Iterable[_OpenTelemetryPlugin]], ): self.exporter = _OpenTelemetryExporterDelegator(plugins) + self._registered_methods = set() def observability_init(self): try: @@ -266,8 +268,11 @@ class OpenTelemetryObservability(grpc._observability.ObservabilityPlugin): self, method_name: bytes, target: bytes ) -> ClientCallTracerCapsule: trace_id = b"TRACE_ID" + registered_method = False + if method_name in self._registered_methods: + registered_method = True capsule = _cyobservability.create_client_call_tracer( - method_name, target, trace_id + method_name, target, trace_id, registered_method ) return capsule @@ -295,10 +300,22 @@ class OpenTelemetryObservability(grpc._observability.ObservabilityPlugin): status_code: grpc.StatusCode, ) -> None: status_code = GRPC_STATUS_CODE_TO_STRING.get(status_code, "UNKNOWN") + registered_method = False + encoded_method = method.encode("utf8") + if encoded_method in self._registered_methods: + registered_method = True _cyobservability._record_rpc_latency( - self.exporter, method, target, rpc_latency, status_code + self.exporter, + method, + target, + rpc_latency, + status_code, + registered_method, ) + def save_registered_method(self, method_name: bytes) -> None: + self._registered_methods.add(method_name) + def _start_open_telemetry_observability( otel_o11y: OpenTelemetryObservability, diff --git a/src/python/grpcio_observability/grpc_observability/client_call_tracer.cc b/src/python/grpcio_observability/grpc_observability/client_call_tracer.cc index d29aae548a4..5d31619b949 100644 --- a/src/python/grpcio_observability/grpc_observability/client_call_tracer.cc +++ b/src/python/grpcio_observability/grpc_observability/client_call_tracer.cc @@ -23,7 +23,7 @@ #include "absl/time/clock.h" #include "constants.h" #include "observability_util.h" -#include "python_census_context.h" +#include "python_observability_context.h" #include @@ -42,10 +42,11 @@ constexpr uint32_t PythonOpenCensusCallTracer::PythonOpenCensusCallTracer( const char* method, const char* target, const char* trace_id, - const char* parent_span_id, bool tracing_enabled) + const char* parent_span_id, bool tracing_enabled, bool registered_method) : method_(GetMethod(method)), target_(GetTarget(target)), - tracing_enabled_(tracing_enabled) { + tracing_enabled_(tracing_enabled), + registered_method_(registered_method) { GenerateClientContext(absl::StrCat("Sent.", method_), absl::string_view(trace_id), absl::string_view(parent_span_id), &context_); @@ -82,11 +83,14 @@ PythonOpenCensusCallTracer::~PythonOpenCensusCallTracer() { if (PythonCensusStatsEnabled()) { context_.Labels().emplace_back(kClientMethod, std::string(method_)); RecordIntMetric(kRpcClientRetriesPerCallMeasureName, retries_ - 1, + registered_method_, context_.Labels()); // exclude first attempt RecordIntMetric(kRpcClientTransparentRetriesPerCallMeasureName, - transparent_retries_, context_.Labels()); + transparent_retries_, registered_method_, + context_.Labels()); RecordDoubleMetric(kRpcClientRetryDelayPerCallMeasureName, - ToDoubleSeconds(retry_delay_), context_.Labels()); + ToDoubleSeconds(retry_delay_), registered_method_, + context_.Labels()); } if (tracing_enabled_) { @@ -149,7 +153,8 @@ PythonOpenCensusCallTracer::PythonOpenCensusCallAttemptTracer:: } context_.Labels().emplace_back(kClientMethod, std::string(parent_->method_)); context_.Labels().emplace_back(kClientTarget, std::string(parent_->target_)); - RecordIntMetric(kRpcClientStartedRpcsMeasureName, 1, context_.Labels()); + RecordIntMetric(kRpcClientStartedRpcsMeasureName, 1, + parent_->registered_method_, context_.Labels()); } void PythonOpenCensusCallTracer::PythonOpenCensusCallAttemptTracer:: @@ -235,20 +240,21 @@ void PythonOpenCensusCallTracer::PythonOpenCensusCallAttemptTracer:: static_cast(transport_stream_stats != nullptr ? transport_stream_stats->outgoing.data_bytes : 0), - context_.Labels()); + parent_->registered_method_, context_.Labels()); RecordDoubleMetric( kRpcClientReceivedBytesPerRpcMeasureName, static_cast(transport_stream_stats != nullptr ? transport_stream_stats->incoming.data_bytes : 0), - context_.Labels()); + parent_->registered_method_, context_.Labels()); RecordDoubleMetric(kRpcClientServerLatencyMeasureName, absl::ToDoubleSeconds(absl::Nanoseconds(elapsed_time)), - context_.Labels()); + parent_->registered_method_, context_.Labels()); RecordDoubleMetric(kRpcClientRoundtripLatencyMeasureName, absl::ToDoubleSeconds(absl::Now() - start_time_), - context_.Labels()); - RecordIntMetric(kRpcClientCompletedRpcMeasureName, 1, context_.Labels()); + parent_->registered_method_, context_.Labels()); + RecordIntMetric(kRpcClientCompletedRpcMeasureName, 1, + parent_->registered_method_, context_.Labels()); } void PythonOpenCensusCallTracer::PythonOpenCensusCallAttemptTracer:: @@ -262,9 +268,11 @@ void PythonOpenCensusCallTracer::PythonOpenCensusCallAttemptTracer::RecordEnd( context_.Labels().emplace_back(kClientStatus, StatusCodeToString(status_code_)); RecordIntMetric(kRpcClientSentMessagesPerRpcMeasureName, - sent_message_count_, context_.Labels()); + sent_message_count_, parent_->registered_method_, + context_.Labels()); RecordIntMetric(kRpcClientReceivedMessagesPerRpcMeasureName, - recv_message_count_, context_.Labels()); + recv_message_count_, parent_->registered_method_, + context_.Labels()); grpc_core::MutexLock lock(&parent_->mu_); if (--parent_->num_active_rpcs_ == 0) { diff --git a/src/python/grpcio_observability/grpc_observability/client_call_tracer.h b/src/python/grpcio_observability/grpc_observability/client_call_tracer.h index 1aefd75d5f6..e100c4bcfc8 100644 --- a/src/python/grpcio_observability/grpc_observability/client_call_tracer.h +++ b/src/python/grpcio_observability/grpc_observability/client_call_tracer.h @@ -24,7 +24,7 @@ #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" #include "absl/time/time.h" -#include "python_census_context.h" +#include "python_observability_context.h" #include @@ -96,7 +96,8 @@ class PythonOpenCensusCallTracer : public grpc_core::ClientCallTracer { explicit PythonOpenCensusCallTracer(const char* method, const char* target, const char* trace_id, const char* parent_span_id, - bool tracing_enabled); + bool tracing_enabled, + bool registered_method); ~PythonOpenCensusCallTracer() override; std::string TraceId() override { @@ -127,6 +128,7 @@ class PythonOpenCensusCallTracer : public grpc_core::ClientCallTracer { absl::string_view target_; PythonCensusContext context_; bool tracing_enabled_; + const bool registered_method_; mutable grpc_core::Mutex mu_; // Non-transparent attempts per call uint64_t retries_ ABSL_GUARDED_BY(&mu_) = 0; diff --git a/src/python/grpcio_observability/grpc_observability/constants.h b/src/python/grpcio_observability/grpc_observability/constants.h index 79212599487..cd8bc34c8d7 100644 --- a/src/python/grpcio_observability/grpc_observability/constants.h +++ b/src/python/grpcio_observability/grpc_observability/constants.h @@ -24,6 +24,7 @@ const std::string kClientTarget = "grpc.target"; const std::string kClientStatus = "grpc.status"; const std::string kServerMethod = "grpc.method"; const std::string kServerStatus = "grpc.status"; +const std::string kRegisteredMethod = "registerMethod"; typedef enum { kMeasurementDouble = 0, kMeasurementInt } MeasurementType; diff --git a/src/python/grpcio_observability/grpc_observability/observability_util.cc b/src/python/grpcio_observability/grpc_observability/observability_util.cc index 6af56d45601..ada4cd2cca2 100644 --- a/src/python/grpcio_observability/grpc_observability/observability_util.cc +++ b/src/python/grpcio_observability/grpc_observability/observability_util.cc @@ -24,7 +24,7 @@ #include "absl/types/optional.h" #include "client_call_tracer.h" #include "constants.h" -#include "python_census_context.h" +#include "python_observability_context.h" #include "server_call_tracer.h" #include @@ -61,10 +61,12 @@ int GetMaxExportBufferSize() { } // namespace void RecordIntMetric(MetricsName name, int64_t value, + const bool registered_method, const std::vector