From 834b511348f53bcf884daecc8cc9981a871146fe Mon Sep 17 00:00:00 2001 From: AJ Heller Date: Wed, 1 May 2024 09:32:37 -0700 Subject: [PATCH 1/9] [EventEngine] Enable test-only WindowsEventEngine clients (#35546) Closes #35546 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35546 from drfloob:win-ee-client-flip-202401 78abb9550b832239e052b3081d922d820e8e3210 PiperOrigin-RevId: 629747109 --- bazel/experiments.bzl | 4 ++++ src/core/lib/event_engine/windows/windows_endpoint.cc | 8 ++++---- src/core/lib/experiments/rollouts.yaml | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) 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/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 From 76c93769e2fbf28ac8b7d9b4a69598691e396e53 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 1 May 2024 10:04:11 -0700 Subject: [PATCH 2/9] [LB policies] fix handling of UpdateLocked() result (#36463) This fixes some TODOs added in #30809 for cases where LB policies lazily create child policies. Credit to @ejona86 for pointing out that simply calling `RequestReresolution()` in this case will ultimately result in the exponential backoff behavior we want. This also adds some missing plumbing in code added as part of the dualstack work (in the endpoint_list library and in ring_hash) to propagate non-OK statuses from `UpdateLocked()`. When I first made the dualstack changes, I didn't bother with this plumbing, because there are no cases today where these code-paths will actually see a non-OK status (`EndpointAddresses` won't allow creating an endpoint with 0 addresses, and that's the only case where pick_first will return a non-OK status), and I wasn't sure if we would stick with the approach of returning status from `UpdateLocked()` due to the aforementioned lazy creation case. However, now that we have a good solution for the lazy creation case, I've added the necessary plumbing, just so that we don't have a bug if in the future pick_first winds up returning non-OK status in some other case. I have not bothered to fix the propagation in the grpclb policy, since that looked like it would be slightly more work than it's really worth at this point. Closes #36463 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36463 from markdroth:lb_reresolve_for_lazy_child_creation 49043b2d80b52134294f1ac4b84c56441edd218b PiperOrigin-RevId: 629755047 --- src/core/load_balancing/endpoint_list.cc | 6 +-- src/core/load_balancing/endpoint_list.h | 21 +++++++---- src/core/load_balancing/priority/priority.cc | 11 ++++-- .../load_balancing/ring_hash/ring_hash.cc | 37 ++++++++++++++----- src/core/load_balancing/rls/rls.cc | 13 +++++-- .../load_balancing/round_robin/round_robin.cc | 21 ++++++++--- .../weighted_round_robin.cc | 20 +++++++--- 7 files changed, 92 insertions(+), 37 deletions(-) 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(); } From 6f09d2ab007998ba7ad94f52489895db451cd762 Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Wed, 1 May 2024 10:45:06 -0700 Subject: [PATCH 3/9] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36472) [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT Replacing GPR_ASSERT with absl CHECK. These changes have been made using string replacement and regex. Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced. Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer. Closes #36472 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36472 from tanvi-jagtap:tjagtap_src_core_lib_promise 03fe59d7c08a9705b2b505c4091115a74121d37a PiperOrigin-RevId: 629767763 --- src/core/BUILD | 32 +++++++++++++++++-- src/core/lib/promise/activity.cc | 3 +- src/core/lib/promise/activity.h | 11 ++++--- src/core/lib/promise/context.h | 3 +- src/core/lib/promise/detail/join_state.h | 18 ++++++----- src/core/lib/promise/detail/seq_state.h | 25 ++++++++------- src/core/lib/promise/detail/status.h | 3 +- .../promise/event_engine_wakeup_scheduler.h | 4 ++- src/core/lib/promise/for_each.h | 9 +++--- src/core/lib/promise/interceptor_list.h | 3 +- src/core/lib/promise/latch.h | 13 ++++---- src/core/lib/promise/mpsc.h | 5 +-- src/core/lib/promise/observable.h | 5 +-- src/core/lib/promise/party.cc | 13 ++++---- src/core/lib/promise/party.h | 15 +++++---- src/core/lib/promise/pipe.h | 25 ++++++++------- src/core/lib/promise/poll.h | 8 +++-- src/core/lib/promise/promise_mutex.h | 12 ++++--- src/core/lib/promise/status_flag.h | 13 ++++---- src/core/lib/promise/try_join.h | 3 +- src/core/lib/promise/try_seq.h | 3 +- 21 files changed, 138 insertions(+), 88 deletions(-) diff --git a/src/core/BUILD b/src/core/BUILD index 26bdbd93ded..d24666519d2 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -483,6 +483,7 @@ grpc_cc_library( grpc_cc_library( name = "poll", + external_deps = ["absl/log:check"], language = "c++", public_hdrs = [ "lib/promise/poll.h", @@ -497,6 +498,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 +544,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/strings", "absl/strings:str_format", ], @@ -564,7 +567,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 +711,7 @@ grpc_cc_library( grpc_cc_library( name = "promise_status", external_deps = [ + "absl/log:check", "absl/status", "absl/status:statusor", ], @@ -750,6 +757,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 +792,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 +847,7 @@ grpc_cc_library( name = "seq_state", external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/strings", ], language = "c++", @@ -872,6 +884,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 +912,7 @@ grpc_cc_library( ], external_deps = [ "absl/base:core_headers", + "absl/log:check", "absl/status", "absl/strings", "absl/strings:str_format", @@ -943,6 +957,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 +985,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 +1026,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 +1049,7 @@ grpc_cc_library( "lib/promise/pipe.h", ], external_deps = [ + "absl/log:check", "absl/strings", "absl/types:optional", "absl/types:variant", @@ -1056,6 +1076,7 @@ grpc_cc_library( hdrs = [ "lib/promise/promise_mutex.h", ], + external_deps = ["absl/log:check"], language = "c++", deps = [ "activity", @@ -1103,7 +1124,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 +1147,7 @@ grpc_cc_library( external_deps = [ "absl/container:flat_hash_set", "absl/functional:any_invocable", + "absl/log:check", ], language = "c++", deps = [ @@ -1135,6 +1160,7 @@ grpc_cc_library( grpc_cc_library( name = "for_each", external_deps = [ + "absl/log:check", "absl/status", "absl/strings", ], 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 From 1e5fc3df8bc6c4bcb3d1610ff5ced4fa5f3356ce Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 1 May 2024 11:12:39 -0700 Subject: [PATCH 4/9] [reorg] move server code to src/core/server (#36475) Closes #36475 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36475 from markdroth:reorg_server 30edc04c0ff20159a0d2726b4c791bba4cdd5fc0 PiperOrigin-RevId: 629776917 --- BUILD | 4 +- CMakeLists.txt | 116 ++++++++++++++-- Makefile | 10 +- Package.swift | 22 +-- build_autogenerated.yaml | 126 +++++++++++++++--- config.m4 | 12 +- config.w32 | 12 +- gRPC-C++.podspec | 24 ++-- gRPC-Core.podspec | 34 ++--- grpc.gemspec | 22 +-- package.xml | 22 +-- src/core/BUILD | 18 +-- .../transport/binder/server/binder_server.cc | 2 +- .../transport/binder/server/binder_server.h | 2 +- .../server/chaotic_good_server.cc | 2 +- .../chaotic_good/server/chaotic_good_server.h | 2 +- .../transport/chttp2/server/chttp2_server.cc | 2 +- .../transport/chttp2/server/chttp2_server.h | 2 +- .../ext/transport/inproc/inproc_transport.cc | 2 +- .../inproc/legacy_inproc_transport.cc | 2 +- src/core/lib/surface/call.cc | 2 +- src/core/lib/surface/call.h | 2 +- .../plugin_registry/grpc_plugin_registry.cc | 4 +- src/core/{lib/surface => server}/server.cc | 2 +- src/core/{lib/surface => server}/server.h | 8 +- .../server_call_tracer_filter.cc | 2 +- .../server_call_tracer_filter.h | 6 +- .../server_config_selector.h | 10 +- .../server_config_selector_filter.cc | 7 +- .../server_config_selector_filter.h | 6 +- .../surface => server}/server_interface.h | 6 +- .../xds_channel_stack_modifier.cc | 2 +- .../xds_channel_stack_modifier.h | 6 +- .../xds_server_config_fetcher.cc | 8 +- src/cpp/server/server_cc.cc | 2 +- src/python/grpcio/grpc_core_dependencies.py | 10 +- test/core/bad_client/bad_client.cc | 2 +- .../core/bad_client/tests/bad_streaming_id.cc | 2 +- test/core/bad_client/tests/badreq.cc | 2 +- .../bad_client/tests/connection_prefix.cc | 2 +- test/core/bad_client/tests/headers.cc | 2 +- .../tests/initial_settings_frame.cc | 2 +- test/core/bad_client/tests/out_of_bounds.cc | 2 +- .../tests/server_registered_method.cc | 2 +- test/core/bad_client/tests/simple_request.cc | 2 +- test/core/bad_client/tests/unknown_frame.cc | 2 +- test/core/bad_client/tests/window_overflow.cc | 2 +- test/core/bad_connection/close_fd_test.cc | 2 +- test/core/channelz/channelz_test.cc | 2 +- test/core/end2end/fixtures/sockpair_fixture.h | 2 +- test/core/end2end/tests/channelz.cc | 2 +- .../{server_config_selector => server}/BUILD | 21 ++- .../server_config_selector_test.cc | 2 +- .../xds_channel_stack_modifier_test.cc | 2 +- .../binder/end2end/fuzzers/server_fuzzer.cc | 2 +- .../binder/end2end/testing_channel_create.h | 2 +- .../chaotic_good/chaotic_good_server_test.cc | 2 +- .../chttp2/graceful_shutdown_test.cc | 2 +- test/core/xds/BUILD | 19 --- test/cpp/end2end/client_lb_end2end_test.cc | 2 +- test/cpp/end2end/xds/xds_end2end_test_lib.cc | 2 +- test/cpp/end2end/xds/xds_utils.cc | 2 +- test/cpp/microbenchmarks/fullstack_fixtures.h | 2 +- test/cpp/performance/writes_per_rpc_test.cc | 2 +- tools/doxygen/Doxyfile.c++.internal | 22 +-- tools/doxygen/Doxyfile.core.internal | 22 +-- tools/run_tests/generated/tests.json | 24 ++++ 67 files changed, 446 insertions(+), 235 deletions(-) rename src/core/{lib/surface => server}/server.cc (99%) rename src/core/{lib/surface => server}/server.h (99%) rename src/core/{lib/channel => server}/server_call_tracer_filter.cc (98%) rename src/core/{lib/channel => server}/server_call_tracer_filter.h (81%) rename src/core/{ext/filters/server_config_selector => server}/server_config_selector.h (91%) rename src/core/{ext/filters/server_config_selector => server}/server_config_selector_filter.cc (97%) rename src/core/{ext/filters/server_config_selector => server}/server_config_selector_filter.h (75%) rename src/core/{lib/surface => server}/server_interface.h (88%) rename src/core/{ext/xds => server}/xds_channel_stack_modifier.cc (98%) rename src/core/{ext/xds => server}/xds_channel_stack_modifier.h (91%) rename src/core/{ext/xds => server}/xds_server_config_fetcher.cc (99%) rename test/core/{server_config_selector => server}/BUILD (66%) rename test/core/{server_config_selector => server}/server_config_selector_test.cc (96%) rename test/core/{xds => server}/xds_channel_stack_modifier_test.cc (98%) diff --git a/BUILD b/BUILD index b2ddbc9f49d..420251227fb 100644 --- a/BUILD +++ b/BUILD @@ -1862,10 +1862,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", 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..c4eacbae00d 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", @@ -1800,9 +1792,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 +1931,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/build_autogenerated.yaml b/build_autogenerated.yaml index 4e50264e937..636d5ea958c 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -256,8 +256,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 +785,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 +836,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 +1134,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 +1202,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 +1277,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 +1639,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 +1655,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 +1680,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 +1933,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 +2004,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 +2340,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 +2602,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 +2664,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 +2805,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 +3019,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 +3080,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 +4679,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 +4711,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 +11834,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 +11868,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 +17938,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 +20950,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/gRPC-C++.podspec b/gRPC-C++.podspec index 91edbbe6cb0..fca100b28d2 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', @@ -1241,8 +1237,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 +1305,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 +1583,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 +2132,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 +2184,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', @@ -2511,8 +2507,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 +2575,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..c1ad3a41850 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', @@ -1913,9 +1905,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 +2044,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 +2382,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 +2911,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 +2962,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', @@ -3289,8 +3285,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 +3353,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..05b8d202eca 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 ) @@ -1802,9 +1794,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 +1933,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..62f4ba023b7 100644 --- a/package.xml +++ b/package.xml @@ -172,9 +172,6 @@ - - - @@ -1066,8 +1063,6 @@ - - @@ -1103,7 +1098,6 @@ - @@ -1161,8 +1155,6 @@ - - @@ -1784,9 +1776,6 @@ - - - @@ -1926,6 +1915,17 @@ + + + + + + + + + + + diff --git a/src/core/BUILD b/src/core/BUILD index d24666519d2..31b1e432aeb 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", @@ -3066,7 +3066,7 @@ grpc_cc_library( grpc_cc_library( name = "server_interface", hdrs = [ - "lib/surface/server_interface.h", + "server/server_interface.h", ], language = "c++", deps = [ @@ -3617,7 +3617,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", @@ -3640,10 +3640,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", @@ -5199,10 +5199,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++", @@ -5224,7 +5224,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", 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/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/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 39529d08306..61a2a6926b5 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -73,7 +73,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_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/test/core/bad_client/bad_client.cc b/test/core/bad_client/bad_client.cc index 29c423c4631..ee7e1ee4d39 100644 --- a/test/core/bad_client/bad_client.cc +++ b/test/core/bad_client/bad_client.cc @@ -43,8 +43,8 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/surface/completion_queue.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/transport.h" +#include "src/core/server/server.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/bad_streaming_id.cc b/test/core/bad_client/tests/bad_streaming_id.cc index f2e770b1ae8..a29c64cea1a 100644 --- a/test/core/bad_client/tests/bad_streaming_id.cc +++ b/test/core/bad_client/tests/bad_streaming_id.cc @@ -25,7 +25,7 @@ #include #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/badreq.cc b/test/core/bad_client/tests/badreq.cc index b85a0c7f65e..4d595b9f4e2 100644 --- a/test/core/bad_client/tests/badreq.cc +++ b/test/core/bad_client/tests/badreq.cc @@ -21,7 +21,7 @@ #include #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/connection_prefix.cc b/test/core/bad_client/tests/connection_prefix.cc index be1b487b500..993e799839e 100644 --- a/test/core/bad_client/tests/connection_prefix.cc +++ b/test/core/bad_client/tests/connection_prefix.cc @@ -21,7 +21,7 @@ #include #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/headers.cc b/test/core/bad_client/tests/headers.cc index 242b2b39b11..0aa31a507c3 100644 --- a/test/core/bad_client/tests/headers.cc +++ b/test/core/bad_client/tests/headers.cc @@ -20,7 +20,7 @@ #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/initial_settings_frame.cc b/test/core/bad_client/tests/initial_settings_frame.cc index f8388784596..deca4fdaebd 100644 --- a/test/core/bad_client/tests/initial_settings_frame.cc +++ b/test/core/bad_client/tests/initial_settings_frame.cc @@ -23,7 +23,7 @@ #include #include "src/core/lib/experiments/experiments.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/out_of_bounds.cc b/test/core/bad_client/tests/out_of_bounds.cc index 8ae1a5365bd..1d03c4f8b56 100644 --- a/test/core/bad_client/tests/out_of_bounds.cc +++ b/test/core/bad_client/tests/out_of_bounds.cc @@ -25,7 +25,7 @@ #include #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/server_registered_method.cc b/test/core/bad_client/tests/server_registered_method.cc index c402f1702d4..32f69f20a40 100644 --- a/test/core/bad_client/tests/server_registered_method.cc +++ b/test/core/bad_client/tests/server_registered_method.cc @@ -23,7 +23,7 @@ #include #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/simple_request.cc b/test/core/bad_client/tests/simple_request.cc index 1c10e3850ea..7fa0065b6e5 100644 --- a/test/core/bad_client/tests/simple_request.cc +++ b/test/core/bad_client/tests/simple_request.cc @@ -18,7 +18,7 @@ #include #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/unknown_frame.cc b/test/core/bad_client/tests/unknown_frame.cc index 06776083808..7b3e1364ba5 100644 --- a/test/core/bad_client/tests/unknown_frame.cc +++ b/test/core/bad_client/tests/unknown_frame.cc @@ -25,7 +25,7 @@ #include #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_client/tests/window_overflow.cc b/test/core/bad_client/tests/window_overflow.cc index 7a55752a58d..b58ca84febe 100644 --- a/test/core/bad_client/tests/window_overflow.cc +++ b/test/core/bad_client/tests/window_overflow.cc @@ -23,7 +23,7 @@ #include #include -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/bad_client/bad_client.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc index d870e529d7d..a51f141270e 100644 --- a/test/core/bad_connection/close_fd_test.cc +++ b/test/core/bad_connection/close_fd_test.cc @@ -60,7 +60,7 @@ #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/completion_queue.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/test_util/test_config.h" static void* tag(intptr_t t) { return reinterpret_cast(t); } diff --git a/test/core/channelz/channelz_test.cc b/test/core/channelz/channelz_test.cc index 5c1cdd71483..bd82d6c50f3 100644 --- a/test/core/channelz/channelz_test.cc +++ b/test/core/channelz/channelz_test.cc @@ -48,7 +48,7 @@ #include "src/core/lib/json/json.h" #include "src/core/lib/json/json_reader.h" #include "src/core/lib/surface/channel.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/event_engine/event_engine_test_utils.h" #include "test/core/test_util/test_config.h" #include "test/cpp/util/channel_trace_proto_helper.h" diff --git a/test/core/end2end/fixtures/sockpair_fixture.h b/test/core/end2end/fixtures/sockpair_fixture.h index 0832f0def52..0d35b3ea64f 100644 --- a/test/core/end2end/fixtures/sockpair_fixture.h +++ b/test/core/end2end/fixtures/sockpair_fixture.h @@ -42,8 +42,8 @@ #include "src/core/lib/surface/channel_create.h" #include "src/core/lib/surface/channel_stack_type.h" #include "src/core/lib/surface/completion_queue.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/transport.h" +#include "src/core/server/server.h" #include "test/core/end2end/end2end_tests.h" namespace grpc_core { diff --git a/test/core/end2end/tests/channelz.cc b/test/core/end2end/tests/channelz.cc index 7836b291243..570ba3e9670 100644 --- a/test/core/end2end/tests/channelz.cc +++ b/test/core/end2end/tests/channelz.cc @@ -29,7 +29,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" #include "src/core/lib/surface/channel.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/end2end/end2end_tests.h" using testing::HasSubstr; diff --git a/test/core/server_config_selector/BUILD b/test/core/server/BUILD similarity index 66% rename from test/core/server_config_selector/BUILD rename to test/core/server/BUILD index ead31a56d35..c91dfe4a9b3 100644 --- a/test/core/server_config_selector/BUILD +++ b/test/core/server/BUILD @@ -16,7 +16,7 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_test", "grpc_package") licenses(["notice"]) -grpc_package(name = "test/core/server_config_selector") +grpc_package(name = "test/core/server") grpc_cc_test( name = "server_config_selector_test", @@ -35,3 +35,22 @@ grpc_cc_test( "//test/core/test_util:grpc_test_util", ], ) + +grpc_cc_test( + name = "xds_channel_stack_modifier_test", + srcs = ["xds_channel_stack_modifier_test.cc"], + external_deps = ["gtest"], + language = "C++", + tags = ["no_test_ios"], + uses_event_engine = False, + uses_polling = False, + deps = [ + "//:gpr", + "//:grpc", + "//:grpc_base", + "//:grpc_opencensus_plugin", + "//src/core:channel_args", + "//src/core:grpc_xds_channel_stack_modifier", + "//test/core/test_util:grpc_test_util", + ], +) diff --git a/test/core/server_config_selector/server_config_selector_test.cc b/test/core/server/server_config_selector_test.cc similarity index 96% rename from test/core/server_config_selector/server_config_selector_test.cc rename to test/core/server/server_config_selector_test.cc index e59d8c80c7c..3bdf5a7dca0 100644 --- a/test/core/server_config_selector/server_config_selector_test.cc +++ b/test/core/server/server_config_selector_test.cc @@ -16,7 +16,7 @@ // // -#include "src/core/ext/filters/server_config_selector/server_config_selector.h" +#include "src/core/server/server_config_selector.h" #include "absl/status/status.h" #include "gtest/gtest.h" diff --git a/test/core/xds/xds_channel_stack_modifier_test.cc b/test/core/server/xds_channel_stack_modifier_test.cc similarity index 98% rename from test/core/xds/xds_channel_stack_modifier_test.cc rename to test/core/server/xds_channel_stack_modifier_test.cc index cf793a73387..f01860e4adb 100644 --- a/test/core/xds/xds_channel_stack_modifier_test.cc +++ b/test/core/server/xds_channel_stack_modifier_test.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/test/core/transport/binder/end2end/fuzzers/server_fuzzer.cc b/test/core/transport/binder/end2end/fuzzers/server_fuzzer.cc index 48ce0e6fcea..68996f1020f 100644 --- a/test/core/transport/binder/end2end/fuzzers/server_fuzzer.cc +++ b/test/core/transport/binder/end2end/fuzzers/server_fuzzer.cc @@ -20,7 +20,7 @@ #include "src/core/lib/config/core_configuration.h" #include "src/core/lib/iomgr/executor.h" #include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "src/libfuzzer/libfuzzer_macro.h" #include "test/core/transport/binder/end2end/fuzzers/binder_transport_fuzzer.pb.h" #include "test/core/transport/binder/end2end/fuzzers/fuzzer_utils.h" diff --git a/test/core/transport/binder/end2end/testing_channel_create.h b/test/core/transport/binder/end2end/testing_channel_create.h index 3a738146ade..8838f7265e7 100644 --- a/test/core/transport/binder/end2end/testing_channel_create.h +++ b/test/core/transport/binder/end2end/testing_channel_create.h @@ -20,7 +20,7 @@ #include #include "src/core/ext/transport/binder/transport/binder_transport.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/transport/binder/end2end/fake_binder.h" namespace grpc_binder { diff --git a/test/core/transport/chaotic_good/chaotic_good_server_test.cc b/test/core/transport/chaotic_good/chaotic_good_server_test.cc index af2fc82facd..b5b058b43ee 100644 --- a/test/core/transport/chaotic_good/chaotic_good_server_test.cc +++ b/test/core/transport/chaotic_good/chaotic_good_server_test.cc @@ -36,8 +36,8 @@ #include "src/core/lib/event_engine/tcp_socket_utils.h" #include "src/core/lib/gprpp/notification.h" #include "src/core/lib/gprpp/time.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/uri/uri_parser.h" +#include "src/core/server/server.h" #include "test/core/event_engine/event_engine_test_utils.h" #include "test/core/test_util/port.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/transport/chttp2/graceful_shutdown_test.cc b/test/core/transport/chttp2/graceful_shutdown_test.cc index 0dec68afad0..1f2d5642d55 100644 --- a/test/core/transport/chttp2/graceful_shutdown_test.cc +++ b/test/core/transport/chttp2/graceful_shutdown_test.cc @@ -61,7 +61,7 @@ #include "src/core/lib/slice/slice.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/completion_queue.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/test_util/test_config.h" diff --git a/test/core/xds/BUILD b/test/core/xds/BUILD index a307443ef6a..975cb4d819e 100644 --- a/test/core/xds/BUILD +++ b/test/core/xds/BUILD @@ -72,25 +72,6 @@ grpc_cc_test( ], ) -grpc_cc_test( - name = "xds_channel_stack_modifier_test", - srcs = ["xds_channel_stack_modifier_test.cc"], - external_deps = ["gtest"], - language = "C++", - tags = ["no_test_ios"], - uses_event_engine = False, - uses_polling = False, - deps = [ - "//:gpr", - "//:grpc", - "//:grpc_base", - "//:grpc_opencensus_plugin", - "//src/core:channel_args", - "//src/core:grpc_xds_channel_stack_modifier", - "//test/core/test_util:grpc_test_util", - ], -) - grpc_cc_test( name = "xds_certificate_provider_test", srcs = ["xds_certificate_provider_test.cc"], diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 9a445f137a6..e7f406f45e9 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -65,10 +65,10 @@ #include "src/core/lib/gprpp/time.h" #include "src/core/lib/iomgr/tcp_client.h" #include "src/core/lib/security/credentials/fake/fake_credentials.h" -#include "src/core/lib/surface/server.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/resolver/endpoint_addresses.h" #include "src/core/resolver/fake/fake_resolver.h" +#include "src/core/server/server.h" #include "src/core/service_config/service_config.h" #include "src/core/service_config/service_config_impl.h" #include "src/cpp/server/secure_server_credentials.h" diff --git a/test/cpp/end2end/xds/xds_end2end_test_lib.cc b/test/cpp/end2end/xds/xds_end2end_test_lib.cc index a1fb9720a1b..2946bfb5dde 100644 --- a/test/cpp/end2end/xds/xds_end2end_test_lib.cc +++ b/test/cpp/end2end/xds/xds_end2end_test_lib.cc @@ -41,7 +41,7 @@ #include "src/core/ext/xds/xds_client_grpc.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/env.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "src/proto/grpc/testing/xds/v3/router.grpc.pb.h" #include "test/core/test_util/resolve_localhost_ip46.h" #include "test/core/test_util/tls_utils.h" diff --git a/test/cpp/end2end/xds/xds_utils.cc b/test/cpp/end2end/xds/xds_utils.cc index 459e909cead..1f84b70e5a6 100644 --- a/test/cpp/end2end/xds/xds_utils.cc +++ b/test/cpp/end2end/xds/xds_utils.cc @@ -38,7 +38,7 @@ #include "src/core/ext/xds/xds_client_grpc.h" #include "src/core/lib/gpr/tmpfile.h" #include "src/core/lib/gprpp/env.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "src/cpp/client/secure_credentials.h" #include "src/proto/grpc/testing/xds/v3/router.grpc.pb.h" #include "test/core/test_util/resolve_localhost_ip46.h" diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index de4811b7008..f94a36cfe40 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -42,7 +42,7 @@ #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel_create.h" #include "src/core/lib/surface/completion_queue.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "src/cpp/client/create_channel_internal.h" #include "test/core/test_util/port.h" #include "test/core/test_util/test_config.h" diff --git a/test/cpp/performance/writes_per_rpc_test.cc b/test/cpp/performance/writes_per_rpc_test.cc index 36b5ba173d1..7a24ebd917b 100644 --- a/test/cpp/performance/writes_per_rpc_test.cc +++ b/test/cpp/performance/writes_per_rpc_test.cc @@ -44,7 +44,7 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel_create.h" -#include "src/core/lib/surface/server.h" +#include "src/core/server/server.h" #include "src/cpp/client/create_channel_internal.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/core/event_engine/fuzzing_event_engine/fuzzing_event_engine.h" diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 38676f21685..87f43bfb161 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1150,9 +1150,6 @@ src/core/ext/filters/rbac/rbac_filter.cc \ 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 \ @@ -2082,8 +2079,6 @@ src/core/ext/xds/xds_bootstrap_grpc.h \ 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 \ @@ -2120,7 +2115,6 @@ src/core/ext/xds/xds_route_config.cc \ 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 \ @@ -2178,8 +2172,6 @@ src/core/lib/channel/metrics.cc \ 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 \ @@ -2801,9 +2793,6 @@ src/core/lib/surface/lame_client.h \ src/core/lib/surface/legacy_channel.cc \ src/core/lib/surface/legacy_channel.h \ src/core/lib/surface/metadata_array.cc \ -src/core/lib/surface/server.cc \ -src/core/lib/surface/server.h \ -src/core/lib/surface/server_interface.h \ src/core/lib/surface/validate_metadata.cc \ src/core/lib/surface/validate_metadata.h \ src/core/lib/surface/version.cc \ @@ -2943,6 +2932,17 @@ src/core/resolver/xds/xds_resolver.cc \ 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/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 8876021891b..06fbb0305b5 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -955,9 +955,6 @@ src/core/ext/filters/rbac/rbac_filter.cc \ 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 \ @@ -1853,8 +1850,6 @@ src/core/ext/xds/xds_bootstrap_grpc.h \ 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 \ @@ -1890,7 +1885,6 @@ src/core/ext/xds/xds_route_config.cc \ 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 \ @@ -1950,8 +1944,6 @@ src/core/lib/channel/metrics.cc \ 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 \ @@ -2577,9 +2569,6 @@ src/core/lib/surface/lame_client.h \ src/core/lib/surface/legacy_channel.cc \ src/core/lib/surface/legacy_channel.h \ src/core/lib/surface/metadata_array.cc \ -src/core/lib/surface/server.cc \ -src/core/lib/surface/server.h \ -src/core/lib/surface/server_interface.h \ src/core/lib/surface/validate_metadata.cc \ src/core/lib/surface/validate_metadata.h \ src/core/lib/surface/version.cc \ @@ -2724,6 +2713,17 @@ src/core/resolver/xds/xds_resolver.cc \ 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/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 61b98ca9bd1..c5e2f513b2e 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -11765,6 +11765,30 @@ ], "uses_polling": false }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "xds_channel_stack_modifier_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, From 68b20d8a01d8d05e75fcac290923aacc946aac3b Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Wed, 1 May 2024 16:57:36 -0400 Subject: [PATCH 5/9] fix: use `github.rest.actions.cancelWorkflowRun` instead of `github.actions.cancelWorkflowRun` (#36499) This is breaking change per `actions/github-script` v5 update see https://github.com/actions/github-script?tab=readme-ov-file#v5 Signed-off-by: Rui Chen --- .github/workflows/pr-auto-fix.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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'; From 811bb258d8cab7ce3aabe603f150f0605e9eecd0 Mon Sep 17 00:00:00 2001 From: Xuan Wang Date: Wed, 1 May 2024 14:38:10 -0700 Subject: [PATCH 6/9] [Python Otel] Use registered method at server side (#36371) Add registered method change to sync stack server. ## Note * We're keeping both generic and registered handler in generated stubs (`*_pb2_grpc.py`) because registered method flow is not implemented in aysncio yet, since the stub is used for both sync and asyncio, we can't remove generic method flow until we fully implement the registered method flow in asyncio. Closes #36371 PiperOrigin-RevId: 629842051 --- examples/python/helloworld/helloworld_pb2.py | 6 +- .../python/helloworld/helloworld_pb2_grpc.py | 3 +- src/compiler/python_generator.cc | 3 + src/python/grpcio/grpc/__init__.py | 16 ++ .../grpc/_cython/_cygrpc/channel.pxd.pxi | 1 + .../grpc/_cython/_cygrpc/channel.pyx.pxi | 17 +- .../grpcio/grpc/_cython/_cygrpc/grpc.pxi | 14 ++ .../grpc/_cython/_cygrpc/server.pxd.pxi | 15 ++ .../grpc/_cython/_cygrpc/server.pyx.pxi | 91 ++++++- src/python/grpcio/grpc/_observability.py | 19 +- src/python/grpcio/grpc/_server.py | 163 ++++++++++-- src/python/grpcio/grpc/aio/_base_server.py | 13 + src/python/grpcio/grpc/aio/_server.py | 10 +- .../grpc_observability/BUILD.bazel | 4 +- .../grpc_observability/_cyobservability.pxd | 7 +- .../grpc_observability/_cyobservability.pyx | 15 +- .../grpc_observability/_gcp_observability.py | 18 +- .../grpc_observability/_observability.py | 3 + .../_open_telemetry_observability.py | 23 +- .../grpc_observability/client_call_tracer.cc | 34 ++- .../grpc_observability/client_call_tracer.h | 6 +- .../grpc_observability/constants.h | 1 + .../grpc_observability/observability_util.cc | 12 +- .../grpc_observability/observability_util.h | 7 +- ...ext.cc => python_observability_context.cc} | 2 +- ...ntext.h => python_observability_context.h} | 7 +- .../grpc_observability/server_call_tracer.cc | 24 +- src/python/grpcio_observability/setup.py | 2 +- .../_open_telemetry_observability_test.py | 25 +- .../tests/observability/_test_server.py | 69 ++++-- src/python/grpcio_tests/tests/tests.json | 1 + .../grpcio_tests/tests/unit/_abort_test.py | 46 ++-- .../tests/unit/_auth_context_test.py | 58 ++--- .../tests/unit/_channel_close_test.py | 30 +-- .../tests/unit/_compression_test.py | 61 ++--- .../unit/_contextvars_propagation_test.py | 22 +- .../tests/unit/_dns_resolver_test.py | 19 +- .../tests/unit/_empty_message_test.py | 39 ++- .../unit/_error_message_encoding_test.py | 18 +- .../tests/unit/_exit_scenarios.py | 35 ++- .../tests/unit/_interceptor_test.py | 168 ++++++++----- .../tests/unit/_invalid_metadata_test.py | 20 +- .../tests/unit/_invocation_defects_test.py | 160 ++++++------ .../tests/unit/_local_credentials_test.py | 19 +- .../tests/unit/_metadata_code_details_test.py | 13 +- .../tests/unit/_metadata_flags_test.py | 60 ++--- .../grpcio_tests/tests/unit/_metadata_test.py | 47 ++-- .../tests/unit/_reconnect_test.py | 15 +- .../tests/unit/_resource_exhausted_test.py | 43 ++-- .../tests/unit/_rpc_test_helpers.py | 98 +++++++- .../tests/unit/_server_shutdown_scenarios.py | 12 +- .../grpcio_tests/tests/unit/_server_test.py | 233 ++++++++++++++++++ .../tests/unit/_session_cache_test.py | 16 +- .../grpcio_tests/tests/unit/_signal_client.py | 13 +- .../tests/unit/_signal_handling_test.py | 19 +- .../tests/unit/_xds_credentials_test.py | 18 +- .../interop/xds_interop_client.py | 1 - 57 files changed, 1353 insertions(+), 561 deletions(-) rename src/python/grpcio_observability/grpc_observability/{python_census_context.cc => python_observability_context.cc} (99%) rename src/python/grpcio_observability/grpc_observability/{python_census_context.h => python_observability_context.h} (98%) 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/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/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_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