server_config_selector.h
Go to the documentation of this file.
1 //
2 // Copyright 2021 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_H
18 #define GRPC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_H
19 
21 
22 #include <memory>
23 
24 #include "absl/status/statusor.h"
25 #include "absl/strings/string_view.h"
26 
28 
36 
37 namespace grpc_core {
38 
39 // ServerConfigSelector allows for choosing the service config to apply to a
40 // server-side call based on the received initial metadata.
41 class ServerConfigSelector : public RefCounted<ServerConfigSelector> {
42  public:
43  // Configuration to apply to an incoming call
44  struct CallConfig {
48  };
49 
50  ~ServerConfigSelector() override = default;
51  // Returns the CallConfig to apply to a call based on the incoming \a metadata
53 };
54 
55 // ServerConfigSelectorProvider allows for subscribers to watch for updates on
56 // ServerConfigSelector. It is propagated via channel args.
58  : public DualRefCounted<ServerConfigSelectorProvider> {
59  public:
61  public:
62  virtual ~ServerConfigSelectorWatcher() = default;
63  virtual void OnServerConfigSelectorUpdate(
65  };
66 
67  ~ServerConfigSelectorProvider() override = default;
68  // Only a single watcher is allowed at present
70  std::unique_ptr<ServerConfigSelectorWatcher> watcher) = 0;
71  virtual void CancelWatch() = 0;
72 
74 
75  grpc_arg MakeChannelArg() const;
76 };
77 
78 } // namespace grpc_core
79 
80 #endif // GRPC_CORE_EXT_FILTERS_SERVER_CONFIG_SELECTOR_SERVER_CONFIG_SELECTOR_H
grpc_core::ServerConfigSelectorProvider
Definition: server_config_selector.h:57
grpc_arg
Definition: grpc_types.h:103
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
metadata_batch.h
metadata
Definition: cq_verifier.cc:48
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::ServerConfigSelector::CallConfig
Definition: server_config_selector.h:44
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
grpc_core::DualRefCounted
Definition: dual_ref_counted.h:48
grpc_core::ServiceConfigParser::ParsedConfigVector
std::vector< std::unique_ptr< ParsedConfig > > ParsedConfigVector
Definition: lib/service_config/service_config_parser.h:77
grpc_core::ServerConfigSelector::GetCallConfig
virtual CallConfig GetCallConfig(grpc_metadata_batch *metadata)=0
grpc_core::ServerConfigSelectorProvider::CancelWatch
virtual void CancelWatch()=0
grpc_types.h
grpc_core::ServerConfigSelector::~ServerConfigSelector
~ServerConfigSelector() override=default
grpc_core::RefCountedPtr
Definition: ref_counted_ptr.h:35
grpc_core::ServerConfigSelectorProvider::~ServerConfigSelectorProvider
~ServerConfigSelectorProvider() override=default
grpc_core::ServerConfigSelectorProvider::MakeChannelArg
grpc_arg MakeChannelArg() const
Definition: server_config_selector.cc:52
grpc_core::ServerConfigSelector::CallConfig::error
grpc_error_handle error
Definition: server_config_selector.h:45
grpc_core::ServerConfigSelectorProvider::Watch
virtual absl::StatusOr< RefCountedPtr< ServerConfigSelector > > Watch(std::unique_ptr< ServerConfigSelectorWatcher > watcher)=0
grpc_core::ServerConfigSelector
Definition: server_config_selector.h:41
error.h
grpc_core::RefCounted
Definition: ref_counted.h:280
grpc_core::ServerConfigSelectorProvider::ServerConfigSelectorWatcher::~ServerConfigSelectorWatcher
virtual ~ServerConfigSelectorWatcher()=default
service_config_parser.h
grpc_core::ServerConfigSelector::CallConfig::service_config
RefCountedPtr< ServiceConfig > service_config
Definition: server_config_selector.h:47
ref_counted.h
grpc_core::ServerConfigSelectorProvider::ServerConfigSelectorWatcher
Definition: server_config_selector.h:60
ref_counted_ptr.h
watcher
ClusterWatcher * watcher
Definition: cds.cc:148
dual_ref_counted.h
grpc_core::ServerConfigSelectorProvider::ServerConfigSelectorWatcher::OnServerConfigSelectorUpdate
virtual void OnServerConfigSelectorUpdate(absl::StatusOr< RefCountedPtr< ServerConfigSelector >> update)=0
service_config.h
absl::StatusOr
Definition: abseil-cpp/absl/status/statusor.h:187
grpc_error
Definition: error_internal.h:42
grpc_metadata_batch
Definition: metadata_batch.h:1259
update
absl::optional< XdsClusterResource > update
Definition: cds.cc:150
grpc_core::ServerConfigSelector::CallConfig::method_configs
const ServiceConfigParser::ParsedConfigVector * method_configs
Definition: server_config_selector.h:46
grpc_core::ServerConfigSelectorProvider::ChannelArgName
static absl::string_view ChannelArgName()
Definition: server_config_selector.cc:58
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:17