[call-v3] Convert ServerConfigSelectorFilter (#35470)

Closes #35470

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35470 from ctiller:scsf 789b365616
PiperOrigin-RevId: 597006442
pull/35491/head^2
Craig Tiller 1 year ago committed by Copybara-Service
parent 6872a7a473
commit 6eaec4f96e
  1. 38
      src/core/ext/filters/server_config_selector/server_config_selector_filter.cc

@ -47,7 +47,8 @@ namespace grpc_core {
namespace {
class ServerConfigSelectorFilter final : public ChannelFilter {
class ServerConfigSelectorFilter final
: public ImplementChannelFilter<ServerConfigSelectorFilter> {
public:
~ServerConfigSelectorFilter() override;
@ -60,8 +61,16 @@ class ServerConfigSelectorFilter final : public ChannelFilter {
static absl::StatusOr<ServerConfigSelectorFilter> Create(
const ChannelArgs& args, ChannelFilter::Args);
ArenaPromise<ServerMetadataHandle> MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) override;
class Call {
public:
absl::Status OnClientInitialMetadata(ClientMetadata& md,
ServerConfigSelectorFilter* filter);
static const NoInterceptor OnServerInitialMetadata;
static const NoInterceptor OnServerTrailingMetadata;
static const NoInterceptor OnClientToServerMessage;
static const NoInterceptor OnServerToClientMessage;
static const NoInterceptor OnFinalize;
};
absl::StatusOr<RefCountedPtr<ServerConfigSelector>> config_selector() {
MutexLock lock(&state_->mu);
@ -130,25 +139,28 @@ ServerConfigSelectorFilter::~ServerConfigSelectorFilter() {
}
}
ArenaPromise<ServerMetadataHandle> ServerConfigSelectorFilter::MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) {
auto sel = config_selector();
if (!sel.ok()) return Immediate(ServerMetadataFromStatus(sel.status()));
auto call_config =
sel.value()->GetCallConfig(call_args.client_initial_metadata.get());
absl::Status ServerConfigSelectorFilter::Call::OnClientInitialMetadata(
ClientMetadata& md, ServerConfigSelectorFilter* filter) {
auto sel = filter->config_selector();
if (!sel.ok()) return sel.status();
auto call_config = sel.value()->GetCallConfig(&md);
if (!call_config.ok()) {
auto r = Immediate(ServerMetadataFromStatus(
absl::UnavailableError(StatusToString(call_config.status()))));
return std::move(r);
return absl::UnavailableError(StatusToString(call_config.status()));
}
auto* service_config_call_data =
GetContext<Arena>()->New<ServiceConfigCallData>(
GetContext<Arena>(), GetContext<grpc_call_context_element>());
service_config_call_data->SetServiceConfig(
std::move(call_config->service_config), call_config->method_configs);
return next_promise_factory(std::move(call_args));
return absl::OkStatus();
}
const NoInterceptor ServerConfigSelectorFilter::Call::OnServerInitialMetadata;
const NoInterceptor ServerConfigSelectorFilter::Call::OnServerTrailingMetadata;
const NoInterceptor ServerConfigSelectorFilter::Call::OnClientToServerMessage;
const NoInterceptor ServerConfigSelectorFilter::Call::OnServerToClientMessage;
const NoInterceptor ServerConfigSelectorFilter::Call::OnFinalize;
} // namespace
const grpc_channel_filter kServerConfigSelectorFilter =

Loading…
Cancel
Save