Add channel arguments to server builder
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94d578e..d4c2792 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2078,6 +2078,7 @@
src/cpp/common/rpc_method.cc
src/cpp/common/version_cc.cc
src/cpp/server/async_generic_service.cc
+ src/cpp/server/channel_argument_option.cc
src/cpp/server/create_default_thread_pool.cc
src/cpp/server/dynamic_thread_pool.cc
src/cpp/server/health/default_health_check_service.cc
@@ -2143,6 +2144,7 @@
include/grpc++/grpc++.h
include/grpc++/health_check_service_interface.h
include/grpc++/impl/call.h
+ include/grpc++/impl/channel_argument_option.h
include/grpc++/impl/client_unary_call.h
include/grpc++/impl/codegen/core_codegen.h
include/grpc++/impl/grpc_library.h
@@ -2264,6 +2266,7 @@
src/cpp/common/rpc_method.cc
src/cpp/common/version_cc.cc
src/cpp/server/async_generic_service.cc
+ src/cpp/server/channel_argument_option.cc
src/cpp/server/create_default_thread_pool.cc
src/cpp/server/dynamic_thread_pool.cc
src/cpp/server/health/default_health_check_service.cc
@@ -2513,6 +2516,7 @@
include/grpc++/grpc++.h
include/grpc++/health_check_service_interface.h
include/grpc++/impl/call.h
+ include/grpc++/impl/channel_argument_option.h
include/grpc++/impl/client_unary_call.h
include/grpc++/impl/codegen/core_codegen.h
include/grpc++/impl/grpc_library.h
@@ -2935,6 +2939,7 @@
src/cpp/common/rpc_method.cc
src/cpp/common/version_cc.cc
src/cpp/server/async_generic_service.cc
+ src/cpp/server/channel_argument_option.cc
src/cpp/server/create_default_thread_pool.cc
src/cpp/server/dynamic_thread_pool.cc
src/cpp/server/health/default_health_check_service.cc
@@ -3000,6 +3005,7 @@
include/grpc++/grpc++.h
include/grpc++/health_check_service_interface.h
include/grpc++/impl/call.h
+ include/grpc++/impl/channel_argument_option.h
include/grpc++/impl/client_unary_call.h
include/grpc++/impl/codegen/core_codegen.h
include/grpc++/impl/grpc_library.h
diff --git a/Makefile b/Makefile
index 57e877b..9542f17 100644
--- a/Makefile
+++ b/Makefile
@@ -3919,6 +3919,7 @@
src/cpp/common/rpc_method.cc \
src/cpp/common/version_cc.cc \
src/cpp/server/async_generic_service.cc \
+ src/cpp/server/channel_argument_option.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/dynamic_thread_pool.cc \
src/cpp/server/health/default_health_check_service.cc \
@@ -3951,6 +3952,7 @@
include/grpc++/grpc++.h \
include/grpc++/health_check_service_interface.h \
include/grpc++/impl/call.h \
+ include/grpc++/impl/channel_argument_option.h \
include/grpc++/impl/client_unary_call.h \
include/grpc++/impl/codegen/core_codegen.h \
include/grpc++/impl/grpc_library.h \
@@ -4118,6 +4120,7 @@
src/cpp/common/rpc_method.cc \
src/cpp/common/version_cc.cc \
src/cpp/server/async_generic_service.cc \
+ src/cpp/server/channel_argument_option.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/dynamic_thread_pool.cc \
src/cpp/server/health/default_health_check_service.cc \
@@ -4333,6 +4336,7 @@
include/grpc++/grpc++.h \
include/grpc++/health_check_service_interface.h \
include/grpc++/impl/call.h \
+ include/grpc++/impl/channel_argument_option.h \
include/grpc++/impl/client_unary_call.h \
include/grpc++/impl/codegen/core_codegen.h \
include/grpc++/impl/grpc_library.h \
@@ -4801,6 +4805,7 @@
src/cpp/common/rpc_method.cc \
src/cpp/common/version_cc.cc \
src/cpp/server/async_generic_service.cc \
+ src/cpp/server/channel_argument_option.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/dynamic_thread_pool.cc \
src/cpp/server/health/default_health_check_service.cc \
@@ -4833,6 +4838,7 @@
include/grpc++/grpc++.h \
include/grpc++/health_check_service_interface.h \
include/grpc++/impl/call.h \
+ include/grpc++/impl/channel_argument_option.h \
include/grpc++/impl/client_unary_call.h \
include/grpc++/impl/codegen/core_codegen.h \
include/grpc++/impl/grpc_library.h \
diff --git a/build.yaml b/build.yaml
index 9ff37d5..5d96524 100644
--- a/build.yaml
+++ b/build.yaml
@@ -776,6 +776,7 @@
- include/grpc++/grpc++.h
- include/grpc++/health_check_service_interface.h
- include/grpc++/impl/call.h
+ - include/grpc++/impl/channel_argument_option.h
- include/grpc++/impl/client_unary_call.h
- include/grpc++/impl/codegen/core_codegen.h
- include/grpc++/impl/grpc_library.h
@@ -832,6 +833,7 @@
- src/cpp/common/rpc_method.cc
- src/cpp/common/version_cc.cc
- src/cpp/server/async_generic_service.cc
+ - src/cpp/server/channel_argument_option.cc
- src/cpp/server/create_default_thread_pool.cc
- src/cpp/server/dynamic_thread_pool.cc
- src/cpp/server/health/default_health_check_service.cc
diff --git a/include/grpc++/impl/channel_argument_option.h b/include/grpc++/impl/channel_argument_option.h
new file mode 100644
index 0000000..057acc2
--- /dev/null
+++ b/include/grpc++/impl/channel_argument_option.h
@@ -0,0 +1,52 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H
+#define GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H
+
+#include <map>
+#include <memory>
+
+#include <grpc++/impl/server_builder_option.h>
+#include <grpc++/support/channel_arguments.h>
+
+namespace grpc {
+
+std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
+ const grpc::string &name, const grpc::string &value);
+std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
+ const grpc::string &name, int value);
+
+} // namespace grpc
+
+#endif // GRPCXX_IMPL_CHANNEL_ARGUMENT_OPTION_H
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h
index 2ac2f0a..d707100 100644
--- a/include/grpc++/server_builder.h
+++ b/include/grpc++/server_builder.h
@@ -39,6 +39,7 @@
#include <memory>
#include <vector>
+#include <grpc++/impl/channel_argument_option.h>
#include <grpc++/impl/server_builder_option.h>
#include <grpc++/impl/server_builder_plugin.h>
#include <grpc++/support/config.h>
@@ -130,6 +131,13 @@
/// Only useful if this is a Synchronous server.
ServerBuilder& SetSyncServerOption(SyncServerOption option, int value);
+ /// Add a channel argument (an escape hatch to tuning core library parameters
+ /// directly)
+ template <class T>
+ ServerBuilder& AddChannelArgument(const grpc::string& arg, const T& value) {
+ return SetOption(MakeChannelArgumentOption(arg, value));
+ }
+
/// Tries to bind \a server to the given \a addr.
///
/// It can be invoked multiple times.
diff --git a/src/cpp/server/channel_argument_option.cc b/src/cpp/server/channel_argument_option.cc
new file mode 100644
index 0000000..723f968
--- /dev/null
+++ b/src/cpp/server/channel_argument_option.cc
@@ -0,0 +1,78 @@
+/*
+ *
+ * Copyright 2017, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <grpc++/impl/channel_argument_option.h>
+
+namespace grpc {
+
+std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
+ const grpc::string &name, const grpc::string &value) {
+ class StringOption final : public ServerBuilderOption {
+ public:
+ StringOption(const grpc::string &name, const grpc::string &value)
+ : name_(name), value_(value) {}
+
+ virtual void UpdateArguments(ChannelArguments *args) override {
+ args->SetString(name_, value_);
+ }
+ virtual void UpdatePlugins(
+ std::vector<std::unique_ptr<ServerBuilderPlugin>> *plugins) override {}
+
+ private:
+ const grpc::string name_;
+ const grpc::string value_;
+ };
+ return std::unique_ptr<ServerBuilderOption>(new StringOption(name, value));
+}
+
+std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption(
+ const grpc::string &name, int value) {
+ class IntOption final : public ServerBuilderOption {
+ public:
+ IntOption(const grpc::string &name, int value)
+ : name_(name), value_(value) {}
+
+ virtual void UpdateArguments(ChannelArguments *args) override {
+ args->SetInt(name_, value_);
+ }
+ virtual void UpdatePlugins(
+ std::vector<std::unique_ptr<ServerBuilderPlugin>> *plugins) override {}
+
+ private:
+ const grpc::string name_;
+ const int value_;
+ };
+ return std::unique_ptr<ServerBuilderOption>(new IntOption(name, value));
+}
+
+} // namespace grpc
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index 551ba46..b0ff5e7 100644
--- a/tools/doxygen/Doxyfile.c++
+++ b/tools/doxygen/Doxyfile.c++
@@ -801,6 +801,7 @@
include/grpc++/grpc++.h \
include/grpc++/health_check_service_interface.h \
include/grpc++/impl/call.h \
+include/grpc++/impl/channel_argument_option.h \
include/grpc++/impl/client_unary_call.h \
include/grpc++/impl/codegen/async_stream.h \
include/grpc++/impl/codegen/async_unary_call.h \
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index 0d7ddfc..5d3e5ed 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -801,6 +801,7 @@
include/grpc++/grpc++.h \
include/grpc++/health_check_service_interface.h \
include/grpc++/impl/call.h \
+include/grpc++/impl/channel_argument_option.h \
include/grpc++/impl/client_unary_call.h \
include/grpc++/impl/codegen/async_stream.h \
include/grpc++/impl/codegen/async_unary_call.h \
@@ -912,6 +913,7 @@
src/cpp/common/secure_create_auth_context.cc \
src/cpp/common/version_cc.cc \
src/cpp/server/async_generic_service.cc \
+src/cpp/server/channel_argument_option.cc \
src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/dynamic_thread_pool.cc \
src/cpp/server/dynamic_thread_pool.h \
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 15bcf56..9994260 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -8253,6 +8253,7 @@
"include/grpc++/grpc++.h",
"include/grpc++/health_check_service_interface.h",
"include/grpc++/impl/call.h",
+ "include/grpc++/impl/channel_argument_option.h",
"include/grpc++/impl/client_unary_call.h",
"include/grpc++/impl/codegen/core_codegen.h",
"include/grpc++/impl/grpc_library.h",
@@ -8309,6 +8310,7 @@
"include/grpc++/grpc++.h",
"include/grpc++/health_check_service_interface.h",
"include/grpc++/impl/call.h",
+ "include/grpc++/impl/channel_argument_option.h",
"include/grpc++/impl/client_unary_call.h",
"include/grpc++/impl/codegen/core_codegen.h",
"include/grpc++/impl/grpc_library.h",
@@ -8358,6 +8360,7 @@
"src/cpp/common/rpc_method.cc",
"src/cpp/common/version_cc.cc",
"src/cpp/server/async_generic_service.cc",
+ "src/cpp/server/channel_argument_option.cc",
"src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.cc",
"src/cpp/server/dynamic_thread_pool.h",
diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj
index 45f3037..c85454a 100644
--- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj
+++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj
@@ -270,6 +270,7 @@
<ClInclude Include="$(SolutionDir)\..\include\grpc++\grpc++.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\health_check_service_interface.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\call.h" />
+ <ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\channel_argument_option.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\client_unary_call.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\core_codegen.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\grpc_library.h" />
@@ -414,6 +415,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\async_generic_service.cc">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\cpp\server\channel_argument_option.cc">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\create_default_thread_pool.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.cc">
diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
index 95cdb74..d800b29 100644
--- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
@@ -70,6 +70,9 @@
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\async_generic_service.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\cpp\server\channel_argument_option.cc">
+ <Filter>src\cpp\server</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\create_default_thread_pool.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
@@ -162,6 +165,9 @@
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\call.h">
<Filter>include\grpc++\impl</Filter>
</ClInclude>
+ <ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\channel_argument_option.h">
+ <Filter>include\grpc++\impl</Filter>
+ </ClInclude>
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\client_unary_call.h">
<Filter>include\grpc++\impl</Filter>
</ClInclude>
diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
index 22ea361..45c0ecd 100644
--- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
+++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
@@ -270,6 +270,7 @@
<ClInclude Include="$(SolutionDir)\..\include\grpc++\grpc++.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\health_check_service_interface.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\call.h" />
+ <ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\channel_argument_option.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\client_unary_call.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\codegen\core_codegen.h" />
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\grpc_library.h" />
@@ -398,6 +399,8 @@
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\async_generic_service.cc">
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\cpp\server\channel_argument_option.cc">
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\create_default_thread_pool.cc">
</ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\dynamic_thread_pool.cc">
diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters
index c3cef2d..987d56d 100644
--- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters
+++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters
@@ -55,6 +55,9 @@
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\async_generic_service.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
+ <ClCompile Include="$(SolutionDir)\..\src\cpp\server\channel_argument_option.cc">
+ <Filter>src\cpp\server</Filter>
+ </ClCompile>
<ClCompile Include="$(SolutionDir)\..\src\cpp\server\create_default_thread_pool.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
@@ -147,6 +150,9 @@
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\call.h">
<Filter>include\grpc++\impl</Filter>
</ClInclude>
+ <ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\channel_argument_option.h">
+ <Filter>include\grpc++\impl</Filter>
+ </ClInclude>
<ClInclude Include="$(SolutionDir)\..\include\grpc++\impl\client_unary_call.h">
<Filter>include\grpc++\impl</Filter>
</ClInclude>