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