diff --git a/BUILD b/BUILD index ddd1f97b541..edfc19a6080 100644 --- a/BUILD +++ b/BUILD @@ -137,6 +137,7 @@ GRPCXX_SRCS = [ "src/cpp/common/resource_quota_cc.cc", "src/cpp/common/rpc_method.cc", "src/cpp/common/version_cc.cc", + "src/cpp/common/validate_service_config.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/channel_argument_option.cc", "src/cpp/server/create_default_thread_pool.cc", @@ -284,6 +285,7 @@ GRPCXX_PUBLIC_HDRS = [ "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/time.h", + "include/grpcpp/support/validate_service_config.h", ] grpc_cc_library( diff --git a/BUILD.gn b/BUILD.gn index dcd5bc880eb..8e493af7540 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1141,6 +1141,7 @@ config("grpc_config") { "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/time.h", + "include/grpcpp/support/validate_service_config.h", "src/core/ext/transport/inproc/inproc_transport.h", "src/core/lib/avl/avl.h", "src/core/lib/backoff/backoff.h", @@ -1340,6 +1341,7 @@ config("grpc_config") { "src/cpp/common/secure_auth_context.h", "src/cpp/common/secure_channel_arguments.cc", "src/cpp/common/secure_create_auth_context.cc", + "src/cpp/common/validate_service_config.cc", "src/cpp/common/version_cc.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/channel_argument_option.cc", diff --git a/CMakeLists.txt b/CMakeLists.txt index 429d083d279..c2da881909d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2977,6 +2977,7 @@ add_library(grpc++ src/cpp/common/core_codegen.cc src/cpp/common/resource_quota_cc.cc src/cpp/common/rpc_method.cc + src/cpp/common/validate_service_config.cc src/cpp/common/version_cc.cc src/cpp/server/async_generic_service.cc src/cpp/server/channel_argument_option.cc @@ -3151,6 +3152,7 @@ foreach(_hdr include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h include/grpcpp/support/time.h + include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h @@ -3373,6 +3375,7 @@ add_library(grpc++_cronet src/cpp/common/core_codegen.cc src/cpp/common/resource_quota_cc.cc src/cpp/common/rpc_method.cc + src/cpp/common/validate_service_config.cc src/cpp/common/version_cc.cc src/cpp/server/async_generic_service.cc src/cpp/server/channel_argument_option.cc @@ -3767,6 +3770,7 @@ foreach(_hdr include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h include/grpcpp/support/time.h + include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h @@ -4584,6 +4588,7 @@ add_library(grpc++_unsecure src/cpp/common/core_codegen.cc src/cpp/common/resource_quota_cc.cc src/cpp/common/rpc_method.cc + src/cpp/common/validate_service_config.cc src/cpp/common/version_cc.cc src/cpp/server/async_generic_service.cc src/cpp/server/channel_argument_option.cc @@ -4757,6 +4762,7 @@ foreach(_hdr include/grpcpp/support/stub_options.h include/grpcpp/support/sync_stream.h include/grpcpp/support/time.h + include/grpcpp/support/validate_service_config.h include/grpc/support/alloc.h include/grpc/support/atm.h include/grpc/support/atm_gcc_atomic.h diff --git a/Makefile b/Makefile index 605e533e8a8..a462b5c5074 100644 --- a/Makefile +++ b/Makefile @@ -5370,6 +5370,7 @@ LIBGRPC++_SRC = \ src/cpp/common/core_codegen.cc \ src/cpp/common/resource_quota_cc.cc \ src/cpp/common/rpc_method.cc \ + src/cpp/common/validate_service_config.cc \ src/cpp/common/version_cc.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/channel_argument_option.cc \ @@ -5509,6 +5510,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ + include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ @@ -5775,6 +5777,7 @@ LIBGRPC++_CRONET_SRC = \ src/cpp/common/core_codegen.cc \ src/cpp/common/resource_quota_cc.cc \ src/cpp/common/rpc_method.cc \ + src/cpp/common/validate_service_config.cc \ src/cpp/common/version_cc.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/channel_argument_option.cc \ @@ -6133,6 +6136,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ + include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ @@ -6933,6 +6937,7 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/common/core_codegen.cc \ src/cpp/common/resource_quota_cc.cc \ src/cpp/common/rpc_method.cc \ + src/cpp/common/validate_service_config.cc \ src/cpp/common/version_cc.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/channel_argument_option.cc \ @@ -7072,6 +7077,7 @@ PUBLIC_HEADERS_CXX += \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ + include/grpcpp/support/validate_service_config.h \ include/grpc/support/alloc.h \ include/grpc/support/atm.h \ include/grpc/support/atm_gcc_atomic.h \ diff --git a/build.yaml b/build.yaml index e2a1b75dda5..99820507a6f 100644 --- a/build.yaml +++ b/build.yaml @@ -1428,6 +1428,7 @@ filegroups: - include/grpcpp/support/stub_options.h - include/grpcpp/support/sync_stream.h - include/grpcpp/support/time.h + - include/grpcpp/support/validate_service_config.h headers: - src/cpp/client/create_channel_internal.h - src/cpp/common/channel_filter.h @@ -1451,6 +1452,7 @@ filegroups: - src/cpp/common/core_codegen.cc - src/cpp/common/resource_quota_cc.cc - src/cpp/common/rpc_method.cc + - src/cpp/common/validate_service_config.cc - src/cpp/common/version_cc.cc - src/cpp/server/async_generic_service.cc - src/cpp/server/channel_argument_option.cc diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 10e37bb5f47..17a87304aae 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -148,6 +148,7 @@ Pod::Spec.new do |s| 'include/grpcpp/support/stub_options.h', 'include/grpcpp/support/sync_stream.h', 'include/grpcpp/support/time.h', + 'include/grpcpp/support/validate_service_config.h', 'include/grpcpp/impl/codegen/async_generic_service.h', 'include/grpcpp/impl/codegen/async_stream.h', 'include/grpcpp/impl/codegen/async_unary_call.h', @@ -233,6 +234,7 @@ Pod::Spec.new do |s| 'src/cpp/common/core_codegen.cc', 'src/cpp/common/resource_quota_cc.cc', 'src/cpp/common/rpc_method.cc', + 'src/cpp/common/validate_service_config.cc', 'src/cpp/common/version_cc.cc', 'src/cpp/server/async_generic_service.cc', 'src/cpp/server/channel_argument_option.cc', diff --git a/grpc.gyp b/grpc.gyp index 833a0b48715..1668900a3c7 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1447,6 +1447,7 @@ 'src/cpp/common/core_codegen.cc', 'src/cpp/common/resource_quota_cc.cc', 'src/cpp/common/rpc_method.cc', + 'src/cpp/common/validate_service_config.cc', 'src/cpp/common/version_cc.cc', 'src/cpp/server/async_generic_service.cc', 'src/cpp/server/channel_argument_option.cc', @@ -1602,6 +1603,7 @@ 'src/cpp/common/core_codegen.cc', 'src/cpp/common/resource_quota_cc.cc', 'src/cpp/common/rpc_method.cc', + 'src/cpp/common/validate_service_config.cc', 'src/cpp/common/version_cc.cc', 'src/cpp/server/async_generic_service.cc', 'src/cpp/server/channel_argument_option.cc', diff --git a/include/grpcpp/support/channel_arguments_impl.h b/include/grpcpp/support/channel_arguments_impl.h index a137a5b7c7d..0efeadca880 100644 --- a/include/grpcpp/support/channel_arguments_impl.h +++ b/include/grpcpp/support/channel_arguments_impl.h @@ -31,15 +31,6 @@ namespace grpc { namespace testing { class ChannelArgumentsTest; } // namespace testing - -namespace experimental { -/// Validates \a service_config_json. If valid, returns an empty string. -/// Otherwise, returns the validation error. -/// TODO(yashykt): Promote it to out of experimental once it is proved useful -/// and gRFC is accepted. -grpc::string ValidateServiceConfigJSON(const grpc::string& service_config_json); -} // namespace experimental - } // namespace grpc namespace grpc_impl { diff --git a/include/grpcpp/support/validate_service_config.h b/include/grpcpp/support/validate_service_config.h new file mode 100644 index 00000000000..d5ea521a1ef --- /dev/null +++ b/include/grpcpp/support/validate_service_config.h @@ -0,0 +1,36 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H +#define GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H + +#include + +namespace grpc { + +namespace experimental { +/// Validates \a service_config_json. If valid, returns an empty string. +/// Otherwise, returns the validation error. +/// TODO(yashykt): Promote it to out of experimental once it is proved useful +/// and gRFC is accepted. +grpc::string ValidateServiceConfigJSON(const grpc::string& service_config_json); +} // namespace experimental + +} // namespace grpc + +#endif // GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H \ No newline at end of file diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index b97e1ed8da9..f35c91572eb 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -217,21 +217,3 @@ void ChannelArguments::SetChannelArgs(grpc_channel_args* channel_args) const { } } // namespace grpc_impl - -namespace grpc { -namespace experimental { -grpc::string ValidateServiceConfigJSON( - const grpc::string& service_config_json) { - grpc_init(); - grpc_error* error = GRPC_ERROR_NONE; - grpc_core::ServiceConfig::Create(service_config_json.c_str(), &error); - grpc::string return_value; - if (error != GRPC_ERROR_NONE) { - return_value = grpc_error_string(error); - GRPC_ERROR_UNREF(error); - } - grpc_shutdown(); - return return_value; -} -} // namespace experimental -} // namespace grpc diff --git a/src/cpp/common/validate_service_config.cc b/src/cpp/common/validate_service_config.cc new file mode 100644 index 00000000000..0f193cf1c42 --- /dev/null +++ b/src/cpp/common/validate_service_config.cc @@ -0,0 +1,40 @@ +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include "src/core/ext/filters/client_channel/service_config.h" + +namespace grpc { +namespace experimental { +grpc::string ValidateServiceConfigJSON( + const grpc::string& service_config_json) { + grpc_init(); + grpc_error* error = GRPC_ERROR_NONE; + grpc_core::ServiceConfig::Create(service_config_json.c_str(), &error); + grpc::string return_value; + if (error != GRPC_ERROR_NONE) { + return_value = grpc_error_string(error); + GRPC_ERROR_UNREF(error); + } + grpc_shutdown(); + return return_value; +} +} // namespace experimental +} // namespace grpc diff --git a/test/cpp/end2end/service_config_end2end_test.cc b/test/cpp/end2end/service_config_end2end_test.cc index e5c3a8e3eff..14786b98f85 100644 --- a/test/cpp/end2end/service_config_end2end_test.cc +++ b/test/cpp/end2end/service_config_end2end_test.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include "src/core/ext/filters/client_channel/backup_poller.h" #include "src/core/ext/filters/client_channel/global_subchannel_pool.h" diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 667b9b3541e..913d7be993b 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -1040,7 +1040,8 @@ include/grpcpp/support/status_code_enum.h \ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ -include/grpcpp/support/time.h +include/grpcpp/support/time.h \ +include/grpcpp/support/validate_service_config.h # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 529b35a2c39..58192bfc34b 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1043,6 +1043,7 @@ include/grpcpp/support/string_ref.h \ include/grpcpp/support/stub_options.h \ include/grpcpp/support/sync_stream.h \ include/grpcpp/support/time.h \ +include/grpcpp/support/validate_service_config.h \ src/core/ext/filters/client_channel/health/health.pb.c \ src/core/ext/filters/client_channel/health/health.pb.h \ src/core/ext/transport/inproc/inproc_transport.h \ @@ -1245,6 +1246,7 @@ src/cpp/common/secure_auth_context.cc \ src/cpp/common/secure_auth_context.h \ src/cpp/common/secure_channel_arguments.cc \ src/cpp/common/secure_create_auth_context.cc \ +src/cpp/common/validate_service_config.cc \ src/cpp/common/version_cc.cc \ src/cpp/server/async_generic_service.cc \ src/cpp/server/channel_argument_option.cc \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index e67465d1602..677fff1d48b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -10311,6 +10311,7 @@ "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/time.h", + "include/grpcpp/support/validate_service_config.h", "src/cpp/client/create_channel_internal.h", "src/cpp/common/channel_filter.h", "src/cpp/server/dynamic_thread_pool.h", @@ -10436,6 +10437,7 @@ "include/grpcpp/support/stub_options.h", "include/grpcpp/support/sync_stream.h", "include/grpcpp/support/time.h", + "include/grpcpp/support/validate_service_config.h", "src/cpp/client/channel_cc.cc", "src/cpp/client/client_context.cc", "src/cpp/client/client_interceptor.cc", @@ -10453,6 +10455,7 @@ "src/cpp/common/core_codegen.cc", "src/cpp/common/resource_quota_cc.cc", "src/cpp/common/rpc_method.cc", + "src/cpp/common/validate_service_config.cc", "src/cpp/common/version_cc.cc", "src/cpp/server/async_generic_service.cc", "src/cpp/server/channel_argument_option.cc",