channel_argument_option.cc
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2017 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
27 #include <grpcpp/support/config.h>
28 
29 namespace grpc {
30 
31 std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
32  const std::string& name, const std::string& value) {
33  class StringOption final : public ServerBuilderOption {
34  public:
35  StringOption(const std::string& name, const std::string& value)
36  : name_(name), value_(value) {}
37 
38  void UpdateArguments(ChannelArguments* args) override {
39  args->SetString(name_, value_);
40  }
41  void UpdatePlugins(
42  std::vector<std::unique_ptr<ServerBuilderPlugin>>* /*plugins*/)
43  override {}
44 
45  private:
46  const std::string name_;
47  const std::string value_;
48  };
49  return std::unique_ptr<ServerBuilderOption>(new StringOption(name, value));
50 }
51 
52 std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
53  const std::string& name, int value) {
54  class IntOption final : public ServerBuilderOption {
55  public:
56  IntOption(const std::string& name, int value)
57  : name_(name), value_(value) {}
58 
59  void UpdateArguments(ChannelArguments* args) override {
60  args->SetInt(name_, value_);
61  }
62  void UpdatePlugins(
63  std::vector<std::unique_ptr<ServerBuilderPlugin>>* /*plugins*/)
64  override {}
65 
66  private:
67  const std::string name_;
68  const int value_;
69  };
70  return std::unique_ptr<ServerBuilderOption>(new IntOption(name, value));
71 }
72 
73 } // namespace grpc
grpc
Definition: grpcpp/alarm.h:33
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
setup.name
name
Definition: setup.py:542
name_
const std::string name_
Definition: priority.cc:233
server_builder_plugin.h
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
channel_arguments.h
grpc::ServerBuilderOption
Interface to pass an option to a ServerBuilder.
Definition: grpcpp/impl/server_builder_option.h:31
server_builder_option.h
config.h
value_
int value_
Definition: orphanable_test.cc:38
value
const char * value
Definition: hpack_parser_table.cc:165
grpc::ChannelArguments
Definition: grpcpp/support/channel_arguments.h:39
grpc::MakeChannelArgumentOption
std::unique_ptr< ServerBuilderOption > MakeChannelArgumentOption(const std::string &name, const std::string &value)
Definition: channel_argument_option.cc:31
channel_argument_option.h


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:52