pull/36225/head
Craig Tiller 10 months ago
parent da43a61322
commit b4857c3019
  1. 4
      src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc
  2. 13
      src/core/lib/surface/channel_init.cc
  3. 20
      src/core/lib/surface/channel_init.h

@ -296,13 +296,13 @@ const grpc_channel_filter LegacyMaxAgeFilter::kFilter =
void RegisterLegacyChannelIdleFilters(CoreConfiguration::Builder* builder) {
builder->channel_init()
->RegisterFilter<LegacyClientIdleFilter>(GRPC_CLIENT_CHANNEL)
->RegisterV2Filter<LegacyClientIdleFilter>(GRPC_CLIENT_CHANNEL)
.ExcludeFromMinimalStack()
.If([](const ChannelArgs& channel_args) {
return GetClientIdleTimeout(channel_args) != Duration::Infinity();
});
builder->channel_init()
->RegisterFilter<LegacyMaxAgeFilter>(GRPC_SERVER_CHANNEL)
->RegisterV2Filter<LegacyMaxAgeFilter>(GRPC_SERVER_CHANNEL)
.ExcludeFromMinimalStack()
.If([](const ChannelArgs& channel_args) {
return LegacyMaxAgeFilter::Config::FromChannelArgs(channel_args)

@ -141,9 +141,9 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig(
GPR_ASSERT(registration->after_.empty());
GPR_ASSERT(registration->before_.empty());
GPR_ASSERT(!registration->before_all_);
terminal_filters.emplace_back(registration->filter_, nullptr,
std::move(registration->predicates_),
registration->registration_source_);
terminal_filters.emplace_back(
registration->filter_, nullptr, std::move(registration->predicates_),
registration->skip_v3_, registration->registration_source_);
} else {
dependencies[registration->filter_]; // Ensure it's in the map.
}
@ -223,9 +223,9 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig(
while (!dependencies.empty()) {
auto filter = take_ready_dependency();
auto* registration = filter_to_registration[filter];
filters.emplace_back(filter, registration->vtable_,
std::move(registration->predicates_),
registration->registration_source_);
filters.emplace_back(
filter, registration->vtable_, std::move(registration->predicates_),
registration->skip_v3_, registration->registration_source_);
for (auto& p : dependencies) {
p.second.erase(filter);
}
@ -414,6 +414,7 @@ absl::StatusOr<ChannelInit::StackSegment> ChannelInit::CreateStackSegment(
size_t channel_data_alignment = 0;
// Based on predicates build a list of filters to include in this segment.
for (const auto& filter : stack_config.filters) {
if (filter.skip_v3) continue;
if (!filter.CheckPredicates(args)) continue;
if (filter.vtable == nullptr) {
return absl::InvalidArgumentError(

@ -162,6 +162,10 @@ class ChannelInit {
// Add a predicate that ensures this filter does not appear in the minimal
// stack.
FilterRegistration& ExcludeFromMinimalStack();
FilterRegistration& SkipV3() {
skip_v3_ = true;
return *this;
}
private:
friend class ChannelInit;
@ -172,6 +176,7 @@ class ChannelInit {
std::vector<InclusionPredicate> predicates_;
bool terminal_ = false;
bool before_all_ = false;
bool skip_v3_ = false;
SourceLocation registration_source_;
};
@ -195,6 +200,15 @@ class ChannelInit {
registration_source);
}
// Filter does not participate in v3
template <typename Filter>
FilterRegistration& RegisterV2Filter(
grpc_channel_stack_type type, SourceLocation registration_source = {}) {
return RegisterFilter(type, &Filter::kFilter, nullptr,
registration_source)
.SkipV3();
}
// Register a post processor for the builder.
// These run after the main graph has been placed into the builder.
// At most one filter per slot per channel stack type can be added.
@ -274,16 +288,18 @@ class ChannelInit {
private:
struct Filter {
Filter(const grpc_channel_filter* filter, const ChannelFilterVtable* vtable,
std::vector<InclusionPredicate> predicates,
std::vector<InclusionPredicate> predicates, bool skip_v3,
SourceLocation registration_source)
: filter(filter),
vtable(vtable),
predicates(std::move(predicates)),
registration_source(registration_source) {}
registration_source(registration_source),
skip_v3(skip_v3) {}
const grpc_channel_filter* filter;
const ChannelFilterVtable* vtable;
std::vector<InclusionPredicate> predicates;
SourceLocation registration_source;
bool skip_v3 = false;
bool CheckPredicates(const ChannelArgs& args) const;
};
struct StackConfig {

Loading…
Cancel
Save