From 84b0bb3d1c5b76188ceebcbc4c244878f84c52c1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 22 Feb 2024 08:39:53 -0800 Subject: [PATCH] [call-v3] Add an opt-out for call-v3 stack instantiation (#35956) We've got a few filters in prod that are going to be awful to convert, and are getting pulled into some unit tests in hard to disable ways -- buuut we don't need them for chaotic good in the reality in which we're deploying it -- so I want an escape hatch for the moment. Closes #35956 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35956 from ctiller:not-now-thanks f5d331b9233437e19880ac92f857a1076e7a1a18 PiperOrigin-RevId: 609384999 --- src/core/lib/channel/promise_based_filter.h | 60 +++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/src/core/lib/channel/promise_based_filter.h b/src/core/lib/channel/promise_based_filter.h index cef590ef4ef..bb642bc7f21 100644 --- a/src/core/lib/channel/promise_based_filter.h +++ b/src/core/lib/channel/promise_based_filter.h @@ -74,6 +74,12 @@ namespace grpc_core { +// HACK: If a filter has this type as a base class it will be skipped in +// v3 filter stacks. This is a temporary measure to allow the v3 filter stack +// to be bought up whilst some tests inadvertently rely on hard to convert +// filters. +class HackyHackyHackySkipInV3FilterStacks {}; + class ChannelFilter { public: class Args { @@ -1906,9 +1912,11 @@ struct ChannelFilterWithFlagsMethods { // ChannelArgs channel_args, ChannelFilter::Args filter_args); // }; template -absl::enable_if_t::value && - !std::is_base_of, F>::value, - grpc_channel_filter> +absl::enable_if_t< + std::is_base_of::value && + !std::is_base_of, F>::value && + !std::is_base_of::value, + grpc_channel_filter> MakePromiseBasedFilter(const char* name) { using CallData = promise_filter_detail::CallData; @@ -1946,6 +1954,52 @@ MakePromiseBasedFilter(const char* name) { }; } +template +absl::enable_if_t< + std::is_base_of::value, + grpc_channel_filter> +MakePromiseBasedFilter(const char* name) { + using CallData = promise_filter_detail::CallData; + + return grpc_channel_filter{ + // start_transport_stream_op_batch + promise_filter_detail::BaseCallDataMethods::StartTransportStreamOpBatch, + // make_call_promise + promise_filter_detail::ChannelFilterMethods::MakeCallPromise, + [](grpc_channel_element* elem, CallSpineInterface*) { + GRPC_LOG_EVERY_N_SEC( + 1, GPR_ERROR, + "gRPC V3 call stack in use, with a filter ('%s') that is not V3.", + elem->filter->name); + }, + // start_transport_op + promise_filter_detail::ChannelFilterMethods::StartTransportOp, + // sizeof_call_data + sizeof(CallData), + // init_call_elem + promise_filter_detail::CallDataFilterWithFlagsMethods< + CallData, kFlags>::InitCallElem, + // set_pollset_or_pollset_set + promise_filter_detail::BaseCallDataMethods::SetPollsetOrPollsetSet, + // destroy_call_elem + promise_filter_detail::CallDataFilterWithFlagsMethods< + CallData, kFlags>::DestroyCallElem, + // sizeof_channel_data + sizeof(F), + // init_channel_elem + promise_filter_detail::ChannelFilterWithFlagsMethods< + F, kFlags>::InitChannelElem, + // post_init_channel_elem + promise_filter_detail::ChannelFilterMethods::PostInitChannelElem, + // destroy_channel_elem + promise_filter_detail::ChannelFilterMethods::DestroyChannelElem, + // get_channel_info + promise_filter_detail::ChannelFilterMethods::GetChannelInfo, + // name + name, + }; +} + template absl::enable_if_t, F>::value, grpc_channel_filter>