aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD7
-rw-r--r--CMakeLists.txt106
-rw-r--r--Makefile110
-rwxr-xr-xRakefile6
-rw-r--r--build.yaml42
-rw-r--r--config.m42
-rw-r--r--config.w322
-rw-r--r--doc/g_stands_for.md3
-rw-r--r--doc/python/sphinx/grpc.rst5
-rwxr-xr-xexamples/ruby/greeter_server.rb5
-rwxr-xr-xexamples/ruby/route_guide/route_guide_server.rb5
-rw-r--r--gRPC-C++.podspec6
-rw-r--r--gRPC-Core.podspec8
-rw-r--r--gRPC-ProtoRPC.podspec2
-rw-r--r--gRPC-RxLibrary.podspec2
-rw-r--r--gRPC.podspec4
-rw-r--r--grpc.gemspec3
-rw-r--r--grpc.gyp8
-rw-r--r--include/grpc/impl/codegen/grpc_types.h6
-rw-r--r--include/grpc/impl/codegen/port_platform.h5
-rw-r--r--include/grpcpp/impl/codegen/call_op_set.h108
-rw-r--r--include/grpcpp/impl/codegen/client_callback.h12
-rw-r--r--include/grpcpp/impl/codegen/client_unary_call.h2
-rw-r--r--include/grpcpp/impl/codegen/interceptor.h31
-rw-r--r--include/grpcpp/impl/codegen/interceptor_common.h88
-rw-r--r--include/grpcpp/impl/codegen/method_handler_impl.h4
-rw-r--r--include/grpcpp/impl/codegen/server_callback.h12
-rw-r--r--include/grpcpp/impl/codegen/server_interface.h2
-rw-r--r--include/grpcpp/impl/codegen/sync_stream.h10
-rw-r--r--package.xml7
-rw-r--r--setup.py2
-rw-r--r--src/compiler/objective_c_generator.cc100
-rw-r--r--src/compiler/objective_c_generator.h7
-rw-r--r--src/compiler/objective_c_plugin.cc21
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.cc2
-rw-r--r--src/core/ext/filters/client_channel/client_channel_factory.h4
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/subchannel_list.h5
-rw-r--r--src/core/ext/filters/client_channel/parse_address.cc29
-rw-r--r--src/core/ext/filters/client_channel/subchannel.cc36
-rw-r--r--src/core/ext/filters/client_channel/subchannel.h15
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.cc32
-rw-r--r--src/core/ext/filters/client_channel/subchannel_index.h3
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.cc10
-rw-r--r--src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc44
-rw-r--r--src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc16
-rw-r--r--src/core/lib/iomgr/cfstream_handle.cc97
-rw-r--r--src/core/lib/iomgr/cfstream_handle.h2
-rw-r--r--src/core/lib/iomgr/grpc_if_nametoindex.h30
-rw-r--r--src/core/lib/iomgr/grpc_if_nametoindex_posix.cc42
-rw-r--r--src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc38
-rw-r--r--src/core/lib/iomgr/port.h1
-rw-r--r--src/core/lib/iomgr/resource_quota.cc1
-rw-r--r--src/core/lib/iomgr/tcp_windows.cc94
-rw-r--r--src/core/lib/surface/channel_init.h5
-rw-r--r--src/core/lib/surface/server.cc104
-rw-r--r--src/core/lib/surface/version.cc2
-rw-r--r--src/core/lib/transport/metadata.cc1
-rw-r--r--src/cpp/common/channel_filter.h5
-rw-r--r--src/cpp/common/version_cc.cc2
-rw-r--r--src/cpp/server/server_cc.cc4
-rw-r--r--src/csharp/Grpc.Core/Interceptors/ServerServiceDefinitionExtensions.cs2
-rwxr-xr-xsrc/csharp/Grpc.Core/Version.csproj.include2
-rw-r--r--src/csharp/Grpc.Core/VersionInfo.cs4
-rwxr-xr-xsrc/csharp/build_packages_dotnetcli.bat2
-rw-r--r--src/csharp/build_unitypackage.bat2
-rw-r--r--src/objective-c/!ProtoCompiler-gRPCPlugin.podspec2
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+ChannelArg.h34
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+ChannelArg.m5
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h10
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+Cronet.h13
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+OAuth2.h29
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+Tests.h25
-rw-r--r--src/objective-c/GRPCClient/GRPCCall+Tests.m4
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.h174
-rw-r--r--src/objective-c/GRPCClient/GRPCCall.m470
-rw-r--r--src/objective-c/GRPCClient/GRPCCallOptions.h348
-rw-r--r--src/objective-c/GRPCClient/GRPCCallOptions.m525
-rw-r--r--src/objective-c/GRPCClient/internal/GRPCCallOptions+Internal.h39
-rw-r--r--src/objective-c/GRPCClient/private/ChannelArgsUtil.h38
-rw-r--r--src/objective-c/GRPCClient/private/ChannelArgsUtil.m94
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.h71
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m339
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelFactory.h34
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h51
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.h101
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannelPool.m276
-rw-r--r--src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m4
-rw-r--r--src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h36
-rw-r--r--src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m79
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.h29
-rw-r--r--src/objective-c/GRPCClient/private/GRPCHost.m288
-rw-r--r--src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h35
-rw-r--r--src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m43
-rw-r--r--src/objective-c/GRPCClient/private/GRPCRequestHeaders.m4
-rw-r--r--src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h38
-rw-r--r--src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m135
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.h14
-rw-r--r--src/objective-c/GRPCClient/private/GRPCWrappedCall.m122
-rw-r--r--src/objective-c/GRPCClient/private/version.h2
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.h118
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.m227
-rw-r--r--src/objective-c/ProtoRPC/ProtoService.h35
-rw-r--r--src/objective-c/ProtoRPC/ProtoService.m67
-rw-r--r--src/objective-c/examples/SwiftSample/ViewController.swift10
-rw-r--r--src/objective-c/tests/APIv2Tests/APIv2Tests.m478
-rw-r--r--src/objective-c/tests/APIv2Tests/Info.plist22
-rw-r--r--src/objective-c/tests/ChannelTests/ChannelPoolTest.m63
-rw-r--r--src/objective-c/tests/ChannelTests/ChannelTests.m112
-rw-r--r--src/objective-c/tests/ChannelTests/Info.plist22
-rw-r--r--src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm6
-rw-r--r--src/objective-c/tests/CronetUnitTests/CronetUnitTests.m13
-rw-r--r--src/objective-c/tests/GRPCClientTests.m14
-rw-r--r--src/objective-c/tests/InteropTests.h21
-rw-r--r--src/objective-c/tests/InteropTests.m322
-rw-r--r--src/objective-c/tests/InteropTestsCallOptions/Info.plist22
-rw-r--r--src/objective-c/tests/InteropTestsCallOptions/InteropTestsCallOptions.m116
-rw-r--r--src/objective-c/tests/InteropTestsLocalCleartext.m12
-rw-r--r--src/objective-c/tests/InteropTestsLocalSSL.m18
-rw-r--r--src/objective-c/tests/InteropTestsMultipleChannels/Info.plist22
-rw-r--r--src/objective-c/tests/InteropTestsMultipleChannels/InteropTestsMultipleChannels.m259
-rw-r--r--src/objective-c/tests/InteropTestsRemote.m18
-rw-r--r--src/objective-c/tests/Podfile22
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/project.pbxproj1085
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/APIv2Tests.xcscheme90
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/ChannelTests.xcscheme90
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsCallOptions.xcscheme56
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme8
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsMultipleChannels.xcscheme56
-rw-r--r--src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme2
-rwxr-xr-xsrc/objective-c/tests/run_tests.sh22
-rw-r--r--src/objective-c/tests/version.h2
-rw-r--r--src/php/composer.json2
-rw-r--r--src/php/ext/grpc/version.h2
-rw-r--r--src/python/grpcio/grpc/__init__.py5
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi13
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi37
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi9
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi1
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi8
-rw-r--r--src/python/grpcio/grpc/_grpcio_metadata.py2
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py2
-rw-r--r--src/python/grpcio/grpc_version.py2
-rw-r--r--src/python/grpcio_channelz/grpc_version.py2
-rw-r--r--src/python/grpcio_health_checking/grpc_health/v1/health.py80
-rw-r--r--src/python/grpcio_health_checking/grpc_version.py2
-rw-r--r--src/python/grpcio_reflection/grpc_version.py2
-rw-r--r--src/python/grpcio_status/grpc_version.py2
-rw-r--r--src/python/grpcio_testing/grpc_version.py2
-rw-r--r--src/python/grpcio_tests/commands.py1
-rw-r--r--src/python/grpcio_tests/grpc_version.py2
-rw-r--r--src/python/grpcio_tests/tests/health_check/BUILD.bazel1
-rw-r--r--src/python/grpcio_tests/tests/health_check/_health_servicer_test.py179
-rw-r--r--src/python/grpcio_tests/tests/tests.json1
-rw-r--r--src/python/grpcio_tests/tests/unit/BUILD.bazel1
-rw-r--r--src/python/grpcio_tests/tests/unit/_cython/_fork_test.py4
-rw-r--r--src/python/grpcio_tests/tests/unit/_logging_test.py104
-rw-r--r--src/python/grpcio_tests/tests/unit/_version_test.py30
-rwxr-xr-xsrc/ruby/end2end/graceful_sig_handling_client.rb61
-rwxr-xr-xsrc/ruby/end2end/graceful_sig_handling_driver.rb83
-rwxr-xr-xsrc/ruby/end2end/graceful_sig_stop_client.rb78
-rwxr-xr-xsrc/ruby/end2end/graceful_sig_stop_driver.rb62
-rw-r--r--src/ruby/ext/grpc/rb_channel.c8
-rw-r--r--src/ruby/lib/grpc/generic/rpc_server.rb61
-rw-r--r--src/ruby/lib/grpc/version.rb2
-rw-r--r--src/ruby/tools/version.rb2
-rw-r--r--templates/CMakeLists.txt.template2
-rw-r--r--templates/gRPC-Core.podspec.template2
-rw-r--r--templates/gRPC.podspec.template2
-rw-r--r--templates/tools/dockerfile/interoptest/grpc_interop_go1.11/Dockerfile.template23
-rw-r--r--templates/tools/dockerfile/interoptest/grpc_interop_go1.11/build_interop.sh.template3
-rw-r--r--templates/tools/dockerfile/ruby_deps.include14
-rw-r--r--test/core/client_channel/BUILD11
-rw-r--r--test/core/client_channel/parse_address_with_named_scope_id_test.cc126
-rw-r--r--test/core/end2end/fixtures/h2_full+trace.cc9
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.cc9
-rw-r--r--test/core/fling/BUILD12
-rw-r--r--test/core/iomgr/BUILD20
-rw-r--r--test/core/iomgr/resolve_address_posix_test.cc81
-rw-r--r--test/core/iomgr/tcp_server_posix_test.cc5
-rw-r--r--test/core/memory_usage/BUILD8
-rw-r--r--test/cpp/end2end/client_interceptors_end2end_test.cc299
-rw-r--r--test/cpp/end2end/interceptors_util.cc10
-rw-r--r--test/cpp/end2end/interceptors_util.h3
-rw-r--r--test/cpp/end2end/server_interceptors_end2end_test.cc81
-rw-r--r--test/cpp/microbenchmarks/bm_call_create.cc2
-rw-r--r--test/cpp/qps/client.h118
-rw-r--r--test/cpp/qps/client_callback.cc201
-rwxr-xr-xtest/cpp/qps/gen_build_yaml.py2
-rw-r--r--third_party/rake-compiler-dock/Dockerfile3
-rw-r--r--tools/distrib/build_ruby_environment_macos.sh2
-rw-r--r--tools/distrib/python/grpcio_tools/grpc_version.py2
-rw-r--r--tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile15
-rw-r--r--tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile18
-rw-r--r--tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile21
-rw-r--r--tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile19
-rw-r--r--tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile40
-rw-r--r--tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_3/Dockerfile41
-rw-r--r--tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_4/Dockerfile40
-rw-r--r--tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_5/Dockerfile40
-rw-r--r--tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_6/Dockerfile (renamed from tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_0_0/Dockerfile)14
-rw-r--r--tools/dockerfile/grpc_artifact_linux_x64/Dockerfile4
-rw-r--r--tools/dockerfile/grpc_artifact_linux_x86/Dockerfile4
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_go1.11/Dockerfile36
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_go1.11/build_interop.sh33
-rw-r--r--tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile14
-rwxr-xr-xtools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh4
-rw-r--r--tools/dockerfile/test/ruby_jessie_x64/Dockerfile14
-rw-r--r--tools/doxygen/Doxyfile.c++2
-rw-r--r--tools/doxygen/Doxyfile.c++.internal3
-rw-r--r--tools/doxygen/Doxyfile.core.internal3
-rw-r--r--tools/internal_ci/helper_scripts/prepare_build_macos_rc2
-rwxr-xr-xtools/internal_ci/linux/grpc_interop_matrix.sh13
-rw-r--r--tools/interop_matrix/client_matrix.py86
-rwxr-xr-xtools/interop_matrix/create_matrix_images.py2
-rwxr-xr-xtools/interop_matrix/run_interop_matrix_tests.py36
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_ruby.sh2
-rw-r--r--tools/run_tests/artifacts/distribtest_targets.py8
-rw-r--r--tools/run_tests/generated/sources_and_headers.json38
-rw-r--r--tools/run_tests/generated/tests.json54
-rwxr-xr-xtools/run_tests/helper_scripts/run_ruby_end2end_tests.sh2
220 files changed, 9428 insertions, 1403 deletions
diff --git a/BUILD b/BUILD
index e3c765198b..453c64ab08 100644
--- a/BUILD
+++ b/BUILD
@@ -64,11 +64,11 @@ config_setting(
)
# This should be updated along with build.yaml
-g_stands_for = "goose"
+g_stands_for = "gold"
core_version = "7.0.0-dev"
-version = "1.18.0-dev"
+version = "1.19.0-dev"
GPR_PUBLIC_HDRS = [
"include/grpc/support/alloc.h",
@@ -732,6 +732,8 @@ grpc_cc_library(
"src/core/lib/iomgr/iomgr_posix.cc",
"src/core/lib/iomgr/iomgr_windows.cc",
"src/core/lib/iomgr/is_epollexclusive_available.cc",
+ "src/core/lib/iomgr/grpc_if_nametoindex_posix.cc",
+ "src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc",
"src/core/lib/iomgr/load_file.cc",
"src/core/lib/iomgr/lockfree_event.cc",
"src/core/lib/iomgr/network_status_tracker.cc",
@@ -873,6 +875,7 @@ grpc_cc_library(
"src/core/lib/iomgr/executor.h",
"src/core/lib/iomgr/gethostname.h",
"src/core/lib/iomgr/gevent_util.h",
+ "src/core/lib/iomgr/grpc_if_nametoindex.h",
"src/core/lib/iomgr/internal_errqueue.h",
"src/core/lib/iomgr/iocp_windows.h",
"src/core/lib/iomgr/iomgr.h",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d3ebb5d177..38f8ad915f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,7 @@
cmake_minimum_required(VERSION 2.8)
set(PACKAGE_NAME "grpc")
-set(PACKAGE_VERSION "1.18.0-dev")
+set(PACKAGE_VERSION "1.19.0-dev")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
@@ -94,7 +94,7 @@ endif()
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
-add_definitions(-DPB_FIELD_16BIT)
+add_definitions(-DPB_FIELD_32BIT)
if (MSVC)
include(cmake/msvc_static_runtime.cmake)
@@ -371,11 +371,17 @@ add_dependencies(buildtests_c murmur_hash_test)
add_dependencies(buildtests_c no_server_test)
add_dependencies(buildtests_c num_external_connectivity_watchers_test)
add_dependencies(buildtests_c parse_address_test)
+if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
+add_dependencies(buildtests_c parse_address_with_named_scope_id_test)
+endif()
add_dependencies(buildtests_c percent_encoding_test)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
-add_dependencies(buildtests_c resolve_address_posix_test)
+add_dependencies(buildtests_c resolve_address_using_ares_resolver_posix_test)
endif()
add_dependencies(buildtests_c resolve_address_using_ares_resolver_test)
+if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
+add_dependencies(buildtests_c resolve_address_using_native_resolver_posix_test)
+endif()
add_dependencies(buildtests_c resolve_address_using_native_resolver_test)
add_dependencies(buildtests_c resource_quota_test)
add_dependencies(buildtests_c secure_channel_create_test)
@@ -989,6 +995,8 @@ add_library(grpc
src/core/lib/iomgr/gethostname_fallback.cc
src/core/lib/iomgr/gethostname_host_name_max.cc
src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
src/core/lib/iomgr/internal_errqueue.cc
src/core/lib/iomgr/iocp_windows.cc
src/core/lib/iomgr/iomgr.cc
@@ -1411,6 +1419,8 @@ add_library(grpc_cronet
src/core/lib/iomgr/gethostname_fallback.cc
src/core/lib/iomgr/gethostname_host_name_max.cc
src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
src/core/lib/iomgr/internal_errqueue.cc
src/core/lib/iomgr/iocp_windows.cc
src/core/lib/iomgr/iomgr.cc
@@ -1817,6 +1827,8 @@ add_library(grpc_test_util
src/core/lib/iomgr/gethostname_fallback.cc
src/core/lib/iomgr/gethostname_host_name_max.cc
src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
src/core/lib/iomgr/internal_errqueue.cc
src/core/lib/iomgr/iocp_windows.cc
src/core/lib/iomgr/iomgr.cc
@@ -2139,6 +2151,8 @@ add_library(grpc_test_util_unsecure
src/core/lib/iomgr/gethostname_fallback.cc
src/core/lib/iomgr/gethostname_host_name_max.cc
src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
src/core/lib/iomgr/internal_errqueue.cc
src/core/lib/iomgr/iocp_windows.cc
src/core/lib/iomgr/iomgr.cc
@@ -2438,6 +2452,8 @@ add_library(grpc_unsecure
src/core/lib/iomgr/gethostname_fallback.cc
src/core/lib/iomgr/gethostname_host_name_max.cc
src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
src/core/lib/iomgr/internal_errqueue.cc
src/core/lib/iomgr/iocp_windows.cc
src/core/lib/iomgr/iomgr.cc
@@ -3323,6 +3339,8 @@ add_library(grpc++_cronet
src/core/lib/iomgr/gethostname_fallback.cc
src/core/lib/iomgr/gethostname_host_name_max.cc
src/core/lib/iomgr/gethostname_sysconf.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
src/core/lib/iomgr/internal_errqueue.cc
src/core/lib/iomgr/iocp_windows.cc
src/core/lib/iomgr/iomgr.cc
@@ -9132,6 +9150,42 @@ target_link_libraries(parse_address_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
+
+add_executable(parse_address_with_named_scope_id_test
+ test/core/client_channel/parse_address_with_named_scope_id_test.cc
+)
+
+
+target_include_directories(parse_address_with_named_scope_id_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
+ PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
+)
+
+target_link_libraries(parse_address_with_named_scope_id_test
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc
+ gpr
+)
+
+ # avoid dependency on libstdc++
+ if (_gRPC_CORE_NOSTDCXX_FLAGS)
+ set_target_properties(parse_address_with_named_scope_id_test PROPERTIES LINKER_LANGUAGE C)
+ target_compile_options(parse_address_with_named_scope_id_test PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${_gRPC_CORE_NOSTDCXX_FLAGS}>)
+ endif()
+
+endif()
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
add_executable(percent_encoding_test
test/core/slice/percent_encoding_test.cc
@@ -9168,12 +9222,12 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
-add_executable(resolve_address_posix_test
+add_executable(resolve_address_using_ares_resolver_posix_test
test/core/iomgr/resolve_address_posix_test.cc
)
-target_include_directories(resolve_address_posix_test
+target_include_directories(resolve_address_using_ares_resolver_posix_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
@@ -9186,7 +9240,7 @@ target_include_directories(resolve_address_posix_test
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
)
-target_link_libraries(resolve_address_posix_test
+target_link_libraries(resolve_address_using_ares_resolver_posix_test
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc
@@ -9195,8 +9249,8 @@ target_link_libraries(resolve_address_posix_test
# avoid dependency on libstdc++
if (_gRPC_CORE_NOSTDCXX_FLAGS)
- set_target_properties(resolve_address_posix_test PROPERTIES LINKER_LANGUAGE C)
- target_compile_options(resolve_address_posix_test PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${_gRPC_CORE_NOSTDCXX_FLAGS}>)
+ set_target_properties(resolve_address_using_ares_resolver_posix_test PROPERTIES LINKER_LANGUAGE C)
+ target_compile_options(resolve_address_using_ares_resolver_posix_test PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${_gRPC_CORE_NOSTDCXX_FLAGS}>)
endif()
endif()
@@ -9236,6 +9290,42 @@ target_link_libraries(resolve_address_using_ares_resolver_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
+if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
+
+add_executable(resolve_address_using_native_resolver_posix_test
+ test/core/iomgr/resolve_address_posix_test.cc
+)
+
+
+target_include_directories(resolve_address_using_native_resolver_posix_test
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
+ PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
+ PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
+ PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
+ PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
+ PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
+ PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
+ PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
+)
+
+target_link_libraries(resolve_address_using_native_resolver_posix_test
+ ${_gRPC_ALLTARGETS_LIBRARIES}
+ grpc_test_util
+ grpc
+ gpr
+)
+
+ # avoid dependency on libstdc++
+ if (_gRPC_CORE_NOSTDCXX_FLAGS)
+ set_target_properties(resolve_address_using_native_resolver_posix_test PROPERTIES LINKER_LANGUAGE C)
+ target_compile_options(resolve_address_using_native_resolver_posix_test PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${_gRPC_CORE_NOSTDCXX_FLAGS}>)
+ endif()
+
+endif()
+endif (gRPC_BUILD_TESTS)
+if (gRPC_BUILD_TESTS)
add_executable(resolve_address_using_native_resolver_test
test/core/iomgr/resolve_address_test.cc
diff --git a/Makefile b/Makefile
index b8a1c92186..504ef40963 100644
--- a/Makefile
+++ b/Makefile
@@ -438,8 +438,8 @@ Q = @
endif
CORE_VERSION = 7.0.0-dev
-CPP_VERSION = 1.18.0-dev
-CSHARP_VERSION = 1.18.0-dev
+CPP_VERSION = 1.19.0-dev
+CSHARP_VERSION = 1.19.0-dev
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
@@ -1076,11 +1076,13 @@ nanopb_fuzzer_serverlist_test: $(BINDIR)/$(CONFIG)/nanopb_fuzzer_serverlist_test
no_server_test: $(BINDIR)/$(CONFIG)/no_server_test
num_external_connectivity_watchers_test: $(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test
parse_address_test: $(BINDIR)/$(CONFIG)/parse_address_test
+parse_address_with_named_scope_id_test: $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test
percent_decode_fuzzer: $(BINDIR)/$(CONFIG)/percent_decode_fuzzer
percent_encode_fuzzer: $(BINDIR)/$(CONFIG)/percent_encode_fuzzer
percent_encoding_test: $(BINDIR)/$(CONFIG)/percent_encoding_test
-resolve_address_posix_test: $(BINDIR)/$(CONFIG)/resolve_address_posix_test
+resolve_address_using_ares_resolver_posix_test: $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test
resolve_address_using_ares_resolver_test: $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test
+resolve_address_using_native_resolver_posix_test: $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test
resolve_address_using_native_resolver_test: $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test
resource_quota_test: $(BINDIR)/$(CONFIG)/resource_quota_test
secure_channel_create_test: $(BINDIR)/$(CONFIG)/secure_channel_create_test
@@ -1527,9 +1529,11 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/no_server_test \
$(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test \
$(BINDIR)/$(CONFIG)/parse_address_test \
+ $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test \
$(BINDIR)/$(CONFIG)/percent_encoding_test \
- $(BINDIR)/$(CONFIG)/resolve_address_posix_test \
+ $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test \
$(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test \
+ $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test \
$(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test \
$(BINDIR)/$(CONFIG)/resource_quota_test \
$(BINDIR)/$(CONFIG)/secure_channel_create_test \
@@ -2129,12 +2133,16 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/num_external_connectivity_watchers_test || ( echo test num_external_connectivity_watchers_test failed ; exit 1 )
$(E) "[RUN] Testing parse_address_test"
$(Q) $(BINDIR)/$(CONFIG)/parse_address_test || ( echo test parse_address_test failed ; exit 1 )
+ $(E) "[RUN] Testing parse_address_with_named_scope_id_test"
+ $(Q) $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test || ( echo test parse_address_with_named_scope_id_test failed ; exit 1 )
$(E) "[RUN] Testing percent_encoding_test"
$(Q) $(BINDIR)/$(CONFIG)/percent_encoding_test || ( echo test percent_encoding_test failed ; exit 1 )
- $(E) "[RUN] Testing resolve_address_posix_test"
- $(Q) $(BINDIR)/$(CONFIG)/resolve_address_posix_test || ( echo test resolve_address_posix_test failed ; exit 1 )
+ $(E) "[RUN] Testing resolve_address_using_ares_resolver_posix_test"
+ $(Q) $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test || ( echo test resolve_address_using_ares_resolver_posix_test failed ; exit 1 )
$(E) "[RUN] Testing resolve_address_using_ares_resolver_test"
$(Q) $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_test || ( echo test resolve_address_using_ares_resolver_test failed ; exit 1 )
+ $(E) "[RUN] Testing resolve_address_using_native_resolver_posix_test"
+ $(Q) $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test || ( echo test resolve_address_using_native_resolver_posix_test failed ; exit 1 )
$(E) "[RUN] Testing resolve_address_using_native_resolver_test"
$(Q) $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_test || ( echo test resolve_address_using_native_resolver_test failed ; exit 1 )
$(E) "[RUN] Testing resource_quota_test"
@@ -3504,6 +3512,8 @@ LIBGRPC_SRC = \
src/core/lib/iomgr/gethostname_fallback.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \
src/core/lib/iomgr/internal_errqueue.cc \
src/core/lib/iomgr/iocp_windows.cc \
src/core/lib/iomgr/iomgr.cc \
@@ -3920,6 +3930,8 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/iomgr/gethostname_fallback.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \
src/core/lib/iomgr/internal_errqueue.cc \
src/core/lib/iomgr/iocp_windows.cc \
src/core/lib/iomgr/iomgr.cc \
@@ -4319,6 +4331,8 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/lib/iomgr/gethostname_fallback.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \
src/core/lib/iomgr/internal_errqueue.cc \
src/core/lib/iomgr/iocp_windows.cc \
src/core/lib/iomgr/iomgr.cc \
@@ -4628,6 +4642,8 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
src/core/lib/iomgr/gethostname_fallback.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \
src/core/lib/iomgr/internal_errqueue.cc \
src/core/lib/iomgr/iocp_windows.cc \
src/core/lib/iomgr/iomgr.cc \
@@ -4901,6 +4917,8 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/iomgr/gethostname_fallback.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \
src/core/lib/iomgr/internal_errqueue.cc \
src/core/lib/iomgr/iocp_windows.cc \
src/core/lib/iomgr/iomgr.cc \
@@ -5763,6 +5781,8 @@ LIBGRPC++_CRONET_SRC = \
src/core/lib/iomgr/gethostname_fallback.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \
src/core/lib/iomgr/internal_errqueue.cc \
src/core/lib/iomgr/iocp_windows.cc \
src/core/lib/iomgr/iomgr.cc \
@@ -13988,6 +14008,38 @@ endif
endif
+PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_SRC = \
+ test/core/client_channel/parse_address_with_named_scope_id_test.cc \
+
+PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test: $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/parse_address_with_named_scope_id_test
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/client_channel/parse_address_with_named_scope_id_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_parse_address_with_named_scope_id_test: $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(PARSE_ADDRESS_WITH_NAMED_SCOPE_ID_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
PERCENT_DECODE_FUZZER_SRC = \
test/core/slice/percent_decode_fuzzer.cc \
@@ -14084,34 +14136,34 @@ endif
endif
-RESOLVE_ADDRESS_POSIX_TEST_SRC = \
+RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_SRC = \
test/core/iomgr/resolve_address_posix_test.cc \
-RESOLVE_ADDRESS_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(RESOLVE_ADDRESS_POSIX_TEST_SRC))))
+RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
-$(BINDIR)/$(CONFIG)/resolve_address_posix_test: openssl_dep_error
+$(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test: openssl_dep_error
else
-$(BINDIR)/$(CONFIG)/resolve_address_posix_test: $(RESOLVE_ADDRESS_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test: $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_posix_test
+ $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_ares_resolver_posix_test
endif
$(OBJDIR)/$(CONFIG)/test/core/iomgr/resolve_address_posix_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
-deps_resolve_address_posix_test: $(RESOLVE_ADDRESS_POSIX_TEST_OBJS:.o=.dep)
+deps_resolve_address_using_ares_resolver_posix_test: $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
--include $(RESOLVE_ADDRESS_POSIX_TEST_OBJS:.o=.dep)
+-include $(RESOLVE_ADDRESS_USING_ARES_RESOLVER_POSIX_TEST_OBJS:.o=.dep)
endif
endif
@@ -14148,6 +14200,38 @@ endif
endif
+RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_SRC = \
+ test/core/iomgr/resolve_address_posix_test.cc \
+
+RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_SRC))))
+ifeq ($(NO_SECURE),true)
+
+# You can't build secure targets if you don't have OpenSSL.
+
+$(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test: openssl_dep_error
+
+else
+
+
+
+$(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test: $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+ $(E) "[LD] Linking $@"
+ $(Q) mkdir -p `dirname $@`
+ $(Q) $(LD) $(LDFLAGS) $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/resolve_address_using_native_resolver_posix_test
+
+endif
+
+$(OBJDIR)/$(CONFIG)/test/core/iomgr/resolve_address_posix_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
+
+deps_resolve_address_using_native_resolver_posix_test: $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS:.o=.dep)
+
+ifneq ($(NO_SECURE),true)
+ifneq ($(NO_DEPS),true)
+-include $(RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_POSIX_TEST_OBJS:.o=.dep)
+endif
+endif
+
+
RESOLVE_ADDRESS_USING_NATIVE_RESOLVER_TEST_SRC = \
test/core/iomgr/resolve_address_test.cc \
diff --git a/Rakefile b/Rakefile
index 0068a3b8e4..d604f7935b 100755
--- a/Rakefile
+++ b/Rakefile
@@ -105,7 +105,7 @@ task 'dlls' do
env_comp = "CC=#{opt[:cross]}-gcc "
env_comp += "CXX=#{opt[:cross]}-g++ "
env_comp += "LD=#{opt[:cross]}-gcc "
- docker_for_windows "gem update --system --no-ri --no-doc && #{env} #{env_comp} make -j #{out} && #{opt[:cross]}-strip -x -S #{out} && cp #{out} #{opt[:out]}"
+ docker_for_windows "gem update --system --no-document && #{env} #{env_comp} make -j #{out} && #{opt[:cross]}-strip -x -S #{out} && cp #{out} #{opt[:out]}"
end
end
@@ -124,10 +124,10 @@ task 'gem:native' do
"invoked on macos with ruby #{RUBY_VERSION}. The ruby macos artifact " \
"build should be running on ruby 2.5."
end
- system "rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
+ system "rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0:2.2.2 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
else
Rake::Task['dlls'].execute
- docker_for_windows "gem update --system --no-ri --no-doc && bundle && rake cross native gem RUBY_CC_VERSION=2.5.0:2.4.0:2.3.0:2.2.2:2.1.6:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
+ docker_for_windows "gem update --system --no-document && bundle && rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0:2.2.2 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
end
end
diff --git a/build.yaml b/build.yaml
index a41decd84f..28375c8258 100644
--- a/build.yaml
+++ b/build.yaml
@@ -13,8 +13,8 @@ settings:
'#09': Per-language overrides are possible with (eg) ruby_version tag here
'#10': See the expand_version.py for all the quirks here
core_version: 7.0.0-dev
- g_stands_for: goose
- version: 1.18.0-dev
+ g_stands_for: gold
+ version: 1.19.0-dev
filegroups:
- name: alts_proto
headers:
@@ -276,6 +276,8 @@ filegroups:
- src/core/lib/iomgr/gethostname_fallback.cc
- src/core/lib/iomgr/gethostname_host_name_max.cc
- src/core/lib/iomgr/gethostname_sysconf.cc
+ - src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
+ - src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
- src/core/lib/iomgr/internal_errqueue.cc
- src/core/lib/iomgr/iocp_windows.cc
- src/core/lib/iomgr/iomgr.cc
@@ -452,6 +454,7 @@ filegroups:
- src/core/lib/iomgr/exec_ctx.h
- src/core/lib/iomgr/executor.h
- src/core/lib/iomgr/gethostname.h
+ - src/core/lib/iomgr/grpc_if_nametoindex.h
- src/core/lib/iomgr/internal_errqueue.h
- src/core/lib/iomgr/iocp_windows.h
- src/core/lib/iomgr/iomgr.h
@@ -3241,6 +3244,20 @@ targets:
- grpc
- gpr
uses_polling: false
+- name: parse_address_with_named_scope_id_test
+ build: test
+ language: c
+ src:
+ - test/core/client_channel/parse_address_with_named_scope_id_test.cc
+ deps:
+ - grpc_test_util
+ - grpc
+ - gpr
+ platforms:
+ - mac
+ - linux
+ - posix
+ uses_polling: false
- name: percent_decode_fuzzer
build: fuzzer
language: c
@@ -3275,7 +3292,7 @@ targets:
- grpc
- gpr
uses_polling: false
-- name: resolve_address_posix_test
+- name: resolve_address_using_ares_resolver_posix_test
build: test
language: c
src:
@@ -3284,6 +3301,8 @@ targets:
- grpc_test_util
- grpc
- gpr
+ args:
+ - --resolver=ares
exclude_iomgrs:
- uv
platforms:
@@ -3301,6 +3320,23 @@ targets:
- gpr
args:
- --resolver=ares
+- name: resolve_address_using_native_resolver_posix_test
+ build: test
+ language: c
+ src:
+ - test/core/iomgr/resolve_address_posix_test.cc
+ deps:
+ - grpc_test_util
+ - grpc
+ - gpr
+ args:
+ - --resolver=native
+ exclude_iomgrs:
+ - uv
+ platforms:
+ - mac
+ - linux
+ - posix
- name: resolve_address_using_native_resolver_test
build: test
language: c
diff --git a/config.m4 b/config.m4
index 25ffe2148a..3c3c0210d8 100644
--- a/config.m4
+++ b/config.m4
@@ -128,6 +128,8 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/iomgr/gethostname_fallback.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
src/core/lib/iomgr/gethostname_sysconf.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \
+ src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \
src/core/lib/iomgr/internal_errqueue.cc \
src/core/lib/iomgr/iocp_windows.cc \
src/core/lib/iomgr/iomgr.cc \
diff --git a/config.w32 b/config.w32
index b6e71dd09a..f87859ad09 100644
--- a/config.w32
+++ b/config.w32
@@ -103,6 +103,8 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\iomgr\\gethostname_fallback.cc " +
"src\\core\\lib\\iomgr\\gethostname_host_name_max.cc " +
"src\\core\\lib\\iomgr\\gethostname_sysconf.cc " +
+ "src\\core\\lib\\iomgr\\grpc_if_nametoindex_posix.cc " +
+ "src\\core\\lib\\iomgr\\grpc_if_nametoindex_unsupported.cc " +
"src\\core\\lib\\iomgr\\internal_errqueue.cc " +
"src\\core\\lib\\iomgr\\iocp_windows.cc " +
"src\\core\\lib\\iomgr\\iomgr.cc " +
diff --git a/doc/g_stands_for.md b/doc/g_stands_for.md
index 1e49b4d3f1..7bc8a003b5 100644
--- a/doc/g_stands_for.md
+++ b/doc/g_stands_for.md
@@ -17,4 +17,5 @@
- 1.15 'g' stands for ['glider'](https://github.com/grpc/grpc/tree/v1.15.x)
- 1.16 'g' stands for ['gao'](https://github.com/grpc/grpc/tree/v1.16.x)
- 1.17 'g' stands for ['gizmo'](https://github.com/grpc/grpc/tree/v1.17.x)
-- 1.18 'g' stands for ['goose'](https://github.com/grpc/grpc/tree/master)
+- 1.18 'g' stands for ['goose'](https://github.com/grpc/grpc/tree/v1.18.x)
+- 1.19 'g' stands for ['gold'](https://github.com/grpc/grpc/tree/master)
diff --git a/doc/python/sphinx/grpc.rst b/doc/python/sphinx/grpc.rst
index bd2df9596b..f534d25c63 100644
--- a/doc/python/sphinx/grpc.rst
+++ b/doc/python/sphinx/grpc.rst
@@ -19,6 +19,11 @@ Go to `gRPC Python Examples <https://github.com/grpc/grpc/tree/master/examples/p
Module Contents
---------------
+Version
+^^^^^^^
+
+The version string is available as :code:`grpc.__version__`.
+
Create Client
^^^^^^^^^^^^^
diff --git a/examples/ruby/greeter_server.rb b/examples/ruby/greeter_server.rb
index dca61714b8..5290429742 100755
--- a/examples/ruby/greeter_server.rb
+++ b/examples/ruby/greeter_server.rb
@@ -39,7 +39,10 @@ def main
s = GRPC::RpcServer.new
s.add_http2_port('0.0.0.0:50051', :this_port_is_insecure)
s.handle(GreeterServer)
- s.run_till_terminated
+ # Runs the server with SIGHUP, SIGINT and SIGQUIT signal handlers to
+ # gracefully shutdown.
+ # User could also choose to run server via call to run_till_terminated
+ s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])
end
main
diff --git a/examples/ruby/route_guide/route_guide_server.rb b/examples/ruby/route_guide/route_guide_server.rb
index 5eb268b533..ffcebd8418 100755
--- a/examples/ruby/route_guide/route_guide_server.rb
+++ b/examples/ruby/route_guide/route_guide_server.rb
@@ -172,7 +172,10 @@ def main
s.add_http2_port(port, :this_port_is_insecure)
GRPC.logger.info("... running insecurely on #{port}")
s.handle(ServerImpl.new(feature_db))
- s.run_till_terminated
+ # Runs the server with SIGHUP, SIGINT and SIGQUIT signal handlers to
+ # gracefully shutdown.
+ # User could also choose to run server via call to run_till_terminated
+ s.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])
end
main
diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec
index 29a79dd47a..4e0a471fb4 100644
--- a/gRPC-C++.podspec
+++ b/gRPC-C++.podspec
@@ -23,7 +23,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-C++'
# TODO (mxyan): use version that match gRPC version when pod is stabilized
- # version = '1.18.0-dev'
+ # version = '1.19.0-dev'
version = '0.0.6-dev'
s.version = version
s.summary = 'gRPC C++ library'
@@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.license = 'Apache License, Version 2.0'
s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
- grpc_version = '1.18.0-dev'
+ grpc_version = '1.19.0-dev'
s.source = {
:git => 'https://github.com/grpc/grpc.git',
@@ -423,6 +423,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/exec_ctx.h',
'src/core/lib/iomgr/executor.h',
'src/core/lib/iomgr/gethostname.h',
+ 'src/core/lib/iomgr/grpc_if_nametoindex.h',
'src/core/lib/iomgr/internal_errqueue.h',
'src/core/lib/iomgr/iocp_windows.h',
'src/core/lib/iomgr/iomgr.h',
@@ -616,6 +617,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/exec_ctx.h',
'src/core/lib/iomgr/executor.h',
'src/core/lib/iomgr/gethostname.h',
+ 'src/core/lib/iomgr/grpc_if_nametoindex.h',
'src/core/lib/iomgr/internal_errqueue.h',
'src/core/lib/iomgr/iocp_windows.h',
'src/core/lib/iomgr/iomgr.h',
diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec
index f873bc693b..4e4c866241 100644
--- a/gRPC-Core.podspec
+++ b/gRPC-Core.podspec
@@ -22,7 +22,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-Core'
- version = '1.18.0-dev'
+ version = '1.19.0-dev'
s.version = version
s.summary = 'Core cross-platform gRPC library, written in C'
s.homepage = 'https://grpc.io'
@@ -93,7 +93,7 @@ Pod::Spec.new do |s|
}
s.default_subspecs = 'Interface', 'Implementation'
- s.compiler_flags = '-DGRPC_ARES=0', '-DPB_FIELD_16BIT'
+ s.compiler_flags = '-DGRPC_ARES=0', '-DPB_FIELD_32BIT'
s.libraries = 'c++'
# Like many other C libraries, gRPC-Core has its public headers under `include/<libname>/` and its
@@ -417,6 +417,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/exec_ctx.h',
'src/core/lib/iomgr/executor.h',
'src/core/lib/iomgr/gethostname.h',
+ 'src/core/lib/iomgr/grpc_if_nametoindex.h',
'src/core/lib/iomgr/internal_errqueue.h',
'src/core/lib/iomgr/iocp_windows.h',
'src/core/lib/iomgr/iomgr.h',
@@ -571,6 +572,8 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/gethostname_fallback.cc',
'src/core/lib/iomgr/gethostname_host_name_max.cc',
'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc',
'src/core/lib/iomgr/internal_errqueue.cc',
'src/core/lib/iomgr/iocp_windows.cc',
'src/core/lib/iomgr/iomgr.cc',
@@ -1040,6 +1043,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/exec_ctx.h',
'src/core/lib/iomgr/executor.h',
'src/core/lib/iomgr/gethostname.h',
+ 'src/core/lib/iomgr/grpc_if_nametoindex.h',
'src/core/lib/iomgr/internal_errqueue.h',
'src/core/lib/iomgr/iocp_windows.h',
'src/core/lib/iomgr/iomgr.h',
diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec
index 13fe3e0b9c..7bf53799de 100644
--- a/gRPC-ProtoRPC.podspec
+++ b/gRPC-ProtoRPC.podspec
@@ -21,7 +21,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-ProtoRPC'
- version = '1.18.0-dev'
+ version = '1.19.0-dev'
s.version = version
s.summary = 'RPC library for Protocol Buffers, based on gRPC'
s.homepage = 'https://grpc.io'
diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec
index e132ad41b4..34bec88c8b 100644
--- a/gRPC-RxLibrary.podspec
+++ b/gRPC-RxLibrary.podspec
@@ -21,7 +21,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC-RxLibrary'
- version = '1.18.0-dev'
+ version = '1.19.0-dev'
s.version = version
s.summary = 'Reactive Extensions library for iOS/OSX.'
s.homepage = 'https://grpc.io'
diff --git a/gRPC.podspec b/gRPC.podspec
index 940a1ac621..a833f8c2aa 100644
--- a/gRPC.podspec
+++ b/gRPC.podspec
@@ -20,7 +20,7 @@
Pod::Spec.new do |s|
s.name = 'gRPC'
- version = '1.18.0-dev'
+ version = '1.19.0-dev'
s.version = version
s.summary = 'gRPC client library for iOS/OSX'
s.homepage = 'https://grpc.io'
@@ -58,7 +58,7 @@ Pod::Spec.new do |s|
ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}"
- ss.private_header_files = "#{src_dir}/private/*.h"
+ ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h"
ss.dependency 'gRPC-Core', version
end
diff --git a/grpc.gemspec b/grpc.gemspec
index 3c680b044f..42b1db35b4 100644
--- a/grpc.gemspec
+++ b/grpc.gemspec
@@ -353,6 +353,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/iomgr/exec_ctx.h )
s.files += %w( src/core/lib/iomgr/executor.h )
s.files += %w( src/core/lib/iomgr/gethostname.h )
+ s.files += %w( src/core/lib/iomgr/grpc_if_nametoindex.h )
s.files += %w( src/core/lib/iomgr/internal_errqueue.h )
s.files += %w( src/core/lib/iomgr/iocp_windows.h )
s.files += %w( src/core/lib/iomgr/iomgr.h )
@@ -507,6 +508,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/iomgr/gethostname_fallback.cc )
s.files += %w( src/core/lib/iomgr/gethostname_host_name_max.cc )
s.files += %w( src/core/lib/iomgr/gethostname_sysconf.cc )
+ s.files += %w( src/core/lib/iomgr/grpc_if_nametoindex_posix.cc )
+ s.files += %w( src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc )
s.files += %w( src/core/lib/iomgr/internal_errqueue.cc )
s.files += %w( src/core/lib/iomgr/iocp_windows.cc )
s.files += %w( src/core/lib/iomgr/iomgr.cc )
diff --git a/grpc.gyp b/grpc.gyp
index 80b6d0315a..13b9c1bc78 100644
--- a/grpc.gyp
+++ b/grpc.gyp
@@ -310,6 +310,8 @@
'src/core/lib/iomgr/gethostname_fallback.cc',
'src/core/lib/iomgr/gethostname_host_name_max.cc',
'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc',
'src/core/lib/iomgr/internal_errqueue.cc',
'src/core/lib/iomgr/iocp_windows.cc',
'src/core/lib/iomgr/iomgr.cc',
@@ -672,6 +674,8 @@
'src/core/lib/iomgr/gethostname_fallback.cc',
'src/core/lib/iomgr/gethostname_host_name_max.cc',
'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc',
'src/core/lib/iomgr/internal_errqueue.cc',
'src/core/lib/iomgr/iocp_windows.cc',
'src/core/lib/iomgr/iomgr.cc',
@@ -914,6 +918,8 @@
'src/core/lib/iomgr/gethostname_fallback.cc',
'src/core/lib/iomgr/gethostname_host_name_max.cc',
'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc',
'src/core/lib/iomgr/internal_errqueue.cc',
'src/core/lib/iomgr/iocp_windows.cc',
'src/core/lib/iomgr/iomgr.cc',
@@ -1133,6 +1139,8 @@
'src/core/lib/iomgr/gethostname_fallback.cc',
'src/core/lib/iomgr/gethostname_host_name_max.cc',
'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc',
'src/core/lib/iomgr/internal_errqueue.cc',
'src/core/lib/iomgr/iocp_windows.cc',
'src/core/lib/iomgr/iomgr.cc',
diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h
index a9fb27946e..5d577eb855 100644
--- a/include/grpc/impl/codegen/grpc_types.h
+++ b/include/grpc/impl/codegen/grpc_types.h
@@ -163,7 +163,7 @@ typedef struct {
/** Maximum time that a channel may exist. Int valued, milliseconds.
* INT_MAX means unlimited. */
#define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms"
-/** Grace period after the chennel reaches its max age. Int valued,
+/** Grace period after the channel reaches its max age. Int valued,
milliseconds. INT_MAX means unlimited. */
#define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms"
/** Enable/disable support for per-message compression. Defaults to 1, unless
@@ -355,6 +355,10 @@ typedef struct {
* is 10000. Setting this to "0" will disable c-ares query timeouts
* entirely. */
#define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout"
+/** gRPC Objective-C channel pooling domain string. */
+#define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain"
+/** gRPC Objective-C channel pooling id. */
+#define GRPC_ARG_CHANNEL_ID "grpc.channel_id"
/** \} */
/** Result of a grpc call. If the caller satisfies the prerequisites of a
diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h
index 031c0c36ae..aaeb23694e 100644
--- a/include/grpc/impl/codegen/port_platform.h
+++ b/include/grpc/impl/codegen/port_platform.h
@@ -121,6 +121,7 @@
#else /* _LP64 */
#define GPR_ARCH_32 1
#endif /* _LP64 */
+#include <linux/version.h>
#elif defined(ANDROID) || defined(__ANDROID__)
#define GPR_PLATFORM_STRING "android"
#define GPR_ANDROID 1
@@ -465,6 +466,10 @@ typedef unsigned __int64 uint64_t;
#define GRPC_ARES 1
#endif
+#ifndef GRPC_IF_NAMETOINDEX
+#define GRPC_IF_NAMETOINDEX 1
+#endif
+
#ifndef GRPC_MUST_USE_RESULT
#if defined(__GNUC__) && !defined(__MINGW32__)
#define GRPC_MUST_USE_RESULT __attribute__((warn_unused_result))
diff --git a/include/grpcpp/impl/codegen/call_op_set.h b/include/grpcpp/impl/codegen/call_op_set.h
index b2100c68b7..c0de5ed602 100644
--- a/include/grpcpp/impl/codegen/call_op_set.h
+++ b/include/grpcpp/impl/codegen/call_op_set.h
@@ -303,9 +303,29 @@ class CallOpSendMessage {
template <class M>
Status SendMessage(const M& message) GRPC_MUST_USE_RESULT;
+ /// Send \a message using \a options for the write. The \a options are cleared
+ /// after use. This form of SendMessage allows gRPC to reference \a message
+ /// beyond the lifetime of SendMessage.
+ template <class M>
+ Status SendMessagePtr(const M* message,
+ WriteOptions options) GRPC_MUST_USE_RESULT;
+
+ /// This form of SendMessage allows gRPC to reference \a message beyond the
+ /// lifetime of SendMessage.
+ template <class M>
+ Status SendMessagePtr(const M* message) GRPC_MUST_USE_RESULT;
+
protected:
void AddOp(grpc_op* ops, size_t* nops) {
- if (!send_buf_.Valid() || hijacked_) return;
+ if (msg_ == nullptr && !send_buf_.Valid()) return;
+ if (hijacked_) {
+ serializer_ = nullptr;
+ return;
+ }
+ if (msg_ != nullptr) {
+ GPR_CODEGEN_ASSERT(serializer_(msg_).ok());
+ }
+ serializer_ = nullptr;
grpc_op* op = &ops[(*nops)++];
op->op = GRPC_OP_SEND_MESSAGE;
op->flags = write_options_.flags();
@@ -314,21 +334,38 @@ class CallOpSendMessage {
// Flags are per-message: clear them after use.
write_options_.Clear();
}
- void FinishOp(bool* status) { send_buf_.Clear(); }
+ void FinishOp(bool* status) {
+ if (msg_ == nullptr && !send_buf_.Valid()) return;
+ if (hijacked_ && failed_send_) {
+ // Hijacking interceptor failed this Op
+ *status = false;
+ } else if (!*status) {
+ // This Op was passed down to core and the Op failed
+ failed_send_ = true;
+ }
+ }
void SetInterceptionHookPoint(
InterceptorBatchMethodsImpl* interceptor_methods) {
- if (!send_buf_.Valid()) return;
+ if (msg_ == nullptr && !send_buf_.Valid()) return;
interceptor_methods->AddInterceptionHookPoint(
experimental::InterceptionHookPoints::PRE_SEND_MESSAGE);
- interceptor_methods->SetSendMessage(&send_buf_);
+ interceptor_methods->SetSendMessage(&send_buf_, &msg_, &failed_send_,
+ serializer_);
}
void SetFinishInterceptionHookPoint(
InterceptorBatchMethodsImpl* interceptor_methods) {
+ if (msg_ != nullptr || send_buf_.Valid()) {
+ interceptor_methods->AddInterceptionHookPoint(
+ experimental::InterceptionHookPoints::POST_SEND_MESSAGE);
+ }
+ send_buf_.Clear();
+ msg_ = nullptr;
// The contents of the SendMessage value that was previously set
// has had its references stolen by core's operations
- interceptor_methods->SetSendMessage(nullptr);
+ interceptor_methods->SetSendMessage(nullptr, nullptr, &failed_send_,
+ nullptr);
}
void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
@@ -336,25 +373,38 @@ class CallOpSendMessage {
}
private:
+ const void* msg_ = nullptr; // The original non-serialized message
bool hijacked_ = false;
+ bool failed_send_ = false;
ByteBuffer send_buf_;
WriteOptions write_options_;
+ std::function<Status(const void*)> serializer_;
};
template <class M>
Status CallOpSendMessage::SendMessage(const M& message, WriteOptions options) {
write_options_ = options;
- bool own_buf;
- // TODO(vjpai): Remove the void below when possible
- // The void in the template parameter below should not be needed
- // (since it should be implicit) but is needed due to an observed
- // difference in behavior between clang and gcc for certain internal users
- Status result = SerializationTraits<M, void>::Serialize(
- message, send_buf_.bbuf_ptr(), &own_buf);
- if (!own_buf) {
- send_buf_.Duplicate();
- }
- return result;
+ serializer_ = [this](const void* message) {
+ bool own_buf;
+ send_buf_.Clear();
+ // TODO(vjpai): Remove the void below when possible
+ // The void in the template parameter below should not be needed
+ // (since it should be implicit) but is needed due to an observed
+ // difference in behavior between clang and gcc for certain internal users
+ Status result = SerializationTraits<M, void>::Serialize(
+ *static_cast<const M*>(message), send_buf_.bbuf_ptr(), &own_buf);
+ if (!own_buf) {
+ send_buf_.Duplicate();
+ }
+ return result;
+ };
+ // Serialize immediately only if we do not have access to the message pointer
+ if (msg_ == nullptr) {
+ Status result = serializer_(&message);
+ serializer_ = nullptr;
+ return result;
+ }
+ return Status();
}
template <class M>
@@ -362,6 +412,19 @@ Status CallOpSendMessage::SendMessage(const M& message) {
return SendMessage(message, WriteOptions());
}
+template <class M>
+Status CallOpSendMessage::SendMessagePtr(const M* message,
+ WriteOptions options) {
+ msg_ = message;
+ return SendMessage(*message, options);
+}
+
+template <class M>
+Status CallOpSendMessage::SendMessagePtr(const M* message) {
+ msg_ = message;
+ return SendMessage(*message, WriteOptions());
+}
+
template <class R>
class CallOpRecvMessage {
public:
@@ -410,14 +473,16 @@ class CallOpRecvMessage {
void SetInterceptionHookPoint(
InterceptorBatchMethodsImpl* interceptor_methods) {
- interceptor_methods->SetRecvMessage(message_);
+ if (message_ == nullptr) return;
+ interceptor_methods->SetRecvMessage(message_, &got_message);
}
void SetFinishInterceptionHookPoint(
InterceptorBatchMethodsImpl* interceptor_methods) {
- if (!got_message) return;
+ if (message_ == nullptr) return;
interceptor_methods->AddInterceptionHookPoint(
experimental::InterceptionHookPoints::POST_RECV_MESSAGE);
+ if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr);
}
void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
hijacked_ = true;
@@ -505,20 +570,23 @@ class CallOpGenericRecvMessage {
void SetInterceptionHookPoint(
InterceptorBatchMethodsImpl* interceptor_methods) {
- interceptor_methods->SetRecvMessage(message_);
+ if (!deserialize_) return;
+ interceptor_methods->SetRecvMessage(message_, &got_message);
}
void SetFinishInterceptionHookPoint(
InterceptorBatchMethodsImpl* interceptor_methods) {
- if (!got_message) return;
+ if (!deserialize_) return;
interceptor_methods->AddInterceptionHookPoint(
experimental::InterceptionHookPoints::POST_RECV_MESSAGE);
+ if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr);
}
void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) {
hijacked_ = true;
if (!deserialize_) return;
interceptor_methods->AddInterceptionHookPoint(
experimental::InterceptionHookPoints::PRE_RECV_MESSAGE);
+ got_message = true;
}
private:
diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h
index 66cf9b7754..52bcea9970 100644
--- a/include/grpcpp/impl/codegen/client_callback.h
+++ b/include/grpcpp/impl/codegen/client_callback.h
@@ -73,7 +73,7 @@ class CallbackUnaryCallImpl {
CallbackWithStatusTag(call.call(), on_completion, ops);
// TODO(vjpai): Unify code with sync API as much as possible
- Status s = ops->SendMessage(*request);
+ Status s = ops->SendMessagePtr(request);
if (!s.ok()) {
tag->force_run(s);
return;
@@ -340,13 +340,13 @@ class ClientCallbackReaderWriterImpl
context_->initial_metadata_flags());
start_corked_ = false;
}
- // TODO(vjpai): don't assert
- GPR_CODEGEN_ASSERT(write_ops_.SendMessage(*msg).ok());
if (options.is_last_message()) {
options.set_buffer_hint();
write_ops_.ClientSendClose();
}
+ // TODO(vjpai): don't assert
+ GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok());
callbacks_outstanding_++;
if (started_) {
call_.PerformOps(&write_ops_);
@@ -524,7 +524,7 @@ class ClientCallbackReaderImpl
: context_(context), call_(call), reactor_(reactor) {
this->BindReactor(reactor);
// TODO(vjpai): don't assert
- GPR_CODEGEN_ASSERT(start_ops_.SendMessage(*request).ok());
+ GPR_CODEGEN_ASSERT(start_ops_.SendMessagePtr(request).ok());
start_ops_.ClientSendClose();
}
@@ -649,13 +649,13 @@ class ClientCallbackWriterImpl
context_->initial_metadata_flags());
start_corked_ = false;
}
- // TODO(vjpai): don't assert
- GPR_CODEGEN_ASSERT(write_ops_.SendMessage(*msg).ok());
if (options.is_last_message()) {
options.set_buffer_hint();
write_ops_.ClientSendClose();
}
+ // TODO(vjpai): don't assert
+ GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(msg, options).ok());
callbacks_outstanding_++;
if (started_) {
call_.PerformOps(&write_ops_);
diff --git a/include/grpcpp/impl/codegen/client_unary_call.h b/include/grpcpp/impl/codegen/client_unary_call.h
index 5151839412..b9f8e1663f 100644
--- a/include/grpcpp/impl/codegen/client_unary_call.h
+++ b/include/grpcpp/impl/codegen/client_unary_call.h
@@ -57,7 +57,7 @@ class BlockingUnaryCallImpl {
CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>,
CallOpClientSendClose, CallOpClientRecvStatus>
ops;
- status_ = ops.SendMessage(request);
+ status_ = ops.SendMessagePtr(&request);
if (!status_.ok()) {
return;
}
diff --git a/include/grpcpp/impl/codegen/interceptor.h b/include/grpcpp/impl/codegen/interceptor.h
index 46175cd73b..5dea796a3b 100644
--- a/include/grpcpp/impl/codegen/interceptor.h
+++ b/include/grpcpp/impl/codegen/interceptor.h
@@ -46,9 +46,10 @@ namespace experimental {
/// operation has been requested and it is available. POST_RECV means that a
/// result is available but has not yet been passed back to the application.
enum class InterceptionHookPoints {
- /// The first two in this list are for clients and servers
+ /// The first three in this list are for clients and servers
PRE_SEND_INITIAL_METADATA,
PRE_SEND_MESSAGE,
+ POST_SEND_MESSAGE,
PRE_SEND_STATUS, // server only
PRE_SEND_CLOSE, // client only: WritesDone for stream; after write in unary
/// The following three are for hijacked clients only and can only be
@@ -109,7 +110,24 @@ class InterceptorBatchMethods {
/// Returns a modifable ByteBuffer holding the serialized form of the message
/// that is going to be sent. Valid for PRE_SEND_MESSAGE interceptions.
/// A return value of nullptr indicates that this ByteBuffer is not valid.
- virtual ByteBuffer* GetSendMessage() = 0;
+ virtual ByteBuffer* GetSerializedSendMessage() = 0;
+
+ /// Returns a non-modifiable pointer to the non-serialized form of the message
+ /// to be sent. Valid for PRE_SEND_MESSAGE interceptions. A return value of
+ /// nullptr indicates that this field is not valid. Also note that this is
+ /// only supported for sync and callback APIs at the present moment.
+ virtual const void* GetSendMessage() = 0;
+
+ /// Overwrites the message to be sent with \a message. \a message should be in
+ /// the non-serialized form expected by the method. Valid for PRE_SEND_MESSAGE
+ /// interceptions. Note that the interceptor is responsible for maintaining
+ /// the life of the message for the duration on the send operation, i.e., till
+ /// POST_SEND_MESSAGE.
+ virtual void ModifySendMessage(const void* message) = 0;
+
+ /// Checks whether the SEND MESSAGE op succeeded. Valid for POST_SEND_MESSAGE
+ /// interceptions.
+ virtual bool GetSendMessageStatus() = 0;
/// Returns a modifiable multimap of the initial metadata to be sent. Valid
/// for PRE_SEND_INITIAL_METADATA interceptions. A value of nullptr indicates
@@ -156,6 +174,15 @@ class InterceptorBatchMethods {
/// started from interceptors without infinite regress through the interceptor
/// list.
virtual std::unique_ptr<ChannelInterface> GetInterceptedChannel() = 0;
+
+ /// On a hijacked RPC, an interceptor can decide to fail a PRE_RECV_MESSAGE
+ /// op. This would be a signal to the reader that there will be no more
+ /// messages, or the stream has failed or been cancelled.
+ virtual void FailHijackedRecvMessage() = 0;
+
+ /// On a hijacked RPC/ to-be hijacked RPC, this can be called to fail a SEND
+ /// MESSAGE op
+ virtual void FailHijackedSendMessage() = 0;
};
/// Interface for an interceptor. Interceptor authors must create a class
diff --git a/include/grpcpp/impl/codegen/interceptor_common.h b/include/grpcpp/impl/codegen/interceptor_common.h
index d0aa23cb0a..09721343ff 100644
--- a/include/grpcpp/impl/codegen/interceptor_common.h
+++ b/include/grpcpp/impl/codegen/interceptor_common.h
@@ -79,7 +79,26 @@ class InterceptorBatchMethodsImpl
hooks_[static_cast<size_t>(type)] = true;
}
- ByteBuffer* GetSendMessage() override { return send_message_; }
+ ByteBuffer* GetSerializedSendMessage() override {
+ GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr);
+ if (*orig_send_message_ != nullptr) {
+ GPR_CODEGEN_ASSERT(serializer_(*orig_send_message_).ok());
+ *orig_send_message_ = nullptr;
+ }
+ return send_message_;
+ }
+
+ const void* GetSendMessage() override {
+ GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr);
+ return *orig_send_message_;
+ }
+
+ void ModifySendMessage(const void* message) override {
+ GPR_CODEGEN_ASSERT(orig_send_message_ != nullptr);
+ *orig_send_message_ = message;
+ }
+
+ bool GetSendMessageStatus() override { return !*fail_send_message_; }
std::multimap<grpc::string, grpc::string>* GetSendInitialMetadata() override {
return send_initial_metadata_;
@@ -110,12 +129,25 @@ class InterceptorBatchMethodsImpl
Status* GetRecvStatus() override { return recv_status_; }
+ void FailHijackedSendMessage() override {
+ GPR_CODEGEN_ASSERT(hooks_[static_cast<size_t>(
+ experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)]);
+ *fail_send_message_ = true;
+ }
+
std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata()
override {
return recv_trailing_metadata_->map();
}
- void SetSendMessage(ByteBuffer* buf) { send_message_ = buf; }
+ void SetSendMessage(ByteBuffer* buf, const void** msg,
+ bool* fail_send_message,
+ std::function<Status(const void*)> serializer) {
+ send_message_ = buf;
+ orig_send_message_ = msg;
+ fail_send_message_ = fail_send_message;
+ serializer_ = serializer;
+ }
void SetSendInitialMetadata(
std::multimap<grpc::string, grpc::string>* metadata) {
@@ -134,7 +166,10 @@ class InterceptorBatchMethodsImpl
send_trailing_metadata_ = metadata;
}
- void SetRecvMessage(void* message) { recv_message_ = message; }
+ void SetRecvMessage(void* message, bool* got_message) {
+ recv_message_ = message;
+ got_message_ = got_message;
+ }
void SetRecvInitialMetadata(MetadataMap* map) {
recv_initial_metadata_ = map;
@@ -157,6 +192,12 @@ class InterceptorBatchMethodsImpl
info->channel(), current_interceptor_index_ + 1));
}
+ void FailHijackedRecvMessage() override {
+ GPR_CODEGEN_ASSERT(hooks_[static_cast<size_t>(
+ experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)]);
+ *got_message_ = false;
+ }
+
// Clears all state
void ClearState() {
reverse_ = false;
@@ -334,6 +375,9 @@ class InterceptorBatchMethodsImpl
std::function<void(void)> callback_;
ByteBuffer* send_message_ = nullptr;
+ bool* fail_send_message_ = nullptr;
+ const void** orig_send_message_ = nullptr;
+ std::function<Status(const void*)> serializer_;
std::multimap<grpc::string, grpc::string>* send_initial_metadata_;
@@ -345,6 +389,7 @@ class InterceptorBatchMethodsImpl
std::multimap<grpc::string, grpc::string>* send_trailing_metadata_ = nullptr;
void* recv_message_ = nullptr;
+ bool* got_message_ = nullptr;
MetadataMap* recv_initial_metadata_ = nullptr;
@@ -379,13 +424,36 @@ class CancelInterceptorBatchMethods
"Cancel notification");
}
- ByteBuffer* GetSendMessage() override {
+ ByteBuffer* GetSerializedSendMessage() override {
GPR_CODEGEN_ASSERT(false &&
"It is illegal to call GetSendMessage on a method which "
"has a Cancel notification");
return nullptr;
}
+ bool GetSendMessageStatus() override {
+ GPR_CODEGEN_ASSERT(
+ false &&
+ "It is illegal to call GetSendMessageStatus on a method which "
+ "has a Cancel notification");
+ return false;
+ }
+
+ const void* GetSendMessage() override {
+ GPR_CODEGEN_ASSERT(
+ false &&
+ "It is illegal to call GetOriginalSendMessage on a method which "
+ "has a Cancel notification");
+ return nullptr;
+ }
+
+ void ModifySendMessage(const void* message) override {
+ GPR_CODEGEN_ASSERT(
+ false &&
+ "It is illegal to call ModifySendMessage on a method which "
+ "has a Cancel notification");
+ }
+
std::multimap<grpc::string, grpc::string>* GetSendInitialMetadata() override {
GPR_CODEGEN_ASSERT(false &&
"It is illegal to call GetSendInitialMetadata on a "
@@ -451,6 +519,18 @@ class CancelInterceptorBatchMethods
"method which has a Cancel notification");
return std::unique_ptr<ChannelInterface>(nullptr);
}
+
+ void FailHijackedRecvMessage() override {
+ GPR_CODEGEN_ASSERT(false &&
+ "It is illegal to call FailHijackedRecvMessage on a "
+ "method which has a Cancel notification");
+ }
+
+ void FailHijackedSendMessage() override {
+ GPR_CODEGEN_ASSERT(false &&
+ "It is illegal to call FailHijackedSendMessage on a "
+ "method which has a Cancel notification");
+ }
};
} // namespace internal
} // namespace grpc
diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h
index dd53f975f6..094286294c 100644
--- a/include/grpcpp/impl/codegen/method_handler_impl.h
+++ b/include/grpcpp/impl/codegen/method_handler_impl.h
@@ -79,7 +79,7 @@ class RpcMethodHandler : public MethodHandler {
ops.set_compression_level(param.server_context->compression_level());
}
if (status.ok()) {
- status = ops.SendMessage(rsp);
+ status = ops.SendMessagePtr(&rsp);
}
ops.ServerSendStatus(&param.server_context->trailing_metadata_, status);
param.call->PerformOps(&ops);
@@ -139,7 +139,7 @@ class ClientStreamingHandler : public MethodHandler {
}
}
if (status.ok()) {
- status = ops.SendMessage(rsp);
+ status = ops.SendMessagePtr(&rsp);
}
ops.ServerSendStatus(&param.server_context->trailing_metadata_, status);
param.call->PerformOps(&ops);
diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h
index 1854f6ef2f..a0e59215dd 100644
--- a/include/grpcpp/impl/codegen/server_callback.h
+++ b/include/grpcpp/impl/codegen/server_callback.h
@@ -320,7 +320,7 @@ class CallbackUnaryHandler : public MethodHandler {
// The response is dropped if the status is not OK.
if (s.ok()) {
finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_,
- finish_ops_.SendMessage(resp_));
+ finish_ops_.SendMessagePtr(&resp_));
} else {
finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s);
}
@@ -449,7 +449,7 @@ class CallbackClientStreamingHandler : public MethodHandler {
// The response is dropped if the status is not OK.
if (s.ok()) {
finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_,
- finish_ops_.SendMessage(resp_));
+ finish_ops_.SendMessagePtr(&resp_));
} else {
finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s);
}
@@ -642,7 +642,7 @@ class CallbackServerStreamingHandler : public MethodHandler {
ctx_->sent_initial_metadata_ = true;
}
// TODO(vjpai): don't assert
- GPR_CODEGEN_ASSERT(write_ops_.SendMessage(*resp, options).ok());
+ GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok());
call_.PerformOps(&write_ops_);
}
@@ -652,7 +652,7 @@ class CallbackServerStreamingHandler : public MethodHandler {
// Don't send any message if the status is bad
if (s.ok()) {
// TODO(vjpai): don't assert
- GPR_CODEGEN_ASSERT(finish_ops_.SendMessage(*resp, options).ok());
+ GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok());
}
Finish(std::move(s));
}
@@ -804,7 +804,7 @@ class CallbackBidiHandler : public MethodHandler {
ctx_->sent_initial_metadata_ = true;
}
// TODO(vjpai): don't assert
- GPR_CODEGEN_ASSERT(write_ops_.SendMessage(*resp, options).ok());
+ GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok());
call_.PerformOps(&write_ops_);
}
@@ -813,7 +813,7 @@ class CallbackBidiHandler : public MethodHandler {
// Don't send any message if the status is bad
if (s.ok()) {
// TODO(vjpai): don't assert
- GPR_CODEGEN_ASSERT(finish_ops_.SendMessage(*resp, options).ok());
+ GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok());
}
Finish(std::move(s));
}
diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h
index e0e2629827..890a5650d0 100644
--- a/include/grpcpp/impl/codegen/server_interface.h
+++ b/include/grpcpp/impl/codegen/server_interface.h
@@ -272,7 +272,7 @@ class ServerInterface : public internal::CallHook {
/* Set interception point for recv message */
interceptor_methods_.AddInterceptionHookPoint(
experimental::InterceptionHookPoints::POST_RECV_MESSAGE);
- interceptor_methods_.SetRecvMessage(request_);
+ interceptor_methods_.SetRecvMessage(request_, nullptr);
return RegisteredAsyncRequest::FinalizeResult(tag, status);
}
diff --git a/include/grpcpp/impl/codegen/sync_stream.h b/include/grpcpp/impl/codegen/sync_stream.h
index 6981076f04..d9edad4215 100644
--- a/include/grpcpp/impl/codegen/sync_stream.h
+++ b/include/grpcpp/impl/codegen/sync_stream.h
@@ -253,7 +253,7 @@ class ClientReader final : public ClientReaderInterface<R> {
ops.SendInitialMetadata(&context->send_initial_metadata_,
context->initial_metadata_flags());
// TODO(ctiller): don't assert
- GPR_CODEGEN_ASSERT(ops.SendMessage(request).ok());
+ GPR_CODEGEN_ASSERT(ops.SendMessagePtr(&request).ok());
ops.ClientSendClose();
call_.PerformOps(&ops);
cq_.Pluck(&ops);
@@ -331,7 +331,7 @@ class ClientWriter : public ClientWriterInterface<W> {
context_->initial_metadata_flags());
context_->set_initial_metadata_corked(false);
}
- if (!ops.SendMessage(msg, options).ok()) {
+ if (!ops.SendMessagePtr(&msg, options).ok()) {
return false;
}
@@ -502,7 +502,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
context_->initial_metadata_flags());
context_->set_initial_metadata_corked(false);
}
- if (!ops.SendMessage(msg, options).ok()) {
+ if (!ops.SendMessagePtr(&msg, options).ok()) {
return false;
}
@@ -656,7 +656,7 @@ class ServerWriter final : public ServerWriterInterface<W> {
options.set_buffer_hint();
}
- if (!ctx_->pending_ops_.SendMessage(msg, options).ok()) {
+ if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
return false;
}
if (!ctx_->sent_initial_metadata_) {
@@ -734,7 +734,7 @@ class ServerReaderWriterBody final {
if (options.is_last_message()) {
options.set_buffer_hint();
}
- if (!ctx_->pending_ops_.SendMessage(msg, options).ok()) {
+ if (!ctx_->pending_ops_.SendMessagePtr(&msg, options).ok()) {
return false;
}
if (!ctx_->sent_initial_metadata_) {
diff --git a/package.xml b/package.xml
index 2632fcb276..de5c56f451 100644
--- a/package.xml
+++ b/package.xml
@@ -13,8 +13,8 @@
<date>2018-01-19</date>
<time>16:06:07</time>
<version>
- <release>1.18.0dev</release>
- <api>1.18.0dev</api>
+ <release>1.19.0dev</release>
+ <api>1.19.0dev</api>
</version>
<stability>
<release>beta</release>
@@ -358,6 +358,7 @@
<file baseinstalldir="/" name="src/core/lib/iomgr/exec_ctx.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/executor.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/gethostname.h" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/grpc_if_nametoindex.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/internal_errqueue.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/iocp_windows.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/iomgr.h" role="src" />
@@ -512,6 +513,8 @@
<file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_fallback.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_host_name_max.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/gethostname_sysconf.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/grpc_if_nametoindex_posix.cc" role="src" />
+ <file baseinstalldir="/" name="src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/internal_errqueue.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/iocp_windows.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/iomgr.cc" role="src" />
diff --git a/setup.py b/setup.py
index 7bdfc99e24..7f58e7ca07 100644
--- a/setup.py
+++ b/setup.py
@@ -160,7 +160,7 @@ if EXTRA_ENV_COMPILE_ARGS is None:
EXTRA_ENV_COMPILE_ARGS += ' -std=gnu99 -fvisibility=hidden -fno-wrapv -fno-exceptions'
elif "darwin" in sys.platform:
EXTRA_ENV_COMPILE_ARGS += ' -fvisibility=hidden -fno-wrapv -fno-exceptions'
-EXTRA_ENV_COMPILE_ARGS += ' -DPB_FIELD_16BIT'
+EXTRA_ENV_COMPILE_ARGS += ' -DPB_FIELD_32BIT'
if EXTRA_ENV_LINK_ARGS is None:
EXTRA_ENV_LINK_ARGS = ''
diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc
index 39f68cb956..af5398ec68 100644
--- a/src/compiler/objective_c_generator.cc
+++ b/src/compiler/objective_c_generator.cc
@@ -113,6 +113,29 @@ void PrintAdvancedSignature(Printer* printer, const MethodDescriptor* method,
PrintMethodSignature(printer, method, vars);
}
+void PrintV2Signature(Printer* printer, const MethodDescriptor* method,
+ map< ::grpc::string, ::grpc::string> vars) {
+ if (method->client_streaming()) {
+ vars["return_type"] = "GRPCStreamingProtoCall *";
+ } else {
+ vars["return_type"] = "GRPCUnaryProtoCall *";
+ }
+ vars["method_name"] =
+ grpc_generator::LowercaseFirstLetter(vars["method_name"]);
+
+ PrintAllComments(method, printer);
+
+ printer->Print(vars, "- ($return_type$)$method_name$With");
+ if (method->client_streaming()) {
+ printer->Print("ResponseHandler:(id<GRPCProtoResponseHandler>)handler");
+ } else {
+ printer->Print(vars,
+ "Message:($request_class$ *)message "
+ "responseHandler:(id<GRPCProtoResponseHandler>)handler");
+ }
+ printer->Print(" callOptions:(GRPCCallOptions *_Nullable)callOptions");
+}
+
inline map< ::grpc::string, ::grpc::string> GetMethodVars(
const MethodDescriptor* method) {
map< ::grpc::string, ::grpc::string> res;
@@ -135,6 +158,16 @@ void PrintMethodDeclarations(Printer* printer, const MethodDescriptor* method) {
printer->Print(";\n\n\n");
}
+void PrintV2MethodDeclarations(Printer* printer,
+ const MethodDescriptor* method) {
+ map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method);
+
+ PrintProtoRpcDeclarationAsPragma(printer, method, vars);
+
+ PrintV2Signature(printer, method, vars);
+ printer->Print(";\n\n");
+}
+
void PrintSimpleImplementation(Printer* printer, const MethodDescriptor* method,
map< ::grpc::string, ::grpc::string> vars) {
printer->Print("{\n");
@@ -177,6 +210,25 @@ void PrintAdvancedImplementation(Printer* printer,
printer->Print("}\n");
}
+void PrintV2Implementation(Printer* printer, const MethodDescriptor* method,
+ map< ::grpc::string, ::grpc::string> vars) {
+ printer->Print(" {\n");
+ if (method->client_streaming()) {
+ printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n");
+ printer->Print(" responseHandler:handler\n");
+ printer->Print(" callOptions:callOptions\n");
+ printer->Print(
+ vars, " responseClass:[$response_class$ class]];\n}\n\n");
+ } else {
+ printer->Print(vars, " return [self RPCToMethod:@\"$method_name$\"\n");
+ printer->Print(" message:message\n");
+ printer->Print(" responseHandler:handler\n");
+ printer->Print(" callOptions:callOptions\n");
+ printer->Print(
+ vars, " responseClass:[$response_class$ class]];\n}\n\n");
+ }
+}
+
void PrintMethodImplementations(Printer* printer,
const MethodDescriptor* method) {
map< ::grpc::string, ::grpc::string> vars = GetMethodVars(method);
@@ -184,12 +236,16 @@ void PrintMethodImplementations(Printer* printer,
PrintProtoRpcDeclarationAsPragma(printer, method, vars);
// TODO(jcanizales): Print documentation from the method.
+ printer->Print("// Deprecated methods.\n");
PrintSimpleSignature(printer, method, vars);
PrintSimpleImplementation(printer, method, vars);
printer->Print("// Returns a not-yet-started RPC object.\n");
PrintAdvancedSignature(printer, method, vars);
PrintAdvancedImplementation(printer, method, vars);
+
+ PrintV2Signature(printer, method, vars);
+ PrintV2Implementation(printer, method, vars);
}
} // namespace
@@ -231,6 +287,25 @@ void PrintMethodImplementations(Printer* printer,
return output;
}
+::grpc::string GetV2Protocol(const ServiceDescriptor* service) {
+ ::grpc::string output;
+
+ // Scope the output stream so it closes and finalizes output to the string.
+ grpc::protobuf::io::StringOutputStream output_stream(&output);
+ Printer printer(&output_stream, '$');
+
+ map< ::grpc::string, ::grpc::string> vars = {
+ {"service_class", ServiceClassName(service) + "2"}};
+
+ printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n");
+ for (int i = 0; i < service->method_count(); i++) {
+ PrintV2MethodDeclarations(&printer, service->method(i));
+ }
+ printer.Print("@end\n\n");
+
+ return output;
+}
+
::grpc::string GetInterface(const ServiceDescriptor* service) {
::grpc::string output;
@@ -248,10 +323,16 @@ void PrintMethodImplementations(Printer* printer,
" */\n");
printer.Print(vars,
"@interface $service_class$ :"
- " GRPCProtoService<$service_class$>\n");
+ " GRPCProtoService<$service_class$, $service_class$2>\n");
printer.Print(
- "- (instancetype)initWithHost:(NSString *)host"
+ "- (instancetype)initWithHost:(NSString *)host "
+ "callOptions:(GRPCCallOptions "
+ "*_Nullable)callOptions"
" NS_DESIGNATED_INITIALIZER;\n");
+ printer.Print("- (instancetype)initWithHost:(NSString *)host;\n");
+ printer.Print(
+ "+ (instancetype)serviceWithHost:(NSString *)host "
+ "callOptions:(GRPCCallOptions *_Nullable)callOptions;\n");
printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n");
printer.Print("@end\n");
@@ -273,11 +354,18 @@ void PrintMethodImplementations(Printer* printer,
printer.Print(vars,
"@implementation $service_class$\n\n"
"// Designated initializer\n"
- "- (instancetype)initWithHost:(NSString *)host {\n"
+ "- (instancetype)initWithHost:(NSString *)host "
+ "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n"
" self = [super initWithHost:host\n"
" packageName:@\"$package$\"\n"
- " serviceName:@\"$service_name$\"];\n"
+ " serviceName:@\"$service_name$\"\n"
+ " callOptions:callOptions];\n"
" return self;\n"
+ "}\n\n"
+ "- (instancetype)initWithHost:(NSString *)host {\n"
+ " return [super initWithHost:host\n"
+ " packageName:@\"$package$\"\n"
+ " serviceName:@\"$service_name$\"];\n"
"}\n\n");
printer.Print(
@@ -293,6 +381,10 @@ void PrintMethodImplementations(Printer* printer,
"#pragma mark - Class Methods\n\n"
"+ (instancetype)serviceWithHost:(NSString *)host {\n"
" return [[self alloc] initWithHost:host];\n"
+ "}\n\n"
+ "+ (instancetype)serviceWithHost:(NSString *)host "
+ "callOptions:(GRPCCallOptions *_Nullable)callOptions {\n"
+ " return [[self alloc] initWithHost:host callOptions:callOptions];\n"
"}\n\n");
printer.Print("#pragma mark - Method Implementations\n\n");
diff --git a/src/compiler/objective_c_generator.h b/src/compiler/objective_c_generator.h
index eb1c7ff005..c171e5bf77 100644
--- a/src/compiler/objective_c_generator.h
+++ b/src/compiler/objective_c_generator.h
@@ -32,9 +32,14 @@ using ::grpc::string;
string GetAllMessageClasses(const FileDescriptor* file);
// Returns the content to be included defining the @protocol segment at the
-// insertion point of the generated implementation file.
+// insertion point of the generated implementation file. This interface is
+// legacy and for backwards compatibility.
string GetProtocol(const ServiceDescriptor* service);
+// Returns the content to be included defining the @protocol segment at the
+// insertion point of the generated implementation file.
+string GetV2Protocol(const ServiceDescriptor* service);
+
// Returns the content to be included defining the @interface segment at the
// insertion point of the generated implementation file.
string GetInterface(const ServiceDescriptor* service);
diff --git a/src/compiler/objective_c_plugin.cc b/src/compiler/objective_c_plugin.cc
index f0fe3688cc..87977095d0 100644
--- a/src/compiler/objective_c_plugin.cc
+++ b/src/compiler/objective_c_plugin.cc
@@ -93,7 +93,13 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
SystemImport("RxLibrary/GRXWriteable.h") +
SystemImport("RxLibrary/GRXWriter.h");
- ::grpc::string forward_declarations = "@class GRPCProtoCall;\n\n";
+ ::grpc::string forward_declarations =
+ "@class GRPCProtoCall;\n"
+ "@class GRPCUnaryProtoCall;\n"
+ "@class GRPCStreamingProtoCall;\n"
+ "@class GRPCCallOptions;\n"
+ "@protocol GRPCProtoResponseHandler;\n"
+ "\n";
::grpc::string class_declarations =
grpc_objective_c_generator::GetAllMessageClasses(file);
@@ -103,6 +109,12 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
class_imports += ImportProtoHeaders(file->dependency(i), " ");
}
+ ::grpc::string ng_protocols;
+ for (int i = 0; i < file->service_count(); i++) {
+ const grpc::protobuf::ServiceDescriptor* service = file->service(i);
+ ng_protocols += grpc_objective_c_generator::GetV2Protocol(service);
+ }
+
::grpc::string protocols;
for (int i = 0; i < file->service_count(); i++) {
const grpc::protobuf::ServiceDescriptor* service = file->service(i);
@@ -120,9 +132,10 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
PreprocIfNot(kProtocolOnly, system_imports) + "\n" +
class_declarations + "\n" +
PreprocIfNot(kForwardDeclare, class_imports) + "\n" +
- forward_declarations + "\n" + kNonNullBegin + "\n" + protocols +
- "\n" + PreprocIfNot(kProtocolOnly, interfaces) + "\n" +
- kNonNullEnd + "\n");
+ forward_declarations + "\n" + kNonNullBegin + "\n" +
+ ng_protocols + protocols + "\n" +
+ PreprocIfNot(kProtocolOnly, interfaces) + "\n" + kNonNullEnd +
+ "\n");
}
{
diff --git a/src/core/ext/filters/client_channel/client_channel_factory.cc b/src/core/ext/filters/client_channel/client_channel_factory.cc
index 172e9f03c7..130bbe0418 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.cc
+++ b/src/core/ext/filters/client_channel/client_channel_factory.cc
@@ -30,7 +30,7 @@ void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory) {
}
grpc_subchannel* grpc_client_channel_factory_create_subchannel(
- grpc_client_channel_factory* factory, const grpc_subchannel_args* args) {
+ grpc_client_channel_factory* factory, const grpc_channel_args* args) {
return factory->vtable->create_subchannel(factory, args);
}
diff --git a/src/core/ext/filters/client_channel/client_channel_factory.h b/src/core/ext/filters/client_channel/client_channel_factory.h
index 601ec46b2a..91dec12282 100644
--- a/src/core/ext/filters/client_channel/client_channel_factory.h
+++ b/src/core/ext/filters/client_channel/client_channel_factory.h
@@ -49,7 +49,7 @@ struct grpc_client_channel_factory_vtable {
void (*ref)(grpc_client_channel_factory* factory);
void (*unref)(grpc_client_channel_factory* factory);
grpc_subchannel* (*create_subchannel)(grpc_client_channel_factory* factory,
- const grpc_subchannel_args* args);
+ const grpc_channel_args* args);
grpc_channel* (*create_client_channel)(grpc_client_channel_factory* factory,
const char* target,
grpc_client_channel_type type,
@@ -61,7 +61,7 @@ void grpc_client_channel_factory_unref(grpc_client_channel_factory* factory);
/** Create a new grpc_subchannel */
grpc_subchannel* grpc_client_channel_factory_create_subchannel(
- grpc_client_channel_factory* factory, const grpc_subchannel_args* args);
+ grpc_client_channel_factory* factory, const grpc_channel_args* args);
/** Create a new grpc_channel */
grpc_channel* grpc_client_channel_factory_create_channel(
diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
index 6f31a643c1..1d0ecbe3f6 100644
--- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
+++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h
@@ -509,12 +509,10 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
GRPC_ARG_SERVER_ADDRESS_LIST,
GRPC_ARG_INHIBIT_HEALTH_CHECKING};
// Create a subchannel for each address.
- grpc_subchannel_args sc_args;
for (size_t i = 0; i < addresses.size(); i++) {
// If there were any balancer addresses, we would have chosen grpclb
// policy, which does not use a SubchannelList.
GPR_ASSERT(!addresses[i].IsBalancer());
- memset(&sc_args, 0, sizeof(grpc_subchannel_args));
InlinedVector<grpc_arg, 4> args_to_add;
args_to_add.emplace_back(
grpc_create_subchannel_address_arg(&addresses[i].address()));
@@ -527,9 +525,8 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
&args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove),
args_to_add.data(), args_to_add.size());
gpr_free(args_to_add[0].value.string);
- sc_args.args = new_args;
grpc_subchannel* subchannel = grpc_client_channel_factory_create_subchannel(
- client_channel_factory, &sc_args);
+ client_channel_factory, new_args);
grpc_channel_args_destroy(new_args);
if (subchannel == nullptr) {
// Subchannel could not be created.
diff --git a/src/core/ext/filters/client_channel/parse_address.cc b/src/core/ext/filters/client_channel/parse_address.cc
index 707beb8876..c5e1ed811b 100644
--- a/src/core/ext/filters/client_channel/parse_address.cc
+++ b/src/core/ext/filters/client_channel/parse_address.cc
@@ -19,6 +19,7 @@
#include <grpc/support/port_platform.h>
#include "src/core/ext/filters/client_channel/parse_address.h"
+#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
#include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/socket_utils.h"
@@ -35,6 +36,11 @@
#include "src/core/lib/gpr/host_port.h"
#include "src/core/lib/gpr/string.h"
+#ifdef GRPC_POSIX_SOCKET
+#include <errno.h>
+#include <net/if.h>
+#endif
+
#ifdef GRPC_HAVE_UNIX_SOCKET
bool grpc_parse_unix(const grpc_uri* uri,
@@ -69,7 +75,12 @@ bool grpc_parse_ipv4_hostport(const char* hostport, grpc_resolved_address* addr,
// Split host and port.
char* host;
char* port;
- if (!gpr_split_host_port(hostport, &host, &port)) return false;
+ if (!gpr_split_host_port(hostport, &host, &port)) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
+ }
+ return false;
+ }
// Parse IP address.
memset(addr, 0, sizeof(*addr));
addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in));
@@ -115,7 +126,12 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
// Split host and port.
char* host;
char* port;
- if (!gpr_split_host_port(hostport, &host, &port)) return false;
+ if (!gpr_split_host_port(hostport, &host, &port)) {
+ if (log_errors) {
+ gpr_log(GPR_ERROR, "Failed gpr_split_host_port(%s, ...)", hostport);
+ }
+ return false;
+ }
// Parse IP address.
memset(addr, 0, sizeof(*addr));
addr->len = static_cast<socklen_t>(sizeof(grpc_sockaddr_in6));
@@ -150,10 +166,13 @@ bool grpc_parse_ipv6_hostport(const char* hostport, grpc_resolved_address* addr,
if (gpr_parse_bytes_to_uint32(host_end + 1,
strlen(host) - host_without_scope_len - 1,
&sin6_scope_id) == 0) {
- if (log_errors) {
- gpr_log(GPR_ERROR, "invalid ipv6 scope id: '%s'", host_end + 1);
+ if ((sin6_scope_id = grpc_if_nametoindex(host_end + 1)) == 0) {
+ gpr_log(GPR_ERROR,
+ "Invalid interface name: '%s'. "
+ "Non-numeric and failed if_nametoindex.",
+ host_end + 1);
+ goto done;
}
- goto done;
}
// Handle "sin6_scope_id" being type "u_long". See grpc issue #10027.
in6->sin6_scope_id = sin6_scope_id;
diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc
index 9077aa9753..640a052e91 100644
--- a/src/core/ext/filters/client_channel/subchannel.cc
+++ b/src/core/ext/filters/client_channel/subchannel.cc
@@ -64,18 +64,6 @@
#define GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS 120
#define GRPC_SUBCHANNEL_RECONNECT_JITTER 0.2
-namespace {
-struct state_watcher {
- grpc_closure closure;
- grpc_subchannel* subchannel;
- grpc_connectivity_state connectivity_state;
- grpc_connectivity_state last_connectivity_state;
- grpc_core::OrphanablePtr<grpc_core::HealthCheckClient> health_check_client;
- grpc_closure health_check_closure;
- grpc_connectivity_state health_state;
-};
-} // namespace
-
typedef struct external_state_watcher {
grpc_subchannel* subchannel;
grpc_pollset_set* pollset_set;
@@ -101,9 +89,6 @@ struct grpc_subchannel {
keep the subchannel open */
gpr_atm ref_pair;
- /** non-transport related channel filters */
- const grpc_channel_filter** filters;
- size_t num_filters;
/** channel arguments */
grpc_channel_args* args;
@@ -384,7 +369,6 @@ static void subchannel_destroy(void* arg, grpc_error* error) {
c->channelz_subchannel->MarkSubchannelDestroyed();
c->channelz_subchannel.reset();
}
- gpr_free((void*)c->filters);
c->health_check_service_name.reset();
grpc_channel_args_destroy(c->args);
grpc_connectivity_state_destroy(&c->state_tracker);
@@ -553,7 +537,7 @@ struct HealthCheckParams {
} // namespace grpc_core
grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
- const grpc_subchannel_args* args) {
+ const grpc_channel_args* args) {
grpc_subchannel_key* key = grpc_subchannel_key_create(args);
grpc_subchannel* c = grpc_subchannel_index_find(key);
if (c) {
@@ -567,23 +551,13 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
gpr_atm_no_barrier_store(&c->ref_pair, 1 << INTERNAL_REF_BITS);
c->connector = connector;
grpc_connector_ref(c->connector);
- c->num_filters = args->filter_count;
- if (c->num_filters > 0) {
- c->filters = static_cast<const grpc_channel_filter**>(
- gpr_malloc(sizeof(grpc_channel_filter*) * c->num_filters));
- memcpy((void*)c->filters, args->filters,
- sizeof(grpc_channel_filter*) * c->num_filters);
- } else {
- c->filters = nullptr;
- }
c->pollset_set = grpc_pollset_set_create();
grpc_resolved_address* addr =
static_cast<grpc_resolved_address*>(gpr_malloc(sizeof(*addr)));
- grpc_get_subchannel_address_arg(args->args, addr);
+ grpc_get_subchannel_address_arg(args, addr);
grpc_resolved_address* new_address = nullptr;
grpc_channel_args* new_args = nullptr;
- if (grpc_proxy_mappers_map_address(addr, args->args, &new_address,
- &new_args)) {
+ if (grpc_proxy_mappers_map_address(addr, args, &new_address, &new_args)) {
GPR_ASSERT(new_address != nullptr);
gpr_free(addr);
addr = new_address;
@@ -592,7 +566,7 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
grpc_arg new_arg = grpc_create_subchannel_address_arg(addr);
gpr_free(addr);
c->args = grpc_channel_args_copy_and_add_and_remove(
- new_args != nullptr ? new_args : args->args, keys_to_remove,
+ new_args != nullptr ? new_args : args, keys_to_remove,
GPR_ARRAY_SIZE(keys_to_remove), &new_arg, 1);
gpr_free(new_arg.value.string);
if (new_args != nullptr) grpc_channel_args_destroy(new_args);
@@ -605,7 +579,7 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
grpc_connectivity_state_init(&c->state_and_health_tracker, GRPC_CHANNEL_IDLE,
"subchannel");
grpc_core::BackOff::Options backoff_options;
- parse_args_for_backoff_values(args->args, &backoff_options,
+ parse_args_for_backoff_values(args, &backoff_options,
&c->min_connect_timeout_ms);
c->backoff.Init(backoff_options);
gpr_mu_init(&c->mu);
diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h
index 14f87f2c68..8c994c64f5 100644
--- a/src/core/ext/filters/client_channel/subchannel.h
+++ b/src/core/ext/filters/client_channel/subchannel.h
@@ -38,7 +38,6 @@
address. Provides a target for load balancing. */
typedef struct grpc_subchannel grpc_subchannel;
typedef struct grpc_subchannel_call grpc_subchannel_call;
-typedef struct grpc_subchannel_args grpc_subchannel_args;
typedef struct grpc_subchannel_key grpc_subchannel_key;
#ifndef NDEBUG
@@ -186,21 +185,9 @@ void grpc_subchannel_call_set_cleanup_closure(
grpc_call_stack* grpc_subchannel_call_get_call_stack(
grpc_subchannel_call* subchannel_call);
-struct grpc_subchannel_args {
- /* When updating this struct, also update subchannel_index.c */
-
- /** Channel filters for this channel - wrapped factories will likely
- want to mutate this */
- const grpc_channel_filter** filters;
- /** The number of filters in the above array */
- size_t filter_count;
- /** Channel arguments to be supplied to the newly created channel */
- const grpc_channel_args* args;
-};
-
/** create a subchannel given a connector */
grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
- const grpc_subchannel_args* args);
+ const grpc_channel_args* args);
/// Sets \a addr from \a args.
void grpc_get_subchannel_address_arg(const grpc_channel_args* args,
diff --git a/src/core/ext/filters/client_channel/subchannel_index.cc b/src/core/ext/filters/client_channel/subchannel_index.cc
index aa8441f17b..d0ceda8312 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.cc
+++ b/src/core/ext/filters/client_channel/subchannel_index.cc
@@ -39,55 +39,37 @@ static gpr_mu g_mu;
static gpr_refcount g_refcount;
struct grpc_subchannel_key {
- grpc_subchannel_args args;
+ grpc_channel_args* args;
};
static bool g_force_creation = false;
static grpc_subchannel_key* create_key(
- const grpc_subchannel_args* args,
+ const grpc_channel_args* args,
grpc_channel_args* (*copy_channel_args)(const grpc_channel_args* args)) {
grpc_subchannel_key* k =
static_cast<grpc_subchannel_key*>(gpr_malloc(sizeof(*k)));
- k->args.filter_count = args->filter_count;
- if (k->args.filter_count > 0) {
- k->args.filters = static_cast<const grpc_channel_filter**>(
- gpr_malloc(sizeof(*k->args.filters) * k->args.filter_count));
- memcpy(reinterpret_cast<grpc_channel_filter*>(k->args.filters),
- args->filters, sizeof(*k->args.filters) * k->args.filter_count);
- } else {
- k->args.filters = nullptr;
- }
- k->args.args = copy_channel_args(args->args);
+ k->args = copy_channel_args(args);
return k;
}
-grpc_subchannel_key* grpc_subchannel_key_create(
- const grpc_subchannel_args* args) {
+grpc_subchannel_key* grpc_subchannel_key_create(const grpc_channel_args* args) {
return create_key(args, grpc_channel_args_normalize);
}
static grpc_subchannel_key* subchannel_key_copy(grpc_subchannel_key* k) {
- return create_key(&k->args, grpc_channel_args_copy);
+ return create_key(k->args, grpc_channel_args_copy);
}
int grpc_subchannel_key_compare(const grpc_subchannel_key* a,
const grpc_subchannel_key* b) {
// To pretend the keys are different, return a non-zero value.
if (GPR_UNLIKELY(g_force_creation)) return 1;
- int c = GPR_ICMP(a->args.filter_count, b->args.filter_count);
- if (c != 0) return c;
- if (a->args.filter_count > 0) {
- c = memcmp(a->args.filters, b->args.filters,
- a->args.filter_count * sizeof(*a->args.filters));
- if (c != 0) return c;
- }
- return grpc_channel_args_compare(a->args.args, b->args.args);
+ return grpc_channel_args_compare(a->args, b->args);
}
void grpc_subchannel_key_destroy(grpc_subchannel_key* k) {
- gpr_free(reinterpret_cast<grpc_channel_args*>(k->args.filters));
- grpc_channel_args_destroy(const_cast<grpc_channel_args*>(k->args.args));
+ grpc_channel_args_destroy(k->args);
gpr_free(k);
}
diff --git a/src/core/ext/filters/client_channel/subchannel_index.h b/src/core/ext/filters/client_channel/subchannel_index.h
index c135613d26..429634bd54 100644
--- a/src/core/ext/filters/client_channel/subchannel_index.h
+++ b/src/core/ext/filters/client_channel/subchannel_index.h
@@ -27,8 +27,7 @@
shared amongst channels */
/** Create a key that can be used to uniquely identify a subchannel */
-grpc_subchannel_key* grpc_subchannel_key_create(
- const grpc_subchannel_args* args);
+grpc_subchannel_key* grpc_subchannel_key_create(const grpc_channel_args* args);
/** Destroy a subchannel key */
void grpc_subchannel_key_destroy(grpc_subchannel_key* key);
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
index e6c8c38260..a5bf1bf21d 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.cc
@@ -40,14 +40,12 @@ static void client_channel_factory_unref(
grpc_client_channel_factory* cc_factory) {}
static grpc_subchannel* client_channel_factory_create_subchannel(
- grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
- grpc_subchannel_args final_sc_args;
- memcpy(&final_sc_args, args, sizeof(*args));
- final_sc_args.args = grpc_default_authority_add_if_not_present(args->args);
+ grpc_client_channel_factory* cc_factory, const grpc_channel_args* args) {
+ grpc_channel_args* new_args = grpc_default_authority_add_if_not_present(args);
grpc_connector* connector = grpc_chttp2_connector_create();
- grpc_subchannel* s = grpc_subchannel_create(connector, &final_sc_args);
+ grpc_subchannel* s = grpc_subchannel_create(connector, new_args);
grpc_connector_unref(connector);
- grpc_channel_args_destroy(const_cast<grpc_channel_args*>(final_sc_args.args));
+ grpc_channel_args_destroy(new_args);
return s;
}
diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
index 9612698e96..ddd538faa8 100644
--- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
+++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc
@@ -46,10 +46,10 @@ static void client_channel_factory_ref(
static void client_channel_factory_unref(
grpc_client_channel_factory* cc_factory) {}
-static grpc_subchannel_args* get_secure_naming_subchannel_args(
- const grpc_subchannel_args* args) {
+static grpc_channel_args* get_secure_naming_channel_args(
+ const grpc_channel_args* args) {
grpc_channel_credentials* channel_credentials =
- grpc_channel_credentials_find_in_args(args->args);
+ grpc_channel_credentials_find_in_args(args);
if (channel_credentials == nullptr) {
gpr_log(GPR_ERROR,
"Can't create subchannel: channel credentials missing for secure "
@@ -57,7 +57,7 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
return nullptr;
}
// Make sure security connector does not already exist in args.
- if (grpc_security_connector_find_in_args(args->args) != nullptr) {
+ if (grpc_security_connector_find_in_args(args) != nullptr) {
gpr_log(GPR_ERROR,
"Can't create subchannel: security connector already present in "
"channel args.");
@@ -65,19 +65,18 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
}
// To which address are we connecting? By default, use the server URI.
const grpc_arg* server_uri_arg =
- grpc_channel_args_find(args->args, GRPC_ARG_SERVER_URI);
+ grpc_channel_args_find(args, GRPC_ARG_SERVER_URI);
const char* server_uri_str = grpc_channel_arg_get_string(server_uri_arg);
GPR_ASSERT(server_uri_str != nullptr);
grpc_uri* server_uri =
grpc_uri_parse(server_uri_str, true /* supress errors */);
GPR_ASSERT(server_uri != nullptr);
const grpc_core::TargetAuthorityTable* target_authority_table =
- grpc_core::FindTargetAuthorityTableInArgs(args->args);
+ grpc_core::FindTargetAuthorityTableInArgs(args);
grpc_core::UniquePtr<char> authority;
if (target_authority_table != nullptr) {
// Find the authority for the target.
- const char* target_uri_str =
- grpc_get_subchannel_address_uri_arg(args->args);
+ const char* target_uri_str = grpc_get_subchannel_address_uri_arg(args);
grpc_uri* target_uri =
grpc_uri_parse(target_uri_str, false /* suppress errors */);
GPR_ASSERT(target_uri != nullptr);
@@ -100,15 +99,14 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
}
grpc_arg args_to_add[2];
size_t num_args_to_add = 0;
- if (grpc_channel_args_find(args->args, GRPC_ARG_DEFAULT_AUTHORITY) ==
- nullptr) {
+ if (grpc_channel_args_find(args, GRPC_ARG_DEFAULT_AUTHORITY) == nullptr) {
// If the channel args don't already contain GRPC_ARG_DEFAULT_AUTHORITY, add
// the arg, setting it to the value just obtained.
args_to_add[num_args_to_add++] = grpc_channel_arg_string_create(
const_cast<char*>(GRPC_ARG_DEFAULT_AUTHORITY), authority.get());
}
grpc_channel_args* args_with_authority =
- grpc_channel_args_copy_and_add(args->args, args_to_add, num_args_to_add);
+ grpc_channel_args_copy_and_add(args, args_to_add, num_args_to_add);
grpc_uri_destroy(server_uri);
// Create the security connector using the credentials and target name.
grpc_channel_args* new_args_from_connector = nullptr;
@@ -137,29 +135,21 @@ static grpc_subchannel_args* get_secure_naming_subchannel_args(
grpc_channel_args_destroy(new_args_from_connector);
}
grpc_channel_args_destroy(args_with_authority);
- grpc_subchannel_args* final_sc_args =
- static_cast<grpc_subchannel_args*>(gpr_malloc(sizeof(*final_sc_args)));
- memcpy(final_sc_args, args, sizeof(*args));
- final_sc_args->args = new_args;
- return final_sc_args;
+ return new_args;
}
static grpc_subchannel* client_channel_factory_create_subchannel(
- grpc_client_channel_factory* cc_factory, const grpc_subchannel_args* args) {
- grpc_subchannel_args* subchannel_args =
- get_secure_naming_subchannel_args(args);
- if (subchannel_args == nullptr) {
- gpr_log(
- GPR_ERROR,
- "Failed to create subchannel arguments during subchannel creation.");
+ grpc_client_channel_factory* cc_factory, const grpc_channel_args* args) {
+ grpc_channel_args* new_args = get_secure_naming_channel_args(args);
+ if (new_args == nullptr) {
+ gpr_log(GPR_ERROR,
+ "Failed to create channel args during subchannel creation.");
return nullptr;
}
grpc_connector* connector = grpc_chttp2_connector_create();
- grpc_subchannel* s = grpc_subchannel_create(connector, subchannel_args);
+ grpc_subchannel* s = grpc_subchannel_create(connector, new_args);
grpc_connector_unref(connector);
- grpc_channel_args_destroy(
- const_cast<grpc_channel_args*>(subchannel_args->args));
- gpr_free(subchannel_args);
+ grpc_channel_args_destroy(new_args);
return s;
}
diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
index 40a30e4a31..6e08d27b21 100644
--- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
+++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc
@@ -46,9 +46,21 @@ GRPCAPI grpc_channel* grpc_cronet_secure_channel_create(
"grpc_create_cronet_transport: stream_engine = %p, target=%s", engine,
target);
+ // Disable client authority filter when using Cronet
+ grpc_arg disable_client_authority_filter_arg;
+ disable_client_authority_filter_arg.key =
+ const_cast<char*>(GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER);
+ disable_client_authority_filter_arg.type = GRPC_ARG_INTEGER;
+ disable_client_authority_filter_arg.value.integer = 1;
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
+ args, &disable_client_authority_filter_arg, 1);
+
grpc_transport* ct =
- grpc_create_cronet_transport(engine, target, args, reserved);
+ grpc_create_cronet_transport(engine, target, new_args, reserved);
grpc_core::ExecCtx exec_ctx;
- return grpc_channel_create(target, args, GRPC_CLIENT_DIRECT_CHANNEL, ct);
+ grpc_channel* channel =
+ grpc_channel_create(target, new_args, GRPC_CLIENT_DIRECT_CHANNEL, ct);
+ grpc_channel_args_destroy(new_args);
+ return channel;
}
diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc
index 827fd24831..6cb9ca1a0d 100644
--- a/src/core/lib/iomgr/cfstream_handle.cc
+++ b/src/core/lib/iomgr/cfstream_handle.cc
@@ -52,62 +52,52 @@ CFStreamHandle* CFStreamHandle::CreateStreamHandle(
void CFStreamHandle::ReadCallback(CFReadStreamRef stream,
CFStreamEventType type,
void* client_callback_info) {
+ grpc_core::ExecCtx exec_ctx;
CFStreamHandle* handle = static_cast<CFStreamHandle*>(client_callback_info);
- CFSTREAM_HANDLE_REF(handle, "read callback");
- dispatch_async(
- dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- grpc_core::ExecCtx exec_ctx;
- if (grpc_tcp_trace.enabled()) {
- gpr_log(GPR_DEBUG, "CFStream ReadCallback (%p, %p, %lu, %p)", handle,
- stream, type, client_callback_info);
- }
- switch (type) {
- case kCFStreamEventOpenCompleted:
- handle->open_event_.SetReady();
- break;
- case kCFStreamEventHasBytesAvailable:
- case kCFStreamEventEndEncountered:
- handle->read_event_.SetReady();
- break;
- case kCFStreamEventErrorOccurred:
- handle->open_event_.SetReady();
- handle->read_event_.SetReady();
- break;
- default:
- GPR_UNREACHABLE_CODE(return );
- }
- CFSTREAM_HANDLE_UNREF(handle, "read callback");
- });
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "CFStream ReadCallback (%p, %p, %lu, %p)", handle,
+ stream, type, client_callback_info);
+ }
+ switch (type) {
+ case kCFStreamEventOpenCompleted:
+ handle->open_event_.SetReady();
+ break;
+ case kCFStreamEventHasBytesAvailable:
+ case kCFStreamEventEndEncountered:
+ handle->read_event_.SetReady();
+ break;
+ case kCFStreamEventErrorOccurred:
+ handle->open_event_.SetReady();
+ handle->read_event_.SetReady();
+ break;
+ default:
+ GPR_UNREACHABLE_CODE(return );
+ }
}
void CFStreamHandle::WriteCallback(CFWriteStreamRef stream,
CFStreamEventType type,
void* clientCallBackInfo) {
+ grpc_core::ExecCtx exec_ctx;
CFStreamHandle* handle = static_cast<CFStreamHandle*>(clientCallBackInfo);
- CFSTREAM_HANDLE_REF(handle, "write callback");
- dispatch_async(
- dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- grpc_core::ExecCtx exec_ctx;
- if (grpc_tcp_trace.enabled()) {
- gpr_log(GPR_DEBUG, "CFStream WriteCallback (%p, %p, %lu, %p)", handle,
- stream, type, clientCallBackInfo);
- }
- switch (type) {
- case kCFStreamEventOpenCompleted:
- handle->open_event_.SetReady();
- break;
- case kCFStreamEventCanAcceptBytes:
- case kCFStreamEventEndEncountered:
- handle->write_event_.SetReady();
- break;
- case kCFStreamEventErrorOccurred:
- handle->open_event_.SetReady();
- handle->write_event_.SetReady();
- break;
- default:
- GPR_UNREACHABLE_CODE(return );
- }
- CFSTREAM_HANDLE_UNREF(handle, "write callback");
- });
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_DEBUG, "CFStream WriteCallback (%p, %p, %lu, %p)", handle,
+ stream, type, clientCallBackInfo);
+ }
+ switch (type) {
+ case kCFStreamEventOpenCompleted:
+ handle->open_event_.SetReady();
+ break;
+ case kCFStreamEventCanAcceptBytes:
+ case kCFStreamEventEndEncountered:
+ handle->write_event_.SetReady();
+ break;
+ case kCFStreamEventErrorOccurred:
+ handle->open_event_.SetReady();
+ handle->write_event_.SetReady();
+ break;
+ default:
+ GPR_UNREACHABLE_CODE(return );
+ }
}
CFStreamHandle::CFStreamHandle(CFReadStreamRef read_stream,
@@ -116,6 +106,7 @@ CFStreamHandle::CFStreamHandle(CFReadStreamRef read_stream,
open_event_.InitEvent();
read_event_.InitEvent();
write_event_.InitEvent();
+ dispatch_queue_ = dispatch_queue_create(nullptr, DISPATCH_QUEUE_SERIAL);
CFStreamClientContext ctx = {0, static_cast<void*>(this),
CFStreamHandle::Retain, CFStreamHandle::Release,
nil};
@@ -129,10 +120,8 @@ CFStreamHandle::CFStreamHandle(CFReadStreamRef read_stream,
kCFStreamEventOpenCompleted | kCFStreamEventCanAcceptBytes |
kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered,
CFStreamHandle::WriteCallback, &ctx);
- CFReadStreamScheduleWithRunLoop(read_stream, CFRunLoopGetMain(),
- kCFRunLoopCommonModes);
- CFWriteStreamScheduleWithRunLoop(write_stream, CFRunLoopGetMain(),
- kCFRunLoopCommonModes);
+ CFReadStreamSetDispatchQueue(read_stream, dispatch_queue_);
+ CFWriteStreamSetDispatchQueue(write_stream, dispatch_queue_);
}
CFStreamHandle::~CFStreamHandle() {
diff --git a/src/core/lib/iomgr/cfstream_handle.h b/src/core/lib/iomgr/cfstream_handle.h
index 4258e72431..93ec5f044b 100644
--- a/src/core/lib/iomgr/cfstream_handle.h
+++ b/src/core/lib/iomgr/cfstream_handle.h
@@ -62,6 +62,8 @@ class CFStreamHandle final {
grpc_core::LockfreeEvent read_event_;
grpc_core::LockfreeEvent write_event_;
+ dispatch_queue_t dispatch_queue_;
+
gpr_refcount refcount_;
};
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex.h b/src/core/lib/iomgr/grpc_if_nametoindex.h
new file mode 100644
index 0000000000..ed9612dcb9
--- /dev/null
+++ b/src/core/lib/iomgr/grpc_if_nametoindex.h
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright 2015 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 GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H
+#define GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H
+
+#include <grpc/support/port_platform.h>
+
+#include <stddef.h>
+
+/* Returns the interface index corresponding to the interface "name" provided.
+ * Returns non-zero upon success, and zero upon failure. */
+uint32_t grpc_if_nametoindex(char* name);
+
+#endif /* GRPC_CORE_LIB_IOMGR_GRPC_IF_NAMETOINDEX_H */
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc b/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
new file mode 100644
index 0000000000..f1ba20dcec
--- /dev/null
+++ b/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc
@@ -0,0 +1,42 @@
+/*
+ *
+ * Copyright 2016 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 <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/port.h"
+
+#if GRPC_IF_NAMETOINDEX == 1 && defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX)
+
+#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
+
+#include <errno.h>
+#include <net/if.h>
+
+#include <grpc/support/log.h>
+
+uint32_t grpc_if_nametoindex(char* name) {
+ uint32_t out = if_nametoindex(name);
+ if (out == 0) {
+ gpr_log(GPR_DEBUG, "if_nametoindex failed for name %s. errno %d", name,
+ errno);
+ }
+ return out;
+}
+
+#endif /* GRPC_IF_NAMETOINDEX == 1 && \
+ defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX) */
diff --git a/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc b/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
new file mode 100644
index 0000000000..08644cccf3
--- /dev/null
+++ b/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2016 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 <grpc/support/port_platform.h>
+
+#include "src/core/lib/iomgr/port.h"
+
+#if GRPC_IF_NAMETOINDEX == 0 || !defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX)
+
+#include "src/core/lib/iomgr/grpc_if_nametoindex.h"
+
+#include <grpc/support/log.h>
+
+uint32_t grpc_if_nametoindex(char* name) {
+ gpr_log(GPR_DEBUG,
+ "Not attempting to convert interface name %s to index for current "
+ "platform.",
+ name);
+ return 0;
+}
+
+#endif /* GRPC_IF_NAMETOINDEX == 0 || \
+ !defined(GRPC_POSIX_SOCKET_IF_NAMETOINDEX) */
diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h
index c8046b21dc..7b6ca1bc0e 100644
--- a/src/core/lib/iomgr/port.h
+++ b/src/core/lib/iomgr/port.h
@@ -184,6 +184,7 @@
#define GRPC_POSIX_SOCKET_EV_EPOLLEX 1
#define GRPC_POSIX_SOCKET_EV_POLL 1
#define GRPC_POSIX_SOCKET_EV_EPOLL1 1
+#define GRPC_POSIX_SOCKET_IF_NAMETOINDEX 1
#define GRPC_POSIX_SOCKET_IOMGR 1
#define GRPC_POSIX_SOCKET_RESOLVE_ADDRESS 1
#define GRPC_POSIX_SOCKET_SOCKADDR 1
diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc
index 7e4b3c9b2f..61c366098e 100644
--- a/src/core/lib/iomgr/resource_quota.cc
+++ b/src/core/lib/iomgr/resource_quota.cc
@@ -665,6 +665,7 @@ void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota) {
GPR_ASSERT(resource_quota->num_threads_allocated == 0);
GRPC_COMBINER_UNREF(resource_quota->combiner, "resource_quota");
gpr_free(resource_quota->name);
+ gpr_mu_destroy(&resource_quota->thread_count_mu);
gpr_free(resource_quota);
}
}
diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc
index 4b5250803d..86ee1010cf 100644
--- a/src/core/lib/iomgr/tcp_windows.cc
+++ b/src/core/lib/iomgr/tcp_windows.cc
@@ -42,6 +42,7 @@
#include "src/core/lib/iomgr/tcp_windows.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/slice/slice_string_helpers.h"
#if defined(__MSYS__) && defined(GPR_ARCH_64)
/* Nasty workaround for nasty bug when using the 64 bits msys compiler
@@ -112,7 +113,10 @@ typedef struct grpc_tcp {
grpc_closure* read_cb;
grpc_closure* write_cb;
- grpc_slice read_slice;
+
+ /* garbage after the last read */
+ grpc_slice_buffer last_read_buffer;
+
grpc_slice_buffer* write_slices;
grpc_slice_buffer* read_slices;
@@ -131,6 +135,7 @@ static void tcp_free(grpc_tcp* tcp) {
grpc_winsocket_destroy(tcp->socket);
gpr_mu_destroy(&tcp->mu);
gpr_free(tcp->peer_string);
+ grpc_slice_buffer_destroy_internal(&tcp->last_read_buffer);
grpc_resource_user_unref(tcp->resource_user);
if (tcp->shutting_down) GRPC_ERROR_UNREF(tcp->shutdown_error);
gpr_free(tcp);
@@ -179,9 +184,12 @@ static void on_read(void* tcpp, grpc_error* error) {
grpc_tcp* tcp = (grpc_tcp*)tcpp;
grpc_closure* cb = tcp->read_cb;
grpc_winsocket* socket = tcp->socket;
- grpc_slice sub;
grpc_winsocket_callback_info* info = &socket->read_info;
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_INFO, "TCP:%p on_read", tcp);
+ }
+
GRPC_ERROR_REF(error);
if (error == GRPC_ERROR_NONE) {
@@ -189,13 +197,35 @@ static void on_read(void* tcpp, grpc_error* error) {
char* utf8_message = gpr_format_message(info->wsa_error);
error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(utf8_message);
gpr_free(utf8_message);
- grpc_slice_unref_internal(tcp->read_slice);
+ grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
} else {
if (info->bytes_transfered != 0 && !tcp->shutting_down) {
- sub = grpc_slice_sub_no_ref(tcp->read_slice, 0, info->bytes_transfered);
- grpc_slice_buffer_add(tcp->read_slices, sub);
+ GPR_ASSERT((size_t)info->bytes_transfered <= tcp->read_slices->length);
+ if (static_cast<size_t>(info->bytes_transfered) !=
+ tcp->read_slices->length) {
+ grpc_slice_buffer_trim_end(
+ tcp->read_slices,
+ tcp->read_slices->length -
+ static_cast<size_t>(info->bytes_transfered),
+ &tcp->last_read_buffer);
+ }
+ GPR_ASSERT((size_t)info->bytes_transfered == tcp->read_slices->length);
+
+ if (grpc_tcp_trace.enabled()) {
+ size_t i;
+ for (i = 0; i < tcp->read_slices->count; i++) {
+ char* dump = grpc_dump_slice(tcp->read_slices->slices[i],
+ GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ gpr_log(GPR_INFO, "READ %p (peer=%s): %s", tcp, tcp->peer_string,
+ dump);
+ gpr_free(dump);
+ }
+ }
} else {
- grpc_slice_unref_internal(tcp->read_slice);
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_INFO, "TCP:%p unref read_slice", tcp);
+ }
+ grpc_slice_buffer_reset_and_unref_internal(tcp->read_slices);
error = tcp->shutting_down
? GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"TCP stream shutting down", &tcp->shutdown_error, 1)
@@ -209,6 +239,8 @@ static void on_read(void* tcpp, grpc_error* error) {
GRPC_CLOSURE_SCHED(cb, error);
}
+#define DEFAULT_TARGET_READ_SIZE 8192
+#define MAX_WSABUF_COUNT 16
static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
grpc_closure* cb) {
grpc_tcp* tcp = (grpc_tcp*)ep;
@@ -217,7 +249,12 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
int status;
DWORD bytes_read = 0;
DWORD flags = 0;
- WSABUF buffer;
+ WSABUF buffers[MAX_WSABUF_COUNT];
+ size_t i;
+
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_INFO, "TCP:%p win_read", tcp);
+ }
if (tcp->shutting_down) {
GRPC_CLOSURE_SCHED(
@@ -229,18 +266,27 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
tcp->read_cb = cb;
tcp->read_slices = read_slices;
grpc_slice_buffer_reset_and_unref_internal(read_slices);
+ grpc_slice_buffer_swap(read_slices, &tcp->last_read_buffer);
- tcp->read_slice = GRPC_SLICE_MALLOC(8192);
+ if (tcp->read_slices->length < DEFAULT_TARGET_READ_SIZE / 2 &&
+ tcp->read_slices->count < MAX_WSABUF_COUNT) {
+ // TODO(jtattermusch): slice should be allocated using resource quota
+ grpc_slice_buffer_add(tcp->read_slices,
+ GRPC_SLICE_MALLOC(DEFAULT_TARGET_READ_SIZE));
+ }
- buffer.len = (ULONG)GRPC_SLICE_LENGTH(
- tcp->read_slice); // we know slice size fits in 32bit.
- buffer.buf = (char*)GRPC_SLICE_START_PTR(tcp->read_slice);
+ GPR_ASSERT(tcp->read_slices->count <= MAX_WSABUF_COUNT);
+ for (i = 0; i < tcp->read_slices->count; i++) {
+ buffers[i].len = (ULONG)GRPC_SLICE_LENGTH(
+ tcp->read_slices->slices[i]); // we know slice size fits in 32bit.
+ buffers[i].buf = (char*)GRPC_SLICE_START_PTR(tcp->read_slices->slices[i]);
+ }
TCP_REF(tcp, "read");
/* First let's try a synchronous, non-blocking read. */
- status =
- WSARecv(tcp->socket->socket, &buffer, 1, &bytes_read, &flags, NULL, NULL);
+ status = WSARecv(tcp->socket->socket, buffers, (DWORD)tcp->read_slices->count,
+ &bytes_read, &flags, NULL, NULL);
info->wsa_error = status == 0 ? 0 : WSAGetLastError();
/* Did we get data immediately ? Yay. */
@@ -252,8 +298,8 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices,
/* Otherwise, let's retry, by queuing a read. */
memset(&tcp->socket->read_info.overlapped, 0, sizeof(OVERLAPPED));
- status = WSARecv(tcp->socket->socket, &buffer, 1, &bytes_read, &flags,
- &info->overlapped, NULL);
+ status = WSARecv(tcp->socket->socket, buffers, (DWORD)tcp->read_slices->count,
+ &bytes_read, &flags, &info->overlapped, NULL);
if (status != 0) {
int wsa_error = WSAGetLastError();
@@ -275,6 +321,10 @@ static void on_write(void* tcpp, grpc_error* error) {
grpc_winsocket_callback_info* info = &handle->write_info;
grpc_closure* cb;
+ if (grpc_tcp_trace.enabled()) {
+ gpr_log(GPR_INFO, "TCP:%p on_write", tcp);
+ }
+
GRPC_ERROR_REF(error);
gpr_mu_lock(&tcp->mu);
@@ -303,11 +353,21 @@ static void win_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
unsigned i;
DWORD bytes_sent;
int status;
- WSABUF local_buffers[16];
+ WSABUF local_buffers[MAX_WSABUF_COUNT];
WSABUF* allocated = NULL;
WSABUF* buffers = local_buffers;
size_t len;
+ if (grpc_tcp_trace.enabled()) {
+ size_t i;
+ for (i = 0; i < slices->count; i++) {
+ char* data =
+ grpc_dump_slice(slices->slices[i], GPR_DUMP_HEX | GPR_DUMP_ASCII);
+ gpr_log(GPR_INFO, "WRITE %p (peer=%s): %s", tcp, tcp->peer_string, data);
+ gpr_free(data);
+ }
+ }
+
if (tcp->shutting_down) {
GRPC_CLOSURE_SCHED(
cb, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
@@ -412,6 +472,7 @@ static void win_shutdown(grpc_endpoint* ep, grpc_error* why) {
static void win_destroy(grpc_endpoint* ep) {
grpc_network_status_unregister_endpoint(ep);
grpc_tcp* tcp = (grpc_tcp*)ep;
+ grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer);
TCP_UNREF(tcp, "destroy");
}
@@ -463,6 +524,7 @@ grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket,
GRPC_CLOSURE_INIT(&tcp->on_read, on_read, tcp, grpc_schedule_on_exec_ctx);
GRPC_CLOSURE_INIT(&tcp->on_write, on_write, tcp, grpc_schedule_on_exec_ctx);
tcp->peer_string = gpr_strdup(peer_string);
+ grpc_slice_buffer_init(&tcp->last_read_buffer);
tcp->resource_user = grpc_resource_user_create(resource_quota, peer_string);
/* Tell network status tracking code about the new endpoint */
grpc_network_status_register_endpoint(&tcp->base);
diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h
index f01852473b..d17a721606 100644
--- a/src/core/lib/surface/channel_init.h
+++ b/src/core/lib/surface/channel_init.h
@@ -45,6 +45,11 @@ void grpc_channel_init_init(void);
/// registration order (in the case of a tie).
/// Stages are registered against one of the pre-determined channel stack
/// types.
+/// If the channel stack type is GRPC_CLIENT_SUBCHANNEL, the caller should
+/// ensure that subchannels with different filter lists will always have
+/// different channel args. This requires setting a channel arg in case the
+/// registration function relies on some condition other than channel args to
+/// decide whether to add a filter or not.
void grpc_channel_init_register_stage(grpc_channel_stack_type type,
int priority,
grpc_channel_init_stage stage_fn,
diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc
index 67b38e6f0c..7ae6e51a5f 100644
--- a/src/core/lib/surface/server.cc
+++ b/src/core/lib/surface/server.cc
@@ -194,13 +194,10 @@ struct call_data {
};
struct request_matcher {
- request_matcher(grpc_server* server);
- ~request_matcher();
-
grpc_server* server;
- std::atomic<call_data*> pending_head{nullptr};
- call_data* pending_tail = nullptr;
- gpr_locked_mpscq* requests_per_cq = nullptr;
+ call_data* pending_head;
+ call_data* pending_tail;
+ gpr_locked_mpscq* requests_per_cq;
};
struct registered_method {
@@ -349,30 +346,22 @@ static void channel_broadcaster_shutdown(channel_broadcaster* cb,
* request_matcher
*/
-namespace {
-request_matcher::request_matcher(grpc_server* server) : server(server) {
- requests_per_cq = static_cast<gpr_locked_mpscq*>(
- gpr_malloc(sizeof(*requests_per_cq) * server->cq_count));
- for (size_t i = 0; i < server->cq_count; i++) {
- gpr_locked_mpscq_init(&requests_per_cq[i]);
- }
-}
-
-request_matcher::~request_matcher() {
+static void request_matcher_init(request_matcher* rm, grpc_server* server) {
+ memset(rm, 0, sizeof(*rm));
+ rm->server = server;
+ rm->requests_per_cq = static_cast<gpr_locked_mpscq*>(
+ gpr_malloc(sizeof(*rm->requests_per_cq) * server->cq_count));
for (size_t i = 0; i < server->cq_count; i++) {
- GPR_ASSERT(gpr_locked_mpscq_pop(&requests_per_cq[i]) == nullptr);
- gpr_locked_mpscq_destroy(&requests_per_cq[i]);
+ gpr_locked_mpscq_init(&rm->requests_per_cq[i]);
}
- gpr_free(requests_per_cq);
-}
-} // namespace
-
-static void request_matcher_init(request_matcher* rm, grpc_server* server) {
- new (rm) request_matcher(server);
}
static void request_matcher_destroy(request_matcher* rm) {
- rm->~request_matcher();
+ for (size_t i = 0; i < rm->server->cq_count; i++) {
+ GPR_ASSERT(gpr_locked_mpscq_pop(&rm->requests_per_cq[i]) == nullptr);
+ gpr_locked_mpscq_destroy(&rm->requests_per_cq[i]);
+ }
+ gpr_free(rm->requests_per_cq);
}
static void kill_zombie(void* elem, grpc_error* error) {
@@ -381,10 +370,9 @@ static void kill_zombie(void* elem, grpc_error* error) {
}
static void request_matcher_zombify_all_pending_calls(request_matcher* rm) {
- call_data* calld;
- while ((calld = rm->pending_head.load(std::memory_order_relaxed)) !=
- nullptr) {
- rm->pending_head.store(calld->pending_next, std::memory_order_relaxed);
+ while (rm->pending_head) {
+ call_data* calld = rm->pending_head;
+ rm->pending_head = calld->pending_next;
gpr_atm_no_barrier_store(&calld->state, ZOMBIED);
GRPC_CLOSURE_INIT(
&calld->kill_zombie_closure, kill_zombie,
@@ -582,9 +570,8 @@ static void publish_new_rpc(void* arg, grpc_error* error) {
}
gpr_atm_no_barrier_store(&calld->state, PENDING);
- if (rm->pending_head.load(std::memory_order_relaxed) == nullptr) {
- rm->pending_head.store(calld, std::memory_order_relaxed);
- rm->pending_tail = calld;
+ if (rm->pending_head == nullptr) {
+ rm->pending_tail = rm->pending_head = calld;
} else {
rm->pending_tail->pending_next = calld;
rm->pending_tail = calld;
@@ -1448,39 +1435,30 @@ static grpc_call_error queue_call_request(grpc_server* server, size_t cq_idx,
rm = &rc->data.registered.method->matcher;
break;
}
-
- // Fast path: if there is no pending request to be processed, immediately
- // return.
- if (!gpr_locked_mpscq_push(&rm->requests_per_cq[cq_idx], &rc->request_link) ||
- // Note: We are reading the pending_head without holding the server's call
- // mutex. Even if we read a non-null value here due to reordering,
- // we will check it below again after grabbing the lock.
- rm->pending_head.load(std::memory_order_relaxed) == nullptr) {
- return GRPC_CALL_OK;
- }
- // Slow path: This was the first queued request and there are pendings:
- // We need to lock and start matching calls.
- gpr_mu_lock(&server->mu_call);
- while ((calld = rm->pending_head.load(std::memory_order_relaxed)) !=
- nullptr) {
- rc = reinterpret_cast<requested_call*>(
- gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx]));
- if (rc == nullptr) break;
- rm->pending_head.store(calld->pending_next, std::memory_order_relaxed);
- gpr_mu_unlock(&server->mu_call);
- if (!gpr_atm_full_cas(&calld->state, PENDING, ACTIVATED)) {
- // Zombied Call
- GRPC_CLOSURE_INIT(
- &calld->kill_zombie_closure, kill_zombie,
- grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
- grpc_schedule_on_exec_ctx);
- GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
- } else {
- publish_call(server, calld, cq_idx, rc);
- }
+ if (gpr_locked_mpscq_push(&rm->requests_per_cq[cq_idx], &rc->request_link)) {
+ /* this was the first queued request: we need to lock and start
+ matching calls */
gpr_mu_lock(&server->mu_call);
+ while ((calld = rm->pending_head) != nullptr) {
+ rc = reinterpret_cast<requested_call*>(
+ gpr_locked_mpscq_pop(&rm->requests_per_cq[cq_idx]));
+ if (rc == nullptr) break;
+ rm->pending_head = calld->pending_next;
+ gpr_mu_unlock(&server->mu_call);
+ if (!gpr_atm_full_cas(&calld->state, PENDING, ACTIVATED)) {
+ // Zombied Call
+ GRPC_CLOSURE_INIT(
+ &calld->kill_zombie_closure, kill_zombie,
+ grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0),
+ grpc_schedule_on_exec_ctx);
+ GRPC_CLOSURE_SCHED(&calld->kill_zombie_closure, GRPC_ERROR_NONE);
+ } else {
+ publish_call(server, calld, cq_idx, rc);
+ }
+ gpr_mu_lock(&server->mu_call);
+ }
+ gpr_mu_unlock(&server->mu_call);
}
- gpr_mu_unlock(&server->mu_call);
return GRPC_CALL_OK;
}
diff --git a/src/core/lib/surface/version.cc b/src/core/lib/surface/version.cc
index 4829cc80a5..70d7580bec 100644
--- a/src/core/lib/surface/version.cc
+++ b/src/core/lib/surface/version.cc
@@ -25,4 +25,4 @@
const char* grpc_version_string(void) { return "7.0.0-dev"; }
-const char* grpc_g_stands_for(void) { return "goose"; }
+const char* grpc_g_stands_for(void) { return "gold"; }
diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc
index 60af22393e..30482a1b3b 100644
--- a/src/core/lib/transport/metadata.cc
+++ b/src/core/lib/transport/metadata.cc
@@ -187,6 +187,7 @@ static void gc_mdtab(mdtab_shard* shard) {
((destroy_user_data_func)gpr_atm_no_barrier_load(
&md->destroy_user_data))(user_data);
}
+ gpr_mu_destroy(&md->mu_user_data);
gpr_free(md);
*prev_next = next;
num_freed++;
diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h
index 5e569c97e6..1a3295fc80 100644
--- a/src/cpp/common/channel_filter.h
+++ b/src/cpp/common/channel_filter.h
@@ -366,6 +366,11 @@ void ChannelFilterPluginShutdown();
/// The \a include_filter argument specifies a function that will be called
/// to determine at run-time whether or not to add the filter. If the
/// value is nullptr, the filter will be added unconditionally.
+/// If the channel stack type is GRPC_CLIENT_SUBCHANNEL, the caller should
+/// ensure that subchannels with different filter lists will always have
+/// different channel args. This requires setting a channel arg in case the
+/// registration function relies on some condition other than channel args to
+/// decide whether to add a filter or not.
template <typename ChannelDataType, typename CallDataType>
void RegisterChannelFilter(
const char* name, grpc_channel_stack_type stack_type, int priority,
diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc
index 55da89e6c8..358131c7c4 100644
--- a/src/cpp/common/version_cc.cc
+++ b/src/cpp/common/version_cc.cc
@@ -22,5 +22,5 @@
#include <grpcpp/grpcpp.h>
namespace grpc {
-grpc::string Version() { return "1.18.0-dev"; }
+grpc::string Version() { return "1.19.0-dev"; }
} // namespace grpc
diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc
index 1e3c57446f..13741ce7aa 100644
--- a/src/cpp/server/server_cc.cc
+++ b/src/cpp/server/server_cc.cc
@@ -278,7 +278,7 @@ class Server::SyncRequest final : public internal::CompletionQueueTag {
request_payload_ = nullptr;
interceptor_methods_.AddInterceptionHookPoint(
experimental::InterceptionHookPoints::POST_RECV_MESSAGE);
- interceptor_methods_.SetRecvMessage(request_);
+ interceptor_methods_.SetRecvMessage(request_, nullptr);
}
if (interceptor_methods_.RunInterceptors(
@@ -446,7 +446,7 @@ class Server::CallbackRequest final : public internal::CompletionQueueTag {
req_->request_payload_ = nullptr;
req_->interceptor_methods_.AddInterceptionHookPoint(
experimental::InterceptionHookPoints::POST_RECV_MESSAGE);
- req_->interceptor_methods_.SetRecvMessage(req_->request_);
+ req_->interceptor_methods_.SetRecvMessage(req_->request_, nullptr);
}
if (req_->interceptor_methods_.RunInterceptors(
diff --git a/src/csharp/Grpc.Core/Interceptors/ServerServiceDefinitionExtensions.cs b/src/csharp/Grpc.Core/Interceptors/ServerServiceDefinitionExtensions.cs
index 8987544f7f..56ead8a6a1 100644
--- a/src/csharp/Grpc.Core/Interceptors/ServerServiceDefinitionExtensions.cs
+++ b/src/csharp/Grpc.Core/Interceptors/ServerServiceDefinitionExtensions.cs
@@ -76,4 +76,4 @@ namespace Grpc.Core.Interceptors
return serverServiceDefinition;
}
}
-} \ No newline at end of file
+}
diff --git a/src/csharp/Grpc.Core/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include
index 4fffe4f644..52ab2215eb 100755
--- a/src/csharp/Grpc.Core/Version.csproj.include
+++ b/src/csharp/Grpc.Core/Version.csproj.include
@@ -1,7 +1,7 @@
<!-- This file is generated -->
<Project>
<PropertyGroup>
- <GrpcCsharpVersion>1.18.0-dev</GrpcCsharpVersion>
+ <GrpcCsharpVersion>1.19.0-dev</GrpcCsharpVersion>
<GoogleProtobufVersion>3.6.1</GoogleProtobufVersion>
</PropertyGroup>
</Project>
diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs
index 633880189c..8f3be310ee 100644
--- a/src/csharp/Grpc.Core/VersionInfo.cs
+++ b/src/csharp/Grpc.Core/VersionInfo.cs
@@ -33,11 +33,11 @@ namespace Grpc.Core
/// <summary>
/// Current <c>AssemblyFileVersion</c> of gRPC C# assemblies
/// </summary>
- public const string CurrentAssemblyFileVersion = "1.18.0.0";
+ public const string CurrentAssemblyFileVersion = "1.19.0.0";
/// <summary>
/// Current version of gRPC C#
/// </summary>
- public const string CurrentVersion = "1.18.0-dev";
+ public const string CurrentVersion = "1.19.0-dev";
}
}
diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat
index 76d4f14390..fef1a43bb8 100755
--- a/src/csharp/build_packages_dotnetcli.bat
+++ b/src/csharp/build_packages_dotnetcli.bat
@@ -13,7 +13,7 @@
@rem limitations under the License.
@rem Current package versions
-set VERSION=1.18.0-dev
+set VERSION=1.19.0-dev
@rem Adjust the location of nuget.exe
set NUGET=C:\nuget\nuget.exe
diff --git a/src/csharp/build_unitypackage.bat b/src/csharp/build_unitypackage.bat
index 3334d24c11..6b66b941a8 100644
--- a/src/csharp/build_unitypackage.bat
+++ b/src/csharp/build_unitypackage.bat
@@ -13,7 +13,7 @@
@rem limitations under the License.
@rem Current package versions
-set VERSION=1.18.0-dev
+set VERSION=1.19.0-dev
@rem Adjust the location of nuget.exe
set NUGET=C:\nuget\nuget.exe
diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
index 55ca6048bc..659cfebbdc 100644
--- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
+++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec
@@ -42,7 +42,7 @@ Pod::Spec.new do |s|
# exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed
# before them.
s.name = '!ProtoCompiler-gRPCPlugin'
- v = '1.18.0-dev'
+ v = '1.19.0-dev'
s.version = v
s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.'
s.description = <<-DESC
diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
index 803f19dedf..2ddd53a5c6 100644
--- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
+++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h
@@ -19,52 +19,20 @@
#include <AvailabilityMacros.h>
-typedef NS_ENUM(NSInteger, GRPCCompressAlgorithm) {
- GRPCCompressNone,
- GRPCCompressDeflate,
- GRPCCompressGzip,
-};
-
-/**
- * Methods to configure GRPC channel options.
- */
+// Deprecated interface. Please use GRPCCallOptions instead.
@interface GRPCCall (ChannelArg)
-/**
- * Use the provided @c userAgentPrefix at the beginning of the HTTP User Agent string for all calls
- * to the specified @c host.
- */
+ (void)setUserAgentPrefix:(nonnull NSString *)userAgentPrefix forHost:(nonnull NSString *)host;
-
-/** The default response size limit is 4MB. Set this to override that default. */
+ (void)setResponseSizeLimit:(NSUInteger)limit forHost:(nonnull NSString *)host;
-
+ (void)closeOpenConnections DEPRECATED_MSG_ATTRIBUTE(
"The API for this feature is experimental, "
"and might be removed or modified at any "
"time.");
-
+ (void)setDefaultCompressMethod:(GRPCCompressAlgorithm)algorithm forhost:(nonnull NSString *)host;
-
-/** Enable keepalive and configure keepalive parameters. A user should call this function once to
- * enable keepalive for a particular host. gRPC client sends a ping after every \a interval ms to
- * check if the transport is still alive. After waiting for \a timeout ms, if the client does not
- * receive the ping ack, it closes the transport; all pending calls to this host will fail with
- * error GRPC_STATUS_INTERNAL with error information "keepalive watchdog timeout". */
+ (void)setKeepaliveWithInterval:(int)interval
timeout:(int)timeout
forHost:(nonnull NSString *)host;
-
-/** Enable/Disable automatic retry of gRPC calls on the channel. If automatic retry is enabled, the
- * retry is controlled by server's service config. If automatic retry is disabled, failed calls are
- * immediately returned to the application layer. */
+ (void)enableRetry:(BOOL)enabled forHost:(nonnull NSString *)host;
-
-/** Set channel connection timeout and backoff parameters. All parameters are positive integers in
- * milliseconds. Set a parameter to 0 to make gRPC use default value for that parameter.
- *
- * Refer to gRPC's doc at https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md for the
- * details of each parameter. */
+ (void)setMinConnectTimeout:(unsigned int)timeout
initialBackoff:(unsigned int)initialBackoff
maxBackoff:(unsigned int)maxBackoff
diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
index 0e631fb3ad..ae60d6208e 100644
--- a/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
+++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m
@@ -18,6 +18,7 @@
#import "GRPCCall+ChannelArg.h"
+#import "private/GRPCChannelPool.h"
#import "private/GRPCHost.h"
#import <grpc/impl/codegen/compression_types.h>
@@ -31,11 +32,11 @@
+ (void)setResponseSizeLimit:(NSUInteger)limit forHost:(nonnull NSString *)host {
GRPCHost *hostConfig = [GRPCHost hostWithAddress:host];
- hostConfig.responseSizeLimitOverride = @(limit);
+ hostConfig.responseSizeLimitOverride = limit;
}
+ (void)closeOpenConnections {
- [GRPCHost flushChannelCache];
+ [[GRPCChannelPool sharedInstance] disconnectAllChannels];
}
+ (void)setDefaultCompressMethod:(GRPCCompressAlgorithm)algorithm forhost:(nonnull NSString *)host {
diff --git a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h
index d7d15c4ee3..7d6f79b765 100644
--- a/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h
+++ b/src/objective-c/GRPCClient/GRPCCall+ChannelCredentials.h
@@ -18,20 +18,12 @@
#import "GRPCCall.h"
-/** Helpers for setting TLS Trusted Roots, Client Certificates, and Private Key */
+// Deprecated interface. Please use GRPCCallOptions instead.
@interface GRPCCall (ChannelCredentials)
-/**
- * Use the provided @c pemRootCert as the set of trusted root Certificate Authorities for @c host.
- */
+ (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCert
forHost:(nonnull NSString *)host
error:(NSError *_Nullable *_Nullable)errorPtr;
-/**
- * Configures @c host with TLS/SSL Client Credentials and optionally trusted root Certificate
- * Authorities. If @c pemRootCerts is nil, the default CA Certificates bundled with gRPC will be
- * used.
- */
+ (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts
withPrivateKey:(nullable NSString *)pemPrivateKey
withCertChain:(nullable NSString *)pemCertChain
diff --git a/src/objective-c/GRPCClient/GRPCCall+Cronet.h b/src/objective-c/GRPCClient/GRPCCall+Cronet.h
index 2a5f6e9cf0..3059c6f186 100644
--- a/src/objective-c/GRPCClient/GRPCCall+Cronet.h
+++ b/src/objective-c/GRPCClient/GRPCCall+Cronet.h
@@ -20,22 +20,11 @@
#import "GRPCCall.h"
-/**
- * Methods for using cronet transport.
- */
+// Deprecated interface. Please use GRPCCallOptions instead.
@interface GRPCCall (Cronet)
-/**
- * This method should be called before issuing the first RPC. It should be
- * called only once. Create an instance of Cronet engine in your app elsewhere
- * and pass the instance pointer in the stream_engine parameter. Once set,
- * all subsequent RPCs will use Cronet transport. The method is not thread
- * safe.
- */
+ (void)useCronetWithEngine:(stream_engine*)engine;
-
+ (stream_engine*)cronetEngine;
-
+ (BOOL)isUsingCronet;
@end
diff --git a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h
index adb1042aa0..60cdc50bfd 100644
--- a/src/objective-c/GRPCClient/GRPCCall+OAuth2.h
+++ b/src/objective-c/GRPCClient/GRPCCall+OAuth2.h
@@ -18,34 +18,13 @@
#import "GRPCCall.h"
-/**
- * The protocol of an OAuth2 token object from which GRPCCall can acquire a token.
- */
-@protocol GRPCAuthorizationProtocol
-- (void)getTokenWithHandler:(void (^)(NSString *token))hander;
-@end
+#import "GRPCCallOptions.h"
-/** Helpers for setting and reading headers compatible with OAuth2. */
+// Deprecated interface. Please use GRPCCallOptions instead.
@interface GRPCCall (OAuth2)
-/**
- * Setting this property is equivalent to setting "Bearer <passed token>" as the value of the
- * request header with key "authorization" (the authorization header). Setting it to nil removes the
- * authorization header from the request.
- * The value obtained by getting the property is the OAuth2 bearer token if the authorization header
- * of the request has the form "Bearer <token>", or nil otherwise.
- */
-@property(atomic, copy) NSString *oauth2AccessToken;
-
-/** Returns the value (if any) of the "www-authenticate" response header (the challenge header). */
-@property(atomic, readonly) NSString *oauth2ChallengeHeader;
-
-/**
- * The authorization token object to be used when starting the call. If the value is set to nil, no
- * oauth authentication will be used.
- *
- * If tokenProvider exists, it takes precedence over the token set by oauth2AccessToken.
- */
+@property(atomic, copy) NSString* oauth2AccessToken;
+@property(atomic, copy, readonly) NSString* oauth2ChallengeHeader;
@property(atomic, strong) id<GRPCAuthorizationProtocol> tokenProvider;
@end
diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.h b/src/objective-c/GRPCClient/GRPCCall+Tests.h
index 5d35182ae5..edaa5ed582 100644
--- a/src/objective-c/GRPCClient/GRPCCall+Tests.h
+++ b/src/objective-c/GRPCClient/GRPCCall+Tests.h
@@ -18,34 +18,13 @@
#import "GRPCCall.h"
-/**
- * Methods to let tune down the security of gRPC connections for specific hosts. These shouldn't be
- * used in releases, but are sometimes needed for testing.
- */
+// Deprecated interface. Please use GRPCCallOptions instead.
@interface GRPCCall (Tests)
-/**
- * Establish all SSL connections to the provided host using the passed SSL target name and the root
- * certificates found in the file at |certsPath|.
- *
- * Must be called before any gRPC call to that host is made. It's illegal to pass the same host to
- * more than one invocation of the methods of this category.
- */
+ (void)useTestCertsPath:(NSString *)certsPath
testName:(NSString *)testName
forHost:(NSString *)host;
-
-/**
- * Establish all connections to the provided host using cleartext instead of SSL.
- *
- * Must be called before any gRPC call to that host is made. It's illegal to pass the same host to
- * more than one invocation of the methods of this category.
- */
+ (void)useInsecureConnectionsForHost:(NSString *)host;
-
-/**
- * Resets all host configurations to their default values, and flushes all connections from the
- * cache.
- */
+ (void)resetHostSettings;
+
@end
diff --git a/src/objective-c/GRPCClient/GRPCCall+Tests.m b/src/objective-c/GRPCClient/GRPCCall+Tests.m
index 0db3ad6b39..ac3b6a658f 100644
--- a/src/objective-c/GRPCClient/GRPCCall+Tests.m
+++ b/src/objective-c/GRPCClient/GRPCCall+Tests.m
@@ -20,6 +20,8 @@
#import "private/GRPCHost.h"
+#import "GRPCCallOptions.h"
+
@implementation GRPCCall (Tests)
+ (void)useTestCertsPath:(NSString *)certsPath
@@ -42,7 +44,7 @@
+ (void)useInsecureConnectionsForHost:(NSString *)host {
GRPCHost *hostConfig = [GRPCHost hostWithAddress:host];
- hostConfig.secure = NO;
+ hostConfig.transportType = GRPCTransportTypeInsecure;
}
+ (void)resetHostSettings {
diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h
index ddc6ae054d..6669067fbf 100644
--- a/src/objective-c/GRPCClient/GRPCCall.h
+++ b/src/objective-c/GRPCClient/GRPCCall.h
@@ -37,6 +37,10 @@
#include <AvailabilityMacros.h>
+#include "GRPCCallOptions.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
#pragma mark gRPC errors
/** Domain of NSError objects produced by gRPC. */
@@ -140,42 +144,148 @@ typedef NS_ENUM(NSUInteger, GRPCErrorCode) {
};
/**
- * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1
+ * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by
+ * the server.
*/
-typedef NS_ENUM(NSUInteger, GRPCCallSafety) {
- /** Signal that there is no guarantees on how the call affects the server state. */
- GRPCCallSafetyDefault = 0,
- /** Signal that the call is idempotent. gRPC is free to use PUT verb. */
- GRPCCallSafetyIdempotentRequest = 1,
- /** Signal that the call is cacheable and will not affect server state. gRPC is free to use GET
- verb. */
- GRPCCallSafetyCacheableRequest = 2,
-};
+extern NSString *const kGRPCHeadersKey;
+extern NSString *const kGRPCTrailersKey;
+
+/** An object can implement this protocol to receive responses from server from a call. */
+@protocol GRPCResponseHandler<NSObject>
+
+@required
/**
- * Keys used in |NSError|'s |userInfo| dictionary to store the response headers and trailers sent by
- * the server.
+ * All the responses must be issued to a user-provided dispatch queue. This property specifies the
+ * dispatch queue to be used for issuing the notifications.
+ */
+@property(atomic, readonly) dispatch_queue_t dispatchQueue;
+
+@optional
+
+/**
+ * Issued when initial metadata is received from the server.
+ */
+- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata;
+
+/**
+ * Issued when a message is received from the server. The message is the raw data received from the
+ * server, with decompression and without proto deserialization.
*/
-extern id const kGRPCHeadersKey;
-extern id const kGRPCTrailersKey;
+- (void)didReceiveRawMessage:(nullable NSData *)message;
+
+/**
+ * Issued when a call finished. If the call finished successfully, \a error is nil and \a
+ * trainingMetadata consists any trailing metadata received from the server. Otherwise, \a error
+ * is non-nil and contains the corresponding error information, including gRPC error codes and
+ * error descriptions.
+ */
+- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata
+ error:(nullable NSError *)error;
+
+@end
+
+/**
+ * Call related parameters. These parameters are automatically specified by Protobuf. If directly
+ * using the \a GRPCCall2 class, users should specify these parameters manually.
+ */
+@interface GRPCRequestOptions : NSObject<NSCopying>
+
+- (instancetype)init NS_UNAVAILABLE;
+
++ (instancetype) new NS_UNAVAILABLE;
+
+/** Initialize with all properties. */
+- (instancetype)initWithHost:(NSString *)host
+ path:(NSString *)path
+ safety:(GRPCCallSafety)safety NS_DESIGNATED_INITIALIZER;
+
+/** The host serving the RPC service. */
+@property(copy, readonly) NSString *host;
+/** The path to the RPC call. */
+@property(copy, readonly) NSString *path;
+/**
+ * Specify whether the call is idempotent or cachable. gRPC may select different HTTP verbs for the
+ * call based on this information. The default verb used by gRPC is POST.
+ */
+@property(readonly) GRPCCallSafety safety;
+
+@end
#pragma mark GRPCCall
-/** Represents a single gRPC remote call. */
-@interface GRPCCall : GRXWriter
+/**
+ * A \a GRPCCall2 object represents an RPC call.
+ */
+@interface GRPCCall2 : NSObject
+
+- (instancetype)init NS_UNAVAILABLE;
+
++ (instancetype) new NS_UNAVAILABLE;
/**
- * The authority for the RPC. If nil, the default authority will be used. This property must be nil
- * when Cronet transport is enabled.
+ * Designated initializer for a call.
+ * \param requestOptions Protobuf generated parameters for the call.
+ * \param responseHandler The object to which responses should be issued.
+ * \param callOptions Options for the call.
*/
-@property(atomic, copy, readwrite) NSString *serverName;
+- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
+ responseHandler:(id<GRPCResponseHandler>)responseHandler
+ callOptions:(nullable GRPCCallOptions *)callOptions
+ NS_DESIGNATED_INITIALIZER;
+/**
+ * Convenience initializer for a call that uses default call options (see GRPCCallOptions.m for
+ * the default options).
+ */
+- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
+ responseHandler:(id<GRPCResponseHandler>)responseHandler;
/**
- * The timeout for the RPC call in seconds. If set to 0, the call will not timeout. If set to
- * positive, the gRPC call returns with status GRPCErrorCodeDeadlineExceeded if it is not completed
- * within \a timeout seconds. A negative value is not allowed.
+ * Starts the call. This function must only be called once for each instance.
*/
-@property NSTimeInterval timeout;
+- (void)start;
+
+/**
+ * Cancel the request of this call at best effort. It attempts to notify the server that the RPC
+ * should be cancelled, and issue didCloseWithTrailingMetadata:error: callback with error code
+ * CANCELED if no other error code has already been issued.
+ */
+- (void)cancel;
+
+/**
+ * Send a message to the server. Data are sent as raw bytes in gRPC message frames.
+ */
+- (void)writeData:(NSData *)data;
+
+/**
+ * Finish the RPC request and half-close the call. The server may still send messages and/or
+ * trailers to the client. The method must only be called once and after start is called.
+ */
+- (void)finish;
+
+/**
+ * Get a copy of the original call options.
+ */
+@property(readonly, copy) GRPCCallOptions *callOptions;
+
+/** Get a copy of the original request options. */
+@property(readonly, copy) GRPCRequestOptions *requestOptions;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+
+/**
+ * This interface is deprecated. Please use \a GRPCcall2.
+ *
+ * Represents a single gRPC remote call.
+ */
+@interface GRPCCall : GRXWriter
+
+- (instancetype)init NS_UNAVAILABLE;
/**
* The container of the request headers of an RPC conforms to this protocol, which is a subset of
@@ -236,7 +346,7 @@ extern id const kGRPCTrailersKey;
*/
- (instancetype)initWithHost:(NSString *)host
path:(NSString *)path
- requestsWriter:(GRXWriter *)requestsWriter NS_DESIGNATED_INITIALIZER;
+ requestsWriter:(GRXWriter *)requestWriter;
/**
* Finishes the request side of this call, notifies the server that the RPC should be cancelled, and
@@ -245,22 +355,13 @@ extern id const kGRPCTrailersKey;
- (void)cancel;
/**
- * Set the call flag for a specific host path.
- *
- * Host parameter should not contain the scheme (http:// or https://), only the name or IP addr
- * and the port number, for example @"localhost:5050".
+ * The following methods are deprecated.
*/
+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path;
-
-/**
- * Set the dispatch queue to be used for callbacks. Current implementation requires \a queue to be a
- * serial queue.
- *
- * This configuration is only effective before the call starts.
- */
+@property(atomic, copy, readwrite) NSString *serverName;
+@property NSTimeInterval timeout;
- (void)setResponseDispatchQueue:(dispatch_queue_t)queue;
-// TODO(jcanizales): Let specify a deadline. As a category of GRXWriter?
@end
#pragma mark Backwards compatibiity
@@ -283,3 +384,4 @@ DEPRECATED_MSG_ATTRIBUTE("Use NSDictionary or NSMutableDictionary instead.")
@interface NSMutableDictionary (GRPCRequestHeaders)<GRPCRequestHeaders>
@end
#pragma clang diagnostic pop
+#pragma clang diagnostic pop
diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m
index 084fbdeb49..83c6edc6e3 100644
--- a/src/objective-c/GRPCClient/GRPCCall.m
+++ b/src/objective-c/GRPCClient/GRPCCall.m
@@ -20,11 +20,16 @@
#import "GRPCCall+OAuth2.h"
+#import <RxLibrary/GRXBufferedPipe.h>
#import <RxLibrary/GRXConcurrentWriteable.h>
#import <RxLibrary/GRXImmediateSingleWriter.h>
+#import <RxLibrary/GRXWriter+Immediate.h>
#include <grpc/grpc.h>
#include <grpc/support/time.h>
+#import "GRPCCallOptions.h"
+#import "private/GRPCChannelPool.h"
+#import "private/GRPCCompletionQueue.h"
#import "private/GRPCConnectivityMonitor.h"
#import "private/GRPCHost.h"
#import "private/GRPCRequestHeaders.h"
@@ -52,6 +57,313 @@ const char *kCFStreamVarName = "grpc_cfstream";
@property(atomic, strong) NSDictionary *responseHeaders;
@property(atomic, strong) NSDictionary *responseTrailers;
@property(atomic) BOOL isWaitingForToken;
+
+- (instancetype)initWithHost:(NSString *)host
+ path:(NSString *)path
+ callSafety:(GRPCCallSafety)safety
+ requestsWriter:(GRXWriter *)requestsWriter
+ callOptions:(GRPCCallOptions *)callOptions;
+
+@end
+
+@implementation GRPCRequestOptions
+
+- (instancetype)initWithHost:(NSString *)host path:(NSString *)path safety:(GRPCCallSafety)safety {
+ NSAssert(host.length != 0 && path.length != 0, @"host and path cannot be empty");
+ if (host.length == 0 || path.length == 0) {
+ return nil;
+ }
+ if ((self = [super init])) {
+ _host = [host copy];
+ _path = [path copy];
+ _safety = safety;
+ }
+ return self;
+}
+
+- (id)copyWithZone:(NSZone *)zone {
+ GRPCRequestOptions *request =
+ [[GRPCRequestOptions alloc] initWithHost:_host path:_path safety:_safety];
+
+ return request;
+}
+
+@end
+
+@implementation GRPCCall2 {
+ /** Options for the call. */
+ GRPCCallOptions *_callOptions;
+ /** The handler of responses. */
+ id<GRPCResponseHandler> _handler;
+
+ // Thread safety of ivars below are protected by _dispatchQueue.
+
+ /**
+ * Make use of legacy GRPCCall to make calls. Nullified when call is finished.
+ */
+ GRPCCall *_call;
+ /** Flags whether initial metadata has been published to response handler. */
+ BOOL _initialMetadataPublished;
+ /** Streaming call writeable to the underlying call. */
+ GRXBufferedPipe *_pipe;
+ /** Serial dispatch queue for tasks inside the call. */
+ dispatch_queue_t _dispatchQueue;
+ /** Flags whether call has started. */
+ BOOL _started;
+ /** Flags whether call has been canceled. */
+ BOOL _canceled;
+ /** Flags whether call has been finished. */
+ BOOL _finished;
+}
+
+- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
+ responseHandler:(id<GRPCResponseHandler>)responseHandler
+ callOptions:(GRPCCallOptions *)callOptions {
+ NSAssert(requestOptions.host.length != 0 && requestOptions.path.length != 0,
+ @"Neither host nor path can be nil.");
+ NSAssert(requestOptions.safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value.");
+ NSAssert(responseHandler != nil, @"Response handler required.");
+ if (requestOptions.host.length == 0 || requestOptions.path.length == 0) {
+ return nil;
+ }
+ if (requestOptions.safety > GRPCCallSafetyCacheableRequest) {
+ return nil;
+ }
+ if (responseHandler == nil) {
+ return nil;
+ }
+
+ if ((self = [super init])) {
+ _requestOptions = [requestOptions copy];
+ if (callOptions == nil) {
+ _callOptions = [[GRPCCallOptions alloc] init];
+ } else {
+ _callOptions = [callOptions copy];
+ }
+ _handler = responseHandler;
+ _initialMetadataPublished = NO;
+ _pipe = [GRXBufferedPipe pipe];
+ // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+ if (@available(iOS 8.0, macOS 10.10, *)) {
+ _dispatchQueue = dispatch_queue_create(
+ NULL,
+ dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0));
+ } else {
+#else
+ {
+#endif
+ _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
+ }
+ dispatch_set_target_queue(_dispatchQueue, responseHandler.dispatchQueue);
+ _started = NO;
+ _canceled = NO;
+ _finished = NO;
+ }
+
+ return self;
+}
+
+- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
+ responseHandler:(id<GRPCResponseHandler>)responseHandler {
+ return
+ [self initWithRequestOptions:requestOptions responseHandler:responseHandler callOptions:nil];
+}
+
+- (void)start {
+ GRPCCall *copiedCall = nil;
+ @synchronized(self) {
+ NSAssert(!_started, @"Call already started.");
+ NSAssert(!_canceled, @"Call already canceled.");
+ if (_started) {
+ return;
+ }
+ if (_canceled) {
+ return;
+ }
+
+ _started = YES;
+ if (!_callOptions) {
+ _callOptions = [[GRPCCallOptions alloc] init];
+ }
+
+ _call = [[GRPCCall alloc] initWithHost:_requestOptions.host
+ path:_requestOptions.path
+ callSafety:_requestOptions.safety
+ requestsWriter:_pipe
+ callOptions:_callOptions];
+ if (_callOptions.initialMetadata) {
+ [_call.requestHeaders addEntriesFromDictionary:_callOptions.initialMetadata];
+ }
+ copiedCall = _call;
+ }
+
+ void (^valueHandler)(id value) = ^(id value) {
+ @synchronized(self) {
+ if (self->_handler) {
+ if (!self->_initialMetadataPublished) {
+ self->_initialMetadataPublished = YES;
+ [self issueInitialMetadata:self->_call.responseHeaders];
+ }
+ if (value) {
+ [self issueMessage:value];
+ }
+ }
+ }
+ };
+ void (^completionHandler)(NSError *errorOrNil) = ^(NSError *errorOrNil) {
+ @synchronized(self) {
+ if (self->_handler) {
+ if (!self->_initialMetadataPublished) {
+ self->_initialMetadataPublished = YES;
+ [self issueInitialMetadata:self->_call.responseHeaders];
+ }
+ [self issueClosedWithTrailingMetadata:self->_call.responseTrailers error:errorOrNil];
+ }
+ // Clearing _call must happen *after* dispatching close in order to get trailing
+ // metadata from _call.
+ if (self->_call) {
+ // Clean up the request writers. This should have no effect to _call since its
+ // response writeable is already nullified.
+ [self->_pipe writesFinishedWithError:nil];
+ self->_call = nil;
+ self->_pipe = nil;
+ }
+ }
+ };
+ id<GRXWriteable> responseWriteable =
+ [[GRXWriteable alloc] initWithValueHandler:valueHandler completionHandler:completionHandler];
+ [copiedCall startWithWriteable:responseWriteable];
+}
+
+- (void)cancel {
+ GRPCCall *copiedCall = nil;
+ @synchronized(self) {
+ if (_canceled) {
+ return;
+ }
+
+ _canceled = YES;
+
+ copiedCall = _call;
+ _call = nil;
+ _pipe = nil;
+
+ if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ // Copy to local so that block is freed after cancellation completes.
+ id<GRPCResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ self->_handler = nil;
+ }
+
+ [copiedHandler didCloseWithTrailingMetadata:nil
+ error:[NSError errorWithDomain:kGRPCErrorDomain
+ code:GRPCErrorCodeCancelled
+ userInfo:@{
+ NSLocalizedDescriptionKey :
+ @"Canceled by app"
+ }]];
+ });
+ } else {
+ _handler = nil;
+ }
+ }
+ [copiedCall cancel];
+}
+
+- (void)writeData:(NSData *)data {
+ GRXBufferedPipe *copiedPipe = nil;
+ @synchronized(self) {
+ NSAssert(!_canceled, @"Call already canceled.");
+ NSAssert(!_finished, @"Call is half-closed before sending data.");
+ if (_canceled) {
+ return;
+ }
+ if (_finished) {
+ return;
+ }
+
+ if (_pipe) {
+ copiedPipe = _pipe;
+ }
+ }
+ [copiedPipe writeValue:data];
+}
+
+- (void)finish {
+ GRXBufferedPipe *copiedPipe = nil;
+ @synchronized(self) {
+ NSAssert(_started, @"Call not started.");
+ NSAssert(!_canceled, @"Call already canceled.");
+ NSAssert(!_finished, @"Call already half-closed.");
+ if (!_started) {
+ return;
+ }
+ if (_canceled) {
+ return;
+ }
+ if (_finished) {
+ return;
+ }
+
+ if (_pipe) {
+ copiedPipe = _pipe;
+ _pipe = nil;
+ }
+ _finished = YES;
+ }
+ [copiedPipe writesFinishedWithError:nil];
+}
+
+- (void)issueInitialMetadata:(NSDictionary *)initialMetadata {
+ @synchronized(self) {
+ if (initialMetadata != nil &&
+ [_handler respondsToSelector:@selector(didReceiveInitialMetadata:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ id<GRPCResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ }
+ [copiedHandler didReceiveInitialMetadata:initialMetadata];
+ });
+ }
+ }
+}
+
+- (void)issueMessage:(id)message {
+ @synchronized(self) {
+ if (message != nil && [_handler respondsToSelector:@selector(didReceiveRawMessage:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ id<GRPCResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ }
+ [copiedHandler didReceiveRawMessage:message];
+ });
+ }
+ }
+}
+
+- (void)issueClosedWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error {
+ @synchronized(self) {
+ if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ id<GRPCResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ // Clean up _handler so that no more responses are reported to the handler.
+ self->_handler = nil;
+ }
+ [copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error];
+ });
+ } else {
+ _handler = nil;
+ }
+ }
+}
+
@end
// The following methods of a C gRPC call object aren't reentrant, and thus
@@ -75,6 +387,8 @@ const char *kCFStreamVarName = "grpc_cfstream";
NSString *_host;
NSString *_path;
+ GRPCCallSafety _callSafety;
+ GRPCCallOptions *_callOptions;
GRPCWrappedCall *_wrappedCall;
GRPCConnectivityMonitor *_connectivityMonitor;
@@ -113,6 +427,9 @@ const char *kCFStreamVarName = "grpc_cfstream";
// Whether the call is finished. If it is, should not call finishWithError again.
BOOL _finished;
+
+ // The OAuth2 token fetched from a token provider.
+ NSString *_fetchedOauth2AccessToken;
}
@synthesize state = _state;
@@ -127,6 +444,9 @@ const char *kCFStreamVarName = "grpc_cfstream";
}
+ (void)setCallSafety:(GRPCCallSafety)callSafety host:(NSString *)host path:(NSString *)path {
+ if (host.length == 0 || path.length == 0) {
+ return;
+ }
NSString *hostAndPath = [NSString stringWithFormat:@"%@/%@", host, path];
switch (callSafety) {
case GRPCCallSafetyDefault:
@@ -148,24 +468,42 @@ const char *kCFStreamVarName = "grpc_cfstream";
return [callFlags[hostAndPath] intValue];
}
-- (instancetype)init {
- return [self initWithHost:nil path:nil requestsWriter:nil];
-}
-
// Designated initializer
- (instancetype)initWithHost:(NSString *)host
path:(NSString *)path
requestsWriter:(GRXWriter *)requestWriter {
+ return [self initWithHost:host
+ path:path
+ callSafety:GRPCCallSafetyDefault
+ requestsWriter:requestWriter
+ callOptions:nil];
+}
+
+- (instancetype)initWithHost:(NSString *)host
+ path:(NSString *)path
+ callSafety:(GRPCCallSafety)safety
+ requestsWriter:(GRXWriter *)requestWriter
+ callOptions:(GRPCCallOptions *)callOptions {
+ // Purposely using pointer rather than length (host.length == 0) for backwards compatibility.
+ NSAssert(host != nil && path != nil, @"Neither host nor path can be nil.");
+ NSAssert(safety <= GRPCCallSafetyCacheableRequest, @"Invalid call safety value.");
+ NSAssert(requestWriter.state == GRXWriterStateNotStarted,
+ @"The requests writer can't be already started.");
if (!host || !path) {
- [NSException raise:NSInvalidArgumentException format:@"Neither host nor path can be nil."];
+ return nil;
+ }
+ if (safety > GRPCCallSafetyCacheableRequest) {
+ return nil;
}
if (requestWriter.state != GRXWriterStateNotStarted) {
- [NSException raise:NSInvalidArgumentException
- format:@"The requests writer can't be already started."];
+ return nil;
}
+
if ((self = [super init])) {
_host = [host copy];
_path = [path copy];
+ _callSafety = safety;
+ _callOptions = [callOptions copy];
// Serial queue to invoke the non-reentrant methods of the grpc_call object.
_callQueue = dispatch_queue_create("io.grpc.call", NULL);
@@ -209,11 +547,7 @@ const char *kCFStreamVarName = "grpc_cfstream";
[_responseWriteable enqueueSuccessfulCompletion];
}
- // Connectivity monitor is not required for CFStream
- char *enableCFStream = getenv(kCFStreamVarName);
- if (enableCFStream == nil || enableCFStream[0] != '1') {
- [GRPCConnectivityMonitor unregisterObserver:self];
- }
+ [GRPCConnectivityMonitor unregisterObserver:self];
// If the call isn't retained anywhere else, it can be deallocated now.
_retainSelf = nil;
@@ -221,13 +555,14 @@ const char *kCFStreamVarName = "grpc_cfstream";
- (void)cancelCall {
// Can be called from any thread, any number of times.
- [_wrappedCall cancel];
+ @synchronized(self) {
+ [_wrappedCall cancel];
+ }
}
- (void)cancel {
- if (!self.isWaitingForToken) {
+ @synchronized(self) {
[self cancelCall];
- } else {
self.isWaitingForToken = NO;
}
[self
@@ -317,11 +652,37 @@ const char *kCFStreamVarName = "grpc_cfstream";
#pragma mark Send headers
-- (void)sendHeaders:(NSDictionary *)headers {
+- (void)sendHeaders {
+ // TODO (mxyan): Remove after deprecated methods are removed
+ uint32_t callSafetyFlags = 0;
+ switch (_callSafety) {
+ case GRPCCallSafetyDefault:
+ callSafetyFlags = 0;
+ break;
+ case GRPCCallSafetyIdempotentRequest:
+ callSafetyFlags = GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST;
+ break;
+ case GRPCCallSafetyCacheableRequest:
+ callSafetyFlags = GRPC_INITIAL_METADATA_CACHEABLE_REQUEST;
+ break;
+ }
+
+ NSMutableDictionary *headers = [_requestHeaders mutableCopy];
+ NSString *fetchedOauth2AccessToken;
+ @synchronized(self) {
+ fetchedOauth2AccessToken = _fetchedOauth2AccessToken;
+ }
+ if (fetchedOauth2AccessToken != nil) {
+ headers[@"authorization"] = [kBearerPrefix stringByAppendingString:fetchedOauth2AccessToken];
+ } else if (_callOptions.oauth2AccessToken != nil) {
+ headers[@"authorization"] =
+ [kBearerPrefix stringByAppendingString:_callOptions.oauth2AccessToken];
+ }
+
// TODO(jcanizales): Add error handlers for async failures
GRPCOpSendMetadata *op = [[GRPCOpSendMetadata alloc]
initWithMetadata:headers
- flags:[GRPCCall callFlagsForHost:_host path:_path]
+ flags:callSafetyFlags
handler:nil]; // No clean-up needed after SEND_INITIAL_METADATA
if (!_unaryCall) {
[_wrappedCall startBatchWithOperations:@[ op ]];
@@ -458,13 +819,27 @@ const char *kCFStreamVarName = "grpc_cfstream";
_responseWriteable =
[[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue];
- _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host
- serverName:_serverName
- path:_path
- timeout:_timeout];
- NSAssert(_wrappedCall, @"Error allocating RPC objects. Low memory?");
+ GRPCPooledChannel *channel =
+ [[GRPCChannelPool sharedInstance] channelWithHost:_host callOptions:_callOptions];
+ GRPCWrappedCall *wrappedCall = [channel wrappedCallWithPath:_path
+ completionQueue:[GRPCCompletionQueue completionQueue]
+ callOptions:_callOptions];
+
+ if (wrappedCall == nil) {
+ [self maybeFinishWithError:[NSError errorWithDomain:kGRPCErrorDomain
+ code:GRPCErrorCodeUnavailable
+ userInfo:@{
+ NSLocalizedDescriptionKey :
+ @"Failed to create call or channel."
+ }]];
+ return;
+ }
+
+ @synchronized(self) {
+ _wrappedCall = wrappedCall;
+ }
- [self sendHeaders:_requestHeaders];
+ [self sendHeaders];
[self invokeCall];
// Connectivity monitor is not required for CFStream
@@ -486,18 +861,45 @@ const char *kCFStreamVarName = "grpc_cfstream";
// that the life of the instance is determined by this retain cycle.
_retainSelf = self;
- if (self.tokenProvider != nil) {
- self.isWaitingForToken = YES;
- __weak typeof(self) weakSelf = self;
- [self.tokenProvider getTokenWithHandler:^(NSString *token) {
- typeof(self) strongSelf = weakSelf;
- if (strongSelf && strongSelf.isWaitingForToken) {
- if (token) {
- NSString *t = [kBearerPrefix stringByAppendingString:token];
- strongSelf.requestHeaders[kAuthorizationHeader] = t;
+ if (_callOptions == nil) {
+ GRPCMutableCallOptions *callOptions = [[GRPCHost callOptionsForHost:_host] mutableCopy];
+ if (_serverName.length != 0) {
+ callOptions.serverAuthority = _serverName;
+ }
+ if (_timeout > 0) {
+ callOptions.timeout = _timeout;
+ }
+ uint32_t callFlags = [GRPCCall callFlagsForHost:_host path:_path];
+ if (callFlags != 0) {
+ if (callFlags == GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) {
+ _callSafety = GRPCCallSafetyIdempotentRequest;
+ } else if (callFlags == GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) {
+ _callSafety = GRPCCallSafetyCacheableRequest;
+ }
+ }
+
+ id<GRPCAuthorizationProtocol> tokenProvider = self.tokenProvider;
+ if (tokenProvider != nil) {
+ callOptions.authTokenProvider = tokenProvider;
+ }
+ _callOptions = callOptions;
+ }
+
+ NSAssert(_callOptions.authTokenProvider == nil || _callOptions.oauth2AccessToken == nil,
+ @"authTokenProvider and oauth2AccessToken cannot be set at the same time");
+ if (_callOptions.authTokenProvider != nil) {
+ @synchronized(self) {
+ self.isWaitingForToken = YES;
+ }
+ [_callOptions.authTokenProvider getTokenWithHandler:^(NSString *token) {
+ @synchronized(self) {
+ if (self.isWaitingForToken) {
+ if (token) {
+ self->_fetchedOauth2AccessToken = [token copy];
+ }
+ [self startCallWithWriteable:writeable];
+ self.isWaitingForToken = NO;
}
- [strongSelf startCallWithWriteable:writeable];
- strongSelf.isWaitingForToken = NO;
}
}];
} else {
diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.h b/src/objective-c/GRPCClient/GRPCCallOptions.h
new file mode 100644
index 0000000000..b5bf4c9eb6
--- /dev/null
+++ b/src/objective-c/GRPCClient/GRPCCallOptions.h
@@ -0,0 +1,348 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/**
+ * Safety remark of a gRPC method as defined in RFC 2616 Section 9.1
+ */
+typedef NS_ENUM(NSUInteger, GRPCCallSafety) {
+ /** Signal that there is no guarantees on how the call affects the server state. */
+ GRPCCallSafetyDefault = 0,
+ /** Signal that the call is idempotent. gRPC is free to use PUT verb. */
+ GRPCCallSafetyIdempotentRequest = 1,
+ /**
+ * Signal that the call is cacheable and will not affect server state. gRPC is free to use GET
+ * verb.
+ */
+ GRPCCallSafetyCacheableRequest = 2,
+};
+
+// Compression algorithm to be used by a gRPC call
+typedef NS_ENUM(NSUInteger, GRPCCompressionAlgorithm) {
+ GRPCCompressNone = 0,
+ GRPCCompressDeflate,
+ GRPCCompressGzip,
+ GRPCStreamCompressGzip,
+};
+
+// GRPCCompressAlgorithm is deprecated; use GRPCCompressionAlgorithm
+typedef GRPCCompressionAlgorithm GRPCCompressAlgorithm;
+
+/** The transport to be used by a gRPC call */
+typedef NS_ENUM(NSUInteger, GRPCTransportType) {
+ GRPCTransportTypeDefault = 0,
+ /** gRPC internal HTTP/2 stack with BoringSSL */
+ GRPCTransportTypeChttp2BoringSSL = 0,
+ /** Cronet stack */
+ GRPCTransportTypeCronet,
+ /** Insecure channel. FOR TEST ONLY! */
+ GRPCTransportTypeInsecure,
+};
+
+/**
+ * Implement this protocol to provide a token to gRPC when a call is initiated.
+ */
+@protocol GRPCAuthorizationProtocol
+
+/**
+ * This method is called when gRPC is about to start the call. When OAuth token is acquired,
+ * \a handler is expected to be called with \a token being the new token to be used for this call.
+ */
+- (void)getTokenWithHandler:(void (^)(NSString *_Nullable token))handler;
+
+@end
+
+@interface GRPCCallOptions : NSObject<NSCopying, NSMutableCopying>
+
+// Call parameters
+/**
+ * The authority for the RPC. If nil, the default authority will be used.
+ *
+ * Note: This property does not have effect on Cronet transport and will be ignored.
+ * Note: This property cannot be used to validate a self-signed server certificate. It control the
+ * :authority header field of the call and performs an extra check that server's certificate
+ * matches the :authority header.
+ */
+@property(copy, readonly, nullable) NSString *serverAuthority;
+
+/**
+ * The timeout for the RPC call in seconds. If set to 0, the call will not timeout. If set to
+ * positive, the gRPC call returns with status GRPCErrorCodeDeadlineExceeded if it is not completed
+ * within \a timeout seconds. A negative value is not allowed.
+ */
+@property(readonly) NSTimeInterval timeout;
+
+// OAuth2 parameters. Users of gRPC may specify one of the following two parameters.
+
+/**
+ * The OAuth2 access token string. The string is prefixed with "Bearer " then used as value of the
+ * request's "authorization" header field. This parameter should not be used simultaneously with
+ * \a authTokenProvider.
+ */
+@property(copy, readonly, nullable) NSString *oauth2AccessToken;
+
+/**
+ * The interface to get the OAuth2 access token string. gRPC will attempt to acquire token when
+ * initiating the call. This parameter should not be used simultaneously with \a oauth2AccessToken.
+ */
+@property(readonly, nullable) id<GRPCAuthorizationProtocol> authTokenProvider;
+
+/**
+ * Initial metadata key-value pairs that should be included in the request.
+ */
+@property(copy, readonly, nullable) NSDictionary *initialMetadata;
+
+// Channel parameters; take into account of channel signature.
+
+/**
+ * Custom string that is prefixed to a request's user-agent header field before gRPC's internal
+ * user-agent string.
+ */
+@property(copy, readonly, nullable) NSString *userAgentPrefix;
+
+/**
+ * The size limit for the response received from server. If it is exceeded, an error with status
+ * code GRPCErrorCodeResourceExhausted is returned.
+ */
+@property(readonly) NSUInteger responseSizeLimit;
+
+/**
+ * The compression algorithm to be used by the gRPC call. For more details refer to
+ * https://github.com/grpc/grpc/blob/master/doc/compression.md
+ */
+@property(readonly) GRPCCompressionAlgorithm compressionAlgorithm;
+
+/**
+ * Enable/Disable gRPC call's retry feature. The default is enabled. For details of this feature
+ * refer to
+ * https://github.com/grpc/proposal/blob/master/A6-client-retries.md
+ */
+@property(readonly) BOOL retryEnabled;
+
+// HTTP/2 keep-alive feature. The parameter \a keepaliveInterval specifies the interval between two
+// PING frames. The parameter \a keepaliveTimeout specifies the length of the period for which the
+// call should wait for PING ACK. If PING ACK is not received after this period, the call fails.
+// Negative values are not allowed.
+@property(readonly) NSTimeInterval keepaliveInterval;
+@property(readonly) NSTimeInterval keepaliveTimeout;
+
+// Parameters for connection backoff. Negative values are not allowed.
+// For details of gRPC's backoff behavior, refer to
+// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md
+@property(readonly) NSTimeInterval connectMinTimeout;
+@property(readonly) NSTimeInterval connectInitialBackoff;
+@property(readonly) NSTimeInterval connectMaxBackoff;
+
+/**
+ * Specify channel args to be used for this call. For a list of channel args available, see
+ * grpc/grpc_types.h
+ */
+@property(copy, readonly, nullable) NSDictionary *additionalChannelArgs;
+
+// Parameters for SSL authentication.
+
+/**
+ * PEM format root certifications that is trusted. If set to nil, gRPC uses a list of default
+ * root certificates.
+ */
+@property(copy, readonly, nullable) NSString *PEMRootCertificates;
+
+/**
+ * PEM format private key for client authentication, if required by the server.
+ */
+@property(copy, readonly, nullable) NSString *PEMPrivateKey;
+
+/**
+ * PEM format certificate chain for client authentication, if required by the server.
+ */
+@property(copy, readonly, nullable) NSString *PEMCertificateChain;
+
+/**
+ * Select the transport type to be used for this call.
+ */
+@property(readonly) GRPCTransportType transportType;
+
+/**
+ * Override the hostname during the TLS hostname validation process.
+ */
+@property(copy, readonly, nullable) NSString *hostNameOverride;
+
+/**
+ * A string that specify the domain where channel is being cached. Channels with different domains
+ * will not get cached to the same connection.
+ */
+@property(copy, readonly, nullable) NSString *channelPoolDomain;
+
+/**
+ * Channel id allows control of channel caching within a channelPoolDomain. A call with a unique
+ * channelID will create a new channel (connection) instead of reusing an existing one. Multiple
+ * calls in the same channelPoolDomain using identical channelID are allowed to share connection
+ * if other channel options are also the same.
+ */
+@property(readonly) NSUInteger channelID;
+
+/**
+ * Return if the channel options are equal to another object.
+ */
+- (BOOL)hasChannelOptionsEqualTo:(GRPCCallOptions *)callOptions;
+
+/**
+ * Hash for channel options.
+ */
+@property(readonly) NSUInteger channelOptionsHash;
+
+@end
+
+@interface GRPCMutableCallOptions : GRPCCallOptions<NSCopying, NSMutableCopying>
+
+// Call parameters
+/**
+ * The authority for the RPC. If nil, the default authority will be used.
+ *
+ * Note: This property does not have effect on Cronet transport and will be ignored.
+ * Note: This property cannot be used to validate a self-signed server certificate. It control the
+ * :authority header field of the call and performs an extra check that server's certificate
+ * matches the :authority header.
+ */
+@property(copy, readwrite, nullable) NSString *serverAuthority;
+
+/**
+ * The timeout for the RPC call in seconds. If set to 0, the call will not timeout. If set to
+ * positive, the gRPC call returns with status GRPCErrorCodeDeadlineExceeded if it is not completed
+ * within \a timeout seconds. Negative value is invalid; setting the parameter to negative value
+ * will reset the parameter to 0.
+ */
+@property(readwrite) NSTimeInterval timeout;
+
+// OAuth2 parameters. Users of gRPC may specify one of the following two parameters.
+
+/**
+ * The OAuth2 access token string. The string is prefixed with "Bearer " then used as value of the
+ * request's "authorization" header field. This parameter should not be used simultaneously with
+ * \a authTokenProvider.
+ */
+@property(copy, readwrite, nullable) NSString *oauth2AccessToken;
+
+/**
+ * The interface to get the OAuth2 access token string. gRPC will attempt to acquire token when
+ * initiating the call. This parameter should not be used simultaneously with \a oauth2AccessToken.
+ */
+@property(readwrite, nullable) id<GRPCAuthorizationProtocol> authTokenProvider;
+
+/**
+ * Initial metadata key-value pairs that should be included in the request.
+ */
+@property(copy, readwrite, nullable) NSDictionary *initialMetadata;
+
+// Channel parameters; take into account of channel signature.
+
+/**
+ * Custom string that is prefixed to a request's user-agent header field before gRPC's internal
+ * user-agent string.
+ */
+@property(copy, readwrite, nullable) NSString *userAgentPrefix;
+
+/**
+ * The size limit for the response received from server. If it is exceeded, an error with status
+ * code GRPCErrorCodeResourceExhausted is returned.
+ */
+@property(readwrite) NSUInteger responseSizeLimit;
+
+/**
+ * The compression algorithm to be used by the gRPC call. For more details refer to
+ * https://github.com/grpc/grpc/blob/master/doc/compression.md
+ */
+@property(readwrite) GRPCCompressionAlgorithm compressionAlgorithm;
+
+/**
+ * Enable/Disable gRPC call's retry feature. The default is enabled. For details of this feature
+ * refer to
+ * https://github.com/grpc/proposal/blob/master/A6-client-retries.md
+ */
+@property(readwrite) BOOL retryEnabled;
+
+// HTTP/2 keep-alive feature. The parameter \a keepaliveInterval specifies the interval between two
+// PING frames. The parameter \a keepaliveTimeout specifies the length of the period for which the
+// call should wait for PING ACK. If PING ACK is not received after this period, the call fails.
+// Negative values are invalid; setting these parameters to negative value will reset the
+// corresponding parameter to 0.
+@property(readwrite) NSTimeInterval keepaliveInterval;
+@property(readwrite) NSTimeInterval keepaliveTimeout;
+
+// Parameters for connection backoff. Negative value is invalid; setting the parameters to negative
+// value will reset corresponding parameter to 0.
+// For details of gRPC's backoff behavior, refer to
+// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md
+@property(readwrite) NSTimeInterval connectMinTimeout;
+@property(readwrite) NSTimeInterval connectInitialBackoff;
+@property(readwrite) NSTimeInterval connectMaxBackoff;
+
+/**
+ * Specify channel args to be used for this call. For a list of channel args available, see
+ * grpc/grpc_types.h
+ */
+@property(copy, readwrite, nullable) NSDictionary *additionalChannelArgs;
+
+// Parameters for SSL authentication.
+
+/**
+ * PEM format root certifications that is trusted. If set to nil, gRPC uses a list of default
+ * root certificates.
+ */
+@property(copy, readwrite, nullable) NSString *PEMRootCertificates;
+
+/**
+ * PEM format private key for client authentication, if required by the server.
+ */
+@property(copy, readwrite, nullable) NSString *PEMPrivateKey;
+
+/**
+ * PEM format certificate chain for client authentication, if required by the server.
+ */
+@property(copy, readwrite, nullable) NSString *PEMCertificateChain;
+
+/**
+ * Select the transport type to be used for this call.
+ */
+@property(readwrite) GRPCTransportType transportType;
+
+/**
+ * Override the hostname during the TLS hostname validation process.
+ */
+@property(copy, readwrite, nullable) NSString *hostNameOverride;
+
+/**
+ * A string that specify the domain where channel is being cached. Channels with different domains
+ * will not get cached to the same channel. For example, a gRPC example app may use the channel pool
+ * domain 'io.grpc.example' so that its calls do not reuse the channel created by other modules in
+ * the same process.
+ */
+@property(copy, readwrite, nullable) NSString *channelPoolDomain;
+
+/**
+ * Channel id allows a call to force creating a new channel (connection) rather than using a cached
+ * channel. Calls using distinct channelID's will not get cached to the same channel.
+ */
+@property(readwrite) NSUInteger channelID;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/GRPCCallOptions.m b/src/objective-c/GRPCClient/GRPCCallOptions.m
new file mode 100644
index 0000000000..e59a812bd8
--- /dev/null
+++ b/src/objective-c/GRPCClient/GRPCCallOptions.m
@@ -0,0 +1,525 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import "GRPCCallOptions.h"
+#import "internal/GRPCCallOptions+Internal.h"
+
+// The default values for the call options.
+static NSString *const kDefaultServerAuthority = nil;
+static const NSTimeInterval kDefaultTimeout = 0;
+static NSDictionary *const kDefaultInitialMetadata = nil;
+static NSString *const kDefaultUserAgentPrefix = nil;
+static const NSUInteger kDefaultResponseSizeLimit = 0;
+static const GRPCCompressionAlgorithm kDefaultCompressionAlgorithm = GRPCCompressNone;
+static const BOOL kDefaultRetryEnabled = YES;
+static const NSTimeInterval kDefaultKeepaliveInterval = 0;
+static const NSTimeInterval kDefaultKeepaliveTimeout = 0;
+static const NSTimeInterval kDefaultConnectMinTimeout = 0;
+static const NSTimeInterval kDefaultConnectInitialBackoff = 0;
+static const NSTimeInterval kDefaultConnectMaxBackoff = 0;
+static NSDictionary *const kDefaultAdditionalChannelArgs = nil;
+static NSString *const kDefaultPEMRootCertificates = nil;
+static NSString *const kDefaultPEMPrivateKey = nil;
+static NSString *const kDefaultPEMCertificateChain = nil;
+static NSString *const kDefaultOauth2AccessToken = nil;
+static const id<GRPCAuthorizationProtocol> kDefaultAuthTokenProvider = nil;
+static const GRPCTransportType kDefaultTransportType = GRPCTransportTypeChttp2BoringSSL;
+static NSString *const kDefaultHostNameOverride = nil;
+static const id kDefaultLogContext = nil;
+static NSString *const kDefaultChannelPoolDomain = nil;
+static const NSUInteger kDefaultChannelID = 0;
+
+// Check if two objects are equal. Returns YES if both are nil;
+static BOOL areObjectsEqual(id obj1, id obj2) {
+ if (obj1 == obj2) {
+ return YES;
+ }
+ if (obj1 == nil || obj2 == nil) {
+ return NO;
+ }
+ return [obj1 isEqual:obj2];
+}
+
+@implementation GRPCCallOptions {
+ @protected
+ NSString *_serverAuthority;
+ NSTimeInterval _timeout;
+ NSString *_oauth2AccessToken;
+ id<GRPCAuthorizationProtocol> _authTokenProvider;
+ NSDictionary *_initialMetadata;
+ NSString *_userAgentPrefix;
+ NSUInteger _responseSizeLimit;
+ GRPCCompressionAlgorithm _compressionAlgorithm;
+ BOOL _retryEnabled;
+ NSTimeInterval _keepaliveInterval;
+ NSTimeInterval _keepaliveTimeout;
+ NSTimeInterval _connectMinTimeout;
+ NSTimeInterval _connectInitialBackoff;
+ NSTimeInterval _connectMaxBackoff;
+ NSDictionary *_additionalChannelArgs;
+ NSString *_PEMRootCertificates;
+ NSString *_PEMPrivateKey;
+ NSString *_PEMCertificateChain;
+ GRPCTransportType _transportType;
+ NSString *_hostNameOverride;
+ id<NSObject> _logContext;
+ NSString *_channelPoolDomain;
+ NSUInteger _channelID;
+}
+
+@synthesize serverAuthority = _serverAuthority;
+@synthesize timeout = _timeout;
+@synthesize oauth2AccessToken = _oauth2AccessToken;
+@synthesize authTokenProvider = _authTokenProvider;
+@synthesize initialMetadata = _initialMetadata;
+@synthesize userAgentPrefix = _userAgentPrefix;
+@synthesize responseSizeLimit = _responseSizeLimit;
+@synthesize compressionAlgorithm = _compressionAlgorithm;
+@synthesize retryEnabled = _retryEnabled;
+@synthesize keepaliveInterval = _keepaliveInterval;
+@synthesize keepaliveTimeout = _keepaliveTimeout;
+@synthesize connectMinTimeout = _connectMinTimeout;
+@synthesize connectInitialBackoff = _connectInitialBackoff;
+@synthesize connectMaxBackoff = _connectMaxBackoff;
+@synthesize additionalChannelArgs = _additionalChannelArgs;
+@synthesize PEMRootCertificates = _PEMRootCertificates;
+@synthesize PEMPrivateKey = _PEMPrivateKey;
+@synthesize PEMCertificateChain = _PEMCertificateChain;
+@synthesize transportType = _transportType;
+@synthesize hostNameOverride = _hostNameOverride;
+@synthesize logContext = _logContext;
+@synthesize channelPoolDomain = _channelPoolDomain;
+@synthesize channelID = _channelID;
+
+- (instancetype)init {
+ return [self initWithServerAuthority:kDefaultServerAuthority
+ timeout:kDefaultTimeout
+ oauth2AccessToken:kDefaultOauth2AccessToken
+ authTokenProvider:kDefaultAuthTokenProvider
+ initialMetadata:kDefaultInitialMetadata
+ userAgentPrefix:kDefaultUserAgentPrefix
+ responseSizeLimit:kDefaultResponseSizeLimit
+ compressionAlgorithm:kDefaultCompressionAlgorithm
+ retryEnabled:kDefaultRetryEnabled
+ keepaliveInterval:kDefaultKeepaliveInterval
+ keepaliveTimeout:kDefaultKeepaliveTimeout
+ connectMinTimeout:kDefaultConnectMinTimeout
+ connectInitialBackoff:kDefaultConnectInitialBackoff
+ connectMaxBackoff:kDefaultConnectMaxBackoff
+ additionalChannelArgs:kDefaultAdditionalChannelArgs
+ PEMRootCertificates:kDefaultPEMRootCertificates
+ PEMPrivateKey:kDefaultPEMPrivateKey
+ PEMCertificateChain:kDefaultPEMCertificateChain
+ transportType:kDefaultTransportType
+ hostNameOverride:kDefaultHostNameOverride
+ logContext:kDefaultLogContext
+ channelPoolDomain:kDefaultChannelPoolDomain
+ channelID:kDefaultChannelID];
+}
+
+- (instancetype)initWithServerAuthority:(NSString *)serverAuthority
+ timeout:(NSTimeInterval)timeout
+ oauth2AccessToken:(NSString *)oauth2AccessToken
+ authTokenProvider:(id<GRPCAuthorizationProtocol>)authTokenProvider
+ initialMetadata:(NSDictionary *)initialMetadata
+ userAgentPrefix:(NSString *)userAgentPrefix
+ responseSizeLimit:(NSUInteger)responseSizeLimit
+ compressionAlgorithm:(GRPCCompressionAlgorithm)compressionAlgorithm
+ retryEnabled:(BOOL)retryEnabled
+ keepaliveInterval:(NSTimeInterval)keepaliveInterval
+ keepaliveTimeout:(NSTimeInterval)keepaliveTimeout
+ connectMinTimeout:(NSTimeInterval)connectMinTimeout
+ connectInitialBackoff:(NSTimeInterval)connectInitialBackoff
+ connectMaxBackoff:(NSTimeInterval)connectMaxBackoff
+ additionalChannelArgs:(NSDictionary *)additionalChannelArgs
+ PEMRootCertificates:(NSString *)PEMRootCertificates
+ PEMPrivateKey:(NSString *)PEMPrivateKey
+ PEMCertificateChain:(NSString *)PEMCertificateChain
+ transportType:(GRPCTransportType)transportType
+ hostNameOverride:(NSString *)hostNameOverride
+ logContext:(id)logContext
+ channelPoolDomain:(NSString *)channelPoolDomain
+ channelID:(NSUInteger)channelID {
+ if ((self = [super init])) {
+ _serverAuthority = [serverAuthority copy];
+ _timeout = timeout < 0 ? 0 : timeout;
+ _oauth2AccessToken = [oauth2AccessToken copy];
+ _authTokenProvider = authTokenProvider;
+ _initialMetadata =
+ initialMetadata == nil
+ ? nil
+ : [[NSDictionary alloc] initWithDictionary:initialMetadata copyItems:YES];
+ _userAgentPrefix = [userAgentPrefix copy];
+ _responseSizeLimit = responseSizeLimit;
+ _compressionAlgorithm = compressionAlgorithm;
+ _retryEnabled = retryEnabled;
+ _keepaliveInterval = keepaliveInterval < 0 ? 0 : keepaliveInterval;
+ _keepaliveTimeout = keepaliveTimeout < 0 ? 0 : keepaliveTimeout;
+ _connectMinTimeout = connectMinTimeout < 0 ? 0 : connectMinTimeout;
+ _connectInitialBackoff = connectInitialBackoff < 0 ? 0 : connectInitialBackoff;
+ _connectMaxBackoff = connectMaxBackoff < 0 ? 0 : connectMaxBackoff;
+ _additionalChannelArgs =
+ additionalChannelArgs == nil
+ ? nil
+ : [[NSDictionary alloc] initWithDictionary:additionalChannelArgs copyItems:YES];
+ _PEMRootCertificates = [PEMRootCertificates copy];
+ _PEMPrivateKey = [PEMPrivateKey copy];
+ _PEMCertificateChain = [PEMCertificateChain copy];
+ _transportType = transportType;
+ _hostNameOverride = [hostNameOverride copy];
+ _logContext = logContext;
+ _channelPoolDomain = [channelPoolDomain copy];
+ _channelID = channelID;
+ }
+ return self;
+}
+
+- (nonnull id)copyWithZone:(NSZone *)zone {
+ GRPCCallOptions *newOptions =
+ [[GRPCCallOptions allocWithZone:zone] initWithServerAuthority:_serverAuthority
+ timeout:_timeout
+ oauth2AccessToken:_oauth2AccessToken
+ authTokenProvider:_authTokenProvider
+ initialMetadata:_initialMetadata
+ userAgentPrefix:_userAgentPrefix
+ responseSizeLimit:_responseSizeLimit
+ compressionAlgorithm:_compressionAlgorithm
+ retryEnabled:_retryEnabled
+ keepaliveInterval:_keepaliveInterval
+ keepaliveTimeout:_keepaliveTimeout
+ connectMinTimeout:_connectMinTimeout
+ connectInitialBackoff:_connectInitialBackoff
+ connectMaxBackoff:_connectMaxBackoff
+ additionalChannelArgs:_additionalChannelArgs
+ PEMRootCertificates:_PEMRootCertificates
+ PEMPrivateKey:_PEMPrivateKey
+ PEMCertificateChain:_PEMCertificateChain
+ transportType:_transportType
+ hostNameOverride:_hostNameOverride
+ logContext:_logContext
+ channelPoolDomain:_channelPoolDomain
+ channelID:_channelID];
+ return newOptions;
+}
+
+- (nonnull id)mutableCopyWithZone:(NSZone *)zone {
+ GRPCMutableCallOptions *newOptions = [[GRPCMutableCallOptions allocWithZone:zone]
+ initWithServerAuthority:[_serverAuthority copy]
+ timeout:_timeout
+ oauth2AccessToken:[_oauth2AccessToken copy]
+ authTokenProvider:_authTokenProvider
+ initialMetadata:[[NSDictionary alloc] initWithDictionary:_initialMetadata
+ copyItems:YES]
+ userAgentPrefix:[_userAgentPrefix copy]
+ responseSizeLimit:_responseSizeLimit
+ compressionAlgorithm:_compressionAlgorithm
+ retryEnabled:_retryEnabled
+ keepaliveInterval:_keepaliveInterval
+ keepaliveTimeout:_keepaliveTimeout
+ connectMinTimeout:_connectMinTimeout
+ connectInitialBackoff:_connectInitialBackoff
+ connectMaxBackoff:_connectMaxBackoff
+ additionalChannelArgs:[[NSDictionary alloc] initWithDictionary:_additionalChannelArgs
+ copyItems:YES]
+ PEMRootCertificates:[_PEMRootCertificates copy]
+ PEMPrivateKey:[_PEMPrivateKey copy]
+ PEMCertificateChain:[_PEMCertificateChain copy]
+ transportType:_transportType
+ hostNameOverride:[_hostNameOverride copy]
+ logContext:_logContext
+ channelPoolDomain:[_channelPoolDomain copy]
+ channelID:_channelID];
+ return newOptions;
+}
+
+- (BOOL)hasChannelOptionsEqualTo:(GRPCCallOptions *)callOptions {
+ if (callOptions == nil) return NO;
+ if (!areObjectsEqual(callOptions.userAgentPrefix, _userAgentPrefix)) return NO;
+ if (!(callOptions.responseSizeLimit == _responseSizeLimit)) return NO;
+ if (!(callOptions.compressionAlgorithm == _compressionAlgorithm)) return NO;
+ if (!(callOptions.retryEnabled == _retryEnabled)) return NO;
+ if (!(callOptions.keepaliveInterval == _keepaliveInterval)) return NO;
+ if (!(callOptions.keepaliveTimeout == _keepaliveTimeout)) return NO;
+ if (!(callOptions.connectMinTimeout == _connectMinTimeout)) return NO;
+ if (!(callOptions.connectInitialBackoff == _connectInitialBackoff)) return NO;
+ if (!(callOptions.connectMaxBackoff == _connectMaxBackoff)) return NO;
+ if (!areObjectsEqual(callOptions.additionalChannelArgs, _additionalChannelArgs)) return NO;
+ if (!areObjectsEqual(callOptions.PEMRootCertificates, _PEMRootCertificates)) return NO;
+ if (!areObjectsEqual(callOptions.PEMPrivateKey, _PEMPrivateKey)) return NO;
+ if (!areObjectsEqual(callOptions.PEMCertificateChain, _PEMCertificateChain)) return NO;
+ if (!areObjectsEqual(callOptions.hostNameOverride, _hostNameOverride)) return NO;
+ if (!(callOptions.transportType == _transportType)) return NO;
+ if (!areObjectsEqual(callOptions.logContext, _logContext)) return NO;
+ if (!areObjectsEqual(callOptions.channelPoolDomain, _channelPoolDomain)) return NO;
+ if (!(callOptions.channelID == _channelID)) return NO;
+
+ return YES;
+}
+
+- (NSUInteger)channelOptionsHash {
+ NSUInteger result = 0;
+ result ^= _userAgentPrefix.hash;
+ result ^= _responseSizeLimit;
+ result ^= _compressionAlgorithm;
+ result ^= _retryEnabled;
+ result ^= (unsigned int)(_keepaliveInterval * 1000);
+ result ^= (unsigned int)(_keepaliveTimeout * 1000);
+ result ^= (unsigned int)(_connectMinTimeout * 1000);
+ result ^= (unsigned int)(_connectInitialBackoff * 1000);
+ result ^= (unsigned int)(_connectMaxBackoff * 1000);
+ result ^= _additionalChannelArgs.hash;
+ result ^= _PEMRootCertificates.hash;
+ result ^= _PEMPrivateKey.hash;
+ result ^= _PEMCertificateChain.hash;
+ result ^= _hostNameOverride.hash;
+ result ^= _transportType;
+ result ^= _logContext.hash;
+ result ^= _channelPoolDomain.hash;
+ result ^= _channelID;
+
+ return result;
+}
+
+@end
+
+@implementation GRPCMutableCallOptions
+
+@dynamic serverAuthority;
+@dynamic timeout;
+@dynamic oauth2AccessToken;
+@dynamic authTokenProvider;
+@dynamic initialMetadata;
+@dynamic userAgentPrefix;
+@dynamic responseSizeLimit;
+@dynamic compressionAlgorithm;
+@dynamic retryEnabled;
+@dynamic keepaliveInterval;
+@dynamic keepaliveTimeout;
+@dynamic connectMinTimeout;
+@dynamic connectInitialBackoff;
+@dynamic connectMaxBackoff;
+@dynamic additionalChannelArgs;
+@dynamic PEMRootCertificates;
+@dynamic PEMPrivateKey;
+@dynamic PEMCertificateChain;
+@dynamic transportType;
+@dynamic hostNameOverride;
+@dynamic logContext;
+@dynamic channelPoolDomain;
+@dynamic channelID;
+
+- (instancetype)init {
+ return [self initWithServerAuthority:kDefaultServerAuthority
+ timeout:kDefaultTimeout
+ oauth2AccessToken:kDefaultOauth2AccessToken
+ authTokenProvider:kDefaultAuthTokenProvider
+ initialMetadata:kDefaultInitialMetadata
+ userAgentPrefix:kDefaultUserAgentPrefix
+ responseSizeLimit:kDefaultResponseSizeLimit
+ compressionAlgorithm:kDefaultCompressionAlgorithm
+ retryEnabled:kDefaultRetryEnabled
+ keepaliveInterval:kDefaultKeepaliveInterval
+ keepaliveTimeout:kDefaultKeepaliveTimeout
+ connectMinTimeout:kDefaultConnectMinTimeout
+ connectInitialBackoff:kDefaultConnectInitialBackoff
+ connectMaxBackoff:kDefaultConnectMaxBackoff
+ additionalChannelArgs:kDefaultAdditionalChannelArgs
+ PEMRootCertificates:kDefaultPEMRootCertificates
+ PEMPrivateKey:kDefaultPEMPrivateKey
+ PEMCertificateChain:kDefaultPEMCertificateChain
+ transportType:kDefaultTransportType
+ hostNameOverride:kDefaultHostNameOverride
+ logContext:kDefaultLogContext
+ channelPoolDomain:kDefaultChannelPoolDomain
+ channelID:kDefaultChannelID];
+}
+
+- (nonnull id)copyWithZone:(NSZone *)zone {
+ GRPCCallOptions *newOptions =
+ [[GRPCCallOptions allocWithZone:zone] initWithServerAuthority:_serverAuthority
+ timeout:_timeout
+ oauth2AccessToken:_oauth2AccessToken
+ authTokenProvider:_authTokenProvider
+ initialMetadata:_initialMetadata
+ userAgentPrefix:_userAgentPrefix
+ responseSizeLimit:_responseSizeLimit
+ compressionAlgorithm:_compressionAlgorithm
+ retryEnabled:_retryEnabled
+ keepaliveInterval:_keepaliveInterval
+ keepaliveTimeout:_keepaliveTimeout
+ connectMinTimeout:_connectMinTimeout
+ connectInitialBackoff:_connectInitialBackoff
+ connectMaxBackoff:_connectMaxBackoff
+ additionalChannelArgs:_additionalChannelArgs
+ PEMRootCertificates:_PEMRootCertificates
+ PEMPrivateKey:_PEMPrivateKey
+ PEMCertificateChain:_PEMCertificateChain
+ transportType:_transportType
+ hostNameOverride:_hostNameOverride
+ logContext:_logContext
+ channelPoolDomain:_channelPoolDomain
+ channelID:_channelID];
+ return newOptions;
+}
+
+- (nonnull id)mutableCopyWithZone:(NSZone *)zone {
+ GRPCMutableCallOptions *newOptions = [[GRPCMutableCallOptions allocWithZone:zone]
+ initWithServerAuthority:_serverAuthority
+ timeout:_timeout
+ oauth2AccessToken:_oauth2AccessToken
+ authTokenProvider:_authTokenProvider
+ initialMetadata:_initialMetadata
+ userAgentPrefix:_userAgentPrefix
+ responseSizeLimit:_responseSizeLimit
+ compressionAlgorithm:_compressionAlgorithm
+ retryEnabled:_retryEnabled
+ keepaliveInterval:_keepaliveInterval
+ keepaliveTimeout:_keepaliveTimeout
+ connectMinTimeout:_connectMinTimeout
+ connectInitialBackoff:_connectInitialBackoff
+ connectMaxBackoff:_connectMaxBackoff
+ additionalChannelArgs:[_additionalChannelArgs copy]
+ PEMRootCertificates:_PEMRootCertificates
+ PEMPrivateKey:_PEMPrivateKey
+ PEMCertificateChain:_PEMCertificateChain
+ transportType:_transportType
+ hostNameOverride:_hostNameOverride
+ logContext:_logContext
+ channelPoolDomain:_channelPoolDomain
+ channelID:_channelID];
+ return newOptions;
+}
+
+- (void)setServerAuthority:(NSString *)serverAuthority {
+ _serverAuthority = [serverAuthority copy];
+}
+
+- (void)setTimeout:(NSTimeInterval)timeout {
+ if (timeout < 0) {
+ _timeout = 0;
+ } else {
+ _timeout = timeout;
+ }
+}
+
+- (void)setOauth2AccessToken:(NSString *)oauth2AccessToken {
+ _oauth2AccessToken = [oauth2AccessToken copy];
+}
+
+- (void)setAuthTokenProvider:(id<GRPCAuthorizationProtocol>)authTokenProvider {
+ _authTokenProvider = authTokenProvider;
+}
+
+- (void)setInitialMetadata:(NSDictionary *)initialMetadata {
+ _initialMetadata = [[NSDictionary alloc] initWithDictionary:initialMetadata copyItems:YES];
+}
+
+- (void)setUserAgentPrefix:(NSString *)userAgentPrefix {
+ _userAgentPrefix = [userAgentPrefix copy];
+}
+
+- (void)setResponseSizeLimit:(NSUInteger)responseSizeLimit {
+ _responseSizeLimit = responseSizeLimit;
+}
+
+- (void)setCompressionAlgorithm:(GRPCCompressionAlgorithm)compressionAlgorithm {
+ _compressionAlgorithm = compressionAlgorithm;
+}
+
+- (void)setRetryEnabled:(BOOL)retryEnabled {
+ _retryEnabled = retryEnabled;
+}
+
+- (void)setKeepaliveInterval:(NSTimeInterval)keepaliveInterval {
+ if (keepaliveInterval < 0) {
+ _keepaliveInterval = 0;
+ } else {
+ _keepaliveInterval = keepaliveInterval;
+ }
+}
+
+- (void)setKeepaliveTimeout:(NSTimeInterval)keepaliveTimeout {
+ if (keepaliveTimeout < 0) {
+ _keepaliveTimeout = 0;
+ } else {
+ _keepaliveTimeout = keepaliveTimeout;
+ }
+}
+
+- (void)setConnectMinTimeout:(NSTimeInterval)connectMinTimeout {
+ if (connectMinTimeout < 0) {
+ _connectMinTimeout = 0;
+ } else {
+ _connectMinTimeout = connectMinTimeout;
+ }
+}
+
+- (void)setConnectInitialBackoff:(NSTimeInterval)connectInitialBackoff {
+ if (connectInitialBackoff < 0) {
+ _connectInitialBackoff = 0;
+ } else {
+ _connectInitialBackoff = connectInitialBackoff;
+ }
+}
+
+- (void)setConnectMaxBackoff:(NSTimeInterval)connectMaxBackoff {
+ if (connectMaxBackoff < 0) {
+ _connectMaxBackoff = 0;
+ } else {
+ _connectMaxBackoff = connectMaxBackoff;
+ }
+}
+
+- (void)setAdditionalChannelArgs:(NSDictionary *)additionalChannelArgs {
+ _additionalChannelArgs =
+ [[NSDictionary alloc] initWithDictionary:additionalChannelArgs copyItems:YES];
+}
+
+- (void)setPEMRootCertificates:(NSString *)PEMRootCertificates {
+ _PEMRootCertificates = [PEMRootCertificates copy];
+}
+
+- (void)setPEMPrivateKey:(NSString *)PEMPrivateKey {
+ _PEMPrivateKey = [PEMPrivateKey copy];
+}
+
+- (void)setPEMCertificateChain:(NSString *)PEMCertificateChain {
+ _PEMCertificateChain = [PEMCertificateChain copy];
+}
+
+- (void)setTransportType:(GRPCTransportType)transportType {
+ _transportType = transportType;
+}
+
+- (void)setHostNameOverride:(NSString *)hostNameOverride {
+ _hostNameOverride = [hostNameOverride copy];
+}
+
+- (void)setLogContext:(id)logContext {
+ _logContext = logContext;
+}
+
+- (void)setChannelPoolDomain:(NSString *)channelPoolDomain {
+ _channelPoolDomain = [channelPoolDomain copy];
+}
+
+- (void)setChannelID:(NSUInteger)channelID {
+ _channelID = channelID;
+}
+
+@end
diff --git a/src/objective-c/GRPCClient/internal/GRPCCallOptions+Internal.h b/src/objective-c/GRPCClient/internal/GRPCCallOptions+Internal.h
new file mode 100644
index 0000000000..eb691b3acb
--- /dev/null
+++ b/src/objective-c/GRPCClient/internal/GRPCCallOptions+Internal.h
@@ -0,0 +1,39 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "../GRPCCallOptions.h"
+
+@interface GRPCCallOptions ()
+
+/**
+ * Parameter used for internal logging.
+ */
+@property(readonly) id logContext;
+
+@end
+
+@interface GRPCMutableCallOptions ()
+
+/**
+ * Parameter used for internal logging.
+ */
+@property(readwrite) id logContext;
+
+@end
diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.h b/src/objective-c/GRPCClient/private/ChannelArgsUtil.h
new file mode 100644
index 0000000000..f271e846f0
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/ChannelArgsUtil.h
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+#include <grpc/impl/codegen/grpc_types.h>
+
+/** Free resources in the grpc core struct grpc_channel_args */
+void GRPCFreeChannelArgs(grpc_channel_args* channel_args);
+
+/**
+ * Allocates a @c grpc_channel_args and populates it with the options specified
+ * in the
+ * @c dictionary. Keys must be @c NSString, @c NSNumber, or a pointer. If the
+ * value responds to
+ * @c @selector(UTF8String) then it will be mapped to @c GRPC_ARG_STRING. If the
+ * value responds to
+ * @c @selector(intValue), it will be mapped to @c GRPC_ARG_INTEGER. Otherwise,
+ * if the value is not nil, it is mapped as a pointer. The caller of this
+ * function is responsible for calling
+ * @c GRPCFreeChannelArgs to free the @c grpc_channel_args struct.
+ */
+grpc_channel_args* GRPCBuildChannelArgs(NSDictionary* dictionary);
diff --git a/src/objective-c/GRPCClient/private/ChannelArgsUtil.m b/src/objective-c/GRPCClient/private/ChannelArgsUtil.m
new file mode 100644
index 0000000000..c1c65c3384
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/ChannelArgsUtil.m
@@ -0,0 +1,94 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import "ChannelArgsUtil.h"
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
+
+#include <limits.h>
+
+static void *copy_pointer_arg(void *p) {
+ // Add ref count to the object when making copy
+ id obj = (__bridge id)p;
+ return (__bridge_retained void *)obj;
+}
+
+static void destroy_pointer_arg(void *p) {
+ // Decrease ref count to the object when destroying
+ CFRelease((CFTypeRef)p);
+}
+
+static int cmp_pointer_arg(void *p, void *q) { return p == q; }
+
+static const grpc_arg_pointer_vtable objc_arg_vtable = {copy_pointer_arg, destroy_pointer_arg,
+ cmp_pointer_arg};
+
+void GRPCFreeChannelArgs(grpc_channel_args *channel_args) {
+ for (size_t i = 0; i < channel_args->num_args; ++i) {
+ grpc_arg *arg = &channel_args->args[i];
+ gpr_free(arg->key);
+ if (arg->type == GRPC_ARG_STRING) {
+ gpr_free(arg->value.string);
+ }
+ }
+ gpr_free(channel_args->args);
+ gpr_free(channel_args);
+}
+
+grpc_channel_args *GRPCBuildChannelArgs(NSDictionary *dictionary) {
+ if (dictionary.count == 0) {
+ return NULL;
+ }
+
+ NSArray *keys = [dictionary allKeys];
+ NSUInteger argCount = [keys count];
+
+ grpc_channel_args *channelArgs = gpr_malloc(sizeof(grpc_channel_args));
+ channelArgs->args = gpr_malloc(argCount * sizeof(grpc_arg));
+
+ // TODO(kriswuollett) Check that keys adhere to GRPC core library requirements
+
+ NSUInteger j = 0;
+ for (NSUInteger i = 0; i < argCount; ++i) {
+ grpc_arg *arg = &channelArgs->args[j];
+ arg->key = gpr_strdup([keys[i] UTF8String]);
+
+ id value = dictionary[keys[i]];
+ if ([value respondsToSelector:@selector(UTF8String)]) {
+ arg->type = GRPC_ARG_STRING;
+ arg->value.string = gpr_strdup([value UTF8String]);
+ j++;
+ } else if ([value respondsToSelector:@selector(intValue)]) {
+ int64_t value64 = [value longLongValue];
+ if (value64 <= INT_MAX || value64 >= INT_MIN) {
+ arg->type = GRPC_ARG_INTEGER;
+ arg->value.integer = (int)value64;
+ j++;
+ }
+ } else if (value != nil) {
+ arg->type = GRPC_ARG_POINTER;
+ arg->value.pointer.p = (__bridge_retained void *)value;
+ arg->value.pointer.vtable = &objc_arg_vtable;
+ j++;
+ }
+ }
+ channelArgs->num_args = j;
+
+ return channelArgs;
+}
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCChannel.h
index 6499d4398c..bbada0d8cb 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.h
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.h
@@ -20,49 +20,68 @@
#include <grpc/grpc.h>
+@protocol GRPCChannelFactory;
+
@class GRPCCompletionQueue;
+@class GRPCCallOptions;
+@class GRPCChannelConfiguration;
struct grpc_channel_credentials;
+NS_ASSUME_NONNULL_BEGIN
+
/**
- * Each separate instance of this class represents at least one TCP connection to the provided host.
+ * Signature for the channel. If two channel's signatures are the same and connect to the same
+ * remote, they share the same underlying \a GRPCChannel object.
*/
-@interface GRPCChannel : NSObject
+@interface GRPCChannelConfiguration : NSObject<NSCopying>
-@property(nonatomic, readonly, nonnull) struct grpc_channel *unmanagedChannel;
+- (instancetype)init NS_UNAVAILABLE;
-- (nullable instancetype)init NS_UNAVAILABLE;
++ (instancetype) new NS_UNAVAILABLE;
+
+/** The host that this channel is connected to. */
+@property(copy, readonly) NSString *host;
/**
- * Creates a secure channel to the specified @c host using default credentials and channel
- * arguments. If certificates could not be found to create a secure channel, then @c nil is
- * returned.
+ * Options of the corresponding call. Note that only the channel-related options are of interest to
+ * this class.
*/
-+ (nullable GRPCChannel *)secureChannelWithHost:(nonnull NSString *)host;
+@property(readonly) GRPCCallOptions *callOptions;
+
+/** Acquire the factory to generate a new channel with current configurations. */
+@property(readonly) id<GRPCChannelFactory> channelFactory;
+
+/** Acquire the dictionary of channel args with current configurations. */
+@property(copy, readonly) NSDictionary *channelArgs;
+
+- (nullable instancetype)initWithHost:(NSString *)host
+ callOptions:(GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER;
+
+@end
/**
- * Creates a secure channel to the specified @c host using Cronet as a transport mechanism.
+ * Each separate instance of this class represents at least one TCP connection to the provided host.
*/
-#ifdef GRPC_COMPILE_WITH_CRONET
-+ (nullable GRPCChannel *)secureCronetChannelWithHost:(nonnull NSString *)host
- channelArgs:(nonnull NSDictionary *)channelArgs;
-#endif
+@interface GRPCChannel : NSObject
+
+- (nullable instancetype)init NS_UNAVAILABLE;
+
++ (nullable instancetype) new NS_UNAVAILABLE;
+
/**
- * Creates a secure channel to the specified @c host using the specified @c credentials and
- * @c channelArgs. Only in tests should @c GRPC_SSL_TARGET_NAME_OVERRIDE_ARG channel arg be set.
+ * Create a channel with remote \a host and signature \a channelConfigurations.
*/
-+ (nonnull GRPCChannel *)secureChannelWithHost:(nonnull NSString *)host
- credentials:
- (nonnull struct grpc_channel_credentials *)credentials
- channelArgs:(nullable NSDictionary *)channelArgs;
+- (nullable instancetype)initWithChannelConfiguration:
+ (GRPCChannelConfiguration *)channelConfiguration NS_DESIGNATED_INITIALIZER;
/**
- * Creates an insecure channel to the specified @c host using the specified @c channelArgs.
+ * Create a grpc core call object (grpc_call) from this channel. If no call is created, NULL is
+ * returned.
*/
-+ (nonnull GRPCChannel *)insecureChannelWithHost:(nonnull NSString *)host
- channelArgs:(nullable NSDictionary *)channelArgs;
+- (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path
+ completionQueue:(GRPCCompletionQueue *)queue
+ callOptions:(GRPCCallOptions *)callOptions;
-- (nullable grpc_call *)unmanagedCallWithPath:(nonnull NSString *)path
- serverName:(nonnull NSString *)serverName
- timeout:(NSTimeInterval)timeout
- completionQueue:(nonnull GRPCCompletionQueue *)queue;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index b1f6ea270e..1a79fb04a0 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -18,206 +18,243 @@
#import "GRPCChannel.h"
-#include <grpc/grpc_security.h>
-#ifdef GRPC_COMPILE_WITH_CRONET
-#include <grpc/grpc_cronet.h>
-#endif
-#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
-#include <grpc/support/string_util.h>
-#ifdef GRPC_COMPILE_WITH_CRONET
-#import <Cronet/Cronet.h>
-#import <GRPCClient/GRPCCall+Cronet.h>
-#endif
+#import "../internal/GRPCCallOptions+Internal.h"
+#import "ChannelArgsUtil.h"
+#import "GRPCChannelFactory.h"
+#import "GRPCChannelPool.h"
#import "GRPCCompletionQueue.h"
+#import "GRPCCronetChannelFactory.h"
+#import "GRPCInsecureChannelFactory.h"
+#import "GRPCSecureChannelFactory.h"
+#import "version.h"
-static void *copy_pointer_arg(void *p) {
- // Add ref count to the object when making copy
- id obj = (__bridge id)p;
- return (__bridge_retained void *)obj;
-}
+#import <GRPCClient/GRPCCall+Cronet.h>
+#import <GRPCClient/GRPCCallOptions.h>
-static void destroy_pointer_arg(void *p) {
- // Decrease ref count to the object when destroying
- CFRelease((CFTreeRef)p);
-}
+@implementation GRPCChannelConfiguration
-static int cmp_pointer_arg(void *p, void *q) { return p == q; }
+- (instancetype)initWithHost:(NSString *)host callOptions:(GRPCCallOptions *)callOptions {
+ NSAssert(host.length > 0, @"Host must not be empty.");
+ NSAssert(callOptions != nil, @"callOptions must not be empty.");
+ if (host.length == 0 || callOptions == nil) {
+ return nil;
+ }
-static const grpc_arg_pointer_vtable objc_arg_vtable = {copy_pointer_arg, destroy_pointer_arg,
- cmp_pointer_arg};
+ if ((self = [super init])) {
+ _host = [host copy];
+ _callOptions = [callOptions copy];
+ }
+ return self;
+}
-static void FreeChannelArgs(grpc_channel_args *channel_args) {
- for (size_t i = 0; i < channel_args->num_args; ++i) {
- grpc_arg *arg = &channel_args->args[i];
- gpr_free(arg->key);
- if (arg->type == GRPC_ARG_STRING) {
- gpr_free(arg->value.string);
- }
+- (id<GRPCChannelFactory>)channelFactory {
+ GRPCTransportType type = _callOptions.transportType;
+ switch (type) {
+ case GRPCTransportTypeChttp2BoringSSL:
+ // TODO (mxyan): Remove when the API is deprecated
+#ifdef GRPC_COMPILE_WITH_CRONET
+ if (![GRPCCall isUsingCronet]) {
+#else
+ {
+#endif
+ NSError *error;
+ id<GRPCChannelFactory> factory = [GRPCSecureChannelFactory
+ factoryWithPEMRootCertificates:_callOptions.PEMRootCertificates
+ privateKey:_callOptions.PEMPrivateKey
+ certChain:_callOptions.PEMCertificateChain
+ error:&error];
+ NSAssert(factory != nil, @"Failed to create secure channel factory");
+ if (factory == nil) {
+ NSLog(@"Error creating secure channel factory: %@", error);
+ }
+ return factory;
+ }
+ // fallthrough
+ case GRPCTransportTypeCronet:
+ return [GRPCCronetChannelFactory sharedInstance];
+ case GRPCTransportTypeInsecure:
+ return [GRPCInsecureChannelFactory sharedInstance];
}
- gpr_free(channel_args->args);
- gpr_free(channel_args);
}
-/**
- * Allocates a @c grpc_channel_args and populates it with the options specified in the
- * @c dictionary. Keys must be @c NSString. If the value responds to @c @selector(UTF8String) then
- * it will be mapped to @c GRPC_ARG_STRING. If not, it will be mapped to @c GRPC_ARG_INTEGER if the
- * value responds to @c @selector(intValue). Otherwise, an exception will be raised. The caller of
- * this function is responsible for calling @c freeChannelArgs on a non-NULL returned value.
- */
-static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) {
- if (!dictionary) {
- return NULL;
- }
-
- NSArray *keys = [dictionary allKeys];
- NSUInteger argCount = [keys count];
-
- grpc_channel_args *channelArgs = gpr_malloc(sizeof(grpc_channel_args));
- channelArgs->num_args = argCount;
- channelArgs->args = gpr_malloc(argCount * sizeof(grpc_arg));
-
- // TODO(kriswuollett) Check that keys adhere to GRPC core library requirements
-
- for (NSUInteger i = 0; i < argCount; ++i) {
- grpc_arg *arg = &channelArgs->args[i];
- arg->key = gpr_strdup([keys[i] UTF8String]);
-
- id value = dictionary[keys[i]];
- if ([value respondsToSelector:@selector(UTF8String)]) {
- arg->type = GRPC_ARG_STRING;
- arg->value.string = gpr_strdup([value UTF8String]);
- } else if ([value respondsToSelector:@selector(intValue)]) {
- arg->type = GRPC_ARG_INTEGER;
- arg->value.integer = [value intValue];
- } else if (value != nil) {
- arg->type = GRPC_ARG_POINTER;
- arg->value.pointer.p = (__bridge_retained void *)value;
- arg->value.pointer.vtable = &objc_arg_vtable;
- } else {
- [NSException raise:NSInvalidArgumentException
- format:@"Invalid value type: %@", [value class]];
- }
+- (NSDictionary *)channelArgs {
+ NSMutableDictionary *args = [NSMutableDictionary new];
+
+ NSString *userAgent = @"grpc-objc/" GRPC_OBJC_VERSION_STRING;
+ NSString *userAgentPrefix = _callOptions.userAgentPrefix;
+ if (userAgentPrefix.length != 0) {
+ args[@GRPC_ARG_PRIMARY_USER_AGENT_STRING] =
+ [_callOptions.userAgentPrefix stringByAppendingFormat:@" %@", userAgent];
+ } else {
+ args[@GRPC_ARG_PRIMARY_USER_AGENT_STRING] = userAgent;
}
- return channelArgs;
-}
+ NSString *hostNameOverride = _callOptions.hostNameOverride;
+ if (hostNameOverride) {
+ args[@GRPC_SSL_TARGET_NAME_OVERRIDE_ARG] = hostNameOverride;
+ }
-@implementation GRPCChannel {
- // Retain arguments to channel_create because they may not be used on the thread that invoked
- // the channel_create function.
- NSString *_host;
- grpc_channel_args *_channelArgs;
-}
+ if (_callOptions.responseSizeLimit) {
+ args[@GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH] =
+ [NSNumber numberWithUnsignedInteger:_callOptions.responseSizeLimit];
+ }
-#ifdef GRPC_COMPILE_WITH_CRONET
-- (instancetype)initWithHost:(NSString *)host
- cronetEngine:(stream_engine *)cronetEngine
- channelArgs:(NSDictionary *)channelArgs {
- if (!host) {
- [NSException raise:NSInvalidArgumentException format:@"host argument missing"];
+ if (_callOptions.compressionAlgorithm != GRPC_COMPRESS_NONE) {
+ args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] =
+ [NSNumber numberWithInt:_callOptions.compressionAlgorithm];
}
- if (self = [super init]) {
- _channelArgs = BuildChannelArgs(channelArgs);
- _host = [host copy];
- _unmanagedChannel =
- grpc_cronet_secure_channel_create(cronetEngine, _host.UTF8String, _channelArgs, NULL);
+ if (_callOptions.keepaliveInterval != 0) {
+ args[@GRPC_ARG_KEEPALIVE_TIME_MS] =
+ [NSNumber numberWithUnsignedInteger:(NSUInteger)(_callOptions.keepaliveInterval * 1000)];
+ args[@GRPC_ARG_KEEPALIVE_TIMEOUT_MS] =
+ [NSNumber numberWithUnsignedInteger:(NSUInteger)(_callOptions.keepaliveTimeout * 1000)];
}
- return self;
-}
-#endif
+ if (!_callOptions.retryEnabled) {
+ args[@GRPC_ARG_ENABLE_RETRIES] = [NSNumber numberWithInt:_callOptions.retryEnabled ? 1 : 0];
+ }
-- (instancetype)initWithHost:(NSString *)host
- secure:(BOOL)secure
- credentials:(struct grpc_channel_credentials *)credentials
- channelArgs:(NSDictionary *)channelArgs {
- if (!host) {
- [NSException raise:NSInvalidArgumentException format:@"host argument missing"];
+ if (_callOptions.connectMinTimeout > 0) {
+ args[@GRPC_ARG_MIN_RECONNECT_BACKOFF_MS] =
+ [NSNumber numberWithUnsignedInteger:(NSUInteger)(_callOptions.connectMinTimeout * 1000)];
+ }
+ if (_callOptions.connectInitialBackoff > 0) {
+ args[@GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS] = [NSNumber
+ numberWithUnsignedInteger:(NSUInteger)(_callOptions.connectInitialBackoff * 1000)];
+ }
+ if (_callOptions.connectMaxBackoff > 0) {
+ args[@GRPC_ARG_MAX_RECONNECT_BACKOFF_MS] =
+ [NSNumber numberWithUnsignedInteger:(NSUInteger)(_callOptions.connectMaxBackoff * 1000)];
}
- if (secure && !credentials) {
- return nil;
+ if (_callOptions.logContext != nil) {
+ args[@GRPC_ARG_MOBILE_LOG_CONTEXT] = _callOptions.logContext;
}
- if (self = [super init]) {
- _channelArgs = BuildChannelArgs(channelArgs);
- _host = [host copy];
- if (secure) {
- _unmanagedChannel =
- grpc_secure_channel_create(credentials, _host.UTF8String, _channelArgs, NULL);
- } else {
- _unmanagedChannel = grpc_insecure_channel_create(_host.UTF8String, _channelArgs, NULL);
- }
+ if (_callOptions.channelPoolDomain.length != 0) {
+ args[@GRPC_ARG_CHANNEL_POOL_DOMAIN] = _callOptions.channelPoolDomain;
}
- return self;
+ [args addEntriesFromDictionary:_callOptions.additionalChannelArgs];
+
+ return args;
}
-- (void)dealloc {
- // TODO(jcanizales): Be sure to add a test with a server that closes the connection prematurely,
- // as in the past that made this call to crash.
- grpc_channel_destroy(_unmanagedChannel);
- FreeChannelArgs(_channelArgs);
+- (id)copyWithZone:(NSZone *)zone {
+ GRPCChannelConfiguration *newConfig =
+ [[GRPCChannelConfiguration alloc] initWithHost:_host callOptions:_callOptions];
+
+ return newConfig;
}
-#ifdef GRPC_COMPILE_WITH_CRONET
-+ (GRPCChannel *)secureCronetChannelWithHost:(NSString *)host
- channelArgs:(NSDictionary *)channelArgs {
- stream_engine *engine = [GRPCCall cronetEngine];
- if (!engine) {
- [NSException raise:NSInvalidArgumentException format:@"cronet_engine is NULL. Set it first."];
- return nil;
+- (BOOL)isEqual:(id)object {
+ if (![object isKindOfClass:[GRPCChannelConfiguration class]]) {
+ return NO;
}
- return [[GRPCChannel alloc] initWithHost:host cronetEngine:engine channelArgs:channelArgs];
-}
-#endif
+ GRPCChannelConfiguration *obj = (GRPCChannelConfiguration *)object;
+ if (!(obj.host == _host || (_host != nil && [obj.host isEqualToString:_host]))) return NO;
+ if (!(obj.callOptions == _callOptions || [obj.callOptions hasChannelOptionsEqualTo:_callOptions]))
+ return NO;
-+ (GRPCChannel *)secureChannelWithHost:(NSString *)host {
- return [[GRPCChannel alloc] initWithHost:host secure:YES credentials:NULL channelArgs:NULL];
+ return YES;
}
-+ (GRPCChannel *)secureChannelWithHost:(NSString *)host
- credentials:(struct grpc_channel_credentials *)credentials
- channelArgs:(NSDictionary *)channelArgs {
- return [[GRPCChannel alloc] initWithHost:host
- secure:YES
- credentials:credentials
- channelArgs:channelArgs];
+- (NSUInteger)hash {
+ NSUInteger result = 31;
+ result ^= _host.hash;
+ result ^= _callOptions.channelOptionsHash;
+
+ return result;
}
-+ (GRPCChannel *)insecureChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)channelArgs {
- return [[GRPCChannel alloc] initWithHost:host secure:NO credentials:NULL channelArgs:channelArgs];
+@end
+
+@implementation GRPCChannel {
+ GRPCChannelConfiguration *_configuration;
+
+ grpc_channel *_unmanagedChannel;
}
-- (grpc_call *)unmanagedCallWithPath:(NSString *)path
- serverName:(NSString *)serverName
- timeout:(NSTimeInterval)timeout
- completionQueue:(GRPCCompletionQueue *)queue {
- GPR_ASSERT(timeout >= 0);
- if (timeout < 0) {
- timeout = 0;
+- (instancetype)initWithChannelConfiguration:(GRPCChannelConfiguration *)channelConfiguration {
+ NSAssert(channelConfiguration != nil, @"channelConfiguration must not be empty.");
+ if (channelConfiguration == nil) {
+ return nil;
}
- grpc_slice host_slice = grpc_empty_slice();
- if (serverName) {
- host_slice = grpc_slice_from_copied_string(serverName.UTF8String);
+
+ if ((self = [super init])) {
+ _configuration = [channelConfiguration copy];
+
+ // Create gRPC core channel object.
+ NSString *host = channelConfiguration.host;
+ NSAssert(host.length != 0, @"host cannot be nil");
+ NSDictionary *channelArgs;
+ if (channelConfiguration.callOptions.additionalChannelArgs.count != 0) {
+ NSMutableDictionary *args = [channelConfiguration.channelArgs mutableCopy];
+ [args addEntriesFromDictionary:channelConfiguration.callOptions.additionalChannelArgs];
+ channelArgs = args;
+ } else {
+ channelArgs = channelConfiguration.channelArgs;
+ }
+ id<GRPCChannelFactory> factory = channelConfiguration.channelFactory;
+ _unmanagedChannel = [factory createChannelWithHost:host channelArgs:channelArgs];
+ NSAssert(_unmanagedChannel != NULL, @"Failed to create channel");
+ if (_unmanagedChannel == NULL) {
+ NSLog(@"Unable to create channel.");
+ return nil;
+ }
}
+ return self;
+}
+
+- (grpc_call *)unmanagedCallWithPath:(NSString *)path
+ completionQueue:(GRPCCompletionQueue *)queue
+ callOptions:(GRPCCallOptions *)callOptions {
+ NSAssert(path.length > 0, @"path must not be empty.");
+ NSAssert(queue != nil, @"completionQueue must not be empty.");
+ NSAssert(callOptions != nil, @"callOptions must not be empty.");
+ if (path.length == 0) return NULL;
+ if (queue == nil) return NULL;
+ if (callOptions == nil) return NULL;
+
+ grpc_call *call = NULL;
+ // No need to lock here since _unmanagedChannel is only changed in _dealloc
+ NSAssert(_unmanagedChannel != NULL, @"Channel should have valid unmanaged channel.");
+ if (_unmanagedChannel == NULL) return NULL;
+
+ NSString *serverAuthority =
+ callOptions.transportType == GRPCTransportTypeCronet ? nil : callOptions.serverAuthority;
+ NSTimeInterval timeout = callOptions.timeout;
+ NSAssert(timeout >= 0, @"Invalid timeout");
+ if (timeout < 0) return NULL;
+ grpc_slice host_slice = serverAuthority
+ ? grpc_slice_from_copied_string(serverAuthority.UTF8String)
+ : grpc_empty_slice();
grpc_slice path_slice = grpc_slice_from_copied_string(path.UTF8String);
gpr_timespec deadline_ms =
timeout == 0 ? gpr_inf_future(GPR_CLOCK_REALTIME)
: gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_millis((int64_t)(timeout * 1000), GPR_TIMESPAN));
- grpc_call *call = grpc_channel_create_call(_unmanagedChannel, NULL, GRPC_PROPAGATE_DEFAULTS,
- queue.unmanagedQueue, path_slice,
- serverName ? &host_slice : NULL, deadline_ms, NULL);
- if (serverName) {
+ call = grpc_channel_create_call(_unmanagedChannel, NULL, GRPC_PROPAGATE_DEFAULTS,
+ queue.unmanagedQueue, path_slice,
+ serverAuthority ? &host_slice : NULL, deadline_ms, NULL);
+ if (serverAuthority) {
grpc_slice_unref(host_slice);
}
grpc_slice_unref(path_slice);
+ NSAssert(call != nil, @"Unable to create call.");
+ if (call == NULL) {
+ NSLog(@"Unable to create call.");
+ }
return call;
}
+- (void)dealloc {
+ if (_unmanagedChannel) {
+ grpc_channel_destroy(_unmanagedChannel);
+ }
+}
+
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCChannelFactory.h
new file mode 100644
index 0000000000..a934e966e9
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCChannelFactory.h
@@ -0,0 +1,34 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+#include <grpc/impl/codegen/grpc_types.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** A factory interface which generates new channel. */
+@protocol GRPCChannelFactory
+
+/** Create a channel with specific channel args to a specific host. */
+- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
+ channelArgs:(nullable NSDictionary *)args;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h b/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h
new file mode 100644
index 0000000000..e2c3aee3d9
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool+Test.h
@@ -0,0 +1,51 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import "GRPCChannelPool.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+/** Test-only interface for \a GRPCPooledChannel. */
+@interface GRPCPooledChannel (Test)
+
+/**
+ * Initialize a pooled channel with non-default destroy delay for testing purpose.
+ */
+- (nullable instancetype)initWithChannelConfiguration:
+ (GRPCChannelConfiguration *)channelConfiguration
+ destroyDelay:(NSTimeInterval)destroyDelay;
+
+/**
+ * Return the pointer to the raw channel wrapped.
+ */
+@property(atomic, readonly, nullable) GRPCChannel *wrappedChannel;
+
+@end
+
+/** Test-only interface for \a GRPCChannelPool. */
+@interface GRPCChannelPool (Test)
+
+/**
+ * Get an instance of pool isolated from the global shared pool with channels' destroy delay being
+ * \a destroyDelay.
+ */
+- (nullable instancetype)initTestPool;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.h b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
new file mode 100644
index 0000000000..e00ee69e63
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.h
@@ -0,0 +1,101 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <GRPCClient/GRPCCallOptions.h>
+
+#import "GRPCChannelFactory.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@protocol GRPCChannel;
+@class GRPCChannel;
+@class GRPCChannelPool;
+@class GRPCCompletionQueue;
+@class GRPCChannelConfiguration;
+@class GRPCWrappedCall;
+
+/**
+ * A proxied channel object that can be retained and used to create GRPCWrappedCall object
+ * regardless of the current connection status. If a connection is not established when a
+ * GRPCWrappedCall object is requested, it issues a connection/reconnection. This behavior is to
+ * follow that of gRPC core's channel object.
+ */
+@interface GRPCPooledChannel : NSObject
+
+- (nullable instancetype)init NS_UNAVAILABLE;
+
++ (nullable instancetype) new NS_UNAVAILABLE;
+
+/**
+ * Initialize with an actual channel object \a channel and a reference to the channel pool.
+ */
+- (nullable instancetype)initWithChannelConfiguration:
+ (GRPCChannelConfiguration *)channelConfiguration;
+
+/**
+ * Create a GRPCWrappedCall object (grpc_call) from this channel. If channel is disconnected, get a
+ * new channel object from the channel pool.
+ */
+- (nullable GRPCWrappedCall *)wrappedCallWithPath:(NSString *)path
+ completionQueue:(GRPCCompletionQueue *)queue
+ callOptions:(GRPCCallOptions *)callOptions;
+
+/**
+ * Notify the pooled channel that a wrapped call object is no longer referenced and will be
+ * dealloc'ed.
+ */
+- (void)notifyWrappedCallDealloc:(GRPCWrappedCall *)wrappedCall;
+
+/**
+ * Force the channel to disconnect immediately. GRPCWrappedCall objects previously created with
+ * \a wrappedCallWithPath are failed if not already finished. Subsequent calls to
+ * unmanagedCallWithPath: will attempt to reconnect to the remote channel.
+ */
+- (void)disconnect;
+
+@end
+
+/**
+ * Manage the pool of connected channels. When a channel is no longer referenced by any call,
+ * destroy the channel after a certain period of time elapsed.
+ */
+@interface GRPCChannelPool : NSObject
+
+- (nullable instancetype)init NS_UNAVAILABLE;
+
++ (nullable instancetype) new NS_UNAVAILABLE;
+
+/**
+ * Get the global channel pool.
+ */
++ (nullable instancetype)sharedInstance;
+
+/**
+ * Return a channel with a particular configuration. The channel may be a cached channel.
+ */
+- (nullable GRPCPooledChannel *)channelWithHost:(NSString *)host
+ callOptions:(GRPCCallOptions *)callOptions;
+
+/**
+ * Disconnect all channels in this pool.
+ */
+- (void)disconnectAllChannels;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCChannelPool.m b/src/objective-c/GRPCClient/private/GRPCChannelPool.m
new file mode 100644
index 0000000000..a323f0490c
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCChannelPool.m
@@ -0,0 +1,276 @@
+/*
+ *
+ * Copyright 2015 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.
+ *
+ */
+
+#import <Foundation/Foundation.h>
+
+#import "../internal/GRPCCallOptions+Internal.h"
+#import "GRPCChannel.h"
+#import "GRPCChannelFactory.h"
+#import "GRPCChannelPool+Test.h"
+#import "GRPCChannelPool.h"
+#import "GRPCCompletionQueue.h"
+#import "GRPCConnectivityMonitor.h"
+#import "GRPCCronetChannelFactory.h"
+#import "GRPCInsecureChannelFactory.h"
+#import "GRPCSecureChannelFactory.h"
+#import "GRPCWrappedCall.h"
+#import "version.h"
+
+#import <GRPCClient/GRPCCall+Cronet.h>
+#include <grpc/support/log.h>
+
+extern const char *kCFStreamVarName;
+
+static GRPCChannelPool *gChannelPool;
+static dispatch_once_t gInitChannelPool;
+
+/** When all calls of a channel are destroyed, destroy the channel after this much seconds. */
+static const NSTimeInterval kDefaultChannelDestroyDelay = 30;
+
+@implementation GRPCPooledChannel {
+ GRPCChannelConfiguration *_channelConfiguration;
+ NSTimeInterval _destroyDelay;
+
+ NSHashTable<GRPCWrappedCall *> *_wrappedCalls;
+ GRPCChannel *_wrappedChannel;
+ NSDate *_lastTimedDestroy;
+ dispatch_queue_t _timerQueue;
+}
+
+- (instancetype)initWithChannelConfiguration:(GRPCChannelConfiguration *)channelConfiguration {
+ return [self initWithChannelConfiguration:channelConfiguration
+ destroyDelay:kDefaultChannelDestroyDelay];
+}
+
+- (nullable instancetype)initWithChannelConfiguration:
+ (GRPCChannelConfiguration *)channelConfiguration
+ destroyDelay:(NSTimeInterval)destroyDelay {
+ NSAssert(channelConfiguration != nil, @"channelConfiguration cannot be empty.");
+ if (channelConfiguration == nil) {
+ return nil;
+ }
+
+ if ((self = [super init])) {
+ _channelConfiguration = [channelConfiguration copy];
+ _destroyDelay = destroyDelay;
+ _wrappedCalls = [NSHashTable weakObjectsHashTable];
+ _wrappedChannel = nil;
+ _lastTimedDestroy = nil;
+#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
+ if (@available(iOS 8.0, macOS 10.10, *)) {
+ _timerQueue = dispatch_queue_create(NULL, dispatch_queue_attr_make_with_qos_class(
+ DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0));
+ } else {
+#else
+ {
+#endif
+ _timerQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
+ }
+ }
+
+ return self;
+}
+
+- (void)dealloc {
+ // Disconnect GRPCWrappedCall objects created but not yet removed
+ if (_wrappedCalls.allObjects.count != 0) {
+ for (GRPCWrappedCall *wrappedCall in _wrappedCalls.allObjects) {
+ [wrappedCall channelDisconnected];
+ };
+ }
+}
+
+- (GRPCWrappedCall *)wrappedCallWithPath:(NSString *)path
+ completionQueue:(GRPCCompletionQueue *)queue
+ callOptions:(GRPCCallOptions *)callOptions {
+ NSAssert(path.length > 0, @"path must not be empty.");
+ NSAssert(queue != nil, @"completionQueue must not be empty.");
+ NSAssert(callOptions, @"callOptions must not be empty.");
+ if (path.length == 0 || queue == nil || callOptions == nil) {
+ return nil;
+ }
+
+ GRPCWrappedCall *call = nil;
+
+ @synchronized(self) {
+ if (_wrappedChannel == nil) {
+ _wrappedChannel = [[GRPCChannel alloc] initWithChannelConfiguration:_channelConfiguration];
+ if (_wrappedChannel == nil) {
+ NSAssert(_wrappedChannel != nil, @"Unable to get a raw channel for proxy.");
+ return nil;
+ }
+ }
+ _lastTimedDestroy = nil;
+
+ grpc_call *unmanagedCall =
+ [_wrappedChannel unmanagedCallWithPath:path
+ completionQueue:[GRPCCompletionQueue completionQueue]
+ callOptions:callOptions];
+ if (unmanagedCall == NULL) {
+ NSAssert(unmanagedCall != NULL, @"Unable to create grpc_call object");
+ return nil;
+ }
+
+ call = [[GRPCWrappedCall alloc] initWithUnmanagedCall:unmanagedCall pooledChannel:self];
+ if (call == nil) {
+ NSAssert(call != nil, @"Unable to create GRPCWrappedCall object");
+ grpc_call_unref(unmanagedCall);
+ return nil;
+ }
+
+ [_wrappedCalls addObject:call];
+ }
+ return call;
+}
+
+- (void)notifyWrappedCallDealloc:(GRPCWrappedCall *)wrappedCall {
+ NSAssert(wrappedCall != nil, @"wrappedCall cannot be empty.");
+ if (wrappedCall == nil) {
+ return;
+ }
+ @synchronized(self) {
+ // Detect if all objects weakly referenced in _wrappedCalls are (implicitly) removed.
+ // _wrappedCalls.count does not work here since the hash table may include deallocated weak
+ // references. _wrappedCalls.allObjects forces removal of those objects.
+ if (_wrappedCalls.allObjects.count == 0) {
+ // No more call has reference to this channel. We may start the timer for destroying the
+ // channel now.
+ NSDate *now = [NSDate date];
+ NSAssert(now != nil, @"Unable to create NSDate object 'now'.");
+ _lastTimedDestroy = now;
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)_destroyDelay * NSEC_PER_SEC),
+ _timerQueue, ^{
+ @synchronized(self) {
+ // Check _lastTimedDestroy against now in case more calls are created (and
+ // maybe destroyed) after this dispatch_async. In that case the current
+ // dispatch_after block should be discarded; the channel should be
+ // destroyed in a later dispatch_after block.
+ if (now != nil && self->_lastTimedDestroy == now) {
+ self->_wrappedChannel = nil;
+ self->_lastTimedDestroy = nil;
+ }
+ }
+ });
+ }
+ }
+}
+
+- (void)disconnect {
+ NSArray<GRPCWrappedCall *> *copiedWrappedCalls = nil;
+ @synchronized(self) {
+ if (_wrappedChannel != nil) {
+ _wrappedChannel = nil;
+ copiedWrappedCalls = _wrappedCalls.allObjects;
+ [_wrappedCalls removeAllObjects];
+ }
+ }
+ for (GRPCWrappedCall *wrappedCall in copiedWrappedCalls) {
+ [wrappedCall channelDisconnected];
+ }
+}
+
+- (GRPCChannel *)wrappedChannel {
+ GRPCChannel *channel = nil;
+ @synchronized(self) {
+ channel = _wrappedChannel;
+ }
+ return channel;
+}
+
+@end
+
+@interface GRPCChannelPool ()
+
+- (instancetype)initPrivate NS_DESIGNATED_INITIALIZER;
+
+@end
+
+@implementation GRPCChannelPool {
+ NSMutableDictionary<GRPCChannelConfiguration *, GRPCPooledChannel *> *_channelPool;
+}
+
++ (instancetype)sharedInstance {
+ dispatch_once(&gInitChannelPool, ^{
+ gChannelPool = [[GRPCChannelPool alloc] initPrivate];
+ NSAssert(gChannelPool != nil, @"Cannot initialize global channel pool.");
+ });
+ return gChannelPool;
+}
+
+- (instancetype)initPrivate {
+ if ((self = [super init])) {
+ _channelPool = [NSMutableDictionary dictionary];
+
+ // Connectivity monitor is not required for CFStream
+ char *enableCFStream = getenv(kCFStreamVarName);
+ if (enableCFStream == nil || enableCFStream[0] != '1') {
+ [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChange:)];
+ }
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [GRPCConnectivityMonitor unregisterObserver:self];
+}
+
+- (GRPCPooledChannel *)channelWithHost:(NSString *)host callOptions:(GRPCCallOptions *)callOptions {
+ NSAssert(host.length > 0, @"Host must not be empty.");
+ NSAssert(callOptions != nil, @"callOptions must not be empty.");
+ if (host.length == 0 || callOptions == nil) {
+ return nil;
+ }
+
+ GRPCPooledChannel *pooledChannel = nil;
+ GRPCChannelConfiguration *configuration =
+ [[GRPCChannelConfiguration alloc] initWithHost:host callOptions:callOptions];
+ @synchronized(self) {
+ pooledChannel = _channelPool[configuration];
+ if (pooledChannel == nil) {
+ pooledChannel = [[GRPCPooledChannel alloc] initWithChannelConfiguration:configuration];
+ _channelPool[configuration] = pooledChannel;
+ }
+ }
+ return pooledChannel;
+}
+
+- (void)disconnectAllChannels {
+ NSArray<GRPCPooledChannel *> *copiedPooledChannels;
+ @synchronized(self) {
+ copiedPooledChannels = _channelPool.allValues;
+ }
+
+ // Disconnect pooled channels.
+ for (GRPCPooledChannel *pooledChannel in copiedPooledChannels) {
+ [pooledChannel disconnect];
+ }
+}
+
+- (void)connectivityChange:(NSNotification *)note {
+ [self disconnectAllChannels];
+}
+
+@end
+
+@implementation GRPCChannelPool (Test)
+
+- (instancetype)initTestPool {
+ return [self initPrivate];
+}
+
+@end
diff --git a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
index a36788b35a..bb8618ff33 100644
--- a/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
+++ b/src/objective-c/GRPCClient/private/GRPCConnectivityMonitor.m
@@ -76,14 +76,14 @@ static void ReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReach
}
}
-+ (void)registerObserver:(_Nonnull id)observer selector:(SEL)selector {
++ (void)registerObserver:(id)observer selector:(SEL)selector {
[[NSNotificationCenter defaultCenter] addObserver:observer
selector:selector
name:kGRPCConnectivityNotification
object:nil];
}
-+ (void)unregisterObserver:(_Nonnull id)observer {
++ (void)unregisterObserver:(id)observer {
[[NSNotificationCenter defaultCenter] removeObserver:observer];
}
diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h
new file mode 100644
index 0000000000..738dfdb737
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.h
@@ -0,0 +1,36 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+#import "GRPCChannelFactory.h"
+
+@class GRPCChannel;
+typedef struct stream_engine stream_engine;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface GRPCCronetChannelFactory : NSObject<GRPCChannelFactory>
+
++ (nullable instancetype)sharedInstance;
+
+- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
+ channelArgs:(nullable NSDictionary *)args;
+
+- (nullable instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m
new file mode 100644
index 0000000000..5bcb021dc4
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCCronetChannelFactory.m
@@ -0,0 +1,79 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import "GRPCCronetChannelFactory.h"
+
+#import "ChannelArgsUtil.h"
+#import "GRPCChannel.h"
+
+#ifdef GRPC_COMPILE_WITH_CRONET
+
+#import <Cronet/Cronet.h>
+#include <grpc/grpc_cronet.h>
+
+@implementation GRPCCronetChannelFactory {
+ stream_engine *_cronetEngine;
+}
+
++ (instancetype)sharedInstance {
+ static GRPCCronetChannelFactory *instance;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ instance = [[self alloc] initWithEngine:[Cronet getGlobalEngine]];
+ });
+ return instance;
+}
+
+- (instancetype)initWithEngine:(stream_engine *)engine {
+ NSAssert(engine != NULL, @"Cronet engine cannot be empty.");
+ if (!engine) {
+ return nil;
+ }
+ if ((self = [super init])) {
+ _cronetEngine = engine;
+ }
+ return self;
+}
+
+- (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args {
+ grpc_channel_args *channelArgs = GRPCBuildChannelArgs(args);
+ grpc_channel *unmanagedChannel =
+ grpc_cronet_secure_channel_create(_cronetEngine, host.UTF8String, channelArgs, NULL);
+ GRPCFreeChannelArgs(channelArgs);
+ return unmanagedChannel;
+}
+
+@end
+
+#else
+
+@implementation GRPCCronetChannelFactory
+
++ (instancetype)sharedInstance {
+ NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel.");
+ return nil;
+}
+
+- (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args {
+ NSAssert(NO, @"Must enable macro GRPC_COMPILE_WITH_CRONET to build Cronet channel.");
+ return NULL;
+}
+
+@end
+
+#endif
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h
index 291b07df37..ca3c52ea17 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.h
+++ b/src/objective-c/GRPCClient/private/GRPCHost.h
@@ -20,6 +20,10 @@
#import <grpc/impl/codegen/compression_types.h>
+#import "GRPCChannelFactory.h"
+
+#import <GRPCClient/GRPCCallOptions.h>
+
NS_ASSUME_NONNULL_BEGIN
@class GRPCCompletionQueue;
@@ -28,12 +32,10 @@ struct grpc_channel_credentials;
@interface GRPCHost : NSObject
-+ (void)flushChannelCache;
+ (void)resetAllHostSettings;
@property(nonatomic, readonly) NSString *address;
@property(nonatomic, copy, nullable) NSString *userAgentPrefix;
-@property(nonatomic, nullable) struct grpc_channel_credentials *channelCreds;
@property(nonatomic) grpc_compression_algorithm compressAlgorithm;
@property(nonatomic) int keepaliveInterval;
@property(nonatomic) int keepaliveTimeout;
@@ -44,14 +46,14 @@ struct grpc_channel_credentials;
@property(nonatomic) unsigned int initialConnectBackoff;
@property(nonatomic) unsigned int maxConnectBackoff;
-/** The following properties should only be modified for testing: */
+@property(nonatomic) id<GRPCChannelFactory> channelFactory;
-@property(nonatomic, getter=isSecure) BOOL secure;
+/** The following properties should only be modified for testing: */
@property(nonatomic, copy, nullable) NSString *hostNameOverride;
/** The default response size limit is 4MB. Set this to override that default. */
-@property(nonatomic, strong, nullable) NSNumber *responseSizeLimitOverride;
+@property(nonatomic) NSUInteger responseSizeLimitOverride;
- (nullable instancetype)init NS_UNAVAILABLE;
/** Host objects initialized with the same address are the same. */
@@ -62,19 +64,10 @@ struct grpc_channel_credentials;
withCertChain:(nullable NSString *)pemCertChain
error:(NSError **)errorPtr;
-/** Create a grpc_call object to the provided path on this host. */
-- (nullable struct grpc_call *)unmanagedCallWithPath:(NSString *)path
- serverName:(NSString *)serverName
- timeout:(NSTimeInterval)timeout
- completionQueue:(GRPCCompletionQueue *)queue;
-
-// TODO: There's a race when a new RPC is coming through just as an existing one is getting
-// notified that there's no connectivity. If connectivity comes back at that moment, the new RPC
-// will have its channel destroyed by the other RPC, and will never get notified of a problem, so
-// it'll hang (the C layer logs a timeout, with exponential back off). One solution could be to pass
-// the GRPCChannel to the GRPCCall, renaming this as "disconnectChannel:channel", which would only
-// act on that specific channel.
-- (void)disconnect;
+@property(atomic) GRPCTransportType transportType;
+
++ (GRPCCallOptions *)callOptionsForHost:(NSString *)host;
+
@end
NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m
index 85b95dee91..24348c3aed 100644
--- a/src/objective-c/GRPCClient/private/GRPCHost.m
+++ b/src/objective-c/GRPCClient/private/GRPCHost.m
@@ -18,46 +18,36 @@
#import "GRPCHost.h"
+#import <GRPCClient/GRPCCall+Cronet.h>
#import <GRPCClient/GRPCCall.h>
+#import <GRPCClient/GRPCCallOptions.h>
+
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
-#ifdef GRPC_COMPILE_WITH_CRONET
-#import <GRPCClient/GRPCCall+ChannelArg.h>
-#import <GRPCClient/GRPCCall+Cronet.h>
-#endif
-#import "GRPCChannel.h"
+#import "../internal/GRPCCallOptions+Internal.h"
+#import "GRPCChannelFactory.h"
#import "GRPCCompletionQueue.h"
#import "GRPCConnectivityMonitor.h"
+#import "GRPCCronetChannelFactory.h"
+#import "GRPCSecureChannelFactory.h"
#import "NSDictionary+GRPC.h"
#import "version.h"
NS_ASSUME_NONNULL_BEGIN
-extern const char *kCFStreamVarName;
-
-static NSMutableDictionary *kHostCache;
+static NSMutableDictionary *gHostCache;
@implementation GRPCHost {
- // TODO(mlumish): Investigate whether caching channels with strong links is a good idea.
- GRPCChannel *_channel;
+ NSString *_PEMRootCertificates;
+ NSString *_PEMPrivateKey;
+ NSString *_PEMCertificateChain;
}
+ (nullable instancetype)hostWithAddress:(NSString *)address {
return [[self alloc] initWithAddress:address];
}
-- (void)dealloc {
- if (_channelCreds != nil) {
- grpc_channel_credentials_release(_channelCreds);
- }
- // Connectivity monitor is not required for CFStream
- char *enableCFStream = getenv(kCFStreamVarName);
- if (enableCFStream == nil || enableCFStream[0] != '1') {
- [GRPCConnectivityMonitor unregisterObserver:self];
- }
-}
-
// Default initializer.
- (nullable instancetype)initWithAddress:(NSString *)address {
if (!address) {
@@ -76,241 +66,89 @@ static NSMutableDictionary *kHostCache;
// Look up the GRPCHost in the cache.
static dispatch_once_t cacheInitialization;
dispatch_once(&cacheInitialization, ^{
- kHostCache = [NSMutableDictionary dictionary];
+ gHostCache = [NSMutableDictionary dictionary];
});
- @synchronized(kHostCache) {
- GRPCHost *cachedHost = kHostCache[address];
+ @synchronized(gHostCache) {
+ GRPCHost *cachedHost = gHostCache[address];
if (cachedHost) {
return cachedHost;
}
if ((self = [super init])) {
- _address = address;
- _secure = YES;
- kHostCache[address] = self;
- _compressAlgorithm = GRPC_COMPRESS_NONE;
+ _address = [address copy];
_retryEnabled = YES;
- }
-
- // Connectivity monitor is not required for CFStream
- char *enableCFStream = getenv(kCFStreamVarName);
- if (enableCFStream == nil || enableCFStream[0] != '1') {
- [GRPCConnectivityMonitor registerObserver:self selector:@selector(connectivityChange:)];
+ gHostCache[address] = self;
}
}
return self;
}
-+ (void)flushChannelCache {
- @synchronized(kHostCache) {
- [kHostCache enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, GRPCHost *_Nonnull host,
- BOOL *_Nonnull stop) {
- [host disconnect];
- }];
- }
-}
-
+ (void)resetAllHostSettings {
- @synchronized(kHostCache) {
- kHostCache = [NSMutableDictionary dictionary];
- }
-}
-
-- (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path
- serverName:(NSString *)serverName
- timeout:(NSTimeInterval)timeout
- completionQueue:(GRPCCompletionQueue *)queue {
- // The __block attribute is to allow channel take refcount inside @synchronized block. Without
- // this attribute, retain of channel object happens after objc_sync_exit in release builds, which
- // may result in channel released before used. See grpc/#15033.
- __block GRPCChannel *channel;
- // This is racing -[GRPCHost disconnect].
- @synchronized(self) {
- if (!_channel) {
- _channel = [self newChannel];
- }
- channel = _channel;
+ @synchronized(gHostCache) {
+ gHostCache = [NSMutableDictionary dictionary];
}
- return [channel unmanagedCallWithPath:path
- serverName:serverName
- timeout:timeout
- completionQueue:queue];
-}
-
-- (NSData *)nullTerminatedDataWithString:(NSString *)string {
- // dataUsingEncoding: does not return a null-terminated string.
- NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
- NSMutableData *nullTerminated = [NSMutableData dataWithData:data];
- [nullTerminated appendBytes:"\0" length:1];
- return nullTerminated;
}
- (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts
withPrivateKey:(nullable NSString *)pemPrivateKey
withCertChain:(nullable NSString *)pemCertChain
error:(NSError **)errorPtr {
- static NSData *kDefaultRootsASCII;
- static NSError *kDefaultRootsError;
- static dispatch_once_t loading;
- dispatch_once(&loading, ^{
- NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem
- // Do not use NSBundle.mainBundle, as it's nil for tests of library projects.
- NSBundle *bundle = [NSBundle bundleForClass:self.class];
- NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"];
- NSError *error;
- // Files in PEM format can have non-ASCII characters in their comments (e.g. for the name of the
- // issuer). Load them as UTF8 and produce an ASCII equivalent.
- NSString *contentInUTF8 =
- [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
- if (contentInUTF8 == nil) {
- kDefaultRootsError = error;
- return;
- }
- kDefaultRootsASCII = [self nullTerminatedDataWithString:contentInUTF8];
- });
-
- NSData *rootsASCII;
- if (pemRootCerts != nil) {
- rootsASCII = [self nullTerminatedDataWithString:pemRootCerts];
- } else {
- if (kDefaultRootsASCII == nil) {
- if (errorPtr) {
- *errorPtr = kDefaultRootsError;
- }
- NSAssert(
- kDefaultRootsASCII,
- @"Could not read gRPCCertificates.bundle/roots.pem. This file, "
- "with the root certificates, is needed to establish secure (TLS) connections. "
- "Because the file is distributed with the gRPC library, this error is usually a sign "
- "that the library wasn't configured correctly for your project. Error: %@",
- kDefaultRootsError);
- return NO;
- }
- rootsASCII = kDefaultRootsASCII;
- }
-
- grpc_channel_credentials *creds;
- if (pemPrivateKey == nil && pemCertChain == nil) {
- creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL, NULL);
- } else {
- assert(pemPrivateKey != nil && pemCertChain != nil);
- grpc_ssl_pem_key_cert_pair key_cert_pair;
- NSData *privateKeyASCII = [self nullTerminatedDataWithString:pemPrivateKey];
- NSData *certChainASCII = [self nullTerminatedDataWithString:pemCertChain];
- key_cert_pair.private_key = privateKeyASCII.bytes;
- key_cert_pair.cert_chain = certChainASCII.bytes;
- creds = grpc_ssl_credentials_create(rootsASCII.bytes, &key_cert_pair, NULL, NULL);
- }
-
- @synchronized(self) {
- if (_channelCreds != nil) {
- grpc_channel_credentials_release(_channelCreds);
- }
- _channelCreds = creds;
- }
-
+ _PEMRootCertificates = [pemRootCerts copy];
+ _PEMPrivateKey = [pemPrivateKey copy];
+ _PEMCertificateChain = [pemCertChain copy];
return YES;
}
-- (NSDictionary *)channelArgsUsingCronet:(BOOL)useCronet {
- NSMutableDictionary *args = [NSMutableDictionary dictionary];
-
- // TODO(jcanizales): Add OS and device information (see
- // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#user-agents ).
- NSString *userAgent = @"grpc-objc/" GRPC_OBJC_VERSION_STRING;
- if (_userAgentPrefix) {
- userAgent = [_userAgentPrefix stringByAppendingFormat:@" %@", userAgent];
- }
- args[@GRPC_ARG_PRIMARY_USER_AGENT_STRING] = userAgent;
-
- if (_secure && _hostNameOverride) {
- args[@GRPC_SSL_TARGET_NAME_OVERRIDE_ARG] = _hostNameOverride;
- }
-
- if (_responseSizeLimitOverride != nil) {
- args[@GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH] = _responseSizeLimitOverride;
- }
-
- if (_compressAlgorithm != GRPC_COMPRESS_NONE) {
- args[@GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM] = [NSNumber numberWithInt:_compressAlgorithm];
- }
-
- if (_keepaliveInterval != 0) {
- args[@GRPC_ARG_KEEPALIVE_TIME_MS] = [NSNumber numberWithInt:_keepaliveInterval];
- args[@GRPC_ARG_KEEPALIVE_TIMEOUT_MS] = [NSNumber numberWithInt:_keepaliveTimeout];
- }
-
- id logContext = self.logContext;
- if (logContext != nil) {
- args[@GRPC_ARG_MOBILE_LOG_CONTEXT] = logContext;
- }
-
- if (useCronet) {
- args[@GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER] = [NSNumber numberWithInt:1];
- }
-
- if (_retryEnabled == NO) {
- args[@GRPC_ARG_ENABLE_RETRIES] = [NSNumber numberWithInt:0];
- }
-
- if (_minConnectTimeout > 0) {
- args[@GRPC_ARG_MIN_RECONNECT_BACKOFF_MS] = [NSNumber numberWithInt:_minConnectTimeout];
- }
- if (_initialConnectBackoff > 0) {
- args[@GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS] = [NSNumber numberWithInt:_initialConnectBackoff];
- }
- if (_maxConnectBackoff > 0) {
- args[@GRPC_ARG_MAX_RECONNECT_BACKOFF_MS] = [NSNumber numberWithInt:_maxConnectBackoff];
- }
-
- return args;
-}
-
-- (GRPCChannel *)newChannel {
- BOOL useCronet = NO;
-#ifdef GRPC_COMPILE_WITH_CRONET
- useCronet = [GRPCCall isUsingCronet];
-#endif
- NSDictionary *args = [self channelArgsUsingCronet:useCronet];
- if (_secure) {
- GRPCChannel *channel;
- @synchronized(self) {
- if (_channelCreds == nil) {
- [self setTLSPEMRootCerts:nil withPrivateKey:nil withCertChain:nil error:nil];
- }
+- (GRPCCallOptions *)callOptions {
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.userAgentPrefix = _userAgentPrefix;
+ options.responseSizeLimit = _responseSizeLimitOverride;
+ options.compressionAlgorithm = (GRPCCompressionAlgorithm)_compressAlgorithm;
+ options.retryEnabled = _retryEnabled;
+ options.keepaliveInterval = (NSTimeInterval)_keepaliveInterval / 1000;
+ options.keepaliveTimeout = (NSTimeInterval)_keepaliveTimeout / 1000;
+ options.connectMinTimeout = (NSTimeInterval)_minConnectTimeout / 1000;
+ options.connectInitialBackoff = (NSTimeInterval)_initialConnectBackoff / 1000;
+ options.connectMaxBackoff = (NSTimeInterval)_maxConnectBackoff / 1000;
+ options.PEMRootCertificates = _PEMRootCertificates;
+ options.PEMPrivateKey = _PEMPrivateKey;
+ options.PEMCertificateChain = _PEMCertificateChain;
+ options.hostNameOverride = _hostNameOverride;
#ifdef GRPC_COMPILE_WITH_CRONET
- if (useCronet) {
- channel = [GRPCChannel secureCronetChannelWithHost:_address channelArgs:args];
- } else
-#endif
- {
- channel =
- [GRPCChannel secureChannelWithHost:_address credentials:_channelCreds channelArgs:args];
- }
+ // By old API logic, insecure channel precedes Cronet channel; Cronet channel preceeds default
+ // channel.
+ if ([GRPCCall isUsingCronet]) {
+ if (_transportType == GRPCTransportTypeInsecure) {
+ options.transportType = GRPCTransportTypeInsecure;
+ } else {
+ NSAssert(_transportType == GRPCTransportTypeDefault, @"Invalid transport type");
+ options.transportType = GRPCTransportTypeCronet;
}
- return channel;
- } else {
- return [GRPCChannel insecureChannelWithHost:_address channelArgs:args];
+ } else
+#endif
+ {
+ options.transportType = _transportType;
}
-}
+ options.logContext = _logContext;
-- (NSString *)hostName {
- // TODO(jcanizales): Default to nil instead of _address when Issue #2635 is clarified.
- return _hostNameOverride ?: _address;
+ return options;
}
-- (void)disconnect {
- // This is racing -[GRPCHost unmanagedCallWithPath:completionQueue:].
- @synchronized(self) {
- _channel = nil;
++ (GRPCCallOptions *)callOptionsForHost:(NSString *)host {
+ // TODO (mxyan): Remove when old API is deprecated
+ NSURL *hostURL = [NSURL URLWithString:[@"https://" stringByAppendingString:host]];
+ if (hostURL.host && hostURL.port == nil) {
+ host = [hostURL.host stringByAppendingString:@":443"];
}
-}
-// Flushes the host cache when connectivity status changes or when connection switch between Wifi
-// and Cellular data, so that a new call will use a new channel. Otherwise, a new call will still
-// use the cached channel which is no longer available and will cause gRPC to hang.
-- (void)connectivityChange:(NSNotification *)note {
- [self disconnect];
+ GRPCCallOptions *callOptions = nil;
+ @synchronized(gHostCache) {
+ callOptions = [gHostCache[host] callOptions];
+ }
+ if (callOptions == nil) {
+ callOptions = [[GRPCCallOptions alloc] init];
+ }
+ return callOptions;
}
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h
new file mode 100644
index 0000000000..2d471aebed
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.h
@@ -0,0 +1,35 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+#import "GRPCChannelFactory.h"
+
+@class GRPCChannel;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface GRPCInsecureChannelFactory : NSObject<GRPCChannelFactory>
+
++ (nullable instancetype)sharedInstance;
+
+- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
+ channelArgs:(nullable NSDictionary *)args;
+
+- (nullable instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m
new file mode 100644
index 0000000000..8ad1e848f5
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCInsecureChannelFactory.m
@@ -0,0 +1,43 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import "GRPCInsecureChannelFactory.h"
+
+#import "ChannelArgsUtil.h"
+#import "GRPCChannel.h"
+
+@implementation GRPCInsecureChannelFactory
+
++ (instancetype)sharedInstance {
+ static GRPCInsecureChannelFactory *instance;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ instance = [[self alloc] init];
+ });
+ return instance;
+}
+
+- (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args {
+ grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs(args);
+ grpc_channel *unmanagedChannel =
+ grpc_insecure_channel_create(host.UTF8String, coreChannelArgs, NULL);
+ GRPCFreeChannelArgs(coreChannelArgs);
+ return unmanagedChannel;
+}
+
+@end
diff --git a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
index fa4f022ff0..5f117f0607 100644
--- a/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
+++ b/src/objective-c/GRPCClient/private/GRPCRequestHeaders.m
@@ -36,7 +36,7 @@ static void CheckIsNonNilASCII(NSString *name, NSString *value) {
// Precondition: key isn't nil.
static void CheckKeyValuePairIsValid(NSString *key, id value) {
if ([key hasSuffix:@"-bin"]) {
- if (![value isKindOfClass:NSData.class]) {
+ if (![value isKindOfClass:[NSData class]]) {
[NSException raise:NSInvalidArgumentException
format:
@"Expected NSData value for header %@ ending in \"-bin\", "
@@ -44,7 +44,7 @@ static void CheckKeyValuePairIsValid(NSString *key, id value) {
key, value];
}
} else {
- if (![value isKindOfClass:NSString.class]) {
+ if (![value isKindOfClass:[NSString class]]) {
[NSException raise:NSInvalidArgumentException
format:
@"Expected NSString value for header %@ not ending in \"-bin\", "
diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h
new file mode 100644
index 0000000000..588239b706
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.h
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+#import "GRPCChannelFactory.h"
+
+@class GRPCChannel;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface GRPCSecureChannelFactory : NSObject<GRPCChannelFactory>
+
++ (nullable instancetype)factoryWithPEMRootCertificates:(nullable NSString *)rootCerts
+ privateKey:(nullable NSString *)privateKey
+ certChain:(nullable NSString *)certChain
+ error:(NSError **)errorPtr;
+
+- (nullable grpc_channel *)createChannelWithHost:(NSString *)host
+ channelArgs:(nullable NSDictionary *)args;
+
+- (nullable instancetype)init NS_UNAVAILABLE;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m
new file mode 100644
index 0000000000..9699889536
--- /dev/null
+++ b/src/objective-c/GRPCClient/private/GRPCSecureChannelFactory.m
@@ -0,0 +1,135 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import "GRPCSecureChannelFactory.h"
+
+#include <grpc/grpc_security.h>
+
+#import "ChannelArgsUtil.h"
+#import "GRPCChannel.h"
+
+@implementation GRPCSecureChannelFactory {
+ grpc_channel_credentials *_channelCreds;
+}
+
++ (instancetype)factoryWithPEMRootCertificates:(NSString *)rootCerts
+ privateKey:(NSString *)privateKey
+ certChain:(NSString *)certChain
+ error:(NSError **)errorPtr {
+ return [[self alloc] initWithPEMRootCerts:rootCerts
+ privateKey:privateKey
+ certChain:certChain
+ error:errorPtr];
+}
+
+- (NSData *)nullTerminatedDataWithString:(NSString *)string {
+ // dataUsingEncoding: does not return a null-terminated string.
+ NSData *data = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
+ if (data == nil) {
+ return nil;
+ }
+ NSMutableData *nullTerminated = [NSMutableData dataWithData:data];
+ [nullTerminated appendBytes:"\0" length:1];
+ return nullTerminated;
+}
+
+- (instancetype)initWithPEMRootCerts:(NSString *)rootCerts
+ privateKey:(NSString *)privateKey
+ certChain:(NSString *)certChain
+ error:(NSError **)errorPtr {
+ static NSData *defaultRootsASCII;
+ static NSError *defaultRootsError;
+ static dispatch_once_t loading;
+ dispatch_once(&loading, ^{
+ NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem
+ // Do not use NSBundle.mainBundle, as it's nil for tests of library projects.
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"];
+ NSError *error;
+ // Files in PEM format can have non-ASCII characters in their comments (e.g. for the name of the
+ // issuer). Load them as UTF8 and produce an ASCII equivalent.
+ NSString *contentInUTF8 =
+ [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];
+ if (contentInUTF8 == nil) {
+ defaultRootsError = error;
+ return;
+ }
+ defaultRootsASCII = [self nullTerminatedDataWithString:contentInUTF8];
+ });
+
+ NSData *rootsASCII;
+ if (rootCerts != nil) {
+ rootsASCII = [self nullTerminatedDataWithString:rootCerts];
+ } else {
+ if (defaultRootsASCII == nil) {
+ if (errorPtr) {
+ *errorPtr = defaultRootsError;
+ }
+ NSAssert(
+ defaultRootsASCII, NSObjectNotAvailableException,
+ @"Could not read gRPCCertificates.bundle/roots.pem. This file, "
+ "with the root certificates, is needed to establish secure (TLS) connections. "
+ "Because the file is distributed with the gRPC library, this error is usually a sign "
+ "that the library wasn't configured correctly for your project. Error: %@",
+ defaultRootsError);
+ return nil;
+ }
+ rootsASCII = defaultRootsASCII;
+ }
+
+ grpc_channel_credentials *creds = NULL;
+ if (privateKey.length == 0 && certChain.length == 0) {
+ creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL, NULL);
+ } else {
+ grpc_ssl_pem_key_cert_pair key_cert_pair;
+ NSData *privateKeyASCII = [self nullTerminatedDataWithString:privateKey];
+ NSData *certChainASCII = [self nullTerminatedDataWithString:certChain];
+ key_cert_pair.private_key = privateKeyASCII.bytes;
+ key_cert_pair.cert_chain = certChainASCII.bytes;
+ if (key_cert_pair.private_key == NULL || key_cert_pair.cert_chain == NULL) {
+ creds = grpc_ssl_credentials_create(rootsASCII.bytes, NULL, NULL, NULL);
+ } else {
+ creds = grpc_ssl_credentials_create(rootsASCII.bytes, &key_cert_pair, NULL, NULL);
+ }
+ }
+
+ if ((self = [super init])) {
+ _channelCreds = creds;
+ }
+ return self;
+}
+
+- (grpc_channel *)createChannelWithHost:(NSString *)host channelArgs:(NSDictionary *)args {
+ NSAssert(host.length != 0, @"host cannot be empty");
+ if (host.length == 0) {
+ return NULL;
+ }
+ grpc_channel_args *coreChannelArgs = GRPCBuildChannelArgs(args);
+ grpc_channel *unmanagedChannel =
+ grpc_secure_channel_create(_channelCreds, host.UTF8String, coreChannelArgs, NULL);
+ GRPCFreeChannelArgs(coreChannelArgs);
+ return unmanagedChannel;
+}
+
+- (void)dealloc {
+ if (_channelCreds != NULL) {
+ grpc_channel_credentials_release(_channelCreds);
+ }
+}
+
+@end
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
index f711850c2f..92bd1be257 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h
@@ -71,12 +71,16 @@
#pragma mark GRPCWrappedCall
+@class GRPCPooledChannel;
+
@interface GRPCWrappedCall : NSObject
-- (instancetype)initWithHost:(NSString *)host
- serverName:(NSString *)serverName
- path:(NSString *)path
- timeout:(NSTimeInterval)timeout NS_DESIGNATED_INITIALIZER;
+- (instancetype)init NS_UNAVAILABLE;
+
++ (instancetype) new NS_UNAVAILABLE;
+
+- (instancetype)initWithUnmanagedCall:(grpc_call *)unmanagedCall
+ pooledChannel:(GRPCPooledChannel *)pooledChannel NS_DESIGNATED_INITIALIZER;
- (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void (^)(void))errorHandler;
@@ -84,4 +88,6 @@
- (void)cancel;
+- (void)channelDisconnected;
+
@end
diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
index 7781d27ca4..7d7e77f6ba 100644
--- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
+++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m
@@ -23,6 +23,8 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
+#import "GRPCChannel.h"
+#import "GRPCChannelPool.h"
#import "GRPCCompletionQueue.h"
#import "GRPCHost.h"
#import "NSData+GRPC.h"
@@ -234,35 +236,22 @@
#pragma mark GRPCWrappedCall
@implementation GRPCWrappedCall {
- GRPCCompletionQueue *_queue;
+ // pooledChannel holds weak reference to this object so this is ok
+ GRPCPooledChannel *_pooledChannel;
grpc_call *_call;
}
-- (instancetype)init {
- return [self initWithHost:nil serverName:nil path:nil timeout:0];
-}
-
-- (instancetype)initWithHost:(NSString *)host
- serverName:(NSString *)serverName
- path:(NSString *)path
- timeout:(NSTimeInterval)timeout {
- if (!path || !host) {
- [NSException raise:NSInvalidArgumentException format:@"path and host cannot be nil."];
+- (instancetype)initWithUnmanagedCall:(grpc_call *)unmanagedCall
+ pooledChannel:(GRPCPooledChannel *)pooledChannel {
+ NSAssert(unmanagedCall != NULL, @"unmanagedCall cannot be empty.");
+ NSAssert(pooledChannel != nil, @"pooledChannel cannot be empty.");
+ if (unmanagedCall == NULL || pooledChannel == nil) {
+ return nil;
}
- if (self = [super init]) {
- // Each completion queue consumes one thread. There's a trade to be made between creating and
- // consuming too many threads and having contention of multiple calls in a single completion
- // queue. Currently we use a singleton queue.
- _queue = [GRPCCompletionQueue completionQueue];
-
- _call = [[GRPCHost hostWithAddress:host] unmanagedCallWithPath:path
- serverName:serverName
- timeout:timeout
- completionQueue:_queue];
- if (_call == NULL) {
- return nil;
- }
+ if ((self = [super init])) {
+ _call = unmanagedCall;
+ _pooledChannel = pooledChannel;
}
return self;
}
@@ -278,41 +267,70 @@
[GRPCOpBatchLog addOpBatchToLog:operations];
#endif
- size_t nops = operations.count;
- grpc_op *ops_array = gpr_malloc(nops * sizeof(grpc_op));
- size_t i = 0;
- for (GRPCOperation *operation in operations) {
- ops_array[i++] = operation.op;
- }
- grpc_call_error error =
- grpc_call_start_batch(_call, ops_array, nops, (__bridge_retained void *)(^(bool success) {
- if (!success) {
- if (errorHandler) {
- errorHandler();
- } else {
- return;
- }
- }
- for (GRPCOperation *operation in operations) {
- [operation finish];
- }
- }),
- NULL);
- gpr_free(ops_array);
-
- if (error != GRPC_CALL_OK) {
- [NSException
- raise:NSInternalInconsistencyException
- format:@"A precondition for calling grpc_call_start_batch wasn't met. Error %i", error];
+ @synchronized(self) {
+ if (_call != NULL) {
+ size_t nops = operations.count;
+ grpc_op *ops_array = gpr_malloc(nops * sizeof(grpc_op));
+ size_t i = 0;
+ for (GRPCOperation *operation in operations) {
+ ops_array[i++] = operation.op;
+ }
+ grpc_call_error error =
+ grpc_call_start_batch(_call, ops_array, nops, (__bridge_retained void *)(^(bool success) {
+ if (!success) {
+ if (errorHandler) {
+ errorHandler();
+ } else {
+ return;
+ }
+ }
+ for (GRPCOperation *operation in operations) {
+ [operation finish];
+ }
+ }),
+ NULL);
+ gpr_free(ops_array);
+
+ NSAssert(error == GRPC_CALL_OK, @"Error starting a batch of operations: %i", error);
+ // To avoid compiler complaint when NSAssert is disabled.
+ if (error != GRPC_CALL_OK) {
+ return;
+ }
+ }
}
}
- (void)cancel {
- grpc_call_cancel(_call, NULL);
+ @synchronized(self) {
+ if (_call != NULL) {
+ grpc_call_cancel(_call, NULL);
+ }
+ }
+}
+
+- (void)channelDisconnected {
+ @synchronized(self) {
+ if (_call != NULL) {
+ // Unreference the call will lead to its cancellation in the core. Note that since
+ // this function is only called with a network state change, any existing GRPCCall object will
+ // also receive the same notification and cancel themselves with GRPCErrorCodeUnavailable, so
+ // the user gets GRPCErrorCodeUnavailable in this case.
+ grpc_call_unref(_call);
+ _call = NULL;
+ }
+ }
}
- (void)dealloc {
- grpc_call_unref(_call);
+ @synchronized(self) {
+ if (_call != NULL) {
+ grpc_call_unref(_call);
+ _call = NULL;
+ }
+ }
+ // Explicitly converting weak reference _pooledChannel to strong.
+ __strong GRPCPooledChannel *channel = _pooledChannel;
+ [channel notifyWrappedCallDealloc:self];
}
@end
diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h
index 0be0e3c9a0..5e089fde31 100644
--- a/src/objective-c/GRPCClient/private/version.h
+++ b/src/objective-c/GRPCClient/private/version.h
@@ -22,4 +22,4 @@
// instead. This file can be regenerated from the template by running
// `tools/buildgen/generate_projects.sh`.
-#define GRPC_OBJC_VERSION_STRING @"1.18.0-dev"
+#define GRPC_OBJC_VERSION_STRING @"1.19.0-dev"
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.h b/src/objective-c/ProtoRPC/ProtoRPC.h
index 45d3526092..8ce3421cc1 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.h
+++ b/src/objective-c/ProtoRPC/ProtoRPC.h
@@ -21,6 +21,122 @@
#import "ProtoMethod.h"
+NS_ASSUME_NONNULL_BEGIN
+
+@class GPBMessage;
+
+/** An object can implement this protocol to receive responses from server from a call. */
+@protocol GRPCProtoResponseHandler<NSObject>
+
+@required
+
+/**
+ * All the responses must be issued to a user-provided dispatch queue. This property specifies the
+ * dispatch queue to be used for issuing the notifications.
+ */
+@property(atomic, readonly) dispatch_queue_t dispatchQueue;
+
+@optional
+
+/**
+ * Issued when initial metadata is received from the server.
+ */
+- (void)didReceiveInitialMetadata:(nullable NSDictionary *)initialMetadata;
+
+/**
+ * Issued when a message is received from the server. The message is the deserialized proto object.
+ */
+- (void)didReceiveProtoMessage:(nullable GPBMessage *)message;
+
+/**
+ * Issued when a call finished. If the call finished successfully, \a error is nil and \a
+ * trainingMetadata consists any trailing metadata received from the server. Otherwise, \a error
+ * is non-nil and contains the corresponding error information, including gRPC error codes and
+ * error descriptions.
+ */
+- (void)didCloseWithTrailingMetadata:(nullable NSDictionary *)trailingMetadata
+ error:(nullable NSError *)error;
+
+@end
+
+/** A unary-request RPC call with Protobuf. */
+@interface GRPCUnaryProtoCall : NSObject
+
+- (instancetype)init NS_UNAVAILABLE;
+
++ (instancetype) new NS_UNAVAILABLE;
+
+/**
+ * Users should not use this initializer directly. Call objects will be created, initialized, and
+ * returned to users by methods of the generated service.
+ */
+- (nullable instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
+ message:(GPBMessage *)message
+ responseHandler:(id<GRPCProtoResponseHandler>)handler
+ callOptions:(nullable GRPCCallOptions *)callOptions
+ responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Start the call. This function must only be called once for each instance.
+ */
+- (void)start;
+
+/**
+ * Cancel the request of this call at best effort. It attempts to notify the server that the RPC
+ * should be cancelled, and issue didCloseWithTrailingMetadata:error: callback with error code
+ * CANCELED if no other error code has already been issued.
+ */
+- (void)cancel;
+
+@end
+
+/** A client-streaming RPC call with Protobuf. */
+@interface GRPCStreamingProtoCall : NSObject
+
+- (instancetype)init NS_UNAVAILABLE;
+
++ (instancetype) new NS_UNAVAILABLE;
+
+/**
+ * Users should not use this initializer directly. Call objects will be created, initialized, and
+ * returned to users by methods of the generated service.
+ */
+- (nullable instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
+ responseHandler:(id<GRPCProtoResponseHandler>)handler
+ callOptions:(nullable GRPCCallOptions *)callOptions
+ responseClass:(Class)responseClass NS_DESIGNATED_INITIALIZER;
+
+/**
+ * Start the call. This function must only be called once for each instance.
+ */
+- (void)start;
+
+/**
+ * Cancel the request of this call at best effort. It attempts to notify the server that the RPC
+ * should be cancelled, and issue didCloseWithTrailingMetadata:error: callback with error code
+ * CANCELED if no other error code has already been issued.
+ */
+- (void)cancel;
+
+/**
+ * Send a message to the server. The message should be a Protobuf message which will be serialized
+ * internally.
+ */
+- (void)writeMessage:(GPBMessage *)message;
+
+/**
+ * Finish the RPC request and half-close the call. The server may still send messages and/or
+ * trailers to the client.
+ */
+- (void)finish;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
+
__attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC
: GRPCCall
@@ -47,3 +163,5 @@ __attribute__((deprecated("Please use GRPCProtoCall."))) @interface ProtoRPC
#pragma clang diagnostic pop
@end
+
+#pragma clang diagnostic pop
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m
index 5dca971b08..0ab96a5ba2 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.m
+++ b/src/objective-c/ProtoRPC/ProtoRPC.m
@@ -23,9 +23,13 @@
#else
#import <GPBProtocolBuffers.h>
#endif
+#import <GRPCClient/GRPCCall.h>
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriter+Transformations.h>
+/**
+ * Generate an NSError object that represents a failure in parsing a proto class.
+ */
static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsingError) {
NSDictionary *info = @{
NSLocalizedDescriptionKey : @"Unable to parse response from the server",
@@ -41,6 +45,227 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
return [NSError errorWithDomain:@"io.grpc" code:13 userInfo:info];
}
+@implementation GRPCUnaryProtoCall {
+ GRPCStreamingProtoCall *_call;
+ GPBMessage *_message;
+}
+
+- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
+ message:(GPBMessage *)message
+ responseHandler:(id<GRPCProtoResponseHandler>)handler
+ callOptions:(GRPCCallOptions *)callOptions
+ responseClass:(Class)responseClass {
+ NSAssert(message != nil, @"message cannot be empty.");
+ NSAssert(responseClass != nil, @"responseClass cannot be empty.");
+ if (message == nil || responseClass == nil) {
+ return nil;
+ }
+ if ((self = [super init])) {
+ _call = [[GRPCStreamingProtoCall alloc] initWithRequestOptions:requestOptions
+ responseHandler:handler
+ callOptions:callOptions
+ responseClass:responseClass];
+ _message = [message copy];
+ }
+ return self;
+}
+
+- (void)start {
+ [_call start];
+ [_call writeMessage:_message];
+ [_call finish];
+}
+
+- (void)cancel {
+ [_call cancel];
+}
+
+@end
+
+@interface GRPCStreamingProtoCall ()<GRPCResponseHandler>
+
+@end
+
+@implementation GRPCStreamingProtoCall {
+ GRPCRequestOptions *_requestOptions;
+ id<GRPCProtoResponseHandler> _handler;
+ GRPCCallOptions *_callOptions;
+ Class _responseClass;
+
+ GRPCCall2 *_call;
+ dispatch_queue_t _dispatchQueue;
+}
+
+- (instancetype)initWithRequestOptions:(GRPCRequestOptions *)requestOptions
+ responseHandler:(id<GRPCProtoResponseHandler>)handler
+ callOptions:(GRPCCallOptions *)callOptions
+ responseClass:(Class)responseClass {
+ NSAssert(requestOptions.host.length != 0 && requestOptions.path.length != 0 &&
+ requestOptions.safety <= GRPCCallSafetyCacheableRequest,
+ @"Invalid callOptions.");
+ NSAssert(handler != nil, @"handler cannot be empty.");
+ if (requestOptions.host.length == 0 || requestOptions.path.length == 0 ||
+ requestOptions.safety > GRPCCallSafetyCacheableRequest) {
+ return nil;
+ }
+ if (handler == nil) {
+ return nil;
+ }
+
+ if ((self = [super init])) {
+ _requestOptions = [requestOptions copy];
+ _handler = handler;
+ _callOptions = [callOptions copy];
+ _responseClass = responseClass;
+
+ // Set queue QoS only when iOS version is 8.0 or above and Xcode version is 9.0 or above
+#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000 || __MAC_OS_X_VERSION_MAX_ALLOWED < 101300
+ if (@available(iOS 8.0, macOS 10.10, *)) {
+ _dispatchQueue = dispatch_queue_create(
+ NULL,
+ dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_DEFAULT, 0));
+ } else {
+#else
+ {
+#endif
+ _dispatchQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
+ }
+ dispatch_set_target_queue(_dispatchQueue, handler.dispatchQueue);
+
+ _call = [[GRPCCall2 alloc] initWithRequestOptions:_requestOptions
+ responseHandler:self
+ callOptions:_callOptions];
+ }
+ return self;
+}
+
+- (void)start {
+ GRPCCall2 *copiedCall;
+ @synchronized(self) {
+ copiedCall = _call;
+ }
+ [copiedCall start];
+}
+
+- (void)cancel {
+ GRPCCall2 *copiedCall;
+ @synchronized(self) {
+ copiedCall = _call;
+ _call = nil;
+ if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ id<GRPCProtoResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ self->_handler = nil;
+ }
+ [copiedHandler didCloseWithTrailingMetadata:nil
+ error:[NSError errorWithDomain:kGRPCErrorDomain
+ code:GRPCErrorCodeCancelled
+ userInfo:@{
+ NSLocalizedDescriptionKey :
+ @"Canceled by app"
+ }]];
+ });
+ } else {
+ _handler = nil;
+ }
+ }
+ [copiedCall cancel];
+}
+
+- (void)writeMessage:(GPBMessage *)message {
+ NSAssert([message isKindOfClass:[GPBMessage class]], @"Parameter message must be a GPBMessage");
+ if (![message isKindOfClass:[GPBMessage class]]) {
+ NSLog(@"Failed to send a message that is non-proto.");
+ return;
+ }
+
+ GRPCCall2 *copiedCall;
+ @synchronized(self) {
+ copiedCall = _call;
+ }
+ [copiedCall writeData:[message data]];
+}
+
+- (void)finish {
+ GRPCCall2 *copiedCall;
+ @synchronized(self) {
+ copiedCall = _call;
+ _call = nil;
+ }
+ [copiedCall finish];
+}
+
+- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata {
+ @synchronized(self) {
+ if (initialMetadata != nil &&
+ [_handler respondsToSelector:@selector(didReceiveInitialMetadata:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ id<GRPCProtoResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ }
+ [copiedHandler didReceiveInitialMetadata:initialMetadata];
+ });
+ }
+ }
+}
+
+- (void)didReceiveRawMessage:(NSData *)message {
+ if (message == nil) return;
+
+ NSError *error = nil;
+ GPBMessage *parsed = [_responseClass parseFromData:message error:&error];
+ @synchronized(self) {
+ if (parsed && [_handler respondsToSelector:@selector(didReceiveProtoMessage:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ id<GRPCProtoResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ }
+ [copiedHandler didReceiveProtoMessage:parsed];
+ });
+ } else if (!parsed &&
+ [_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ id<GRPCProtoResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ self->_handler = nil;
+ }
+ [copiedHandler
+ didCloseWithTrailingMetadata:nil
+ error:ErrorForBadProto(message, self->_responseClass, error)];
+ });
+ [_call cancel];
+ _call = nil;
+ }
+ }
+}
+
+- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error {
+ @synchronized(self) {
+ if ([_handler respondsToSelector:@selector(didCloseWithTrailingMetadata:error:)]) {
+ dispatch_async(_dispatchQueue, ^{
+ id<GRPCProtoResponseHandler> copiedHandler = nil;
+ @synchronized(self) {
+ copiedHandler = self->_handler;
+ self->_handler = nil;
+ }
+ [copiedHandler didCloseWithTrailingMetadata:trailingMetadata error:error];
+ });
+ }
+ _call = nil;
+ }
+}
+
+- (dispatch_queue_t)dispatchQueue {
+ return _dispatchQueue;
+}
+
+@end
+
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation ProtoRPC {
@@ -72,7 +297,7 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
}
// A writer that serializes the proto messages to send.
GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) {
- if (![proto isKindOfClass:GPBMessage.class]) {
+ if (![proto isKindOfClass:[GPBMessage class]]) {
[NSException raise:NSInvalidArgumentException
format:@"Request must be a proto message: %@", proto];
}
diff --git a/src/objective-c/ProtoRPC/ProtoService.h b/src/objective-c/ProtoRPC/ProtoService.h
index 29c4e9be36..900ec8d0e1 100644
--- a/src/objective-c/ProtoRPC/ProtoService.h
+++ b/src/objective-c/ProtoRPC/ProtoService.h
@@ -21,18 +21,47 @@
@class GRPCProtoCall;
@protocol GRXWriteable;
@class GRXWriter;
+@class GRPCCallOptions;
+@class GRPCProtoCall;
+@class GRPCUnaryProtoCall;
+@class GRPCStreamingProtoCall;
+@protocol GRPCProtoResponseHandler;
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnullability-completeness"
__attribute__((deprecated("Please use GRPCProtoService."))) @interface ProtoService
- : NSObject -
- (instancetype)initWithHost : (NSString *)host packageName
- : (NSString *)packageName serviceName : (NSString *)serviceName NS_DESIGNATED_INITIALIZER;
+ : NSObject
+
+ -
+ (nullable instancetype)initWithHost : (nonnull NSString *)host packageName
+ : (nonnull NSString *)packageName serviceName : (nonnull NSString *)serviceName callOptions
+ : (nullable GRPCCallOptions *)callOptions NS_DESIGNATED_INITIALIZER;
+
+- (instancetype)initWithHost:(NSString *)host
+ packageName:(NSString *)packageName
+ serviceName:(NSString *)serviceName;
- (GRPCProtoCall *)RPCToMethod:(NSString *)method
requestsWriter:(GRXWriter *)requestsWriter
responseClass:(Class)responseClass
responsesWriteable:(id<GRXWriteable>)responsesWriteable;
+
+- (nullable GRPCUnaryProtoCall *)RPCToMethod:(nonnull NSString *)method
+ message:(nonnull id)message
+ responseHandler:(nonnull id<GRPCProtoResponseHandler>)handler
+ callOptions:(nullable GRPCCallOptions *)callOptions
+ responseClass:(nonnull Class)responseClass;
+
+- (nullable GRPCStreamingProtoCall *)RPCToMethod:(nonnull NSString *)method
+ responseHandler:(nonnull id<GRPCProtoResponseHandler>)handler
+ callOptions:(nullable GRPCCallOptions *)callOptions
+ responseClass:(nonnull Class)responseClass;
+
@end
+#pragma clang diagnostic pop
+
/**
* This subclass is empty now. Eventually we'll remove ProtoService class
* to avoid potential naming conflict
diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m
index 3e9cc5c0b2..80a1f2f226 100644
--- a/src/objective-c/ProtoRPC/ProtoService.m
+++ b/src/objective-c/ProtoRPC/ProtoService.m
@@ -18,6 +18,7 @@
#import "ProtoService.h"
+#import <GRPCClient/GRPCCall.h>
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriter.h>
@@ -31,6 +32,7 @@
NSString *_host;
NSString *_packageName;
NSString *_serviceName;
+ GRPCCallOptions *_callOptions;
}
- (instancetype)init {
@@ -40,19 +42,41 @@
// Designated initializer
- (instancetype)initWithHost:(NSString *)host
packageName:(NSString *)packageName
- serviceName:(NSString *)serviceName {
- if (!host || !serviceName) {
- [NSException raise:NSInvalidArgumentException
- format:@"Neither host nor serviceName can be nil."];
+ serviceName:(NSString *)serviceName
+ callOptions:(GRPCCallOptions *)callOptions {
+ NSAssert(host.length != 0 && packageName.length != 0 && serviceName.length != 0,
+ @"Invalid parameter.");
+ if (host.length == 0 || packageName.length == 0 || serviceName.length == 0) {
+ return nil;
}
if ((self = [super init])) {
_host = [host copy];
_packageName = [packageName copy];
_serviceName = [serviceName copy];
+ _callOptions = [callOptions copy];
}
return self;
}
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
+// Do not call designated initializer here due to nullability incompatibility. This method is from
+// old API and does not assert on nullability of the parameters.
+
+- (instancetype)initWithHost:(NSString *)host
+ packageName:(NSString *)packageName
+ serviceName:(NSString *)serviceName {
+ if ((self = [super init])) {
+ _host = [host copy];
+ _packageName = [packageName copy];
+ _serviceName = [serviceName copy];
+ _callOptions = nil;
+ }
+ return self;
+}
+
+#pragma clang diagnostic pop
+
- (GRPCProtoCall *)RPCToMethod:(NSString *)method
requestsWriter:(GRXWriter *)requestsWriter
responseClass:(Class)responseClass
@@ -65,6 +89,41 @@
responseClass:responseClass
responsesWriteable:responsesWriteable];
}
+
+- (GRPCUnaryProtoCall *)RPCToMethod:(NSString *)method
+ message:(id)message
+ responseHandler:(id<GRPCProtoResponseHandler>)handler
+ callOptions:(GRPCCallOptions *)callOptions
+ responseClass:(Class)responseClass {
+ GRPCProtoMethod *methodName =
+ [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method];
+ GRPCRequestOptions *requestOptions =
+ [[GRPCRequestOptions alloc] initWithHost:_host
+ path:methodName.HTTPPath
+ safety:GRPCCallSafetyDefault];
+ return [[GRPCUnaryProtoCall alloc] initWithRequestOptions:requestOptions
+ message:message
+ responseHandler:handler
+ callOptions:callOptions ?: _callOptions
+ responseClass:responseClass];
+}
+
+- (GRPCStreamingProtoCall *)RPCToMethod:(NSString *)method
+ responseHandler:(id<GRPCProtoResponseHandler>)handler
+ callOptions:(GRPCCallOptions *)callOptions
+ responseClass:(Class)responseClass {
+ GRPCProtoMethod *methodName =
+ [[GRPCProtoMethod alloc] initWithPackage:_packageName service:_serviceName method:method];
+ GRPCRequestOptions *requestOptions =
+ [[GRPCRequestOptions alloc] initWithHost:_host
+ path:methodName.HTTPPath
+ safety:GRPCCallSafetyDefault];
+ return [[GRPCStreamingProtoCall alloc] initWithRequestOptions:requestOptions
+ responseHandler:handler
+ callOptions:callOptions ?: _callOptions
+ responseClass:responseClass];
+}
+
@end
@implementation GRPCProtoService
diff --git a/src/objective-c/examples/SwiftSample/ViewController.swift b/src/objective-c/examples/SwiftSample/ViewController.swift
index 0ba6e21f02..4ed10266a4 100644
--- a/src/objective-c/examples/SwiftSample/ViewController.swift
+++ b/src/objective-c/examples/SwiftSample/ViewController.swift
@@ -54,8 +54,8 @@ class ViewController: UIViewController {
} else {
NSLog("2. Finished with error: \(error!)")
}
- NSLog("2. Response headers: \(RPC.responseHeaders)")
- NSLog("2. Response trailers: \(RPC.responseTrailers)")
+ NSLog("2. Response headers: \(String(describing: RPC.responseHeaders))")
+ NSLog("2. Response trailers: \(String(describing: RPC.responseTrailers))")
}
// TODO(jcanizales): Revert to using subscript syntax once XCode 8 is released.
@@ -68,7 +68,7 @@ class ViewController: UIViewController {
let method = GRPCProtoMethod(package: "grpc.testing", service: "TestService", method: "UnaryCall")!
- let requestsWriter = GRXWriter(value: request.data())
+ let requestsWriter = GRXWriter(value: request.data())!
let call = GRPCCall(host: RemoteHost, path: method.httpPath, requestsWriter: requestsWriter)!
@@ -80,8 +80,8 @@ class ViewController: UIViewController {
} else {
NSLog("3. Finished with error: \(error!)")
}
- NSLog("3. Response headers: \(call.responseHeaders)")
- NSLog("3. Response trailers: \(call.responseTrailers)")
+ NSLog("3. Response headers: \(String(describing: call.responseHeaders))")
+ NSLog("3. Response trailers: \(String(describing: call.responseTrailers))")
})
}
}
diff --git a/src/objective-c/tests/APIv2Tests/APIv2Tests.m b/src/objective-c/tests/APIv2Tests/APIv2Tests.m
new file mode 100644
index 0000000000..ca7bf47283
--- /dev/null
+++ b/src/objective-c/tests/APIv2Tests/APIv2Tests.m
@@ -0,0 +1,478 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <GRPCClient/GRPCCall.h>
+#import <ProtoRPC/ProtoMethod.h>
+#import <RemoteTest/Messages.pbobjc.h>
+#import <XCTest/XCTest.h>
+
+#include <grpc/grpc.h>
+
+#import "../version.h"
+
+// The server address is derived from preprocessor macro, which is
+// in turn derived from environment variable of the same name.
+#define NSStringize_helper(x) #x
+#define NSStringize(x) @NSStringize_helper(x)
+static NSString *const kHostAddress = NSStringize(HOST_PORT_LOCAL);
+static NSString *const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE);
+
+// Package and service name of test server
+static NSString *const kPackage = @"grpc.testing";
+static NSString *const kService = @"TestService";
+
+static GRPCProtoMethod *kInexistentMethod;
+static GRPCProtoMethod *kEmptyCallMethod;
+static GRPCProtoMethod *kUnaryCallMethod;
+static GRPCProtoMethod *kFullDuplexCallMethod;
+
+static const int kSimpleDataLength = 100;
+
+static const NSTimeInterval kTestTimeout = 16;
+
+// Reveal the _class ivar for testing access
+@interface GRPCCall2 () {
+ @public
+ GRPCCall *_call;
+}
+
+@end
+
+// Convenience class to use blocks as callbacks
+@interface ClientTestsBlockCallbacks : NSObject<GRPCResponseHandler>
+
+- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
+ messageCallback:(void (^)(id))messageCallback
+ closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback;
+
+@end
+
+@implementation ClientTestsBlockCallbacks {
+ void (^_initialMetadataCallback)(NSDictionary *);
+ void (^_messageCallback)(id);
+ void (^_closeCallback)(NSDictionary *, NSError *);
+ dispatch_queue_t _dispatchQueue;
+}
+
+- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
+ messageCallback:(void (^)(id))messageCallback
+ closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback {
+ if ((self = [super init])) {
+ _initialMetadataCallback = initialMetadataCallback;
+ _messageCallback = messageCallback;
+ _closeCallback = closeCallback;
+ _dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL);
+ }
+ return self;
+}
+
+- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata {
+ if (self->_initialMetadataCallback) {
+ self->_initialMetadataCallback(initialMetadata);
+ }
+}
+
+- (void)didReceiveRawMessage:(GPBMessage *)message {
+ if (self->_messageCallback) {
+ self->_messageCallback(message);
+ }
+}
+
+- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error {
+ if (self->_closeCallback) {
+ self->_closeCallback(trailingMetadata, error);
+ }
+}
+
+- (dispatch_queue_t)dispatchQueue {
+ return _dispatchQueue;
+}
+
+@end
+
+@interface CallAPIv2Tests : XCTestCase<GRPCAuthorizationProtocol>
+
+@end
+
+@implementation CallAPIv2Tests
+
+- (void)setUp {
+ // This method isn't implemented by the remote server.
+ kInexistentMethod =
+ [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"Inexistent"];
+ kEmptyCallMethod =
+ [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"EmptyCall"];
+ kUnaryCallMethod =
+ [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"UnaryCall"];
+ kFullDuplexCallMethod =
+ [[GRPCProtoMethod alloc] initWithPackage:kPackage service:kService method:@"FullDuplexCall"];
+}
+
+- (void)testMetadata {
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"RPC unauthorized."];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ request.fillUsername = YES;
+ request.fillOauthScope = YES;
+
+ GRPCRequestOptions *callRequest =
+ [[GRPCRequestOptions alloc] initWithHost:(NSString *)kRemoteSSLHost
+ path:kUnaryCallMethod.HTTPPath
+ safety:GRPCCallSafetyDefault];
+ __block NSDictionary *init_md;
+ __block NSDictionary *trailing_md;
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.oauth2AccessToken = @"bogusToken";
+ GRPCCall2 *call = [[GRPCCall2 alloc]
+ initWithRequestOptions:callRequest
+ responseHandler:[[ClientTestsBlockCallbacks alloc]
+ initWithInitialMetadataCallback:^(NSDictionary *initialMetadata) {
+ init_md = initialMetadata;
+ }
+ messageCallback:^(id message) {
+ XCTFail(@"Received unexpected response.");
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ trailing_md = trailingMetadata;
+ if (error) {
+ XCTAssertEqual(error.code, 16,
+ @"Finished with unexpected error: %@", error);
+ XCTAssertEqualObjects(init_md,
+ error.userInfo[kGRPCHeadersKey]);
+ XCTAssertEqualObjects(trailing_md,
+ error.userInfo[kGRPCTrailersKey]);
+ NSString *challengeHeader = init_md[@"www-authenticate"];
+ XCTAssertGreaterThan(challengeHeader.length, 0,
+ @"No challenge in response headers %@",
+ init_md);
+ [expectation fulfill];
+ }
+ }]
+ callOptions:options];
+
+ [call start];
+ [call writeData:[request data]];
+ [call finish];
+
+ [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
+}
+
+- (void)testUserAgentPrefix {
+ __weak XCTestExpectation *completion = [self expectationWithDescription:@"Empty RPC completed."];
+ __weak XCTestExpectation *recvInitialMd =
+ [self expectationWithDescription:@"Did not receive initial md."];
+
+ GRPCRequestOptions *request = [[GRPCRequestOptions alloc] initWithHost:kHostAddress
+ path:kEmptyCallMethod.HTTPPath
+ safety:GRPCCallSafetyDefault];
+ NSDictionary *headers =
+ [NSDictionary dictionaryWithObjectsAndKeys:@"", @"x-grpc-test-echo-useragent", nil];
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = GRPCTransportTypeInsecure;
+ options.userAgentPrefix = @"Foo";
+ options.initialMetadata = headers;
+ GRPCCall2 *call = [[GRPCCall2 alloc]
+ initWithRequestOptions:request
+ responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:^(
+ NSDictionary *initialMetadata) {
+ NSString *userAgent = initialMetadata[@"x-grpc-test-echo-useragent"];
+ // Test the regex is correct
+ NSString *expectedUserAgent = @"Foo grpc-objc/";
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:GRPC_OBJC_VERSION_STRING];
+ expectedUserAgent = [expectedUserAgent stringByAppendingString:@" grpc-c/"];
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:GRPC_C_VERSION_STRING];
+ expectedUserAgent = [expectedUserAgent stringByAppendingString:@" (ios; chttp2; "];
+ expectedUserAgent = [expectedUserAgent
+ stringByAppendingString:[NSString stringWithUTF8String:grpc_g_stands_for()]];
+ expectedUserAgent = [expectedUserAgent stringByAppendingString:@")"];
+ XCTAssertEqualObjects(userAgent, expectedUserAgent);
+
+ NSError *error = nil;
+ // Change in format of user-agent field in a direction that does not match
+ // the regex will likely cause problem for certain gRPC users. For details,
+ // refer to internal doc https://goo.gl/c2diBc
+ NSRegularExpression *regex = [NSRegularExpression
+ regularExpressionWithPattern:
+ @" grpc-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?/[^ ,]+( \\([^)]*\\))?"
+ options:0
+ error:&error];
+
+ NSString *customUserAgent =
+ [regex stringByReplacingMatchesInString:userAgent
+ options:0
+ range:NSMakeRange(0, [userAgent length])
+ withTemplate:@""];
+ XCTAssertEqualObjects(customUserAgent, @"Foo");
+ [recvInitialMd fulfill];
+ }
+ messageCallback:^(id message) {
+ XCTAssertNotNil(message);
+ XCTAssertEqual([message length], 0,
+ @"Non-empty response received: %@", message);
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ if (error) {
+ XCTFail(@"Finished with unexpected error: %@", error);
+ } else {
+ [completion fulfill];
+ }
+ }]
+ callOptions:options];
+ [call writeData:[NSData data]];
+ [call start];
+
+ [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
+}
+
+- (void)getTokenWithHandler:(void (^)(NSString *token))handler {
+ dispatch_queue_t queue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
+ dispatch_sync(queue, ^{
+ handler(@"test-access-token");
+ });
+}
+
+- (void)testOAuthToken {
+ __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."];
+
+ GRPCRequestOptions *requestOptions =
+ [[GRPCRequestOptions alloc] initWithHost:kHostAddress
+ path:kEmptyCallMethod.HTTPPath
+ safety:GRPCCallSafetyDefault];
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = GRPCTransportTypeInsecure;
+ options.authTokenProvider = self;
+ __block GRPCCall2 *call = [[GRPCCall2 alloc]
+ initWithRequestOptions:requestOptions
+ responseHandler:[[ClientTestsBlockCallbacks alloc]
+ initWithInitialMetadataCallback:nil
+ messageCallback:nil
+ closeCallback:^(NSDictionary *trailingMetadata,
+ NSError *error) {
+ [completion fulfill];
+ }]
+ callOptions:options];
+ [call writeData:[NSData data]];
+ [call start];
+ [call finish];
+
+ [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
+}
+
+- (void)testResponseSizeLimitExceeded {
+ __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."];
+
+ GRPCRequestOptions *requestOptions =
+ [[GRPCRequestOptions alloc] initWithHost:kHostAddress
+ path:kUnaryCallMethod.HTTPPath
+ safety:GRPCCallSafetyDefault];
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.responseSizeLimit = kSimpleDataLength;
+ options.transportType = GRPCTransportTypeInsecure;
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ request.payload.body = [NSMutableData dataWithLength:options.responseSizeLimit];
+ request.responseSize = (int32_t)(options.responseSizeLimit * 2);
+
+ GRPCCall2 *call = [[GRPCCall2 alloc]
+ initWithRequestOptions:requestOptions
+ responseHandler:[[ClientTestsBlockCallbacks alloc]
+ initWithInitialMetadataCallback:nil
+ messageCallback:nil
+ closeCallback:^(NSDictionary *trailingMetadata,
+ NSError *error) {
+ XCTAssertNotNil(error,
+ @"Expecting non-nil error");
+ XCTAssertEqual(error.code,
+ GRPCErrorCodeResourceExhausted);
+ [completion fulfill];
+ }]
+ callOptions:options];
+ [call writeData:[request data]];
+ [call start];
+ [call finish];
+
+ [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
+}
+
+- (void)testIdempotentProtoRPC {
+ __weak XCTestExpectation *response = [self expectationWithDescription:@"Expected response."];
+ __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ request.responseSize = kSimpleDataLength;
+ request.fillUsername = YES;
+ request.fillOauthScope = YES;
+ GRPCRequestOptions *requestOptions =
+ [[GRPCRequestOptions alloc] initWithHost:kHostAddress
+ path:kUnaryCallMethod.HTTPPath
+ safety:GRPCCallSafetyIdempotentRequest];
+
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = GRPCTransportTypeInsecure;
+ GRPCCall2 *call = [[GRPCCall2 alloc]
+ initWithRequestOptions:requestOptions
+ responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ NSData *data = (NSData *)message;
+ XCTAssertNotNil(data, @"nil value received as response.");
+ XCTAssertGreaterThan(data.length, 0,
+ @"Empty response received.");
+ RMTSimpleResponse *responseProto =
+ [RMTSimpleResponse parseFromData:data error:NULL];
+ // We expect empty strings, not nil:
+ XCTAssertNotNil(responseProto.username,
+ @"Response's username is nil.");
+ XCTAssertNotNil(responseProto.oauthScope,
+ @"Response's OAuth scope is nil.");
+ [response fulfill];
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ XCTAssertNil(error, @"Finished with unexpected error: %@",
+ error);
+ [completion fulfill];
+ }]
+ callOptions:options];
+
+ [call start];
+ [call writeData:[request data]];
+ [call finish];
+
+ [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
+}
+
+- (void)testTimeout {
+ __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."];
+
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.timeout = 0.001;
+ GRPCRequestOptions *requestOptions =
+ [[GRPCRequestOptions alloc] initWithHost:kHostAddress
+ path:kFullDuplexCallMethod.HTTPPath
+ safety:GRPCCallSafetyDefault];
+
+ GRPCCall2 *call = [[GRPCCall2 alloc]
+ initWithRequestOptions:requestOptions
+ responseHandler:
+ [[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ messageCallback:^(NSData *data) {
+ XCTFail(@"Failure: response received; Expect: no response received.");
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ XCTAssertNotNil(error,
+ @"Failure: no error received; Expect: receive "
+ @"deadline exceeded.");
+ XCTAssertEqual(error.code, GRPCErrorCodeDeadlineExceeded);
+ [completion fulfill];
+ }]
+ callOptions:options];
+
+ [call start];
+
+ [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
+}
+
+- (void)testTimeoutBackoffWithTimeout:(double)timeout Backoff:(double)backoff {
+ const double maxConnectTime = timeout > backoff ? timeout : backoff;
+ const double kMargin = 0.1;
+
+ __weak XCTestExpectation *completion = [self expectationWithDescription:@"Timeout in a second."];
+ NSString *const kDummyAddress = [NSString stringWithFormat:@"127.0.0.1:10000"];
+ GRPCRequestOptions *requestOptions =
+ [[GRPCRequestOptions alloc] initWithHost:kDummyAddress
+ path:@"/dummy/path"
+ safety:GRPCCallSafetyDefault];
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.connectMinTimeout = timeout;
+ options.connectInitialBackoff = backoff;
+ options.connectMaxBackoff = 0;
+
+ NSDate *startTime = [NSDate date];
+ GRPCCall2 *call = [[GRPCCall2 alloc]
+ initWithRequestOptions:requestOptions
+ responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ messageCallback:^(NSData *data) {
+ XCTFail(@"Received message. Should not reach here.");
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ XCTAssertNotNil(error,
+ @"Finished with no error; expecting error");
+ XCTAssertLessThan(
+ [[NSDate date] timeIntervalSinceDate:startTime],
+ maxConnectTime + kMargin);
+ [completion fulfill];
+ }]
+ callOptions:options];
+
+ [call start];
+
+ [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
+}
+
+- (void)testTimeoutBackoff1 {
+ [self testTimeoutBackoffWithTimeout:0.7 Backoff:0.4];
+}
+
+- (void)testTimeoutBackoff2 {
+ [self testTimeoutBackoffWithTimeout:0.3 Backoff:0.8];
+}
+
+- (void)testCompression {
+ __weak XCTestExpectation *completion = [self expectationWithDescription:@"RPC completed."];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ request.expectCompressed = [RMTBoolValue message];
+ request.expectCompressed.value = YES;
+ request.responseCompressed = [RMTBoolValue message];
+ request.expectCompressed.value = YES;
+ request.responseSize = kSimpleDataLength;
+ request.payload.body = [NSMutableData dataWithLength:kSimpleDataLength];
+ GRPCRequestOptions *requestOptions =
+ [[GRPCRequestOptions alloc] initWithHost:kHostAddress
+ path:kUnaryCallMethod.HTTPPath
+ safety:GRPCCallSafetyDefault];
+
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = GRPCTransportTypeInsecure;
+ options.compressionAlgorithm = GRPCCompressGzip;
+ GRPCCall2 *call = [[GRPCCall2 alloc]
+ initWithRequestOptions:requestOptions
+ responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ messageCallback:^(NSData *data) {
+ NSError *error;
+ RMTSimpleResponse *response =
+ [RMTSimpleResponse parseFromData:data error:&error];
+ XCTAssertNil(error, @"Error when parsing response: %@", error);
+ XCTAssertEqual(response.payload.body.length, kSimpleDataLength);
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ XCTAssertNil(error, @"Received failure: %@", error);
+ [completion fulfill];
+ }]
+
+ callOptions:options];
+
+ [call start];
+ [call writeData:[request data]];
+ [call finish];
+
+ [self waitForExpectationsWithTimeout:kTestTimeout handler:nil];
+}
+
+@end
diff --git a/src/objective-c/tests/APIv2Tests/Info.plist b/src/objective-c/tests/APIv2Tests/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/src/objective-c/tests/APIv2Tests/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/src/objective-c/tests/ChannelTests/ChannelPoolTest.m b/src/objective-c/tests/ChannelTests/ChannelPoolTest.m
new file mode 100644
index 0000000000..eab8c5193f
--- /dev/null
+++ b/src/objective-c/tests/ChannelTests/ChannelPoolTest.m
@@ -0,0 +1,63 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <XCTest/XCTest.h>
+
+#import "../../GRPCClient/private/GRPCChannel.h"
+#import "../../GRPCClient/private/GRPCChannelPool+Test.h"
+#import "../../GRPCClient/private/GRPCCompletionQueue.h"
+
+#define TEST_TIMEOUT 32
+
+static NSString *kDummyHost = @"dummy.host";
+static NSString *kDummyHost2 = @"dummy.host.2";
+static NSString *kDummyPath = @"/dummy/path";
+
+@interface ChannelPoolTest : XCTestCase
+
+@end
+
+@implementation ChannelPoolTest
+
++ (void)setUp {
+ grpc_init();
+}
+
+- (void)testCreateAndCacheChannel {
+ GRPCChannelPool *pool = [[GRPCChannelPool alloc] initTestPool];
+ GRPCCallOptions *options1 = [[GRPCCallOptions alloc] init];
+ GRPCCallOptions *options2 = [options1 copy];
+ GRPCMutableCallOptions *options3 = [options1 mutableCopy];
+ options3.transportType = GRPCTransportTypeInsecure;
+
+ GRPCPooledChannel *channel1 = [pool channelWithHost:kDummyHost callOptions:options1];
+ GRPCPooledChannel *channel2 = [pool channelWithHost:kDummyHost callOptions:options2];
+ GRPCPooledChannel *channel3 = [pool channelWithHost:kDummyHost callOptions:options3];
+ GRPCPooledChannel *channel4 = [pool channelWithHost:kDummyHost2 callOptions:options1];
+
+ XCTAssertNotNil(channel1);
+ XCTAssertNotNil(channel2);
+ XCTAssertNotNil(channel3);
+ XCTAssertNotNil(channel4);
+ XCTAssertEqual(channel1, channel2);
+ XCTAssertNotEqual(channel1, channel3);
+ XCTAssertNotEqual(channel1, channel4);
+ XCTAssertNotEqual(channel3, channel4);
+}
+
+@end
diff --git a/src/objective-c/tests/ChannelTests/ChannelTests.m b/src/objective-c/tests/ChannelTests/ChannelTests.m
new file mode 100644
index 0000000000..df78e8b116
--- /dev/null
+++ b/src/objective-c/tests/ChannelTests/ChannelTests.m
@@ -0,0 +1,112 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <XCTest/XCTest.h>
+
+#import "../../GRPCClient/GRPCCallOptions.h"
+#import "../../GRPCClient/private/GRPCChannel.h"
+#import "../../GRPCClient/private/GRPCChannelPool+Test.h"
+#import "../../GRPCClient/private/GRPCChannelPool.h"
+#import "../../GRPCClient/private/GRPCCompletionQueue.h"
+#import "../../GRPCClient/private/GRPCWrappedCall.h"
+
+static NSString *kDummyHost = @"dummy.host";
+static NSString *kDummyPath = @"/dummy/path";
+
+@interface ChannelTests : XCTestCase
+
+@end
+
+@implementation ChannelTests
+
++ (void)setUp {
+ grpc_init();
+}
+
+- (void)testPooledChannelCreatingChannel {
+ GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
+ GRPCChannelConfiguration *config =
+ [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
+ GRPCPooledChannel *channel = [[GRPCPooledChannel alloc] initWithChannelConfiguration:config];
+ GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
+ GRPCWrappedCall *wrappedCall =
+ [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
+ XCTAssertNotNil(channel.wrappedChannel);
+ (void)wrappedCall;
+}
+
+- (void)testTimedDestroyChannel {
+ const NSTimeInterval kDestroyDelay = 1.0;
+ GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
+ GRPCChannelConfiguration *config =
+ [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
+ GRPCPooledChannel *channel =
+ [[GRPCPooledChannel alloc] initWithChannelConfiguration:config destroyDelay:kDestroyDelay];
+ GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
+ GRPCWrappedCall *wrappedCall;
+ GRPCChannel *wrappedChannel;
+ @autoreleasepool {
+ wrappedCall = [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
+ XCTAssertNotNil(channel.wrappedChannel);
+
+ // Unref and ref channel immediately; expect using the same raw channel.
+ wrappedChannel = channel.wrappedChannel;
+
+ wrappedCall = nil;
+ wrappedCall = [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
+ XCTAssertEqual(channel.wrappedChannel, wrappedChannel);
+
+ // Unref and ref channel after destroy delay; expect a new raw channel.
+ wrappedCall = nil;
+ }
+ sleep(kDestroyDelay + 1);
+ XCTAssertNil(channel.wrappedChannel);
+ wrappedCall = [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
+ XCTAssertNotEqual(channel.wrappedChannel, wrappedChannel);
+}
+
+- (void)testDisconnect {
+ const NSTimeInterval kDestroyDelay = 1.0;
+ GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
+ GRPCChannelConfiguration *config =
+ [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
+ GRPCPooledChannel *channel =
+ [[GRPCPooledChannel alloc] initWithChannelConfiguration:config destroyDelay:kDestroyDelay];
+ GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
+ GRPCWrappedCall *wrappedCall =
+ [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
+ XCTAssertNotNil(channel.wrappedChannel);
+
+ // Disconnect; expect wrapped channel to be dropped
+ [channel disconnect];
+ XCTAssertNil(channel.wrappedChannel);
+
+ // Create a new call and unref the old call; confirm that destroy of the old call does not make
+ // the channel disconnect, even after the destroy delay.
+ GRPCWrappedCall *wrappedCall2 =
+ [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
+ XCTAssertNotNil(channel.wrappedChannel);
+ GRPCChannel *wrappedChannel = channel.wrappedChannel;
+ wrappedCall = nil;
+ sleep(kDestroyDelay + 1);
+ XCTAssertNotNil(channel.wrappedChannel);
+ XCTAssertEqual(wrappedChannel, channel.wrappedChannel);
+ (void)wrappedCall2;
+}
+
+@end
diff --git a/src/objective-c/tests/ChannelTests/Info.plist b/src/objective-c/tests/ChannelTests/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/src/objective-c/tests/ChannelTests/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm
index 80fa0f4785..fe85e915d4 100644
--- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm
+++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.mm
@@ -81,13 +81,7 @@ static void cronet_init_client_secure_fullstack(grpc_end2end_test_fixture *f,
grpc_channel_args *client_args,
stream_engine *cronetEngine) {
fullstack_secure_fixture_data *ffd = (fullstack_secure_fixture_data *)f->fixture_data;
- grpc_arg arg;
- arg.key = const_cast<char *>(GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER);
- arg.type = GRPC_ARG_INTEGER;
- arg.value.integer = 1;
- client_args = grpc_channel_args_copy_and_add(client_args, &arg, 1);
f->client = grpc_cronet_secure_channel_create(cronetEngine, ffd->localaddr, client_args, NULL);
- grpc_channel_args_destroy(client_args);
GPR_ASSERT(f->client != NULL);
}
diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
index 84893b92c1..d732bc6ba9 100644
--- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
+++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m
@@ -124,14 +124,6 @@ unsigned int parse_h2_length(const char *field) {
((unsigned int)(unsigned char)(field[2]));
}
-grpc_channel_args *add_disable_client_authority_filter_args(grpc_channel_args *args) {
- grpc_arg arg;
- arg.key = const_cast<char *>(GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER);
- arg.type = GRPC_ARG_INTEGER;
- arg.value.integer = 1;
- return grpc_channel_args_copy_and_add(args, &arg, 1);
-}
-
- (void)testInternalError {
grpc_call *c;
grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world");
@@ -151,9 +143,7 @@ grpc_channel_args *add_disable_client_authority_filter_args(grpc_channel_args *a
gpr_join_host_port(&addr, "127.0.0.1", port);
grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL);
stream_engine *cronetEngine = [Cronet getGlobalEngine];
- grpc_channel_args *client_args = add_disable_client_authority_filter_args(NULL);
- grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, client_args, NULL);
- grpc_channel_args_destroy(client_args);
+ grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, NULL, NULL);
cq_verifier *cqv = cq_verifier_create(cq);
grpc_op ops[6];
@@ -265,7 +255,6 @@ grpc_channel_args *add_disable_client_authority_filter_args(grpc_channel_args *a
arg.type = GRPC_ARG_INTEGER;
arg.value.integer = useCoalescing ? 1 : 0;
grpc_channel_args *args = grpc_channel_args_copy_and_add(NULL, &arg, 1);
- args = add_disable_client_authority_filter_args(args);
grpc_call *c;
grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world");
diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m
index a0de8ba899..3ef046835e 100644
--- a/src/objective-c/tests/GRPCClientTests.m
+++ b/src/objective-c/tests/GRPCClientTests.m
@@ -362,9 +362,10 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
// TODO(makarandd): Move to a different file that contains only unit tests
- (void)testExceptions {
+ GRXWriter *writer = [GRXWriter writerWithValue:[NSData data]];
// Try to set parameters to nil for GRPCCall. This should cause an exception
@try {
- (void)[[GRPCCall alloc] initWithHost:nil path:nil requestsWriter:nil];
+ (void)[[GRPCCall alloc] initWithHost:nil path:nil requestsWriter:writer];
XCTFail(@"Did not receive an exception when parameters are nil");
} @catch (NSException *theException) {
NSLog(@"Received exception as expected: %@", theException.name);
@@ -554,13 +555,14 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
__weak XCTestExpectation *completion = [self expectationWithDescription:@"Timeout in a second."];
NSString *const kDummyAddress = [NSString stringWithFormat:@"8.8.8.8:1"];
- GRPCCall *call = [[GRPCCall alloc] initWithHost:kDummyAddress
- path:@""
- requestsWriter:[GRXWriter writerWithValue:[NSData data]]];
+ [GRPCCall useInsecureConnectionsForHost:kDummyAddress];
[GRPCCall setMinConnectTimeout:timeout * 1000
initialBackoff:backoff * 1000
maxBackoff:0
forHost:kDummyAddress];
+ GRPCCall *call = [[GRPCCall alloc] initWithHost:kDummyAddress
+ path:@"/dummyPath"
+ requestsWriter:[GRXWriter writerWithValue:[NSData data]]];
NSDate *startTime = [NSDate date];
id<GRXWriteable> responsesWriteable = [[GRXWriteable alloc] initWithValueHandler:^(id value) {
XCTAssert(NO, @"Received message. Should not reach here");
@@ -583,11 +585,11 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
// The numbers of the following three tests are selected to be smaller than the default values of
// initial backoff (1s) and min_connect_timeout (20s), so that if they fail we know the default
// values fail to be overridden by the channel args.
-- (void)testTimeoutBackoff2 {
+- (void)testTimeoutBackoff1 {
[self testTimeoutBackoffWithTimeout:0.7 Backoff:0.3];
}
-- (void)testTimeoutBackoff3 {
+- (void)testTimeoutBackoff2 {
[self testTimeoutBackoffWithTimeout:0.3 Backoff:0.7];
}
diff --git a/src/objective-c/tests/InteropTests.h b/src/objective-c/tests/InteropTests.h
index 039d92a8d3..038f24b62e 100644
--- a/src/objective-c/tests/InteropTests.h
+++ b/src/objective-c/tests/InteropTests.h
@@ -18,6 +18,8 @@
#import <XCTest/XCTest.h>
+#import <GRPCClient/GRPCCallOptions.h>
+
/**
* Implements tests as described here:
* https://github.com/grpc/grpc/blob/master/doc/interop-test-descriptions.md
@@ -38,4 +40,23 @@
* remote servers enconde responses with different overhead (?), so this is defined per-subclass.
*/
- (int32_t)encodingOverhead;
+
+/**
+ * The type of transport to be used. The base implementation returns default. Subclasses should
+ * override to appropriate settings.
+ */
++ (GRPCTransportType)transportType;
+
+/**
+ * The root certificates to be used. The base implementation returns nil. Subclasses should override
+ * to appropriate settings.
+ */
++ (NSString *)PEMRootCertificates;
+
+/**
+ * The root certificates to be used. The base implementation returns nil. Subclasses should override
+ * to appropriate settings.
+ */
++ (NSString *)hostNameOverride;
+
@end
diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m
index 9d79606881..717dfd81f7 100644
--- a/src/objective-c/tests/InteropTests.m
+++ b/src/objective-c/tests/InteropTests.m
@@ -74,6 +74,58 @@ BOOL isRemoteInteropTest(NSString *host) {
return [host isEqualToString:@"grpc-test.sandbox.googleapis.com"];
}
+// Convenience class to use blocks as callbacks
+@interface InteropTestsBlockCallbacks : NSObject<GRPCProtoResponseHandler>
+
+- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
+ messageCallback:(void (^)(id))messageCallback
+ closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback;
+
+@end
+
+@implementation InteropTestsBlockCallbacks {
+ void (^_initialMetadataCallback)(NSDictionary *);
+ void (^_messageCallback)(id);
+ void (^_closeCallback)(NSDictionary *, NSError *);
+ dispatch_queue_t _dispatchQueue;
+}
+
+- (instancetype)initWithInitialMetadataCallback:(void (^)(NSDictionary *))initialMetadataCallback
+ messageCallback:(void (^)(id))messageCallback
+ closeCallback:(void (^)(NSDictionary *, NSError *))closeCallback {
+ if ((self = [super init])) {
+ _initialMetadataCallback = initialMetadataCallback;
+ _messageCallback = messageCallback;
+ _closeCallback = closeCallback;
+ _dispatchQueue = dispatch_queue_create(nil, DISPATCH_QUEUE_SERIAL);
+ }
+ return self;
+}
+
+- (void)didReceiveInitialMetadata:(NSDictionary *)initialMetadata {
+ if (_initialMetadataCallback) {
+ _initialMetadataCallback(initialMetadata);
+ }
+}
+
+- (void)didReceiveProtoMessage:(GPBMessage *)message {
+ if (_messageCallback) {
+ _messageCallback(message);
+ }
+}
+
+- (void)didCloseWithTrailingMetadata:(NSDictionary *)trailingMetadata error:(NSError *)error {
+ if (_closeCallback) {
+ _closeCallback(trailingMetadata, error);
+ }
+}
+
+- (dispatch_queue_t)dispatchQueue {
+ return _dispatchQueue;
+}
+
+@end
+
#pragma mark Tests
@implementation InteropTests {
@@ -91,6 +143,18 @@ BOOL isRemoteInteropTest(NSString *host) {
return 0;
}
++ (GRPCTransportType)transportType {
+ return GRPCTransportTypeChttp2BoringSSL;
+}
+
++ (NSString *)PEMRootCertificates {
+ return nil;
+}
+
++ (NSString *)hostNameOverride {
+ return nil;
+}
+
+ (void)setUp {
NSLog(@"InteropTest Started, class: %@", [[self class] description]);
#ifdef GRPC_COMPILE_WITH_CRONET
@@ -109,11 +173,11 @@ BOOL isRemoteInteropTest(NSString *host) {
[GRPCCall resetHostSettings];
- _service = self.class.host ? [RMTTestService serviceWithHost:self.class.host] : nil;
+ _service = [[self class] host] ? [RMTTestService serviceWithHost:[[self class] host]] : nil;
}
- (void)testEmptyUnaryRPC {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
GPBEmpty *request = [GPBEmpty message];
@@ -131,8 +195,40 @@ BOOL isRemoteInteropTest(NSString *host) {
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
+- (void)testEmptyUnaryRPCWithV2API {
+ XCTAssertNotNil([[self class] host]);
+ __weak XCTestExpectation *expectReceive =
+ [self expectationWithDescription:@"EmptyUnaryWithV2API received message"];
+ __weak XCTestExpectation *expectComplete =
+ [self expectationWithDescription:@"EmptyUnaryWithV2API completed"];
+
+ GPBEmpty *request = [GPBEmpty message];
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = [[self class] transportType];
+ options.PEMRootCertificates = [[self class] PEMRootCertificates];
+ options.hostNameOverride = [[self class] hostNameOverride];
+
+ GRPCUnaryProtoCall *call = [_service
+ emptyCallWithMessage:request
+ responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ if (message) {
+ id expectedResponse = [GPBEmpty message];
+ XCTAssertEqualObjects(message, expectedResponse);
+ [expectReceive fulfill];
+ }
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ XCTAssertNil(error, @"Unexpected error: %@", error);
+ [expectComplete fulfill];
+ }]
+ callOptions:options];
+ [call start];
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
- (void)testLargeUnaryRPC {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@@ -155,8 +251,50 @@ BOOL isRemoteInteropTest(NSString *host) {
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
+- (void)testLargeUnaryRPCWithV2API {
+ XCTAssertNotNil([[self class] host]);
+ __weak XCTestExpectation *expectReceive =
+ [self expectationWithDescription:@"LargeUnaryWithV2API received message"];
+ __weak XCTestExpectation *expectComplete =
+ [self expectationWithDescription:@"LargeUnaryWithV2API received complete"];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ request.responseType = RMTPayloadType_Compressable;
+ request.responseSize = 314159;
+ request.payload.body = [NSMutableData dataWithLength:271828];
+
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = [[self class] transportType];
+ options.PEMRootCertificates = [[self class] PEMRootCertificates];
+ options.hostNameOverride = [[self class] hostNameOverride];
+
+ GRPCUnaryProtoCall *call = [_service
+ unaryCallWithMessage:request
+ responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ XCTAssertNotNil(message);
+ if (message) {
+ RMTSimpleResponse *expectedResponse =
+ [RMTSimpleResponse message];
+ expectedResponse.payload.type = RMTPayloadType_Compressable;
+ expectedResponse.payload.body =
+ [NSMutableData dataWithLength:314159];
+ XCTAssertEqualObjects(message, expectedResponse);
+
+ [expectReceive fulfill];
+ }
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ XCTAssertNil(error, @"Unexpected error: %@", error);
+ [expectComplete fulfill];
+ }]
+ callOptions:options];
+ [call start];
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
- (void)testPacketCoalescing {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@@ -195,7 +333,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)test4MBResponsesAreAccepted {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"MaxResponseSize"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@@ -213,7 +351,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testResponsesOverMaxSizeFailWithActionableMessage {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@@ -239,7 +377,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testResponsesOver4MBAreAcceptedIfOptedIn {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation =
[self expectationWithDescription:@"HigherResponseSizeLimit"];
@@ -247,7 +385,7 @@ BOOL isRemoteInteropTest(NSString *host) {
const size_t kPayloadSize = 5 * 1024 * 1024; // 5MB
request.responseSize = kPayloadSize;
- [GRPCCall setResponseSizeLimit:6 * 1024 * 1024 forHost:self.class.host];
+ [GRPCCall setResponseSizeLimit:6 * 1024 * 1024 forHost:[[self class] host]];
[_service unaryCallWithRequest:request
handler:^(RMTSimpleResponse *response, NSError *error) {
@@ -260,7 +398,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testClientStreamingRPC {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ClientStreaming"];
RMTStreamingInputCallRequest *request1 = [RMTStreamingInputCallRequest message];
@@ -295,7 +433,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testServerStreamingRPC {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"ServerStreaming"];
NSArray *expectedSizes = @[ @31415, @9, @2653, @58979 ];
@@ -334,7 +472,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testPingPongRPC {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPong"];
NSArray *requests = @[ @27182, @8, @1828, @45904 ];
@@ -380,8 +518,60 @@ BOOL isRemoteInteropTest(NSString *host) {
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
+- (void)testPingPongRPCWithV2API {
+ XCTAssertNotNil([[self class] host]);
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPongWithV2API"];
+
+ NSArray *requests = @[ @27182, @8, @1828, @45904 ];
+ NSArray *responses = @[ @31415, @9, @2653, @58979 ];
+
+ __block int index = 0;
+
+ id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index]
+ requestedResponseSize:responses[index]];
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = [[self class] transportType];
+ options.PEMRootCertificates = [[self class] PEMRootCertificates];
+ options.hostNameOverride = [[self class] hostNameOverride];
+
+ __block GRPCStreamingProtoCall *call = [_service
+ fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
+ initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ XCTAssertLessThan(index, 4,
+ @"More than 4 responses received.");
+ id expected = [RMTStreamingOutputCallResponse
+ messageWithPayloadSize:responses[index]];
+ XCTAssertEqualObjects(message, expected);
+ index += 1;
+ if (index < 4) {
+ id request = [RMTStreamingOutputCallRequest
+ messageWithPayloadSize:requests[index]
+ requestedResponseSize:responses[index]];
+ [call writeMessage:request];
+ } else {
+ [call finish];
+ }
+ }
+ closeCallback:^(NSDictionary *trailingMetadata,
+ NSError *error) {
+ XCTAssertNil(error,
+ @"Finished with unexpected error: %@",
+ error);
+ XCTAssertEqual(index, 4,
+ @"Received %i responses instead of 4.",
+ index);
+ [expectation fulfill];
+ }]
+ callOptions:options];
+ [call start];
+ [call writeMessage:request];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
- (void)testEmptyStreamRPC {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyStream"];
[_service fullDuplexCallWithRequestsWriter:[GRXWriter emptyWriter]
eventHandler:^(BOOL done, RMTStreamingOutputCallResponse *response,
@@ -394,7 +584,7 @@ BOOL isRemoteInteropTest(NSString *host) {
}
- (void)testCancelAfterBeginRPC {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterBegin"];
// A buffered pipe to which we never write any value acts as a writer that just hangs.
@@ -418,8 +608,32 @@ BOOL isRemoteInteropTest(NSString *host) {
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
+- (void)testCancelAfterBeginRPCWithV2API {
+ XCTAssertNotNil([[self class] host]);
+ __weak XCTestExpectation *expectation =
+ [self expectationWithDescription:@"CancelAfterBeginWithV2API"];
+
+ // A buffered pipe to which we never write any value acts as a writer that just hangs.
+ __block GRPCStreamingProtoCall *call = [_service
+ streamingInputCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
+ initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ XCTFail(@"Not expected to receive message");
+ }
+ closeCallback:^(NSDictionary *trailingMetadata,
+ NSError *error) {
+ XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED);
+ [expectation fulfill];
+ }]
+ callOptions:nil];
+ [call start];
+ [call cancel];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
- (void)testCancelAfterFirstResponseRPC {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation =
[self expectationWithDescription:@"CancelAfterFirstResponse"];
@@ -454,8 +668,76 @@ BOOL isRemoteInteropTest(NSString *host) {
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
+- (void)testCancelAfterFirstResponseRPCWithV2API {
+ XCTAssertNotNil([[self class] host]);
+ __weak XCTestExpectation *completionExpectation =
+ [self expectationWithDescription:@"Call completed."];
+ __weak XCTestExpectation *responseExpectation =
+ [self expectationWithDescription:@"Received response."];
+
+ __block BOOL receivedResponse = NO;
+
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = self.class.transportType;
+ options.PEMRootCertificates = self.class.PEMRootCertificates;
+ options.hostNameOverride = [[self class] hostNameOverride];
+
+ id request =
+ [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415];
+
+ __block GRPCStreamingProtoCall *call = [_service
+ fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
+ initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ XCTAssertFalse(receivedResponse);
+ receivedResponse = YES;
+ [call cancel];
+ [responseExpectation fulfill];
+ }
+ closeCallback:^(NSDictionary *trailingMetadata,
+ NSError *error) {
+ XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED);
+ [completionExpectation fulfill];
+ }]
+ callOptions:options];
+ [call start];
+ [call writeMessage:request];
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
+- (void)testCancelAfterFirstRequestWithV2API {
+ XCTAssertNotNil([[self class] host]);
+ __weak XCTestExpectation *completionExpectation =
+ [self expectationWithDescription:@"Call completed."];
+
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = self.class.transportType;
+ options.PEMRootCertificates = self.class.PEMRootCertificates;
+ options.hostNameOverride = [[self class] hostNameOverride];
+
+ id request =
+ [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415];
+
+ __block GRPCStreamingProtoCall *call = [_service
+ fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
+ initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ XCTFail(@"Received unexpected response.");
+ }
+ closeCallback:^(NSDictionary *trailingMetadata,
+ NSError *error) {
+ XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED);
+ [completionExpectation fulfill];
+ }]
+ callOptions:options];
+ [call start];
+ [call writeMessage:request];
+ [call cancel];
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
- (void)testRPCAfterClosingOpenConnections {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation =
[self expectationWithDescription:@"RPC after closing connection"];
@@ -487,10 +769,10 @@ BOOL isRemoteInteropTest(NSString *host) {
- (void)testCompressedUnaryRPC {
// This test needs to be disabled for remote test because interop server grpc-test
// does not support compression.
- if (isRemoteInteropTest(self.class.host)) {
+ if (isRemoteInteropTest([[self class] host])) {
return;
}
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
@@ -498,7 +780,7 @@ BOOL isRemoteInteropTest(NSString *host) {
request.responseSize = 314159;
request.payload.body = [NSMutableData dataWithLength:271828];
request.expectCompressed.value = YES;
- [GRPCCall setDefaultCompressMethod:GRPCCompressGzip forhost:self.class.host];
+ [GRPCCall setDefaultCompressMethod:GRPCCompressGzip forhost:[[self class] host]];
[_service unaryCallWithRequest:request
handler:^(RMTSimpleResponse *response, NSError *error) {
@@ -517,10 +799,10 @@ BOOL isRemoteInteropTest(NSString *host) {
#ifndef GRPC_COMPILE_WITH_CRONET
- (void)testKeepalive {
- XCTAssertNotNil(self.class.host);
+ XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"Keepalive"];
- [GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:self.class.host];
+ [GRPCCall setKeepaliveWithInterval:1500 timeout:0 forHost:[[self class] host]];
NSArray *requests = @[ @27182, @8 ];
NSArray *responses = @[ @31415, @9 ];
diff --git a/src/objective-c/tests/InteropTestsCallOptions/Info.plist b/src/objective-c/tests/InteropTestsCallOptions/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/src/objective-c/tests/InteropTestsCallOptions/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/src/objective-c/tests/InteropTestsCallOptions/InteropTestsCallOptions.m b/src/objective-c/tests/InteropTestsCallOptions/InteropTestsCallOptions.m
new file mode 100644
index 0000000000..db51cb1cfb
--- /dev/null
+++ b/src/objective-c/tests/InteropTestsCallOptions/InteropTestsCallOptions.m
@@ -0,0 +1,116 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <XCTest/XCTest.h>
+
+#import <RemoteTest/Messages.pbobjc.h>
+#import <RemoteTest/Test.pbobjc.h>
+#import <RemoteTest/Test.pbrpc.h>
+#import <RxLibrary/GRXBufferedPipe.h>
+#import <RxLibrary/GRXWriter+Immediate.h>
+#import <grpc/grpc.h>
+
+#define NSStringize_helper(x) #x
+#define NSStringize(x) @NSStringize_helper(x)
+static NSString *kRemoteHost = NSStringize(HOST_PORT_REMOTE);
+const int32_t kRemoteInteropServerOverhead = 12;
+
+static const NSTimeInterval TEST_TIMEOUT = 16000;
+
+@interface InteropTestsCallOptions : XCTestCase
+
+@end
+
+@implementation InteropTestsCallOptions {
+ RMTTestService *_service;
+}
+
+- (void)setUp {
+ self.continueAfterFailure = NO;
+ _service = [RMTTestService serviceWithHost:kRemoteHost];
+ _service.options = [[GRPCCallOptions alloc] init];
+}
+
+- (void)test4MBResponsesAreAccepted {
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"MaxResponseSize"];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ const int32_t kPayloadSize =
+ 4 * 1024 * 1024 - kRemoteInteropServerOverhead; // 4MB - encoding overhead
+ request.responseSize = kPayloadSize;
+
+ [_service unaryCallWithRequest:request
+ handler:^(RMTSimpleResponse *response, NSError *error) {
+ XCTAssertNil(error, @"Finished with unexpected error: %@", error);
+ XCTAssertEqual(response.payload.body.length, kPayloadSize);
+ [expectation fulfill];
+ }];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
+- (void)testResponsesOverMaxSizeFailWithActionableMessage {
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ResponseOverMaxSize"];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ const int32_t kPayloadSize =
+ 4 * 1024 * 1024 - kRemoteInteropServerOverhead + 1; // 1B over max size
+ request.responseSize = kPayloadSize;
+
+ [_service unaryCallWithRequest:request
+ handler:^(RMTSimpleResponse *response, NSError *error) {
+ XCTAssertEqualObjects(
+ error.localizedDescription,
+ @"Received message larger than max (4194305 vs. 4194304)");
+ [expectation fulfill];
+ }];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
+- (void)testResponsesOver4MBAreAcceptedIfOptedIn {
+ __weak XCTestExpectation *expectation =
+ [self expectationWithDescription:@"HigherResponseSizeLimit"];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ const size_t kPayloadSize = 5 * 1024 * 1024; // 5MB
+ request.responseSize = kPayloadSize;
+
+ GRPCProtoCall *rpc = [_service
+ RPCToUnaryCallWithRequest:request
+ handler:^(RMTSimpleResponse *response, NSError *error) {
+ XCTAssertNil(error, @"Finished with unexpected error: %@", error);
+ XCTAssertEqual(response.payload.body.length, kPayloadSize);
+ [expectation fulfill];
+ }];
+ GRPCCallOptions *options = rpc.options;
+ options.responseSizeLimit = 6 * 1024 * 1024;
+
+ [rpc start];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
+- (void)testPerformanceExample {
+ // This is an example of a performance test case.
+ [self measureBlock:^{
+ // Put the code you want to measure the time of here.
+ }];
+}
+
+@end
diff --git a/src/objective-c/tests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTestsLocalCleartext.m
index d49e875bd0..a9c6918333 100644
--- a/src/objective-c/tests/InteropTestsLocalCleartext.m
+++ b/src/objective-c/tests/InteropTestsLocalCleartext.m
@@ -41,6 +41,14 @@ static int32_t kLocalInteropServerOverhead = 10;
return kLocalCleartextHost;
}
++ (NSString *)PEMRootCertificates {
+ return nil;
+}
+
++ (NSString *)hostNameOverride {
+ return nil;
+}
+
- (int32_t)encodingOverhead {
return kLocalInteropServerOverhead; // bytes
}
@@ -52,4 +60,8 @@ static int32_t kLocalInteropServerOverhead = 10;
[GRPCCall useInsecureConnectionsForHost:kLocalCleartextHost];
}
++ (GRPCTransportType)transportType {
+ return GRPCTransportTypeInsecure;
+}
+
@end
diff --git a/src/objective-c/tests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTestsLocalSSL.m
index a8c4dc7dfd..e8222f602f 100644
--- a/src/objective-c/tests/InteropTestsLocalSSL.m
+++ b/src/objective-c/tests/InteropTestsLocalSSL.m
@@ -40,15 +40,31 @@ static int32_t kLocalInteropServerOverhead = 10;
return kLocalSSLHost;
}
++ (NSString *)PEMRootCertificates {
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *certsPath =
+ [bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
+ NSError *error;
+ return [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
+}
+
++ (NSString *)hostNameOverride {
+ return @"foo.test.google.fr";
+}
+
- (int32_t)encodingOverhead {
return kLocalInteropServerOverhead; // bytes
}
++ (GRPCTransportType)transportType {
+ return GRPCTransportTypeChttp2BoringSSL;
+}
+
- (void)setUp {
[super setUp];
// Register test server certificates and name.
- NSBundle *bundle = [NSBundle bundleForClass:self.class];
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *certsPath =
[bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
[GRPCCall useTestCertsPath:certsPath testName:@"foo.test.google.fr" forHost:kLocalSSLHost];
diff --git a/src/objective-c/tests/InteropTestsMultipleChannels/Info.plist b/src/objective-c/tests/InteropTestsMultipleChannels/Info.plist
new file mode 100644
index 0000000000..6c40a6cd0c
--- /dev/null
+++ b/src/objective-c/tests/InteropTestsMultipleChannels/Info.plist
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/src/objective-c/tests/InteropTestsMultipleChannels/InteropTestsMultipleChannels.m b/src/objective-c/tests/InteropTestsMultipleChannels/InteropTestsMultipleChannels.m
new file mode 100644
index 0000000000..b0d4e4883a
--- /dev/null
+++ b/src/objective-c/tests/InteropTestsMultipleChannels/InteropTestsMultipleChannels.m
@@ -0,0 +1,259 @@
+/*
+ *
+ * Copyright 2018 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.
+ *
+ */
+
+#import <XCTest/XCTest.h>
+
+#import <Cronet/Cronet.h>
+#import <RemoteTest/Messages.pbobjc.h>
+#import <RemoteTest/Test.pbobjc.h>
+#import <RemoteTest/Test.pbrpc.h>
+#import <RxLibrary/GRXBufferedPipe.h>
+
+#define NSStringize_helper(x) #x
+#define NSStringize(x) @NSStringize_helper(x)
+static NSString *const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE);
+static NSString *const kLocalSSLHost = NSStringize(HOST_PORT_LOCALSSL);
+static NSString *const kLocalCleartextHost = NSStringize(HOST_PORT_LOCAL);
+
+static const NSTimeInterval TEST_TIMEOUT = 8000;
+
+@interface RMTStreamingOutputCallRequest (Constructors)
++ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize
+ requestedResponseSize:(NSNumber *)responseSize;
+@end
+
+@implementation RMTStreamingOutputCallRequest (Constructors)
++ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize
+ requestedResponseSize:(NSNumber *)responseSize {
+ RMTStreamingOutputCallRequest *request = [self message];
+ RMTResponseParameters *parameters = [RMTResponseParameters message];
+ parameters.size = responseSize.intValue;
+ [request.responseParametersArray addObject:parameters];
+ request.payload.body = [NSMutableData dataWithLength:payloadSize.unsignedIntegerValue];
+ return request;
+}
+@end
+
+@interface RMTStreamingOutputCallResponse (Constructors)
++ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize;
+@end
+
+@implementation RMTStreamingOutputCallResponse (Constructors)
++ (instancetype)messageWithPayloadSize:(NSNumber *)payloadSize {
+ RMTStreamingOutputCallResponse *response = [self message];
+ response.payload.type = RMTPayloadType_Compressable;
+ response.payload.body = [NSMutableData dataWithLength:payloadSize.unsignedIntegerValue];
+ return response;
+}
+@end
+
+@interface InteropTestsMultipleChannels : XCTestCase
+
+@end
+
+dispatch_once_t initCronet;
+
+@implementation InteropTestsMultipleChannels {
+ RMTTestService *_remoteService;
+ RMTTestService *_remoteCronetService;
+ RMTTestService *_localCleartextService;
+ RMTTestService *_localSSLService;
+}
+
+- (void)setUp {
+ [super setUp];
+
+ self.continueAfterFailure = NO;
+
+ // Default stack with remote host
+ _remoteService = [RMTTestService serviceWithHost:kRemoteSSLHost];
+
+ // Cronet stack with remote host
+ _remoteCronetService = [RMTTestService serviceWithHost:kRemoteSSLHost];
+
+ dispatch_once(&initCronet, ^{
+ [Cronet setHttp2Enabled:YES];
+ [Cronet start];
+ });
+
+ GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
+ options.transportType = GRPCTransportTypeCronet;
+ options.cronetEngine = [Cronet getGlobalEngine];
+ _remoteCronetService.options = options;
+
+ // Local stack with no SSL
+ _localCleartextService = [RMTTestService serviceWithHost:kLocalCleartextHost];
+ options = [[GRPCCallOptions alloc] init];
+ options.transportType = GRPCTransportTypeInsecure;
+ _localCleartextService.options = options;
+
+ // Local stack with SSL
+ _localSSLService = [RMTTestService serviceWithHost:kLocalSSLHost];
+
+ NSBundle *bundle = [NSBundle bundleForClass:[self class]];
+ NSString *certsPath =
+ [bundle pathForResource:@"TestCertificates.bundle/test-certificates" ofType:@"pem"];
+ NSError *error = nil;
+ NSString *certs =
+ [NSString stringWithContentsOfFile:certsPath encoding:NSUTF8StringEncoding error:&error];
+ XCTAssertNil(error);
+
+ options = [[GRPCCallOptions alloc] init];
+ options.transportType = GRPCTransportTypeChttp2BoringSSL;
+ options.PEMRootCertificates = certs;
+ options.hostNameOverride = @"foo.test.google.fr";
+ _localSSLService.options = options;
+}
+
+- (void)testEmptyUnaryRPC {
+ __weak XCTestExpectation *expectRemote = [self expectationWithDescription:@"Remote RPC finish"];
+ __weak XCTestExpectation *expectCronetRemote =
+ [self expectationWithDescription:@"Remote RPC finish"];
+ __weak XCTestExpectation *expectCleartext =
+ [self expectationWithDescription:@"Remote RPC finish"];
+ __weak XCTestExpectation *expectSSL = [self expectationWithDescription:@"Remote RPC finish"];
+
+ GPBEmpty *request = [GPBEmpty message];
+
+ void (^handler)(GPBEmpty *response, NSError *error) = ^(GPBEmpty *response, NSError *error) {
+ XCTAssertNil(error, @"Finished with unexpected error: %@", error);
+
+ id expectedResponse = [GPBEmpty message];
+ XCTAssertEqualObjects(response, expectedResponse);
+ };
+
+ [_remoteService emptyCallWithRequest:request
+ handler:^(GPBEmpty *response, NSError *error) {
+ handler(response, error);
+ [expectRemote fulfill];
+ }];
+ [_remoteCronetService emptyCallWithRequest:request
+ handler:^(GPBEmpty *response, NSError *error) {
+ handler(response, error);
+ [expectCronetRemote fulfill];
+ }];
+ [_localCleartextService emptyCallWithRequest:request
+ handler:^(GPBEmpty *response, NSError *error) {
+ handler(response, error);
+ [expectCleartext fulfill];
+ }];
+ [_localSSLService emptyCallWithRequest:request
+ handler:^(GPBEmpty *response, NSError *error) {
+ handler(response, error);
+ [expectSSL fulfill];
+ }];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
+- (void)testFullDuplexRPC {
+ __weak XCTestExpectation *expectRemote = [self expectationWithDescription:@"Remote RPC finish"];
+ __weak XCTestExpectation *expectCronetRemote =
+ [self expectationWithDescription:@"Remote RPC finish"];
+ __weak XCTestExpectation *expectCleartext =
+ [self expectationWithDescription:@"Remote RPC finish"];
+ __weak XCTestExpectation *expectSSL = [self expectationWithDescription:@"Remote RPC finish"];
+
+ NSArray *requestSizes = @[ @100, @101, @102, @103 ];
+ NSArray *responseSizes = @[ @104, @105, @106, @107 ];
+ XCTAssertEqual([requestSizes count], [responseSizes count]);
+ NSUInteger kRounds = [requestSizes count];
+
+ NSMutableArray *requests = [NSMutableArray arrayWithCapacity:kRounds];
+ NSMutableArray *responses = [NSMutableArray arrayWithCapacity:kRounds];
+ for (int i = 0; i < kRounds; i++) {
+ requests[i] = [RMTStreamingOutputCallRequest messageWithPayloadSize:requestSizes[i]
+ requestedResponseSize:responseSizes[i]];
+ responses[i] = [RMTStreamingOutputCallResponse messageWithPayloadSize:responseSizes[i]];
+ }
+
+ __block NSMutableArray *steps = [NSMutableArray arrayWithCapacity:4];
+ __block NSMutableArray *requestsBuffers = [NSMutableArray arrayWithCapacity:4];
+ for (int i = 0; i < 4; i++) {
+ steps[i] = [NSNumber numberWithUnsignedInteger:0];
+ requestsBuffers[i] = [[GRXBufferedPipe alloc] init];
+ [requestsBuffers[i] writeValue:requests[0]];
+ }
+
+ BOOL (^handler)(int, BOOL, RMTStreamingOutputCallResponse *, NSError *) =
+ ^(int index, BOOL done, RMTStreamingOutputCallResponse *response, NSError *error) {
+ XCTAssertNil(error, @"Finished with unexpected error: %@", error);
+ XCTAssertTrue(done || response, @"Event handler called without an event.");
+ if (response) {
+ NSUInteger step = [steps[index] unsignedIntegerValue];
+ XCTAssertLessThan(step, kRounds, @"More than %lu responses received.",
+ (unsigned long)kRounds);
+ XCTAssertEqualObjects(response, responses[step]);
+ step++;
+ steps[index] = [NSNumber numberWithUnsignedInteger:step];
+ GRXBufferedPipe *pipe = requestsBuffers[index];
+ if (step < kRounds) {
+ [pipe writeValue:requests[step]];
+ } else {
+ [pipe writesFinishedWithError:nil];
+ }
+ }
+ if (done) {
+ NSUInteger step = [steps[index] unsignedIntegerValue];
+ XCTAssertEqual(step, kRounds, @"Received %lu responses instead of %lu.", step, kRounds);
+ return YES;
+ }
+ return NO;
+ };
+
+ [_remoteService
+ fullDuplexCallWithRequestsWriter:requestsBuffers[0]
+ eventHandler:^(BOOL done,
+ RMTStreamingOutputCallResponse *_Nullable response,
+ NSError *_Nullable error) {
+ if (handler(0, done, response, error)) {
+ [expectRemote fulfill];
+ }
+ }];
+ [_remoteCronetService
+ fullDuplexCallWithRequestsWriter:requestsBuffers[1]
+ eventHandler:^(BOOL done,
+ RMTStreamingOutputCallResponse *_Nullable response,
+ NSError *_Nullable error) {
+ if (handler(1, done, response, error)) {
+ [expectCronetRemote fulfill];
+ }
+ }];
+ [_localCleartextService
+ fullDuplexCallWithRequestsWriter:requestsBuffers[2]
+ eventHandler:^(BOOL done,
+ RMTStreamingOutputCallResponse *_Nullable response,
+ NSError *_Nullable error) {
+ if (handler(2, done, response, error)) {
+ [expectCleartext fulfill];
+ }
+ }];
+ [_localSSLService
+ fullDuplexCallWithRequestsWriter:requestsBuffers[3]
+ eventHandler:^(BOOL done,
+ RMTStreamingOutputCallResponse *_Nullable response,
+ NSError *_Nullable error) {
+ if (handler(3, done, response, error)) {
+ [expectSSL fulfill];
+ }
+ }];
+
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
+@end
diff --git a/src/objective-c/tests/InteropTestsRemote.m b/src/objective-c/tests/InteropTestsRemote.m
index e5738aac73..c1cd9b81ef 100644
--- a/src/objective-c/tests/InteropTestsRemote.m
+++ b/src/objective-c/tests/InteropTestsRemote.m
@@ -41,8 +41,26 @@ static int32_t kRemoteInteropServerOverhead = 12;
return kRemoteSSLHost;
}
++ (NSString *)PEMRootCertificates {
+ return nil;
+}
+
++ (NSString *)hostNameOverride {
+ return nil;
+}
+
- (int32_t)encodingOverhead {
return kRemoteInteropServerOverhead; // bytes
}
+#ifdef GRPC_COMPILE_WITH_CRONET
++ (GRPCTransportType)transportType {
+ return GRPCTransportTypeCronet;
+}
+#else
++ (GRPCTransportType)transportType {
+ return GRPCTransportTypeChttp2BoringSSL;
+}
+#endif
+
@end
diff --git a/src/objective-c/tests/Podfile b/src/objective-c/tests/Podfile
index 5d2f1340da..8e5f588906 100644
--- a/src/objective-c/tests/Podfile
+++ b/src/objective-c/tests/Podfile
@@ -14,7 +14,10 @@ GRPC_LOCAL_SRC = '../../..'
InteropTestsLocalSSL
InteropTestsLocalCleartext
InteropTestsRemoteWithCronet
+ InteropTestsMultipleChannels
+ InteropTestsCallOptions
UnitTests
+ APIv2Tests
).each do |target_name|
target target_name do
pod 'Protobuf', :path => "#{GRPC_LOCAL_SRC}/third_party/protobuf", :inhibit_warnings => true
@@ -30,7 +33,7 @@ GRPC_LOCAL_SRC = '../../..'
pod 'gRPC-ProtoRPC', :path => GRPC_LOCAL_SRC, :inhibit_warnings => true
pod 'RemoteTest', :path => "RemoteTestClient", :inhibit_warnings => true
- if target_name == 'InteropTestsRemoteWithCronet'
+ if target_name == 'InteropTestsRemoteWithCronet' or target_name == 'InteropTestsMultipleChannels'
pod 'gRPC-Core/Cronet-Implementation', :path => GRPC_LOCAL_SRC
pod 'CronetFramework', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c"
end
@@ -72,6 +75,12 @@ end
end
end
+target 'ChannelTests' do
+ pod 'gRPC', :path => GRPC_LOCAL_SRC
+ pod 'gRPC-Core', :path => GRPC_LOCAL_SRC
+ pod 'BoringSSL-GRPC', :podspec => "#{GRPC_LOCAL_SRC}/src/objective-c", :inhibit_warnings => true
+end
+
# gRPC-Core.podspec needs to be modified to be successfully used for local development. A Podfile's
# pre_install hook lets us do that. The block passed to it runs after the podspecs are downloaded
# and before they are installed in the user project.
@@ -139,5 +148,16 @@ post_install do |installer|
end
end
end
+
+ # Enable NSAssert on gRPC
+ if target.name == 'gRPC' || target.name.start_with?('gRPC.') ||
+ target.name == 'ProtoRPC' || target.name.start_with?('ProtoRPC.') ||
+ target.name == 'RxLibrary' || target.name.start_with?('RxLibrary.')
+ target.build_configurations.each do |config|
+ if config.name != 'Release'
+ config.build_settings['ENABLE_NS_ASSERTIONS'] = 'YES'
+ end
+ end
+ end
end
end
diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
index f0d8123263..b6762cc600 100644
--- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
+++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj
@@ -11,14 +11,24 @@
09B76D9585ACE7403804D9DC /* libPods-InteropTestsRemoteWithCronet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */; };
0F9232F984C08643FD40C34F /* libPods-InteropTestsRemote.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */; };
16A9E77B6E336B3C0B9BA6E0 /* libPods-InteropTestsLocalSSL.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */; };
+ 1A0FB7F8C95A2F82538BC950 /* libPods-ChannelTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */; };
20DFDF829DD993A4A00D5662 /* libPods-RxLibraryUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */; };
333E8FC01C8285B7C547D799 /* libPods-InteropTestsLocalCleartext.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */; };
5E0282E9215AA697007AC99D /* UnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E0282E8215AA697007AC99D /* UnitTests.m */; };
5E0282EB215AA697007AC99D /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
+ 5E3B95A521CAC6C500C0A151 /* APIv2Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E3B95A421CAC6C500C0A151 /* APIv2Tests.m */; };
+ 5E7D71AD210954A8001EA6BA /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; };
+ 5E7D71B5210B9EC9001EA6BA /* InteropTestsCallOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 5E7D71B4210B9EC9001EA6BA /* InteropTestsCallOptions.m */; };
+ 5E7D71B7210B9EC9001EA6BA /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
5E8A5DA71D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */; };
5E8A5DA91D3840B4000F8BC4 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
5EAD6D271E27047400002378 /* CronetUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EAD6D261E27047400002378 /* CronetUnitTests.m */; };
5EAD6D291E27047400002378 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
+ 5EB2A2E72107DED300EB4B69 /* ChannelTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB2A2E62107DED300EB4B69 /* ChannelTests.m */; };
+ 5EB2A2E92107DED300EB4B69 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
+ 5EB2A2F82109284500EB4B69 /* InteropTestsMultipleChannels.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB2A2F72109284500EB4B69 /* InteropTestsMultipleChannels.m */; };
+ 5EB2A2FA2109284500EB4B69 /* libTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 635697C71B14FC11007A7283 /* libTests.a */; };
+ 5EB5C3AA21656CEA00ADC300 /* ChannelPoolTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EB5C3A921656CEA00ADC300 /* ChannelPoolTest.m */; };
5EC5E42B2081782C000EF4AD /* InteropTestsRemote.m in Sources */ = {isa = PBXBuildFile; fileRef = 6379CC4F1BE16703001BC0A1 /* InteropTestsRemote.m */; };
5EC5E42C20817832000EF4AD /* InteropTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 635ED2EB1B1A3BC400FDE5C3 /* InteropTests.m */; };
5EC5E43B208185A7000EF4AD /* InteropTestsLocalCleartext.m in Sources */ = {isa = PBXBuildFile; fileRef = 63715F551B780C020029CB0B /* InteropTestsLocalCleartext.m */; };
@@ -53,7 +63,10 @@
63DC84501BE153AA000708E8 /* GRPCClientTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6312AE4D1B1BF49B00341DEE /* GRPCClientTests.m */; };
63E240CE1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m in Sources */ = {isa = PBXBuildFile; fileRef = 63E240CD1B6C4E2B005F3B0E /* InteropTestsLocalSSL.m */; };
63E240D01B6C63DC005F3B0E /* TestCertificates.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */; };
+ 6C1A3F81CCF7C998B4813EFD /* libPods-InteropTestsCallOptions.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */; };
+ 886717A79EFF774F356798E6 /* libPods-InteropTestsMultipleChannels.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 355D0E30AD224763BC9519F4 /* libPods-InteropTestsMultipleChannels.a */; };
91D4B3C85B6D8562F409CB48 /* libPods-InteropTestsLocalSSLCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */; };
+ 98478C9F42329DF769A45B6C /* libPods-APIv2Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */; };
BC111C80CBF7068B62869352 /* libPods-InteropTestsRemoteCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */; };
C3D6F4270A2FFF634D8849ED /* libPods-InteropTestsLocalCleartextCFStream.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */; };
CCF5C0719EF608276AE16374 /* libPods-UnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */; };
@@ -68,6 +81,13 @@
remoteGlobalIDString = 635697C61B14FC11007A7283;
remoteInfo = Tests;
};
+ 5E7D71B8210B9EC9001EA6BA /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 635697BF1B14FC11007A7283 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 635697C61B14FC11007A7283;
+ remoteInfo = Tests;
+ };
5E8A5DAA1D3840B4000F8BC4 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 635697BF1B14FC11007A7283 /* Project object */;
@@ -82,6 +102,20 @@
remoteGlobalIDString = 635697C61B14FC11007A7283;
remoteInfo = Tests;
};
+ 5EB2A2EA2107DED300EB4B69 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 635697BF1B14FC11007A7283 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 635697C61B14FC11007A7283;
+ remoteInfo = Tests;
+ };
+ 5EB2A2FB2109284500EB4B69 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 635697BF1B14FC11007A7283 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 635697C61B14FC11007A7283;
+ remoteInfo = Tests;
+ };
5EE84BF71D4717E40050C6CC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 635697BF1B14FC11007A7283 /* Project object */;
@@ -144,24 +178,33 @@
0A4F89D9C90E9C30990218F0 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartextCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; };
0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.debug.xcconfig"; sourceTree = "<group>"; };
+ 1286B30AD74CB64CD91FB17D /* Pods-APIv2Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.debug.xcconfig"; sourceTree = "<group>"; };
+ 1295CCBD1082B4A7CFCED95F /* Pods-InteropTestsMultipleChannels.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.cronet.xcconfig"; sourceTree = "<group>"; };
+ 12B238CD1702393C2BA5DE80 /* Pods-APIv2Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.release.xcconfig"; sourceTree = "<group>"; };
14B09A58FEE53A7A6B838920 /* Pods-InteropTestsLocalSSL.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.cronet.xcconfig"; sourceTree = "<group>"; };
1588C85DEAF7FC0ACDEA4C02 /* Pods-InteropTestsLocalCleartext.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.test.xcconfig"; sourceTree = "<group>"; };
17F60BF2871F6AF85FB3FA12 /* Pods-InteropTestsRemoteWithCronet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.debug.xcconfig"; sourceTree = "<group>"; };
20DFF2F3C97EF098FE5A3171 /* libPods-Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-UnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.release.xcconfig"; sourceTree = "<group>"; };
2B89F3037963E6EDDD48D8C3 /* Pods-InteropTestsRemoteWithCronet.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.test.xcconfig"; sourceTree = "<group>"; };
303F4A17EB1650FC44603D17 /* Pods-InteropTestsRemoteCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.release.xcconfig"; sourceTree = "<group>"; };
32748C4078AEB05F8F954361 /* Pods-InteropTestsRemoteCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.debug.xcconfig"; sourceTree = "<group>"; };
+ 355D0E30AD224763BC9519F4 /* libPods-InteropTestsMultipleChannels.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsMultipleChannels.a"; sourceTree = BUILT_PRODUCTS_DIR; };
35F2B6BF3BAE8F0DC4AFD76E /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
386712AEACF7C2190C4B8B3F /* Pods-CronetUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.cronet.xcconfig"; sourceTree = "<group>"; };
+ 3A98DF08852F60AF1D96481D /* Pods-InteropTestsCallOptions.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.debug.xcconfig"; sourceTree = "<group>"; };
3B0861FC805389C52DB260D4 /* Pods-RxLibraryUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.release.xcconfig"; sourceTree = "<group>"; };
+ 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.debug.xcconfig"; sourceTree = "<group>"; };
3EB55EF291706E3DDE23C3B7 /* Pods-InteropTestsLocalSSLCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.debug.xcconfig"; sourceTree = "<group>"; };
3F27B2E744482771EB93C394 /* Pods-InteropTestsRemoteWithCronet.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.cronet.xcconfig"; sourceTree = "<group>"; };
41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.test.xcconfig"; sourceTree = "<group>"; };
+ 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ChannelTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4A1A42B2E941CCD453489E5B /* Pods-InteropTestsRemoteCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.cronet.xcconfig"; sourceTree = "<group>"; };
4AD97096D13D7416DC91A72A /* Pods-CoreCronetEnd2EndTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.release.xcconfig"; sourceTree = "<group>"; };
4ADEA1C8BBE10D90940AC68E /* Pods-InteropTestsRemote.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.cronet.xcconfig"; sourceTree = "<group>"; };
51A275E86C141416ED63FF76 /* Pods-InteropTestsLocalCleartext.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.release.xcconfig"; sourceTree = "<group>"; };
+ 51F2A64B7AADBA1B225B132E /* Pods-APIv2Tests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.test.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.test.xcconfig"; sourceTree = "<group>"; };
553BBBED24E4162D1F769D65 /* Pods-InteropTestsLocalSSL.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.debug.xcconfig"; sourceTree = "<group>"; };
55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig"; sourceTree = "<group>"; };
573450F334B331D0BED8B961 /* Pods-CoreCronetEnd2EndTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.cronet.xcconfig"; sourceTree = "<group>"; };
@@ -169,6 +212,12 @@
5E0282E6215AA697007AC99D /* UnitTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnitTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5E0282E8215AA697007AC99D /* UnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UnitTests.m; sourceTree = "<group>"; };
5E0282EA215AA697007AC99D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5E3B95A221CAC6C500C0A151 /* APIv2Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = APIv2Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5E3B95A421CAC6C500C0A151 /* APIv2Tests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = APIv2Tests.m; sourceTree = "<group>"; };
+ 5E3B95A621CAC6C500C0A151 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5E7D71B2210B9EC8001EA6BA /* InteropTestsCallOptions.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsCallOptions.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5E7D71B4210B9EC9001EA6BA /* InteropTestsCallOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsCallOptions.m; sourceTree = "<group>"; };
+ 5E7D71B6210B9EC9001EA6BA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5E8A5DA41D3840B4000F8BC4 /* CoreCronetEnd2EndTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CoreCronetEnd2EndTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5E8A5DA61D3840B4000F8BC4 /* CoreCronetEnd2EndTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CoreCronetEnd2EndTests.mm; sourceTree = "<group>"; };
5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSLCFStream/Pods-InteropTestsLocalSSLCFStream.release.xcconfig"; sourceTree = "<group>"; };
@@ -176,6 +225,13 @@
5EAD6D261E27047400002378 /* CronetUnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CronetUnitTests.m; sourceTree = "<group>"; };
5EAD6D281E27047400002378 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5EAFE8271F8EFB87007F2189 /* version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = version.h; sourceTree = "<group>"; };
+ 5EB2A2E42107DED300EB4B69 /* ChannelTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ChannelTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5EB2A2E62107DED300EB4B69 /* ChannelTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChannelTests.m; sourceTree = "<group>"; };
+ 5EB2A2E82107DED300EB4B69 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5EB2A2F52109284500EB4B69 /* InteropTestsMultipleChannels.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsMultipleChannels.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 5EB2A2F72109284500EB4B69 /* InteropTestsMultipleChannels.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InteropTestsMultipleChannels.m; sourceTree = "<group>"; };
+ 5EB2A2F92109284500EB4B69 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ 5EB5C3A921656CEA00ADC300 /* ChannelPoolTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ChannelPoolTest.m; sourceTree = "<group>"; };
5EC5E421208177CC000EF4AD /* InteropTestsRemoteCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsRemoteCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5EC5E4312081856B000EF4AD /* InteropTestsLocalCleartextCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsLocalCleartextCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
5EC5E442208185CE000EF4AD /* InteropTestsLocalSSLCFStream.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = InteropTestsLocalSSLCFStream.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -200,25 +256,34 @@
63E240CF1B6C63DC005F3B0E /* TestCertificates.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = TestCertificates.bundle; sourceTree = "<group>"; };
64F68A9A6A63CC930DD30A6E /* Pods-CronetUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.debug.xcconfig"; sourceTree = "<group>"; };
6793C9D019CB268C5BB491A2 /* Pods-CoreCronetEnd2EndTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CoreCronetEnd2EndTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests.test.xcconfig"; sourceTree = "<group>"; };
+ 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.cronet.xcconfig"; sourceTree = "<group>"; };
781089FAE980F51F88A3BE0B /* Pods-RxLibraryUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.test.xcconfig"; sourceTree = "<group>"; };
79C68EFFCB5533475D810B79 /* Pods-RxLibraryUnitTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxLibraryUnitTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-RxLibraryUnitTests/Pods-RxLibraryUnitTests.cronet.xcconfig"; sourceTree = "<group>"; };
7A2E97E3F469CC2A758D77DE /* Pods-InteropTestsLocalSSL.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.release.xcconfig"; sourceTree = "<group>"; };
7BA53C6D224288D5870FE6F3 /* Pods-InteropTestsLocalCleartextCFStream.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.release.xcconfig"; sourceTree = "<group>"; };
8B498B05C6DA0818B2FA91D4 /* Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.cronet.xcconfig"; sourceTree = "<group>"; };
+ 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIv2Tests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests.cronet.xcconfig"; sourceTree = "<group>"; };
+ 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.cronet.xcconfig"; sourceTree = "<group>"; };
943138072A9605B5B8DC1FC0 /* Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.debug.xcconfig"; sourceTree = "<group>"; };
94D7A5FAA13480E9A5166D7A /* Pods-UnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.test.xcconfig"; sourceTree = "<group>"; };
9E9444C764F0FFF64A7EB58E /* libPods-InteropTestsRemoteWithCronet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteWithCronet.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.test.xcconfig"; sourceTree = "<group>"; };
A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.debug.xcconfig"; sourceTree = "<group>"; };
A58BE6DF1C62D1739EBB2C78 /* libPods-RxLibraryUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RxLibraryUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
A6F832FCEFA6F6881E620F12 /* Pods-InteropTestsRemote.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.test.xcconfig"; sourceTree = "<group>"; };
AA7CB64B4DD9915AE7C03163 /* Pods-InteropTestsLocalCleartext.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartext.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext.cronet.xcconfig"; sourceTree = "<group>"; };
AC414EF7A6BF76ED02B6E480 /* Pods-InteropTestsRemoteWithCronet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteWithCronet.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteWithCronet/Pods-InteropTestsRemoteWithCronet.release.xcconfig"; sourceTree = "<group>"; };
+ AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsCallOptions.a"; sourceTree = BUILT_PRODUCTS_DIR; };
B226619DC4E709E0FFFF94B8 /* Pods-CronetUnitTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CronetUnitTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-CronetUnitTests/Pods-CronetUnitTests.test.xcconfig"; sourceTree = "<group>"; };
+ B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-APIv2Tests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
B94C27C06733CF98CE1B2757 /* Pods-AllTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.debug.xcconfig"; sourceTree = "<group>"; };
+ BED74BC8ABF9917C66175879 /* Pods-ChannelTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.test.xcconfig"; sourceTree = "<group>"; };
C17F57E5BCB989AB1C2F1F25 /* Pods-InteropTestsRemoteCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemoteCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemoteCFStream/Pods-InteropTestsRemoteCFStream.test.xcconfig"; sourceTree = "<group>"; };
C6134277D2EB8B380862A03F /* libPods-CronetUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CronetUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsCallOptions.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions.release.xcconfig"; sourceTree = "<group>"; };
CAE086D5B470DA367D415AB0 /* libPods-AllTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AllTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
D13BEC8181B8E678A1B52F54 /* Pods-InteropTestsLocalSSL.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalSSL.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL.test.xcconfig"; sourceTree = "<group>"; };
+ D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.release.xcconfig"; sourceTree = "<group>"; };
DB1F4391AF69D20D38D74B67 /* Pods-AllTests.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.test.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.test.xcconfig"; sourceTree = "<group>"; };
DBE059B4AC7A51919467EEC0 /* libPods-InteropTestsRemote.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemote.a"; sourceTree = BUILT_PRODUCTS_DIR; };
DBEDE45BDA60DF1E1C8950C0 /* libPods-InteropTestsLocalSSL.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSL.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -228,9 +293,11 @@
E4275A759BDBDF143B9B438F /* Pods-InteropTestsRemote.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsRemote.release.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsRemote/Pods-InteropTestsRemote.release.xcconfig"; sourceTree = "<group>"; };
E4FD4606D4AB8D5A314D72F0 /* Pods-InteropTestsLocalCleartextCFStream.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsLocalCleartextCFStream.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsLocalCleartextCFStream/Pods-InteropTestsLocalCleartextCFStream.test.xcconfig"; sourceTree = "<group>"; };
E7E4D3FD76E3B745D992AF5F /* Pods-AllTests.cronet.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AllTests.cronet.xcconfig"; path = "Pods/Target Support Files/Pods-AllTests/Pods-AllTests.cronet.xcconfig"; sourceTree = "<group>"; };
+ EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-InteropTestsMultipleChannels.test.xcconfig"; path = "Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels.test.xcconfig"; sourceTree = "<group>"; };
EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-UnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-UnitTests/Pods-UnitTests.release.xcconfig"; sourceTree = "<group>"; };
F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalSSLCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; };
F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsRemoteCFStream.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ChannelTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests.debug.xcconfig"; sourceTree = "<group>"; };
FBD98AC417B9882D32B19F28 /* libPods-CoreCronetEnd2EndTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-CoreCronetEnd2EndTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
FD346DB2C23F676C4842F3FF /* libPods-InteropTestsLocalCleartext.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-InteropTestsLocalCleartext.a"; sourceTree = BUILT_PRODUCTS_DIR; };
FF7B5489BCFE40111D768DD0 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
@@ -246,6 +313,23 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 5E3B959F21CAC6C500C0A151 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 98478C9F42329DF769A45B6C /* libPods-APIv2Tests.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5E7D71AF210B9EC8001EA6BA /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E7D71B7210B9EC9001EA6BA /* libTests.a in Frameworks */,
+ 6C1A3F81CCF7C998B4813EFD /* libPods-InteropTestsCallOptions.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
5E8A5DA11D3840B4000F8BC4 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -264,6 +348,24 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 5EB2A2E12107DED300EB4B69 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5EB2A2E92107DED300EB4B69 /* libTests.a in Frameworks */,
+ 1A0FB7F8C95A2F82538BC950 /* libPods-ChannelTests.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EB2A2F22109284500EB4B69 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5EB2A2FA2109284500EB4B69 /* libTests.a in Frameworks */,
+ 886717A79EFF774F356798E6 /* libPods-InteropTestsMultipleChannels.a in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
5EC5E41E208177CC000EF4AD /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -368,7 +470,11 @@
F44AC3F44E3491A8C0D890FE /* libPods-InteropTestsRemoteCFStream.a */,
0BDA4BA011779D5D25B5618C /* libPods-InteropTestsLocalCleartextCFStream.a */,
F3AB031E0E26AC8EF30A2A2A /* libPods-InteropTestsLocalSSLCFStream.a */,
+ 48F1841C9A920626995DC28C /* libPods-ChannelTests.a */,
+ 355D0E30AD224763BC9519F4 /* libPods-InteropTestsMultipleChannels.a */,
+ AF3FC2CFFE7B0961823BC740 /* libPods-InteropTestsCallOptions.a */,
22A3EBB488699C8CEA19707B /* libPods-UnitTests.a */,
+ B6AD69CACF67505B0F028E92 /* libPods-APIv2Tests.a */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -422,10 +528,26 @@
41AA59529240A6BBBD3DB904 /* Pods-InteropTestsLocalSSLCFStream.test.xcconfig */,
55B630C1FF8C36D1EFC4E0A4 /* Pods-InteropTestsLocalSSLCFStream.cronet.xcconfig */,
5EA908CF4CDA4CE218352A06 /* Pods-InteropTestsLocalSSLCFStream.release.xcconfig */,
+ F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */,
+ BED74BC8ABF9917C66175879 /* Pods-ChannelTests.test.xcconfig */,
+ 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */,
+ D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */,
+ 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */,
+ EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */,
+ 1295CCBD1082B4A7CFCED95F /* Pods-InteropTestsMultipleChannels.cronet.xcconfig */,
+ 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */,
+ 3A98DF08852F60AF1D96481D /* Pods-InteropTestsCallOptions.debug.xcconfig */,
+ A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */,
+ 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */,
+ C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */,
A2DCF2570BE515B62CB924CA /* Pods-UnitTests.debug.xcconfig */,
94D7A5FAA13480E9A5166D7A /* Pods-UnitTests.test.xcconfig */,
E1E7660656D902104F728892 /* Pods-UnitTests.cronet.xcconfig */,
EBFFEC04B514CB0D4922DC40 /* Pods-UnitTests.release.xcconfig */,
+ 1286B30AD74CB64CD91FB17D /* Pods-APIv2Tests.debug.xcconfig */,
+ 51F2A64B7AADBA1B225B132E /* Pods-APIv2Tests.test.xcconfig */,
+ 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */,
+ 12B238CD1702393C2BA5DE80 /* Pods-APIv2Tests.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
@@ -439,6 +561,24 @@
path = UnitTests;
sourceTree = "<group>";
};
+ 5E3B95A321CAC6C500C0A151 /* APIv2Tests */ = {
+ isa = PBXGroup;
+ children = (
+ 5E3B95A421CAC6C500C0A151 /* APIv2Tests.m */,
+ 5E3B95A621CAC6C500C0A151 /* Info.plist */,
+ );
+ path = APIv2Tests;
+ sourceTree = "<group>";
+ };
+ 5E7D71B3210B9EC9001EA6BA /* InteropTestsCallOptions */ = {
+ isa = PBXGroup;
+ children = (
+ 5E7D71B4210B9EC9001EA6BA /* InteropTestsCallOptions.m */,
+ 5E7D71B6210B9EC9001EA6BA /* Info.plist */,
+ );
+ path = InteropTestsCallOptions;
+ sourceTree = "<group>";
+ };
5E8A5DA51D3840B4000F8BC4 /* CoreCronetEnd2EndTests */ = {
isa = PBXGroup;
children = (
@@ -456,6 +596,25 @@
path = CronetUnitTests;
sourceTree = "<group>";
};
+ 5EB2A2E52107DED300EB4B69 /* ChannelTests */ = {
+ isa = PBXGroup;
+ children = (
+ 5EB5C3A921656CEA00ADC300 /* ChannelPoolTest.m */,
+ 5EB2A2E62107DED300EB4B69 /* ChannelTests.m */,
+ 5EB2A2E82107DED300EB4B69 /* Info.plist */,
+ );
+ path = ChannelTests;
+ sourceTree = "<group>";
+ };
+ 5EB2A2F62109284500EB4B69 /* InteropTestsMultipleChannels */ = {
+ isa = PBXGroup;
+ children = (
+ 5EB2A2F72109284500EB4B69 /* InteropTestsMultipleChannels.m */,
+ 5EB2A2F92109284500EB4B69 /* Info.plist */,
+ );
+ path = InteropTestsMultipleChannels;
+ sourceTree = "<group>";
+ };
5EE84BF21D4717E40050C6CC /* InteropTestsRemoteWithCronet */ = {
isa = PBXGroup;
children = (
@@ -473,7 +632,11 @@
5E8A5DA51D3840B4000F8BC4 /* CoreCronetEnd2EndTests */,
5EE84BF21D4717E40050C6CC /* InteropTestsRemoteWithCronet */,
5EAD6D251E27047400002378 /* CronetUnitTests */,
+ 5EB2A2E52107DED300EB4B69 /* ChannelTests */,
+ 5EB2A2F62109284500EB4B69 /* InteropTestsMultipleChannels */,
+ 5E7D71B3210B9EC9001EA6BA /* InteropTestsCallOptions */,
5E0282E7215AA697007AC99D /* UnitTests */,
+ 5E3B95A321CAC6C500C0A151 /* APIv2Tests */,
635697C81B14FC11007A7283 /* Products */,
51E4650F34F854F41FF053B3 /* Pods */,
136D535E19727099B941D7B1 /* Frameworks */,
@@ -495,7 +658,11 @@
5EC5E421208177CC000EF4AD /* InteropTestsRemoteCFStream.xctest */,
5EC5E4312081856B000EF4AD /* InteropTestsLocalCleartextCFStream.xctest */,
5EC5E442208185CE000EF4AD /* InteropTestsLocalSSLCFStream.xctest */,
+ 5EB2A2E42107DED300EB4B69 /* ChannelTests.xctest */,
+ 5EB2A2F52109284500EB4B69 /* InteropTestsMultipleChannels.xctest */,
+ 5E7D71B2210B9EC8001EA6BA /* InteropTestsCallOptions.xctest */,
5E0282E6215AA697007AC99D /* UnitTests.xctest */,
+ 5E3B95A221CAC6C500C0A151 /* APIv2Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
@@ -548,6 +715,45 @@
productReference = 5E0282E6215AA697007AC99D /* UnitTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
+ 5E3B95A121CAC6C500C0A151 /* APIv2Tests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5E3B95A721CAC6C500C0A151 /* Build configuration list for PBXNativeTarget "APIv2Tests" */;
+ buildPhases = (
+ EDDD3FA856BCA3443ED36D1E /* [CP] Check Pods Manifest.lock */,
+ 5E3B959E21CAC6C500C0A151 /* Sources */,
+ 5E3B959F21CAC6C500C0A151 /* Frameworks */,
+ 5E3B95A021CAC6C500C0A151 /* Resources */,
+ C17B826BBD02FDD4A5F355AF /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = APIv2Tests;
+ productName = APIv2Tests;
+ productReference = 5E3B95A221CAC6C500C0A151 /* APIv2Tests.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+ 5E7D71B1210B9EC8001EA6BA /* InteropTestsCallOptions */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5E7D71BA210B9EC9001EA6BA /* Build configuration list for PBXNativeTarget "InteropTestsCallOptions" */;
+ buildPhases = (
+ 2865C6386D677998F861E183 /* [CP] Check Pods Manifest.lock */,
+ 5E7D71AE210B9EC8001EA6BA /* Sources */,
+ 5E7D71AF210B9EC8001EA6BA /* Frameworks */,
+ 5E7D71B0210B9EC8001EA6BA /* Resources */,
+ 6BA6D00B1816306453BF82D4 /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 5E7D71B9210B9EC9001EA6BA /* PBXTargetDependency */,
+ );
+ name = InteropTestsCallOptions;
+ productName = InteropTestsCallOptions;
+ productReference = 5E7D71B2210B9EC8001EA6BA /* InteropTestsCallOptions.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
5E8A5DA31D3840B4000F8BC4 /* CoreCronetEnd2EndTests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 5E8A5DAE1D3840B4000F8BC4 /* Build configuration list for PBXNativeTarget "CoreCronetEnd2EndTests" */;
@@ -588,6 +794,47 @@
productReference = 5EAD6D241E27047400002378 /* CronetUnitTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
+ 5EB2A2E32107DED300EB4B69 /* ChannelTests */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5EB2A2F02107DED300EB4B69 /* Build configuration list for PBXNativeTarget "ChannelTests" */;
+ buildPhases = (
+ 021B3B1F545989843EBC9A4B /* [CP] Check Pods Manifest.lock */,
+ 5EB2A2E02107DED300EB4B69 /* Sources */,
+ 5EB2A2E12107DED300EB4B69 /* Frameworks */,
+ 5EB2A2E22107DED300EB4B69 /* Resources */,
+ 1EAF0CBDBFAB18D4DA64535D /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 5EB2A2EB2107DED300EB4B69 /* PBXTargetDependency */,
+ );
+ name = ChannelTests;
+ productName = ChannelTests;
+ productReference = 5EB2A2E42107DED300EB4B69 /* ChannelTests.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
+ 5EB2A2F42109284500EB4B69 /* InteropTestsMultipleChannels */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 5EB2A3012109284500EB4B69 /* Build configuration list for PBXNativeTarget "InteropTestsMultipleChannels" */;
+ buildPhases = (
+ 8C1ED025E07C4D457C355336 /* [CP] Check Pods Manifest.lock */,
+ 5EB2A2F12109284500EB4B69 /* Sources */,
+ 5EB2A2F22109284500EB4B69 /* Frameworks */,
+ 5EB2A2F32109284500EB4B69 /* Resources */,
+ 8D685CB612835DB3F7A6F14A /* [CP] Embed Pods Frameworks */,
+ 0617B5294978A95BEBBFF733 /* [CP] Copy Pods Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 5EB2A2FC2109284500EB4B69 /* PBXTargetDependency */,
+ );
+ name = InteropTestsMultipleChannels;
+ productName = InteropTestsMultipleChannels;
+ productReference = 5EB2A2F52109284500EB4B69 /* InteropTestsMultipleChannels.xctest */;
+ productType = "com.apple.product-type.bundle.unit-test";
+ };
5EC5E420208177CC000EF4AD /* InteropTestsRemoteCFStream */ = {
isa = PBXNativeTarget;
buildConfigurationList = 5EC5E42A208177CD000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsRemoteCFStream" */;
@@ -796,12 +1043,28 @@
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
};
+ 5E3B95A121CAC6C500C0A151 = {
+ CreatedOnToolsVersion = 10.0;
+ ProvisioningStyle = Automatic;
+ };
+ 5E7D71B1210B9EC8001EA6BA = {
+ CreatedOnToolsVersion = 9.3;
+ ProvisioningStyle = Automatic;
+ };
5E8A5DA31D3840B4000F8BC4 = {
CreatedOnToolsVersion = 7.3.1;
};
5EAD6D231E27047400002378 = {
CreatedOnToolsVersion = 7.3.1;
};
+ 5EB2A2E32107DED300EB4B69 = {
+ CreatedOnToolsVersion = 9.3;
+ ProvisioningStyle = Automatic;
+ };
+ 5EB2A2F42109284500EB4B69 = {
+ CreatedOnToolsVersion = 9.3;
+ ProvisioningStyle = Automatic;
+ };
5EC5E420208177CC000EF4AD = {
CreatedOnToolsVersion = 9.2;
ProvisioningStyle = Automatic;
@@ -861,7 +1124,11 @@
5EC5E420208177CC000EF4AD /* InteropTestsRemoteCFStream */,
5EC5E4302081856B000EF4AD /* InteropTestsLocalCleartextCFStream */,
5EC5E441208185CE000EF4AD /* InteropTestsLocalSSLCFStream */,
+ 5EB2A2E32107DED300EB4B69 /* ChannelTests */,
+ 5EB2A2F42109284500EB4B69 /* InteropTestsMultipleChannels */,
+ 5E7D71B1210B9EC8001EA6BA /* InteropTestsCallOptions */,
5E0282E5215AA697007AC99D /* UnitTests */,
+ 5E3B95A121CAC6C500C0A151 /* APIv2Tests */,
);
};
/* End PBXProject section */
@@ -874,6 +1141,20 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 5E3B95A021CAC6C500C0A151 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5E7D71B0210B9EC8001EA6BA /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
5E8A5DA21D3840B4000F8BC4 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -888,6 +1169,21 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 5EB2A2E22107DED300EB4B69 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EB2A2F32109284500EB4B69 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E7D71AD210954A8001EA6BA /* TestCertificates.bundle in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
5EC5E41F208177CC000EF4AD /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -957,6 +1253,60 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
+ 021B3B1F545989843EBC9A4B /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-ChannelTests-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 0617B5294978A95BEBBFF733 /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-resources.sh",
+ "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle",
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 1EAF0CBDBFAB18D4DA64535D /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests-resources.sh",
+ "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle",
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-ChannelTests/Pods-ChannelTests-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
252A376345E38FD452A89C3D /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -975,6 +1325,24 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
+ 2865C6386D677998F861E183 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-InteropTestsCallOptions-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
31F8D1C407195CBF0C02929B /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -1083,6 +1451,24 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalSSL/Pods-InteropTestsLocalSSL-resources.sh\"\n";
showEnvVarsInLog = 0;
};
+ 6BA6D00B1816306453BF82D4 /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions-resources.sh",
+ "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle",
+ );
+ name = "[CP] Copy Pods Resources";
+ outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsCallOptions/Pods-InteropTestsCallOptions-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
7418AC7B3844B29E48D24FC7 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -1137,6 +1523,42 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsLocalCleartext/Pods-InteropTestsLocalCleartext-resources.sh\"\n";
showEnvVarsInLog = 0;
};
+ 8C1ED025E07C4D457C355336 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-InteropTestsMultipleChannels-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 8D685CB612835DB3F7A6F14A /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-frameworks.sh",
+ "${PODS_ROOT}/CronetFramework/Cronet.framework",
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputPaths = (
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cronet.framework",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-InteropTestsMultipleChannels/Pods-InteropTestsMultipleChannels-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
914ADDD7106BA9BB8A7E569F /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -1281,6 +1703,28 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
+ C17B826BBD02FDD4A5F355AF /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${SRCROOT}/Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests-resources.sh",
+ "${PODS_CONFIGURATION_BUILD_DIR}/gRPC/gRPCCertificates.bundle",
+ );
+ name = "[CP] Copy Pods Resources";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/gRPCCertificates.bundle",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-APIv2Tests/Pods-APIv2Tests-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
C2E09DC4BD239F71160F0CC1 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -1353,6 +1797,28 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-CoreCronetEnd2EndTests/Pods-CoreCronetEnd2EndTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
+ EDDD3FA856BCA3443ED36D1E /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-APIv2Tests-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
F07941C0BAF6A7C67AA60C48 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@@ -1418,6 +1884,22 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 5E3B959E21CAC6C500C0A151 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E3B95A521CAC6C500C0A151 /* APIv2Tests.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5E7D71AE210B9EC8001EA6BA /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5E7D71B5210B9EC9001EA6BA /* InteropTestsCallOptions.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
5E8A5DA01D3840B4000F8BC4 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1434,6 +1916,23 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 5EB2A2E02107DED300EB4B69 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5EB2A2E72107DED300EB4B69 /* ChannelTests.m in Sources */,
+ 5EB5C3AA21656CEA00ADC300 /* ChannelPoolTest.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+ 5EB2A2F12109284500EB4B69 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 5EB2A2F82109284500EB4B69 /* InteropTestsMultipleChannels.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
5EC5E41D208177CC000EF4AD /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1536,6 +2035,11 @@
target = 635697C61B14FC11007A7283 /* Tests */;
targetProxy = 5E0282EC215AA697007AC99D /* PBXContainerItemProxy */;
};
+ 5E7D71B9210B9EC9001EA6BA /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 635697C61B14FC11007A7283 /* Tests */;
+ targetProxy = 5E7D71B8210B9EC9001EA6BA /* PBXContainerItemProxy */;
+ };
5E8A5DAB1D3840B4000F8BC4 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 635697C61B14FC11007A7283 /* Tests */;
@@ -1546,6 +2050,16 @@
target = 635697C61B14FC11007A7283 /* Tests */;
targetProxy = 5EAD6D2A1E27047400002378 /* PBXContainerItemProxy */;
};
+ 5EB2A2EB2107DED300EB4B69 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 635697C61B14FC11007A7283 /* Tests */;
+ targetProxy = 5EB2A2EA2107DED300EB4B69 /* PBXContainerItemProxy */;
+ };
+ 5EB2A2FC2109284500EB4B69 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 635697C61B14FC11007A7283 /* Tests */;
+ targetProxy = 5EB2A2FB2109284500EB4B69 /* PBXContainerItemProxy */;
+ };
5EE84BF81D4717E40050C6CC /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 635697C61B14FC11007A7283 /* Tests */;
@@ -1909,6 +2423,271 @@
};
name = Test;
};
+ 5E3B95A821CAC6C500C0A151 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 1286B30AD74CB64CD91FB17D /* Pods-APIv2Tests.debug.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = APIv2Tests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.APIv2Tests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5E3B95A921CAC6C500C0A151 /* Test */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 51F2A64B7AADBA1B225B132E /* Pods-APIv2Tests.test.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = APIv2Tests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.APIv2Tests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Test;
+ };
+ 5E3B95AA21CAC6C500C0A151 /* Cronet */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 8C233E85C3EB45B3CAE52EDF /* Pods-APIv2Tests.cronet.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = APIv2Tests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.APIv2Tests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Cronet;
+ };
+ 5E3B95AB21CAC6C500C0A151 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 12B238CD1702393C2BA5DE80 /* Pods-APIv2Tests.release.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = APIv2Tests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.2;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ MTL_FAST_MATH = YES;
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.APIv2Tests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+ 5E7D71BB210B9EC9001EA6BA /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 3A98DF08852F60AF1D96481D /* Pods-InteropTestsCallOptions.debug.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = InteropTestsCallOptions/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsCallOptions;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5E7D71BC210B9EC9001EA6BA /* Test */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = A25967A0D40ED14B3287AD81 /* Pods-InteropTestsCallOptions.test.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = InteropTestsCallOptions/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsCallOptions;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Test;
+ };
+ 5E7D71BD210B9EC9001EA6BA /* Cronet */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 73D2DF07027835BA0FB0B1C0 /* Pods-InteropTestsCallOptions.cronet.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = InteropTestsCallOptions/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsCallOptions;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Cronet;
+ };
+ 5E7D71BE210B9EC9001EA6BA /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = C9172F9020E8C97A470D7250 /* Pods-InteropTestsCallOptions.release.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = InteropTestsCallOptions/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsCallOptions;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
5E8A5DAC1D3840B4000F8BC4 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 0D2284C3DF7E57F0ED504E39 /* Pods-CoreCronetEnd2EndTests.debug.xcconfig */;
@@ -2011,6 +2790,266 @@
};
name = Release;
};
+ 5EB2A2EC2107DED300EB4B69 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = F9E48EF5ACB1F38825171C5F /* Pods-ChannelTests.debug.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = ChannelTests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.ChannelTests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5EB2A2ED2107DED300EB4B69 /* Test */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = BED74BC8ABF9917C66175879 /* Pods-ChannelTests.test.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = ChannelTests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.ChannelTests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Test;
+ };
+ 5EB2A2EE2107DED300EB4B69 /* Cronet */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 90E63AD3C4A1E3E6BC745096 /* Pods-ChannelTests.cronet.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = ChannelTests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.ChannelTests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Cronet;
+ };
+ 5EB2A2EF2107DED300EB4B69 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = D52B92A7108602F170DA8091 /* Pods-ChannelTests.release.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = ChannelTests/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.ChannelTests;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
+ 5EB2A2FD2109284500EB4B69 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 3CADF86203B9D03EA96C359D /* Pods-InteropTestsMultipleChannels.debug.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = InteropTestsMultipleChannels/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsMultipleChannels;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ 5EB2A2FE2109284500EB4B69 /* Test */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = EA8B122ACDE73E3AAA0E4A19 /* Pods-InteropTestsMultipleChannels.test.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = InteropTestsMultipleChannels/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsMultipleChannels;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Test;
+ };
+ 5EB2A2FF2109284500EB4B69 /* Cronet */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 1295CCBD1082B4A7CFCED95F /* Pods-InteropTestsMultipleChannels.cronet.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = InteropTestsMultipleChannels/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsMultipleChannels;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Cronet;
+ };
+ 5EB2A3002109284500EB4B69 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 2650FEF00956E7924772F9D9 /* Pods-InteropTestsMultipleChannels.release.xcconfig */;
+ buildSettings = {
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_ENABLE_OBJC_WEAK = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ INFOPLIST_FILE = InteropTestsMultipleChannels/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 11.3;
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = io.grpc.InteropTestsMultipleChannels;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Release;
+ };
5EC3C7A01D4FC18C000330E2 /* Cronet */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -2039,6 +3078,8 @@
"DEBUG=1",
"$(inherited)",
"HOST_PORT_REMOTE=$(HOST_PORT_REMOTE)",
+ "HOST_PORT_LOCALSSL=$(HOST_PORT_LOCALSSL)",
+ "HOST_PORT_LOCAL=$(HOST_PORT_LOCAL)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
@@ -2859,6 +3900,28 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 5E3B95A721CAC6C500C0A151 /* Build configuration list for PBXNativeTarget "APIv2Tests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E3B95A821CAC6C500C0A151 /* Debug */,
+ 5E3B95A921CAC6C500C0A151 /* Test */,
+ 5E3B95AA21CAC6C500C0A151 /* Cronet */,
+ 5E3B95AB21CAC6C500C0A151 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 5E7D71BA210B9EC9001EA6BA /* Build configuration list for PBXNativeTarget "InteropTestsCallOptions" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5E7D71BB210B9EC9001EA6BA /* Debug */,
+ 5E7D71BC210B9EC9001EA6BA /* Test */,
+ 5E7D71BD210B9EC9001EA6BA /* Cronet */,
+ 5E7D71BE210B9EC9001EA6BA /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
5E8A5DAE1D3840B4000F8BC4 /* Build configuration list for PBXNativeTarget "CoreCronetEnd2EndTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -2881,6 +3944,28 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 5EB2A2F02107DED300EB4B69 /* Build configuration list for PBXNativeTarget "ChannelTests" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5EB2A2EC2107DED300EB4B69 /* Debug */,
+ 5EB2A2ED2107DED300EB4B69 /* Test */,
+ 5EB2A2EE2107DED300EB4B69 /* Cronet */,
+ 5EB2A2EF2107DED300EB4B69 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 5EB2A3012109284500EB4B69 /* Build configuration list for PBXNativeTarget "InteropTestsMultipleChannels" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 5EB2A2FD2109284500EB4B69 /* Debug */,
+ 5EB2A2FE2109284500EB4B69 /* Test */,
+ 5EB2A2FF2109284500EB4B69 /* Cronet */,
+ 5EB2A3002109284500EB4B69 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
5EC5E42A208177CD000EF4AD /* Build configuration list for PBXNativeTarget "InteropTestsRemoteCFStream" */ = {
isa = XCConfigurationList;
buildConfigurations = (
diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/APIv2Tests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/APIv2Tests.xcscheme
new file mode 100644
index 0000000000..e0d1d1fdca
--- /dev/null
+++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/APIv2Tests.xcscheme
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "1000"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "NO"
+ buildForArchiving = "NO"
+ buildForAnalyzing = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E3B95A121CAC6C500C0A151"
+ BuildableName = "APIv2Tests.xctest"
+ BlueprintName = "APIv2Tests"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Test"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E3B95A121CAC6C500C0A151"
+ BuildableName = "APIv2Tests.xctest"
+ BlueprintName = "APIv2Tests"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Test"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E3B95A121CAC6C500C0A151"
+ BuildableName = "APIv2Tests.xctest"
+ BlueprintName = "APIv2Tests"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E3B95A121CAC6C500C0A151"
+ BuildableName = "APIv2Tests.xctest"
+ BlueprintName = "APIv2Tests"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/ChannelTests.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/ChannelTests.xcscheme
new file mode 100644
index 0000000000..acae965bed
--- /dev/null
+++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/ChannelTests.xcscheme
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0930"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ <BuildActionEntries>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "NO"
+ buildForArchiving = "NO"
+ buildForAnalyzing = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5EB2A2E32107DED300EB4B69"
+ BuildableName = "ChannelTests.xctest"
+ BlueprintName = "ChannelTests"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ </BuildActionEntries>
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5EB2A2E32107DED300EB4B69"
+ BuildableName = "ChannelTests.xctest"
+ BlueprintName = "ChannelTests"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5EB2A2E32107DED300EB4B69"
+ BuildableName = "ChannelTests.xctest"
+ BlueprintName = "ChannelTests"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5EB2A2E32107DED300EB4B69"
+ BuildableName = "ChannelTests.xctest"
+ BlueprintName = "ChannelTests"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsCallOptions.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsCallOptions.xcscheme
new file mode 100644
index 0000000000..dd83282190
--- /dev/null
+++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsCallOptions.xcscheme
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0930"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Test"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5E7D71B1210B9EC8001EA6BA"
+ BuildableName = "InteropTestsCallOptions.xctest"
+ BlueprintName = "InteropTestsCallOptions"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Test"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme
index 510115fc75..11b41c9214 100644
--- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme
+++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsLocalCleartext.xcscheme
@@ -26,7 +26,6 @@
buildConfiguration = "Test"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -40,12 +39,6 @@
</BuildableReference>
<SkippedTests>
<Test
- Identifier = "GRPCClientTests/testConnectionToRemoteServer">
- </Test>
- <Test
- Identifier = "GRPCClientTests/testMetadata">
- </Test>
- <Test
Identifier = "InteropTests">
</Test>
</SkippedTests>
@@ -58,7 +51,6 @@
buildConfiguration = "Test"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsMultipleChannels.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsMultipleChannels.xcscheme
new file mode 100644
index 0000000000..1b4c1f5e51
--- /dev/null
+++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsMultipleChannels.xcscheme
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0930"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Cronet"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "5EB2A2F42109284500EB4B69"
+ BuildableName = "InteropTestsMultipleChannels.xctest"
+ BlueprintName = "InteropTestsMultipleChannels"
+ ReferencedContainer = "container:Tests.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Cronet"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
diff --git a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme
index 48837e57f9..412bf6a014 100644
--- a/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme
+++ b/src/objective-c/tests/Tests.xcodeproj/xcshareddata/xcschemes/InteropTestsRemote.xcscheme
@@ -26,7 +26,6 @@
buildConfiguration = "Test"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
@@ -61,7 +60,6 @@
buildConfiguration = "Test"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
- language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh
index f37c6cf9f6..f6fea96920 100755
--- a/src/objective-c/tests/run_tests.sh
+++ b/src/objective-c/tests/run_tests.sh
@@ -173,4 +173,26 @@ xcodebuild \
| egrep -v '^$' \
| egrep -v "(GPBDictionary|GPBArray)" -
+echo "TIME: $(date)"
+xcodebuild \
+ -workspace Tests.xcworkspace \
+ -scheme ChannelTests \
+ -destination name="iPhone 8" \
+ test \
+ | egrep -v "$XCODEBUILD_FILTER" \
+ | egrep -v '^$' \
+ | egrep -v "(GPBDictionary|GPBArray)" -
+
+echo "TIME: $(date)"
+xcodebuild \
+ -workspace Tests.xcworkspace \
+ -scheme APIv2Tests \
+ -destination name="iPhone 8" \
+ HOST_PORT_LOCAL=localhost:5050 \
+ HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \
+ test \
+ | egrep -v "$XCODEBUILD_FILTER" \
+ | egrep -v '^$' \
+ | egrep -v "(GPBDictionary|GPBArray)" -
+
exit 0
diff --git a/src/objective-c/tests/version.h b/src/objective-c/tests/version.h
index f2fd692070..54f95ad16a 100644
--- a/src/objective-c/tests/version.h
+++ b/src/objective-c/tests/version.h
@@ -22,5 +22,5 @@
// instead. This file can be regenerated from the template by running
// `tools/buildgen/generate_projects.sh`.
-#define GRPC_OBJC_VERSION_STRING @"1.18.0-dev"
+#define GRPC_OBJC_VERSION_STRING @"1.19.0-dev"
#define GRPC_C_VERSION_STRING @"7.0.0-dev"
diff --git a/src/php/composer.json b/src/php/composer.json
index 9c298c0e85..75fab483f1 100644
--- a/src/php/composer.json
+++ b/src/php/composer.json
@@ -2,7 +2,7 @@
"name": "grpc/grpc-dev",
"description": "gRPC library for PHP - for Developement use only",
"license": "Apache-2.0",
- "version": "1.18.0",
+ "version": "1.19.0",
"require": {
"php": ">=5.5.0",
"google/protobuf": "^v3.3.0"
diff --git a/src/php/ext/grpc/version.h b/src/php/ext/grpc/version.h
index 1ddf90a667..c85ee4d315 100644
--- a/src/php/ext/grpc/version.h
+++ b/src/php/ext/grpc/version.h
@@ -20,6 +20,6 @@
#ifndef VERSION_H
#define VERSION_H
-#define PHP_GRPC_VERSION "1.18.0dev"
+#define PHP_GRPC_VERSION "1.19.0dev"
#endif /* VERSION_H */
diff --git a/src/python/grpcio/grpc/__init__.py b/src/python/grpcio/grpc/__init__.py
index daf869b156..70d7618e05 100644
--- a/src/python/grpcio/grpc/__init__.py
+++ b/src/python/grpcio/grpc/__init__.py
@@ -23,6 +23,11 @@ from grpc._cython import cygrpc as _cygrpc
logging.getLogger(__name__).addHandler(logging.NullHandler())
+try:
+ from ._grpcio_metadata import __version__
+except ImportError:
+ __version__ = "dev0"
+
############################## Future Interface ###############################
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi
index e0e068e452..01b8237484 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pxd.pxi
@@ -28,19 +28,22 @@ cdef tuple _wrap_grpc_arg(grpc_arg arg)
cdef grpc_arg _unwrap_grpc_arg(tuple wrapped_arg)
-cdef class _ArgumentProcessor:
+cdef class _ChannelArg:
cdef grpc_arg c_argument
cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references) except *
-cdef class _ArgumentsProcessor:
+cdef class _ChannelArgs:
cdef readonly tuple _arguments
- cdef list _argument_processors
+ cdef list _channel_args
cdef readonly list _references
cdef grpc_channel_args _c_arguments
- cdef grpc_channel_args *c(self, grpc_arg_pointer_vtable *vtable) except *
- cdef un_c(self)
+ cdef void _c(self, grpc_arg_pointer_vtable *vtable) except *
+ cdef grpc_channel_args *c_args(self) except *
+
+ @staticmethod
+ cdef _ChannelArgs from_args(object arguments, grpc_arg_pointer_vtable * vtable)
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi
index b7a4277ff6..bf12871015 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/arguments.pyx.pxi
@@ -50,7 +50,7 @@ cdef grpc_arg _unwrap_grpc_arg(tuple wrapped_arg):
return wrapped.arg
-cdef class _ArgumentProcessor:
+cdef class _ChannelArg:
cdef void c(self, argument, grpc_arg_pointer_vtable *vtable, references) except *:
key, value = argument
@@ -82,27 +82,34 @@ cdef class _ArgumentProcessor:
'Expected int, bytes, or behavior, got {}'.format(type(value)))
-cdef class _ArgumentsProcessor:
+cdef class _ChannelArgs:
def __cinit__(self, arguments):
self._arguments = () if arguments is None else tuple(arguments)
- self._argument_processors = []
+ self._channel_args = []
self._references = []
+ self._c_arguments.arguments = NULL
- cdef grpc_channel_args *c(self, grpc_arg_pointer_vtable *vtable) except *:
+ cdef void _c(self, grpc_arg_pointer_vtable *vtable) except *:
self._c_arguments.arguments_length = len(self._arguments)
- if self._c_arguments.arguments_length == 0:
- return NULL
- else:
+ if self._c_arguments.arguments_length != 0:
self._c_arguments.arguments = <grpc_arg *>gpr_malloc(
self._c_arguments.arguments_length * sizeof(grpc_arg))
for index, argument in enumerate(self._arguments):
- argument_processor = _ArgumentProcessor()
- argument_processor.c(argument, vtable, self._references)
- self._c_arguments.arguments[index] = argument_processor.c_argument
- self._argument_processors.append(argument_processor)
- return &self._c_arguments
-
- cdef un_c(self):
- if self._arguments:
+ channel_arg = _ChannelArg()
+ channel_arg.c(argument, vtable, self._references)
+ self._c_arguments.arguments[index] = channel_arg.c_argument
+ self._channel_args.append(channel_arg)
+
+ cdef grpc_channel_args *c_args(self) except *:
+ return &self._c_arguments
+
+ def __dealloc__(self):
+ if self._c_arguments.arguments != NULL:
gpr_free(self._c_arguments.arguments)
+
+ @staticmethod
+ cdef _ChannelArgs from_args(object arguments, grpc_arg_pointer_vtable * vtable):
+ cdef _ChannelArgs channel_args = _ChannelArgs(arguments)
+ channel_args._c(vtable)
+ return channel_args
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
index 135d224095..70d4abb730 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/channel.pyx.pxi
@@ -423,16 +423,15 @@ cdef class Channel:
self._vtable.copy = &_copy_pointer
self._vtable.destroy = &_destroy_pointer
self._vtable.cmp = &_compare_pointer
- cdef _ArgumentsProcessor arguments_processor = _ArgumentsProcessor(
- arguments)
- cdef grpc_channel_args *c_arguments = arguments_processor.c(&self._vtable)
+ cdef _ChannelArgs channel_args = _ChannelArgs.from_args(
+ arguments, &self._vtable)
if channel_credentials is None:
self._state.c_channel = grpc_insecure_channel_create(
- <char *>target, c_arguments, NULL)
+ <char *>target, channel_args.c_args(), NULL)
else:
c_channel_credentials = channel_credentials.c()
self._state.c_channel = grpc_secure_channel_create(
- c_channel_credentials, <char *>target, c_arguments, NULL)
+ c_channel_credentials, <char *>target, channel_args.c_args(), NULL)
grpc_channel_credentials_release(c_channel_credentials)
self._state.c_call_completion_queue = (
grpc_completion_queue_create_for_next(NULL))
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
index 52cfccb677..4a6fbe0f96 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pxd.pxi
@@ -16,7 +16,6 @@
cdef class Server:
cdef grpc_arg_pointer_vtable _vtable
- cdef readonly _ArgumentsProcessor _arguments_processor
cdef grpc_server *c_server
cdef bint is_started # start has been called
cdef bint is_shutting_down # shutdown has been called
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
index e89e02b171..d72648a35d 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/server.pyx.pxi
@@ -29,11 +29,9 @@ cdef class Server:
self._vtable.copy = &_copy_pointer
self._vtable.destroy = &_destroy_pointer
self._vtable.cmp = &_compare_pointer
- cdef _ArgumentsProcessor arguments_processor = _ArgumentsProcessor(
- arguments)
- cdef grpc_channel_args *c_arguments = arguments_processor.c(&self._vtable)
- self.c_server = grpc_server_create(c_arguments, NULL)
- arguments_processor.un_c()
+ cdef _ChannelArgs channel_args = _ChannelArgs.from_args(
+ arguments, &self._vtable)
+ self.c_server = grpc_server_create(channel_args.c_args(), NULL)
self.references.append(arguments)
self.is_started = False
self.is_shutting_down = False
diff --git a/src/python/grpcio/grpc/_grpcio_metadata.py b/src/python/grpcio/grpc/_grpcio_metadata.py
index 7a9f173947..dd9d436c3f 100644
--- a/src/python/grpcio/grpc/_grpcio_metadata.py
+++ b/src/python/grpcio/grpc/_grpcio_metadata.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc/_grpcio_metadata.py.template`!!!
-__version__ = """1.18.0.dev0"""
+__version__ = """1.19.0.dev0"""
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 6a1fd676ca..06de23903c 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -102,6 +102,8 @@ CORE_SOURCE_FILES = [
'src/core/lib/iomgr/gethostname_fallback.cc',
'src/core/lib/iomgr/gethostname_host_name_max.cc',
'src/core/lib/iomgr/gethostname_sysconf.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_posix.cc',
+ 'src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc',
'src/core/lib/iomgr/internal_errqueue.cc',
'src/core/lib/iomgr/iocp_windows.cc',
'src/core/lib/iomgr/iomgr.cc',
diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py
index 2e91818d2c..8e2f4d30bb 100644
--- a/src/python/grpcio/grpc_version.py
+++ b/src/python/grpcio/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!!
-VERSION = '1.18.0.dev0'
+VERSION = '1.19.0.dev0'
diff --git a/src/python/grpcio_channelz/grpc_version.py b/src/python/grpcio_channelz/grpc_version.py
index 16356ea402..5f3a894a2a 100644
--- a/src/python/grpcio_channelz/grpc_version.py
+++ b/src/python/grpcio_channelz/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_channelz/grpc_version.py.template`!!!
-VERSION = '1.18.0.dev0'
+VERSION = '1.19.0.dev0'
diff --git a/src/python/grpcio_health_checking/grpc_health/v1/health.py b/src/python/grpcio_health_checking/grpc_health/v1/health.py
index 0583659428..0a5bbb5504 100644
--- a/src/python/grpcio_health_checking/grpc_health/v1/health.py
+++ b/src/python/grpcio_health_checking/grpc_health/v1/health.py
@@ -23,15 +23,61 @@ from grpc_health.v1 import health_pb2_grpc as _health_pb2_grpc
SERVICE_NAME = _health_pb2.DESCRIPTOR.services_by_name['Health'].full_name
+class _Watcher():
+
+ def __init__(self):
+ self._condition = threading.Condition()
+ self._responses = list()
+ self._open = True
+
+ def __iter__(self):
+ return self
+
+ def _next(self):
+ with self._condition:
+ while not self._responses and self._open:
+ self._condition.wait()
+ if self._responses:
+ return self._responses.pop(0)
+ else:
+ raise StopIteration()
+
+ def next(self):
+ return self._next()
+
+ def __next__(self):
+ return self._next()
+
+ def add(self, response):
+ with self._condition:
+ self._responses.append(response)
+ self._condition.notify()
+
+ def close(self):
+ with self._condition:
+ self._open = False
+ self._condition.notify()
+
+
class HealthServicer(_health_pb2_grpc.HealthServicer):
"""Servicer handling RPCs for service statuses."""
def __init__(self):
- self._server_status_lock = threading.Lock()
+ self._lock = threading.RLock()
self._server_status = {}
+ self._watchers = {}
+
+ def _on_close_callback(self, watcher, service):
+
+ def callback():
+ with self._lock:
+ self._watchers[service].remove(watcher)
+ watcher.close()
+
+ return callback
def Check(self, request, context):
- with self._server_status_lock:
+ with self._lock:
status = self._server_status.get(request.service)
if status is None:
context.set_code(grpc.StatusCode.NOT_FOUND)
@@ -39,14 +85,30 @@ class HealthServicer(_health_pb2_grpc.HealthServicer):
else:
return _health_pb2.HealthCheckResponse(status=status)
+ def Watch(self, request, context):
+ service = request.service
+ with self._lock:
+ status = self._server_status.get(service)
+ if status is None:
+ status = _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN # pylint: disable=no-member
+ watcher = _Watcher()
+ watcher.add(_health_pb2.HealthCheckResponse(status=status))
+ if service not in self._watchers:
+ self._watchers[service] = set()
+ self._watchers[service].add(watcher)
+ context.add_callback(self._on_close_callback(watcher, service))
+ return watcher
+
def set(self, service, status):
"""Sets the status of a service.
- Args:
- service: string, the name of the service.
- NOTE, '' must be set.
- status: HealthCheckResponse.status enum value indicating
- the status of the service
- """
- with self._server_status_lock:
+ Args:
+ service: string, the name of the service. NOTE, '' must be set.
+ status: HealthCheckResponse.status enum value indicating the status of
+ the service
+ """
+ with self._lock:
self._server_status[service] = status
+ if service in self._watchers:
+ for watcher in self._watchers[service]:
+ watcher.add(_health_pb2.HealthCheckResponse(status=status))
diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py
index 85fa762f7e..4c2d434066 100644
--- a/src/python/grpcio_health_checking/grpc_version.py
+++ b/src/python/grpcio_health_checking/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!!
-VERSION = '1.18.0.dev0'
+VERSION = '1.19.0.dev0'
diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py
index e62ab169a2..6b88b2dfc5 100644
--- a/src/python/grpcio_reflection/grpc_version.py
+++ b/src/python/grpcio_reflection/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!!
-VERSION = '1.18.0.dev0'
+VERSION = '1.19.0.dev0'
diff --git a/src/python/grpcio_status/grpc_version.py b/src/python/grpcio_status/grpc_version.py
index e009843b94..2e58eb3b26 100644
--- a/src/python/grpcio_status/grpc_version.py
+++ b/src/python/grpcio_status/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_status/grpc_version.py.template`!!!
-VERSION = '1.18.0.dev0'
+VERSION = '1.19.0.dev0'
diff --git a/src/python/grpcio_testing/grpc_version.py b/src/python/grpcio_testing/grpc_version.py
index 7b4c1695fa..d4c5d94ecb 100644
--- a/src/python/grpcio_testing/grpc_version.py
+++ b/src/python/grpcio_testing/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_testing/grpc_version.py.template`!!!
-VERSION = '1.18.0.dev0'
+VERSION = '1.19.0.dev0'
diff --git a/src/python/grpcio_tests/commands.py b/src/python/grpcio_tests/commands.py
index d5327711d3..582ce898de 100644
--- a/src/python/grpcio_tests/commands.py
+++ b/src/python/grpcio_tests/commands.py
@@ -141,6 +141,7 @@ class TestGevent(setuptools.Command):
'unit._exit_test.ExitTest.test_in_flight_partial_unary_stream_call',
'unit._exit_test.ExitTest.test_in_flight_partial_stream_unary_call',
'unit._exit_test.ExitTest.test_in_flight_partial_stream_stream_call',
+ 'health_check._health_servicer_test.HealthServicerTest.test_cancelled_watch_removed_from_watch_list',
# TODO(https://github.com/grpc/grpc/issues/17330) enable these three tests
'channelz._channelz_servicer_test.ChannelzServicerTest.test_many_subchannels',
'channelz._channelz_servicer_test.ChannelzServicerTest.test_many_subchannels_and_sockets',
diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py
index 2fcd1ad617..e1645ab1b8 100644
--- a/src/python/grpcio_tests/grpc_version.py
+++ b/src/python/grpcio_tests/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!!
-VERSION = '1.18.0.dev0'
+VERSION = '1.19.0.dev0'
diff --git a/src/python/grpcio_tests/tests/health_check/BUILD.bazel b/src/python/grpcio_tests/tests/health_check/BUILD.bazel
index 19e1e1b2e1..77bc61aa30 100644
--- a/src/python/grpcio_tests/tests/health_check/BUILD.bazel
+++ b/src/python/grpcio_tests/tests/health_check/BUILD.bazel
@@ -9,6 +9,7 @@ py_test(
"//src/python/grpcio/grpc:grpcio",
"//src/python/grpcio_health_checking/grpc_health/v1:grpc_health",
"//src/python/grpcio_tests/tests/unit:test_common",
+ "//src/python/grpcio_tests/tests/unit/framework/common:common",
],
imports = ["../../",],
)
diff --git a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
index c1d9436c2f..35794987bc 100644
--- a/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
+++ b/src/python/grpcio_tests/tests/health_check/_health_servicer_test.py
@@ -13,6 +13,8 @@
# limitations under the License.
"""Tests of grpc_health.v1.health."""
+import threading
+import time
import unittest
import grpc
@@ -21,22 +23,36 @@ from grpc_health.v1 import health_pb2
from grpc_health.v1 import health_pb2_grpc
from tests.unit import test_common
+from tests.unit.framework.common import test_constants
+
+from six.moves import queue
+
+_SERVING_SERVICE = 'grpc.test.TestServiceServing'
+_UNKNOWN_SERVICE = 'grpc.test.TestServiceUnknown'
+_NOT_SERVING_SERVICE = 'grpc.test.TestServiceNotServing'
+_WATCH_SERVICE = 'grpc.test.WatchService'
+
+
+def _consume_responses(response_iterator, response_queue):
+ for response in response_iterator:
+ response_queue.put(response)
class HealthServicerTest(unittest.TestCase):
def setUp(self):
- servicer = health.HealthServicer()
- servicer.set('', health_pb2.HealthCheckResponse.SERVING)
- servicer.set('grpc.test.TestServiceServing',
- health_pb2.HealthCheckResponse.SERVING)
- servicer.set('grpc.test.TestServiceUnknown',
- health_pb2.HealthCheckResponse.UNKNOWN)
- servicer.set('grpc.test.TestServiceNotServing',
- health_pb2.HealthCheckResponse.NOT_SERVING)
+ self._servicer = health.HealthServicer()
+ self._servicer.set('', health_pb2.HealthCheckResponse.SERVING)
+ self._servicer.set(_SERVING_SERVICE,
+ health_pb2.HealthCheckResponse.SERVING)
+ self._servicer.set(_UNKNOWN_SERVICE,
+ health_pb2.HealthCheckResponse.UNKNOWN)
+ self._servicer.set(_NOT_SERVING_SERVICE,
+ health_pb2.HealthCheckResponse.NOT_SERVING)
self._server = test_common.test_server()
port = self._server.add_insecure_port('[::]:0')
- health_pb2_grpc.add_HealthServicer_to_server(servicer, self._server)
+ health_pb2_grpc.add_HealthServicer_to_server(self._servicer,
+ self._server)
self._server.start()
self._channel = grpc.insecure_channel('localhost:%d' % port)
@@ -46,37 +62,160 @@ class HealthServicerTest(unittest.TestCase):
self._server.stop(None)
self._channel.close()
- def test_empty_service(self):
+ def test_check_empty_service(self):
request = health_pb2.HealthCheckRequest()
resp = self._stub.Check(request)
self.assertEqual(health_pb2.HealthCheckResponse.SERVING, resp.status)
- def test_serving_service(self):
- request = health_pb2.HealthCheckRequest(
- service='grpc.test.TestServiceServing')
+ def test_check_serving_service(self):
+ request = health_pb2.HealthCheckRequest(service=_SERVING_SERVICE)
resp = self._stub.Check(request)
self.assertEqual(health_pb2.HealthCheckResponse.SERVING, resp.status)
- def test_unknown_serivce(self):
- request = health_pb2.HealthCheckRequest(
- service='grpc.test.TestServiceUnknown')
+ def test_check_unknown_serivce(self):
+ request = health_pb2.HealthCheckRequest(service=_UNKNOWN_SERVICE)
resp = self._stub.Check(request)
self.assertEqual(health_pb2.HealthCheckResponse.UNKNOWN, resp.status)
- def test_not_serving_service(self):
- request = health_pb2.HealthCheckRequest(
- service='grpc.test.TestServiceNotServing')
+ def test_check_not_serving_service(self):
+ request = health_pb2.HealthCheckRequest(service=_NOT_SERVING_SERVICE)
resp = self._stub.Check(request)
self.assertEqual(health_pb2.HealthCheckResponse.NOT_SERVING,
resp.status)
- def test_not_found_service(self):
+ def test_check_not_found_service(self):
request = health_pb2.HealthCheckRequest(service='not-found')
with self.assertRaises(grpc.RpcError) as context:
resp = self._stub.Check(request)
self.assertEqual(grpc.StatusCode.NOT_FOUND, context.exception.code())
+ def test_watch_empty_service(self):
+ request = health_pb2.HealthCheckRequest(service='')
+ response_queue = queue.Queue()
+ rendezvous = self._stub.Watch(request)
+ thread = threading.Thread(
+ target=_consume_responses, args=(rendezvous, response_queue))
+ thread.start()
+
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVING,
+ response.status)
+
+ rendezvous.cancel()
+ thread.join()
+ self.assertTrue(response_queue.empty())
+
+ def test_watch_new_service(self):
+ request = health_pb2.HealthCheckRequest(service=_WATCH_SERVICE)
+ response_queue = queue.Queue()
+ rendezvous = self._stub.Watch(request)
+ thread = threading.Thread(
+ target=_consume_responses, args=(rendezvous, response_queue))
+ thread.start()
+
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
+ response.status)
+
+ self._servicer.set(_WATCH_SERVICE,
+ health_pb2.HealthCheckResponse.SERVING)
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVING,
+ response.status)
+
+ self._servicer.set(_WATCH_SERVICE,
+ health_pb2.HealthCheckResponse.NOT_SERVING)
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
+ self.assertEqual(health_pb2.HealthCheckResponse.NOT_SERVING,
+ response.status)
+
+ rendezvous.cancel()
+ thread.join()
+ self.assertTrue(response_queue.empty())
+
+ def test_watch_service_isolation(self):
+ request = health_pb2.HealthCheckRequest(service=_WATCH_SERVICE)
+ response_queue = queue.Queue()
+ rendezvous = self._stub.Watch(request)
+ thread = threading.Thread(
+ target=_consume_responses, args=(rendezvous, response_queue))
+ thread.start()
+
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
+ response.status)
+
+ self._servicer.set('some-other-service',
+ health_pb2.HealthCheckResponse.SERVING)
+ with self.assertRaises(queue.Empty):
+ response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
+
+ rendezvous.cancel()
+ thread.join()
+ self.assertTrue(response_queue.empty())
+
+ def test_two_watchers(self):
+ request = health_pb2.HealthCheckRequest(service=_WATCH_SERVICE)
+ response_queue1 = queue.Queue()
+ response_queue2 = queue.Queue()
+ rendezvous1 = self._stub.Watch(request)
+ rendezvous2 = self._stub.Watch(request)
+ thread1 = threading.Thread(
+ target=_consume_responses, args=(rendezvous1, response_queue1))
+ thread2 = threading.Thread(
+ target=_consume_responses, args=(rendezvous2, response_queue2))
+ thread1.start()
+ thread2.start()
+
+ response1 = response_queue1.get(timeout=test_constants.SHORT_TIMEOUT)
+ response2 = response_queue2.get(timeout=test_constants.SHORT_TIMEOUT)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
+ response1.status)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
+ response2.status)
+
+ self._servicer.set(_WATCH_SERVICE,
+ health_pb2.HealthCheckResponse.SERVING)
+ response1 = response_queue1.get(timeout=test_constants.SHORT_TIMEOUT)
+ response2 = response_queue2.get(timeout=test_constants.SHORT_TIMEOUT)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVING,
+ response1.status)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVING,
+ response2.status)
+
+ rendezvous1.cancel()
+ rendezvous2.cancel()
+ thread1.join()
+ thread2.join()
+ self.assertTrue(response_queue1.empty())
+ self.assertTrue(response_queue2.empty())
+
+ def test_cancelled_watch_removed_from_watch_list(self):
+ request = health_pb2.HealthCheckRequest(service=_WATCH_SERVICE)
+ response_queue = queue.Queue()
+ rendezvous = self._stub.Watch(request)
+ thread = threading.Thread(
+ target=_consume_responses, args=(rendezvous, response_queue))
+ thread.start()
+
+ response = response_queue.get(timeout=test_constants.SHORT_TIMEOUT)
+ self.assertEqual(health_pb2.HealthCheckResponse.SERVICE_UNKNOWN,
+ response.status)
+
+ rendezvous.cancel()
+ self._servicer.set(_WATCH_SERVICE,
+ health_pb2.HealthCheckResponse.SERVING)
+ thread.join()
+
+ # Wait, if necessary, for serving thread to process client cancellation
+ timeout = time.time() + test_constants.SHORT_TIMEOUT
+ while time.time() < timeout and self._servicer._watchers[_WATCH_SERVICE]:
+ time.sleep(1)
+ self.assertFalse(self._servicer._watchers[_WATCH_SERVICE],
+ 'watch set should be empty')
+ self.assertTrue(response_queue.empty())
+
def test_health_service_name(self):
self.assertEqual(health.SERVICE_NAME, 'grpc.health.v1.Health')
diff --git a/src/python/grpcio_tests/tests/tests.json b/src/python/grpcio_tests/tests/tests.json
index f202a3f932..de4c2c1fdd 100644
--- a/src/python/grpcio_tests/tests/tests.json
+++ b/src/python/grpcio_tests/tests/tests.json
@@ -64,6 +64,7 @@
"unit._server_ssl_cert_config_test.ServerSSLCertReloadTestWithoutClientAuth",
"unit._server_test.ServerTest",
"unit._session_cache_test.SSLSessionCacheTest",
+ "unit._version_test.VersionTest",
"unit.beta._beta_features_test.BetaFeaturesTest",
"unit.beta._beta_features_test.ContextManagementAndLifecycleTest",
"unit.beta._connectivity_channel_test.ConnectivityStatesTest",
diff --git a/src/python/grpcio_tests/tests/unit/BUILD.bazel b/src/python/grpcio_tests/tests/unit/BUILD.bazel
index 1b462ec67a..a9bcd9f304 100644
--- a/src/python/grpcio_tests/tests/unit/BUILD.bazel
+++ b/src/python/grpcio_tests/tests/unit/BUILD.bazel
@@ -7,6 +7,7 @@ GRPCIO_TESTS_UNIT = [
"_api_test.py",
"_auth_context_test.py",
"_auth_test.py",
+ "_version_test.py",
"_channel_args_test.py",
"_channel_close_test.py",
"_channel_connectivity_test.py",
diff --git a/src/python/grpcio_tests/tests/unit/_cython/_fork_test.py b/src/python/grpcio_tests/tests/unit/_cython/_fork_test.py
index aeb02458a7..5a5dedd5f2 100644
--- a/src/python/grpcio_tests/tests/unit/_cython/_fork_test.py
+++ b/src/python/grpcio_tests/tests/unit/_cython/_fork_test.py
@@ -27,6 +27,7 @@ def _get_number_active_threads():
class ForkPosixTester(unittest.TestCase):
def setUp(self):
+ self._saved_fork_support_flag = cygrpc._GRPC_ENABLE_FORK_SUPPORT
cygrpc._GRPC_ENABLE_FORK_SUPPORT = True
def testForkManagedThread(self):
@@ -50,6 +51,9 @@ class ForkPosixTester(unittest.TestCase):
thread.join()
self.assertEqual(0, _get_number_active_threads())
+ def tearDown(self):
+ cygrpc._GRPC_ENABLE_FORK_SUPPORT = self._saved_fork_support_flag
+
@unittest.skipUnless(os.name == 'nt', 'Windows-specific tests')
class ForkWindowsTester(unittest.TestCase):
diff --git a/src/python/grpcio_tests/tests/unit/_logging_test.py b/src/python/grpcio_tests/tests/unit/_logging_test.py
index 631b9de9db..8ff127f506 100644
--- a/src/python/grpcio_tests/tests/unit/_logging_test.py
+++ b/src/python/grpcio_tests/tests/unit/_logging_test.py
@@ -14,66 +14,86 @@
"""Test of gRPC Python's interaction with the python logging module"""
import unittest
-import six
-from six.moves import reload_module
import logging
import grpc
-import functools
+import subprocess
import sys
+INTERPRETER = sys.executable
-def patch_stderr(f):
- @functools.wraps(f)
- def _impl(*args, **kwargs):
- old_stderr = sys.stderr
- sys.stderr = six.StringIO()
- try:
- f(*args, **kwargs)
- finally:
- sys.stderr = old_stderr
+class LoggingTest(unittest.TestCase):
- return _impl
+ def test_logger_not_occupied(self):
+ script = """if True:
+ import logging
+ import grpc
-def isolated_logging(f):
+ if len(logging.getLogger().handlers) != 0:
+ raise Exception('expected 0 logging handlers')
- @functools.wraps(f)
- def _impl(*args, **kwargs):
- reload_module(logging)
- reload_module(grpc)
- try:
- f(*args, **kwargs)
- finally:
- reload_module(logging)
+ """
+ self._verifyScriptSucceeds(script)
- return _impl
+ def test_handler_found(self):
+ script = """if True:
+ import logging
+ import grpc
+ """
+ out, err = self._verifyScriptSucceeds(script)
+ self.assertEqual(0, len(err), 'unexpected output to stderr')
-class LoggingTest(unittest.TestCase):
+ def test_can_configure_logger(self):
+ script = """if True:
+ import logging
+ import six
- @isolated_logging
- def test_logger_not_occupied(self):
- self.assertEqual(0, len(logging.getLogger().handlers))
+ import grpc
- @patch_stderr
- @isolated_logging
- def test_handler_found(self):
- self.assertEqual(0, len(sys.stderr.getvalue()))
- @isolated_logging
- def test_can_configure_logger(self):
- intended_stream = six.StringIO()
- logging.basicConfig(stream=intended_stream)
- self.assertEqual(1, len(logging.getLogger().handlers))
- self.assertIs(logging.getLogger().handlers[0].stream, intended_stream)
+ intended_stream = six.StringIO()
+ logging.basicConfig(stream=intended_stream)
+
+ if len(logging.getLogger().handlers) != 1:
+ raise Exception('expected 1 logging handler')
+
+ if logging.getLogger().handlers[0].stream is not intended_stream:
+ raise Exception('wrong handler stream')
+
+ """
+ self._verifyScriptSucceeds(script)
- @isolated_logging
def test_grpc_logger(self):
- self.assertIn("grpc", logging.Logger.manager.loggerDict)
- root_logger = logging.getLogger("grpc")
- self.assertEqual(1, len(root_logger.handlers))
- self.assertIsInstance(root_logger.handlers[0], logging.NullHandler)
+ script = """if True:
+ import logging
+
+ import grpc
+
+ if "grpc" not in logging.Logger.manager.loggerDict:
+ raise Exception('grpc logger not found')
+
+ root_logger = logging.getLogger("grpc")
+ if len(root_logger.handlers) != 1:
+ raise Exception('expected 1 root logger handler')
+ if not isinstance(root_logger.handlers[0], logging.NullHandler):
+ raise Exception('expected logging.NullHandler')
+
+ """
+ self._verifyScriptSucceeds(script)
+
+ def _verifyScriptSucceeds(self, script):
+ process = subprocess.Popen(
+ [INTERPRETER, '-c', script],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ out, err = process.communicate()
+ self.assertEqual(
+ 0, process.returncode,
+ 'process failed with exit code %d (stdout: %s, stderr: %s)' %
+ (process.returncode, out, err))
+ return out, err
if __name__ == '__main__':
diff --git a/src/python/grpcio_tests/tests/unit/_version_test.py b/src/python/grpcio_tests/tests/unit/_version_test.py
new file mode 100644
index 0000000000..3d37b319e5
--- /dev/null
+++ b/src/python/grpcio_tests/tests/unit/_version_test.py
@@ -0,0 +1,30 @@
+# Copyright 2018 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.
+"""Test for grpc.__version__"""
+
+import unittest
+import grpc
+import logging
+from grpc import _grpcio_metadata
+
+
+class VersionTest(unittest.TestCase):
+
+ def test_get_version(self):
+ self.assertEqual(grpc.__version__, _grpcio_metadata.__version__)
+
+
+if __name__ == '__main__':
+ logging.basicConfig()
+ unittest.main(verbosity=2)
diff --git a/src/ruby/end2end/graceful_sig_handling_client.rb b/src/ruby/end2end/graceful_sig_handling_client.rb
new file mode 100755
index 0000000000..14a67a62cc
--- /dev/null
+++ b/src/ruby/end2end/graceful_sig_handling_client.rb
@@ -0,0 +1,61 @@
+#!/usr/bin/env ruby
+
+# Copyright 2015 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.
+
+require_relative './end2end_common'
+
+# Test client. Sends RPC's as normal but process also has signal handlers
+class SigHandlingClientController < ClientControl::ClientController::Service
+ def initialize(stub)
+ @stub = stub
+ end
+
+ def do_echo_rpc(req, _)
+ response = @stub.echo(Echo::EchoRequest.new(request: req.request))
+ fail 'bad response' unless response.response == req.request
+ ClientControl::Void.new
+ end
+end
+
+def main
+ client_control_port = ''
+ server_port = ''
+ OptionParser.new do |opts|
+ opts.on('--client_control_port=P', String) do |p|
+ client_control_port = p
+ end
+ opts.on('--server_port=P', String) do |p|
+ server_port = p
+ end
+ end.parse!
+
+ # Allow a few seconds to be safe.
+ srv = new_rpc_server_for_testing
+ srv.add_http2_port("0.0.0.0:#{client_control_port}",
+ :this_port_is_insecure)
+ stub = Echo::EchoServer::Stub.new("localhost:#{server_port}",
+ :this_channel_is_insecure)
+ control_service = SigHandlingClientController.new(stub)
+ srv.handle(control_service)
+ server_thread = Thread.new do
+ srv.run_till_terminated_or_interrupted(['int'])
+ end
+ srv.wait_till_running
+ # send a first RPC to notify the parent process that we've started
+ stub.echo(Echo::EchoRequest.new(request: 'client/child started'))
+ server_thread.join
+end
+
+main
diff --git a/src/ruby/end2end/graceful_sig_handling_driver.rb b/src/ruby/end2end/graceful_sig_handling_driver.rb
new file mode 100755
index 0000000000..e12ae28485
--- /dev/null
+++ b/src/ruby/end2end/graceful_sig_handling_driver.rb
@@ -0,0 +1,83 @@
+#!/usr/bin/env ruby
+
+# Copyright 2016 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.
+
+# smoke test for a grpc-using app that receives and
+# handles process-ending signals
+
+require_relative './end2end_common'
+
+# A service that calls back it's received_rpc_callback
+# upon receiving an RPC. Used for synchronization/waiting
+# for child process to start.
+class ClientStartedService < Echo::EchoServer::Service
+ def initialize(received_rpc_callback)
+ @received_rpc_callback = received_rpc_callback
+ end
+
+ def echo(echo_req, _)
+ @received_rpc_callback.call unless @received_rpc_callback.nil?
+ @received_rpc_callback = nil
+ Echo::EchoReply.new(response: echo_req.request)
+ end
+end
+
+def main
+ STDERR.puts 'start server'
+ client_started = false
+ client_started_mu = Mutex.new
+ client_started_cv = ConditionVariable.new
+ received_rpc_callback = proc do
+ client_started_mu.synchronize do
+ client_started = true
+ client_started_cv.signal
+ end
+ end
+
+ client_started_service = ClientStartedService.new(received_rpc_callback)
+ server_runner = ServerRunner.new(client_started_service)
+ server_port = server_runner.run
+ STDERR.puts 'start client'
+ control_stub, client_pid = start_client('graceful_sig_handling_client.rb', server_port)
+
+ client_started_mu.synchronize do
+ client_started_cv.wait(client_started_mu) until client_started
+ end
+
+ control_stub.do_echo_rpc(
+ ClientControl::DoEchoRpcRequest.new(request: 'hello'))
+
+ STDERR.puts 'killing client'
+ Process.kill('SIGINT', client_pid)
+ Process.wait(client_pid)
+ client_exit_status = $CHILD_STATUS
+
+ if client_exit_status.exited?
+ if client_exit_status.exitstatus != 0
+ STDERR.puts 'Client did not close gracefully'
+ exit(1)
+ end
+ else
+ STDERR.puts 'Client did not close gracefully'
+ exit(1)
+ end
+
+ STDERR.puts 'Client ended gracefully'
+
+ # no need to call cleanup, client should already be dead
+ server_runner.stop
+end
+
+main
diff --git a/src/ruby/end2end/graceful_sig_stop_client.rb b/src/ruby/end2end/graceful_sig_stop_client.rb
new file mode 100755
index 0000000000..b672dc3f2a
--- /dev/null
+++ b/src/ruby/end2end/graceful_sig_stop_client.rb
@@ -0,0 +1,78 @@
+#!/usr/bin/env ruby
+
+# Copyright 2015 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.
+
+require_relative './end2end_common'
+
+# Test client. Sends RPC's as normal but process also has signal handlers
+class SigHandlingClientController < ClientControl::ClientController::Service
+ def initialize(srv, stub)
+ @srv = srv
+ @stub = stub
+ end
+
+ def do_echo_rpc(req, _)
+ response = @stub.echo(Echo::EchoRequest.new(request: req.request))
+ fail 'bad response' unless response.response == req.request
+ ClientControl::Void.new
+ end
+
+ def shutdown(_, _)
+ # Spawn a new thread because RpcServer#stop is
+ # synchronous and blocks until either this RPC has finished,
+ # or the server's "poll_period" seconds have passed.
+ @shutdown_thread = Thread.new do
+ @srv.stop
+ end
+ ClientControl::Void.new
+ end
+
+ def join_shutdown_thread
+ @shutdown_thread.join
+ end
+end
+
+def main
+ client_control_port = ''
+ server_port = ''
+ OptionParser.new do |opts|
+ opts.on('--client_control_port=P', String) do |p|
+ client_control_port = p
+ end
+ opts.on('--server_port=P', String) do |p|
+ server_port = p
+ end
+ end.parse!
+
+ # The "shutdown" RPC should end very quickly.
+ # Allow a few seconds to be safe.
+ srv = new_rpc_server_for_testing(poll_period: 3)
+ srv.add_http2_port("0.0.0.0:#{client_control_port}",
+ :this_port_is_insecure)
+ stub = Echo::EchoServer::Stub.new("localhost:#{server_port}",
+ :this_channel_is_insecure)
+ control_service = SigHandlingClientController.new(srv, stub)
+ srv.handle(control_service)
+ server_thread = Thread.new do
+ srv.run_till_terminated_or_interrupted(['int'])
+ end
+ srv.wait_till_running
+ # send a first RPC to notify the parent process that we've started
+ stub.echo(Echo::EchoRequest.new(request: 'client/child started'))
+ server_thread.join
+ control_service.join_shutdown_thread
+end
+
+main
diff --git a/src/ruby/end2end/graceful_sig_stop_driver.rb b/src/ruby/end2end/graceful_sig_stop_driver.rb
new file mode 100755
index 0000000000..7a132403eb
--- /dev/null
+++ b/src/ruby/end2end/graceful_sig_stop_driver.rb
@@ -0,0 +1,62 @@
+#!/usr/bin/env ruby
+
+# Copyright 2016 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.
+
+# smoke test for a grpc-using app that receives and
+# handles process-ending signals
+
+require_relative './end2end_common'
+
+# A service that calls back it's received_rpc_callback
+# upon receiving an RPC. Used for synchronization/waiting
+# for child process to start.
+class ClientStartedService < Echo::EchoServer::Service
+ def initialize(received_rpc_callback)
+ @received_rpc_callback = received_rpc_callback
+ end
+
+ def echo(echo_req, _)
+ @received_rpc_callback.call unless @received_rpc_callback.nil?
+ @received_rpc_callback = nil
+ Echo::EchoReply.new(response: echo_req.request)
+ end
+end
+
+def main
+ STDERR.puts 'start server'
+ client_started = false
+ client_started_mu = Mutex.new
+ client_started_cv = ConditionVariable.new
+ received_rpc_callback = proc do
+ client_started_mu.synchronize do
+ client_started = true
+ client_started_cv.signal
+ end
+ end
+
+ client_started_service = ClientStartedService.new(received_rpc_callback)
+ server_runner = ServerRunner.new(client_started_service)
+ server_port = server_runner.run
+ STDERR.puts 'start client'
+ control_stub, client_pid = start_client('./graceful_sig_stop_client.rb', server_port)
+
+ client_started_mu.synchronize do
+ client_started_cv.wait(client_started_mu) until client_started
+ end
+
+ cleanup(control_stub, client_pid, server_runner)
+end
+
+main
diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c
index 6d4b2293a2..5bde962f78 100644
--- a/src/ruby/ext/grpc/rb_channel.c
+++ b/src/ruby/ext/grpc/rb_channel.c
@@ -153,7 +153,7 @@ static void grpc_rb_channel_free(void* p) {
if (ch->bg_wrapped != NULL) {
/* assumption made here: it's ok to directly gpr_mu_lock the global
- * connection polling mutex becuse we're in a finalizer,
+ * connection polling mutex because we're in a finalizer,
* and we can count on this thread to not be interrupted or
* yield the gil. */
grpc_rb_channel_safe_destroy(ch->bg_wrapped);
@@ -292,7 +292,7 @@ static void* get_state_without_gil(void* arg) {
Indicates the current state of the channel, whose value is one of the
constants defined in GRPC::Core::ConnectivityStates.
- It also tries to connect if the chennel is idle in the second form. */
+ It also tries to connect if the channel is idle in the second form. */
static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE* argv,
VALUE self) {
VALUE try_to_connect_param = Qfalse;
@@ -327,8 +327,8 @@ static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
void* success = (void*)0;
gpr_mu_lock(&global_connection_polling_mu);
- // its unsafe to do a "watch" after "channel polling abort" because the cq has
- // been shut down.
+ // it's unsafe to do a "watch" after "channel polling abort" because the cq
+ // has been shut down.
if (abort_channel_polling || stack->bg_wrapped->channel_destroyed) {
gpr_mu_unlock(&global_connection_polling_mu);
return (void*)0;
diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb
index 3b5a0ce27f..f0f73dc56e 100644
--- a/src/ruby/lib/grpc/generic/rpc_server.rb
+++ b/src/ruby/lib/grpc/generic/rpc_server.rb
@@ -240,6 +240,13 @@ module GRPC
# the call has no impact if the server is already stopped, otherwise
# server's current call loop is it's last.
def stop
+ # if called via run_till_terminated_or_interrupted,
+ # signal stop_server_thread and dont do anything
+ if @stop_server.nil? == false && @stop_server == false
+ @stop_server = true
+ @stop_server_cv.broadcast
+ return
+ end
@run_mutex.synchronize do
fail 'Cannot stop before starting' if @running_state == :not_started
return if @running_state != :running
@@ -354,6 +361,60 @@ module GRPC
alias_method :run_till_terminated, :run
+ # runs the server with signal handlers
+ # @param signals
+ # List of String, Integer or both representing signals that the user
+ # would like to send to the server for graceful shutdown
+ # @param wait_interval (optional)
+ # Integer seconds that user would like stop_server_thread to poll
+ # stop_server
+ def run_till_terminated_or_interrupted(signals, wait_interval = 60)
+ @stop_server = false
+ @stop_server_mu = Mutex.new
+ @stop_server_cv = ConditionVariable.new
+
+ @stop_server_thread = Thread.new do
+ loop do
+ break if @stop_server
+ @stop_server_mu.synchronize do
+ @stop_server_cv.wait(@stop_server_mu, wait_interval)
+ end
+ end
+
+ # stop is surrounded by mutex, should handle multiple calls to stop
+ # correctly
+ stop
+ end
+
+ valid_signals = Signal.list
+
+ # register signal handlers
+ signals.each do |sig|
+ # input validation
+ if sig.class == String
+ sig.upcase!
+ if sig.start_with?('SIG')
+ # cut out the SIG prefix to see if valid signal
+ sig = sig[3..-1]
+ end
+ end
+
+ # register signal traps for all valid signals
+ if valid_signals.value?(sig) || valid_signals.key?(sig)
+ Signal.trap(sig) do
+ @stop_server = true
+ @stop_server_cv.broadcast
+ end
+ else
+ fail "#{sig} not a valid signal"
+ end
+ end
+
+ run
+
+ @stop_server_thread.join
+ end
+
# Sends RESOURCE_EXHAUSTED if there are too many unprocessed jobs
def available?(an_rpc)
return an_rpc if @pool.ready_for_work?
diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb
index a4ed052d85..3b7f62d9f5 100644
--- a/src/ruby/lib/grpc/version.rb
+++ b/src/ruby/lib/grpc/version.rb
@@ -14,5 +14,5 @@
# GRPC contains the General RPC module.
module GRPC
- VERSION = '1.18.0.dev'
+ VERSION = '1.19.0.dev'
end
diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb
index 389fb70684..2ad685a7eb 100644
--- a/src/ruby/tools/version.rb
+++ b/src/ruby/tools/version.rb
@@ -14,6 +14,6 @@
module GRPC
module Tools
- VERSION = '1.18.0.dev'
+ VERSION = '1.19.0.dev'
end
end
diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template
index 1628493d00..f33d980cd0 100644
--- a/templates/CMakeLists.txt.template
+++ b/templates/CMakeLists.txt.template
@@ -143,7 +143,7 @@
## Some libraries are shared even with BUILD_SHARED_LIBRARIES=OFF
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
- add_definitions(-DPB_FIELD_16BIT)
+ add_definitions(-DPB_FIELD_32BIT)
if (MSVC)
include(cmake/msvc_static_runtime.cmake)
diff --git a/templates/gRPC-Core.podspec.template b/templates/gRPC-Core.podspec.template
index 461e8b767f..5e6080448b 100644
--- a/templates/gRPC-Core.podspec.template
+++ b/templates/gRPC-Core.podspec.template
@@ -152,7 +152,7 @@
}
s.default_subspecs = 'Interface', 'Implementation'
- s.compiler_flags = '-DGRPC_ARES=0', '-DPB_FIELD_16BIT'
+ s.compiler_flags = '-DGRPC_ARES=0', '-DPB_FIELD_32BIT'
s.libraries = 'c++'
# Like many other C libraries, gRPC-Core has its public headers under `include/<libname>/` and its
diff --git a/templates/gRPC.podspec.template b/templates/gRPC.podspec.template
index a3190c2d8e..593d277e5b 100644
--- a/templates/gRPC.podspec.template
+++ b/templates/gRPC.podspec.template
@@ -60,7 +60,7 @@
ss.source_files = "#{src_dir}/*.{h,m}", "#{src_dir}/**/*.{h,m}"
ss.exclude_files = "#{src_dir}/GRPCCall+GID.{h,m}"
- ss.private_header_files = "#{src_dir}/private/*.h"
+ ss.private_header_files = "#{src_dir}/private/*.h", "#{src_dir}/internal/*.h"
ss.dependency 'gRPC-Core', version
end
diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_go1.11/Dockerfile.template b/templates/tools/dockerfile/interoptest/grpc_interop_go1.11/Dockerfile.template
new file mode 100644
index 0000000000..4921d93f49
--- /dev/null
+++ b/templates/tools/dockerfile/interoptest/grpc_interop_go1.11/Dockerfile.template
@@ -0,0 +1,23 @@
+%YAML 1.2
+--- |
+ # Copyright 2018 The 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.
+
+ FROM golang:1.11
+
+ <%include file="../../go_path.include"/>
+ <%include file="../../python_deps.include"/>
+ # Define the default command.
+ CMD ["bash"]
+
diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_go1.11/build_interop.sh.template b/templates/tools/dockerfile/interoptest/grpc_interop_go1.11/build_interop.sh.template
new file mode 100644
index 0000000000..a08798b1d6
--- /dev/null
+++ b/templates/tools/dockerfile/interoptest/grpc_interop_go1.11/build_interop.sh.template
@@ -0,0 +1,3 @@
+%YAML 1.2
+--- |
+ <%include file="../../go_build_interop.sh.include"/>
diff --git a/templates/tools/dockerfile/ruby_deps.include b/templates/tools/dockerfile/ruby_deps.include
index a8ee3ec7dc..c2d330988c 100644
--- a/templates/tools/dockerfile/ruby_deps.include
+++ b/templates/tools/dockerfile/ruby_deps.include
@@ -2,13 +2,13 @@
# Ruby dependencies
# Install rvm
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN \curl -sSL https://get.rvm.io | bash -s stable
-# Install Ruby 2.1
-RUN /bin/bash -l -c "rvm install ruby-2.1"
-RUN /bin/bash -l -c "rvm use --default ruby-2.1"
-RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
+# Install Ruby 2.5
+RUN /bin/bash -l -c "rvm install ruby-2.5"
+RUN /bin/bash -l -c "rvm use --default ruby-2.5"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
-RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
-RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.5' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler --no-document"
diff --git a/test/core/client_channel/BUILD b/test/core/client_channel/BUILD
index 04485f5240..57e5191af4 100644
--- a/test/core/client_channel/BUILD
+++ b/test/core/client_channel/BUILD
@@ -44,6 +44,17 @@ grpc_cc_test(
)
grpc_cc_test(
+ name = "parse_address_with_named_scope_id_test",
+ srcs = ["parse_address_with_named_scope_id_test.cc"],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
name = "uri_parser_test",
srcs = ["uri_parser_test.cc"],
language = "C++",
diff --git a/test/core/client_channel/parse_address_with_named_scope_id_test.cc b/test/core/client_channel/parse_address_with_named_scope_id_test.cc
new file mode 100644
index 0000000000..bfafa74517
--- /dev/null
+++ b/test/core/client_channel/parse_address_with_named_scope_id_test.cc
@@ -0,0 +1,126 @@
+/*
+ *
+ * Copyright 2017 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 "src/core/ext/filters/client_channel/parse_address.h"
+#include "src/core/lib/iomgr/sockaddr.h"
+#include "src/core/lib/iomgr/socket_utils.h"
+
+#include <net/if.h>
+#include <string.h>
+#ifdef GRPC_HAVE_UNIX_SOCKET
+#include <sys/un.h>
+#endif
+
+#include <grpc/grpc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#include "src/core/lib/gpr/host_port.h"
+#include "src/core/lib/iomgr/exec_ctx.h"
+#include "src/core/lib/iomgr/socket_utils.h"
+#include "test/core/util/test_config.h"
+
+static void test_grpc_parse_ipv6_parity_with_getaddrinfo(
+ const char* target, const struct sockaddr_in6 result_from_getaddrinfo) {
+ // Get the sockaddr that gRPC's ipv6 resolver resolves this too.
+ grpc_core::ExecCtx exec_ctx;
+ grpc_uri* uri = grpc_uri_parse(target, 0);
+ grpc_resolved_address addr;
+ GPR_ASSERT(1 == grpc_parse_ipv6(uri, &addr));
+ grpc_sockaddr_in6* result_from_grpc_parser =
+ reinterpret_cast<grpc_sockaddr_in6*>(addr.addr);
+ // Compare the sockaddr returned from gRPC's ipv6 resolver with that returned
+ // from getaddrinfo.
+ GPR_ASSERT(result_from_grpc_parser->sin6_family == AF_INET6);
+ GPR_ASSERT(result_from_getaddrinfo.sin6_family == AF_INET6);
+ GPR_ASSERT(memcmp(&result_from_grpc_parser->sin6_addr,
+ &result_from_getaddrinfo.sin6_addr, sizeof(in6_addr)) == 0);
+ GPR_ASSERT(result_from_grpc_parser->sin6_scope_id ==
+ result_from_getaddrinfo.sin6_scope_id);
+ GPR_ASSERT(result_from_grpc_parser->sin6_scope_id != 0);
+ // TODO: compare sin6_flow_info fields? parse_ipv6 zero's this field as is.
+ // Cleanup
+ grpc_uri_destroy(uri);
+}
+
+struct sockaddr_in6 resolve_with_gettaddrinfo(const char* uri_text) {
+ grpc_uri* uri = grpc_uri_parse(uri_text, 0);
+ char* host = nullptr;
+ char* port = nullptr;
+ gpr_split_host_port(uri->path, &host, &port);
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = AF_INET6;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_NUMERICHOST;
+ struct addrinfo* result;
+ int res = getaddrinfo(host, port, &hints, &result);
+ if (res != 0) {
+ gpr_log(GPR_ERROR,
+ "getaddrinfo failed to resolve host:%s port:%s. Error: %d.", host,
+ port, res);
+ abort();
+ }
+ size_t num_addrs_from_getaddrinfo = 0;
+ for (struct addrinfo* resp = result; resp != nullptr; resp = resp->ai_next) {
+ num_addrs_from_getaddrinfo++;
+ }
+ GPR_ASSERT(num_addrs_from_getaddrinfo == 1);
+ GPR_ASSERT(result->ai_family == AF_INET6);
+ struct sockaddr_in6 out =
+ *reinterpret_cast<struct sockaddr_in6*>(result->ai_addr);
+ // Cleanup
+ freeaddrinfo(result);
+ gpr_free(host);
+ gpr_free(port);
+ grpc_uri_destroy(uri);
+ return out;
+}
+
+int main(int argc, char** argv) {
+ grpc_test_init(argc, argv);
+ grpc_init();
+ char* arbitrary_interface_name = static_cast<char*>(gpr_zalloc(IF_NAMESIZE));
+ // Per RFC 3493, an interface index is a "small positive integer starts at 1".
+ // Probe candidate interface index numbers until we find one that the
+ // system recognizes, and then use that for the test.
+ for (size_t i = 1; i < 65536; i++) {
+ if (if_indextoname(i, arbitrary_interface_name) != nullptr) {
+ gpr_log(
+ GPR_DEBUG,
+ "Found interface at index %d named %s. Will use this for the test",
+ (int)i, arbitrary_interface_name);
+ break;
+ }
+ }
+ GPR_ASSERT(strlen(arbitrary_interface_name) > 0);
+ char* target = nullptr;
+ gpr_asprintf(&target, "ipv6:[fe80::1234%%%s]:12345",
+ arbitrary_interface_name);
+ struct sockaddr_in6 result_from_getaddrinfo =
+ resolve_with_gettaddrinfo(target);
+ // Run the test
+ gpr_log(GPR_DEBUG,
+ "Run test_grpc_parse_ipv6_parity_with_getaddrinfo with target: %s",
+ target);
+ test_grpc_parse_ipv6_parity_with_getaddrinfo(target, result_from_getaddrinfo);
+ // Cleanup
+ gpr_free(target);
+ gpr_free(arbitrary_interface_name);
+ grpc_shutdown();
+}
diff --git a/test/core/end2end/fixtures/h2_full+trace.cc b/test/core/end2end/fixtures/h2_full+trace.cc
index 2bbad48701..ce8f6bf13a 100644
--- a/test/core/end2end/fixtures/h2_full+trace.cc
+++ b/test/core/end2end/fixtures/h2_full+trace.cc
@@ -113,6 +113,15 @@ int main(int argc, char** argv) {
g_fixture_slowdown_factor = 10;
#endif
+#ifdef GPR_WINDOWS
+ /* on Windows, writing logs to stderr is very slow
+ when stderr is redirected to a disk file.
+ The "trace" tests fixtures generates large amount
+ of logs, so setting a buffer for stderr prevents certain
+ test cases from timing out. */
+ setvbuf(stderr, NULL, _IOLBF, 1024);
+#endif
+
grpc::testing::TestEnvironment env(argc, argv);
grpc_end2end_tests_pre_init();
grpc_init();
diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.cc b/test/core/end2end/fixtures/h2_sockpair+trace.cc
index 45f78b5964..4494d5c474 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.cc
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.cc
@@ -140,6 +140,15 @@ int main(int argc, char** argv) {
g_fixture_slowdown_factor = 10;
#endif
+#ifdef GPR_WINDOWS
+ /* on Windows, writing logs to stderr is very slow
+ when stderr is redirected to a disk file.
+ The "trace" tests fixtures generates large amount
+ of logs, so setting a buffer for stderr prevents certain
+ test cases from timing out. */
+ setvbuf(stderr, NULL, _IOLBF, 1024);
+#endif
+
grpc::testing::TestEnvironment env(argc, argv);
grpc_end2end_tests_pre_init();
grpc_init();
diff --git a/test/core/fling/BUILD b/test/core/fling/BUILD
index 5c6930cc85..0c16b2a879 100644
--- a/test/core/fling/BUILD
+++ b/test/core/fling/BUILD
@@ -21,7 +21,7 @@ licenses(["notice"]) # Apache v2
load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer")
grpc_cc_binary(
- name = "client",
+ name = "fling_client",
testonly = 1,
srcs = ["client.cc"],
language = "C++",
@@ -34,7 +34,7 @@ grpc_cc_binary(
)
grpc_cc_binary(
- name = "server",
+ name = "fling_server",
testonly = 1,
srcs = ["server.cc"],
language = "C++",
@@ -50,8 +50,8 @@ grpc_cc_test(
name = "fling",
srcs = ["fling_test.cc"],
data = [
- ":client",
- ":server",
+ ":fling_client",
+ ":fling_server",
],
deps = [
"//:gpr",
@@ -65,8 +65,8 @@ grpc_cc_test(
name = "fling_stream",
srcs = ["fling_stream_test.cc"],
data = [
- ":client",
- ":server",
+ ":fling_client",
+ ":fling_server",
],
deps = [
"//:gpr",
diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD
index e920ceacf0..7daabd5052 100644
--- a/test/core/iomgr/BUILD
+++ b/test/core/iomgr/BUILD
@@ -128,8 +128,25 @@ grpc_cc_test(
)
grpc_cc_test(
- name = "resolve_address_posix_test",
+ name = "resolve_address_using_ares_resolver_posix_test",
srcs = ["resolve_address_posix_test.cc"],
+ args = [
+ "--resolver=ares",
+ ],
+ language = "C++",
+ deps = [
+ "//:gpr",
+ "//:grpc",
+ "//test/core/util:grpc_test_util",
+ ],
+)
+
+grpc_cc_test(
+ name = "resolve_address_using_native_resolver_posix_test",
+ srcs = ["resolve_address_posix_test.cc"],
+ args = [
+ "--resolver=native",
+ ],
language = "C++",
deps = [
"//:gpr",
@@ -237,7 +254,6 @@ grpc_cc_test(
name = "tcp_server_posix_test",
srcs = ["tcp_server_posix_test.cc"],
language = "C++",
- tags = ["manual"], # TODO(adelez): Remove once this works on Foundry.
deps = [
"//:gpr",
"//:grpc",
diff --git a/test/core/iomgr/resolve_address_posix_test.cc b/test/core/iomgr/resolve_address_posix_test.cc
index 5785c73e22..826c7e1faf 100644
--- a/test/core/iomgr/resolve_address_posix_test.cc
+++ b/test/core/iomgr/resolve_address_posix_test.cc
@@ -18,12 +18,14 @@
#include "src/core/lib/iomgr/resolve_address.h"
+#include <net/if.h>
#include <string.h>
#include <sys/un.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@@ -33,6 +35,7 @@
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
+#include "test/core/util/cmdline.h"
#include "test/core/util/test_config.h"
static gpr_timespec test_deadline(void) {
@@ -117,12 +120,18 @@ static void must_succeed(void* argsp, grpc_error* err) {
GPR_ASSERT(args->addrs != nullptr);
GPR_ASSERT(args->addrs->naddrs > 0);
gpr_atm_rel_store(&args->done_atm, 1);
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
+ gpr_mu_unlock(args->mu);
}
static void must_fail(void* argsp, grpc_error* err) {
args_struct* args = static_cast<args_struct*>(argsp);
GPR_ASSERT(err != GRPC_ERROR_NONE);
gpr_atm_rel_store(&args->done_atm, 1);
+ gpr_mu_lock(args->mu);
+ GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(args->pollset, nullptr));
+ gpr_mu_unlock(args->mu);
}
static void test_unix_socket(void) {
@@ -159,22 +168,92 @@ static void test_unix_socket_path_name_too_long(void) {
args_finish(&args);
}
+static void resolve_address_must_succeed(const char* target) {
+ grpc_core::ExecCtx exec_ctx;
+ args_struct args;
+ args_init(&args);
+ poll_pollset_until_request_done(&args);
+ grpc_resolve_address(
+ target, "1" /* port number */, args.pollset_set,
+ GRPC_CLOSURE_CREATE(must_succeed, &args, grpc_schedule_on_exec_ctx),
+ &args.addrs);
+ grpc_core::ExecCtx::Get()->Flush();
+ args_finish(&args);
+}
+
+static void test_named_and_numeric_scope_ids(void) {
+ char* arbitrary_interface_name = static_cast<char*>(gpr_zalloc(IF_NAMESIZE));
+ int interface_index = 0;
+ // Probe candidate interface index numbers until we find one that the
+ // system recognizes, and then use that for the test.
+ for (size_t i = 1; i < 65536; i++) {
+ if (if_indextoname(i, arbitrary_interface_name) != nullptr) {
+ gpr_log(
+ GPR_DEBUG,
+ "Found interface at index %d named %s. Will use this for the test",
+ (int)i, arbitrary_interface_name);
+ interface_index = (int)i;
+ break;
+ }
+ }
+ GPR_ASSERT(strlen(arbitrary_interface_name) > 0);
+ // Test resolution of an ipv6 address with a named scope ID
+ gpr_log(GPR_DEBUG, "test resolution with a named scope ID");
+ char* target_with_named_scope_id = nullptr;
+ gpr_asprintf(&target_with_named_scope_id, "fe80::1234%%%s",
+ arbitrary_interface_name);
+ resolve_address_must_succeed(target_with_named_scope_id);
+ gpr_free(target_with_named_scope_id);
+ gpr_free(arbitrary_interface_name);
+ // Test resolution of an ipv6 address with a numeric scope ID
+ gpr_log(GPR_DEBUG, "test resolution with a numeric scope ID");
+ char* target_with_numeric_scope_id = nullptr;
+ gpr_asprintf(&target_with_numeric_scope_id, "fe80::1234%%%d",
+ interface_index);
+ resolve_address_must_succeed(target_with_numeric_scope_id);
+ gpr_free(target_with_numeric_scope_id);
+}
+
int main(int argc, char** argv) {
+ // First set the resolver type based off of --resolver
+ const char* resolver_type = nullptr;
+ gpr_cmdline* cl = gpr_cmdline_create("resolve address test");
+ gpr_cmdline_add_string(cl, "resolver", "Resolver type (ares or native)",
+ &resolver_type);
+ // In case that there are more than one argument on the command line,
+ // --resolver will always be the first one, so only parse the first argument
+ // (other arguments may be unknown to cl)
+ gpr_cmdline_parse(cl, argc > 2 ? 2 : argc, argv);
+ const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER");
+ if (cur_resolver != nullptr && strlen(cur_resolver) != 0) {
+ gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s",
+ cur_resolver);
+ }
+ if (gpr_stricmp(resolver_type, "native") == 0) {
+ gpr_setenv("GRPC_DNS_RESOLVER", "native");
+ } else if (gpr_stricmp(resolver_type, "ares") == 0) {
+ gpr_setenv("GRPC_DNS_RESOLVER", "ares");
+ } else {
+ gpr_log(GPR_ERROR, "--resolver_type was not set to ares or native");
+ abort();
+ }
grpc::testing::TestEnvironment env(argc, argv);
grpc_init();
{
grpc_core::ExecCtx exec_ctx;
- char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER");
+ test_named_and_numeric_scope_ids();
// c-ares resolver doesn't support UDS (ability for native DNS resolver
// to handle this is only expected to be used by servers, which
// unconditionally use the native DNS resolver).
+ char* resolver_env = gpr_getenv("GRPC_DNS_RESOLVER");
if (resolver_env == nullptr || gpr_stricmp(resolver_env, "native") == 0) {
test_unix_socket();
test_unix_socket_path_name_too_long();
}
gpr_free(resolver_env);
}
+ gpr_cmdline_destroy(cl);
grpc_shutdown();
return 0;
diff --git a/test/core/iomgr/tcp_server_posix_test.cc b/test/core/iomgr/tcp_server_posix_test.cc
index 2c66cdec77..81e26b20cd 100644
--- a/test/core/iomgr/tcp_server_posix_test.cc
+++ b/test/core/iomgr/tcp_server_posix_test.cc
@@ -439,6 +439,11 @@ int main(int argc, char** argv) {
static_cast<test_addrs*>(gpr_zalloc(sizeof(*dst_addrs)));
grpc::testing::TestEnvironment env(argc, argv);
grpc_init();
+ // wait a few seconds to make sure IPv6 link-local addresses can be bound
+ // if we are running under docker container that has just started.
+ // See https://github.com/moby/moby/issues/38491
+ // See https://github.com/grpc/grpc/issues/15610
+ gpr_sleep_until(grpc_timeout_seconds_to_deadline(4));
{
grpc_core::ExecCtx exec_ctx;
g_pollset = static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size()));
diff --git a/test/core/memory_usage/BUILD b/test/core/memory_usage/BUILD
index 2fe94dfa12..38b088c75c 100644
--- a/test/core/memory_usage/BUILD
+++ b/test/core/memory_usage/BUILD
@@ -19,7 +19,7 @@ grpc_package(name = "test/core/memory_usage")
licenses(["notice"]) # Apache v2
grpc_cc_library(
- name = "client",
+ name = "memory_usage_client",
testonly = 1,
srcs = ["client.cc"],
deps = [
@@ -30,7 +30,7 @@ grpc_cc_library(
)
grpc_cc_library(
- name = "server",
+ name = "memory_usage_server",
testonly = 1,
srcs = ["server.cc"],
deps = [
@@ -45,8 +45,8 @@ grpc_cc_test(
name = "memory_usage_test",
srcs = ["memory_usage_test.cc"],
data = [
- ":client",
- ":server",
+ ":memory_usage_client",
+ ":memory_usage_server",
],
language = "C++",
deps = [
diff --git a/test/cpp/end2end/client_interceptors_end2end_test.cc b/test/cpp/end2end/client_interceptors_end2end_test.cc
index 8abf4eb3f4..177922f457 100644
--- a/test/cpp/end2end/client_interceptors_end2end_test.cc
+++ b/test/cpp/end2end/client_interceptors_end2end_test.cc
@@ -68,7 +68,7 @@ class HijackingInterceptor : public experimental::Interceptor {
if (methods->QueryInterceptionHookPoint(
experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
EchoRequest req;
- auto* buffer = methods->GetSendMessage();
+ auto* buffer = methods->GetSerializedSendMessage();
auto copied_buffer = *buffer;
EXPECT_TRUE(
SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req)
@@ -173,7 +173,7 @@ class HijackingInterceptorMakesAnotherCall : public experimental::Interceptor {
if (methods->QueryInterceptionHookPoint(
experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
EchoRequest req;
- auto* buffer = methods->GetSendMessage();
+ auto* buffer = methods->GetSerializedSendMessage();
auto copied_buffer = *buffer;
EXPECT_TRUE(
SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req)
@@ -270,6 +270,235 @@ class HijackingInterceptorMakesAnotherCallFactory
}
};
+class BidiStreamingRpcHijackingInterceptor : public experimental::Interceptor {
+ public:
+ BidiStreamingRpcHijackingInterceptor(experimental::ClientRpcInfo* info) {
+ info_ = info;
+ }
+
+ virtual void Intercept(experimental::InterceptorBatchMethods* methods) {
+ bool hijack = false;
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) {
+ CheckMetadata(*methods->GetSendInitialMetadata(), "testkey", "testvalue");
+ hijack = true;
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
+ EchoRequest req;
+ auto* buffer = methods->GetSerializedSendMessage();
+ auto copied_buffer = *buffer;
+ EXPECT_TRUE(
+ SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req)
+ .ok());
+ EXPECT_EQ(req.message().find("Hello"), 0u);
+ msg = req.message();
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) {
+ // Got nothing to do here for now
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::POST_RECV_STATUS)) {
+ CheckMetadata(*methods->GetRecvTrailingMetadata(), "testkey",
+ "testvalue");
+ auto* status = methods->GetRecvStatus();
+ EXPECT_EQ(status->ok(), true);
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)) {
+ EchoResponse* resp =
+ static_cast<EchoResponse*>(methods->GetRecvMessage());
+ resp->set_message(msg);
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) {
+ EXPECT_EQ(static_cast<EchoResponse*>(methods->GetRecvMessage())
+ ->message()
+ .find("Hello"),
+ 0u);
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_RECV_STATUS)) {
+ auto* map = methods->GetRecvTrailingMetadata();
+ // insert the metadata that we want
+ EXPECT_EQ(map->size(), static_cast<unsigned>(0));
+ map->insert(std::make_pair("testkey", "testvalue"));
+ auto* status = methods->GetRecvStatus();
+ *status = Status(StatusCode::OK, "");
+ }
+ if (hijack) {
+ methods->Hijack();
+ } else {
+ methods->Proceed();
+ }
+ }
+
+ private:
+ experimental::ClientRpcInfo* info_;
+ grpc::string msg;
+};
+
+class ClientStreamingRpcHijackingInterceptor
+ : public experimental::Interceptor {
+ public:
+ ClientStreamingRpcHijackingInterceptor(experimental::ClientRpcInfo* info) {
+ info_ = info;
+ }
+ virtual void Intercept(experimental::InterceptorBatchMethods* methods) {
+ bool hijack = false;
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) {
+ hijack = true;
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
+ if (++count_ > 10) {
+ methods->FailHijackedSendMessage();
+ }
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::POST_SEND_MESSAGE)) {
+ EXPECT_FALSE(got_failed_send_);
+ got_failed_send_ = !methods->GetSendMessageStatus();
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_RECV_STATUS)) {
+ auto* status = methods->GetRecvStatus();
+ *status = Status(StatusCode::UNAVAILABLE, "Done sending 10 messages");
+ }
+ if (hijack) {
+ methods->Hijack();
+ } else {
+ methods->Proceed();
+ }
+ }
+
+ static bool GotFailedSend() { return got_failed_send_; }
+
+ private:
+ experimental::ClientRpcInfo* info_;
+ int count_ = 0;
+ static bool got_failed_send_;
+};
+
+bool ClientStreamingRpcHijackingInterceptor::got_failed_send_ = false;
+
+class ClientStreamingRpcHijackingInterceptorFactory
+ : public experimental::ClientInterceptorFactoryInterface {
+ public:
+ virtual experimental::Interceptor* CreateClientInterceptor(
+ experimental::ClientRpcInfo* info) override {
+ return new ClientStreamingRpcHijackingInterceptor(info);
+ }
+};
+
+class ServerStreamingRpcHijackingInterceptor
+ : public experimental::Interceptor {
+ public:
+ ServerStreamingRpcHijackingInterceptor(experimental::ClientRpcInfo* info) {
+ info_ = info;
+ }
+
+ virtual void Intercept(experimental::InterceptorBatchMethods* methods) {
+ bool hijack = false;
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) {
+ auto* map = methods->GetSendInitialMetadata();
+ // Check that we can see the test metadata
+ ASSERT_EQ(map->size(), static_cast<unsigned>(1));
+ auto iterator = map->begin();
+ EXPECT_EQ("testkey", iterator->first);
+ EXPECT_EQ("testvalue", iterator->second);
+ hijack = true;
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
+ EchoRequest req;
+ auto* buffer = methods->GetSerializedSendMessage();
+ auto copied_buffer = *buffer;
+ EXPECT_TRUE(
+ SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req)
+ .ok());
+ EXPECT_EQ(req.message(), "Hello");
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) {
+ // Got nothing to do here for now
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::POST_RECV_STATUS)) {
+ auto* map = methods->GetRecvTrailingMetadata();
+ bool found = false;
+ // Check that we received the metadata as an echo
+ for (const auto& pair : *map) {
+ found = pair.first.starts_with("testkey") &&
+ pair.second.starts_with("testvalue");
+ if (found) break;
+ }
+ EXPECT_EQ(found, true);
+ auto* status = methods->GetRecvStatus();
+ EXPECT_EQ(status->ok(), true);
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_RECV_MESSAGE)) {
+ if (++count_ > 10) {
+ methods->FailHijackedRecvMessage();
+ }
+ EchoResponse* resp =
+ static_cast<EchoResponse*>(methods->GetRecvMessage());
+ resp->set_message("Hello");
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) {
+ // Only the last message will be a failure
+ EXPECT_FALSE(got_failed_message_);
+ got_failed_message_ = methods->GetRecvMessage() == nullptr;
+ }
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_RECV_STATUS)) {
+ auto* map = methods->GetRecvTrailingMetadata();
+ // insert the metadata that we want
+ EXPECT_EQ(map->size(), static_cast<unsigned>(0));
+ map->insert(std::make_pair("testkey", "testvalue"));
+ auto* status = methods->GetRecvStatus();
+ *status = Status(StatusCode::OK, "");
+ }
+ if (hijack) {
+ methods->Hijack();
+ } else {
+ methods->Proceed();
+ }
+ }
+
+ static bool GotFailedMessage() { return got_failed_message_; }
+
+ private:
+ experimental::ClientRpcInfo* info_;
+ static bool got_failed_message_;
+ int count_ = 0;
+};
+
+bool ServerStreamingRpcHijackingInterceptor::got_failed_message_ = false;
+
+class ServerStreamingRpcHijackingInterceptorFactory
+ : public experimental::ClientInterceptorFactoryInterface {
+ public:
+ virtual experimental::Interceptor* CreateClientInterceptor(
+ experimental::ClientRpcInfo* info) override {
+ return new ServerStreamingRpcHijackingInterceptor(info);
+ }
+};
+
+class BidiStreamingRpcHijackingInterceptorFactory
+ : public experimental::ClientInterceptorFactoryInterface {
+ public:
+ virtual experimental::Interceptor* CreateClientInterceptor(
+ experimental::ClientRpcInfo* info) override {
+ return new BidiStreamingRpcHijackingInterceptor(info);
+ }
+};
+
class LoggingInterceptor : public experimental::Interceptor {
public:
LoggingInterceptor(experimental::ClientRpcInfo* info) { info_ = info; }
@@ -287,12 +516,16 @@ class LoggingInterceptor : public experimental::Interceptor {
if (methods->QueryInterceptionHookPoint(
experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
EchoRequest req;
- auto* buffer = methods->GetSendMessage();
+ EXPECT_EQ(static_cast<const EchoRequest*>(methods->GetSendMessage())
+ ->message()
+ .find("Hello"),
+ 0u);
+ auto* buffer = methods->GetSerializedSendMessage();
auto copied_buffer = *buffer;
EXPECT_TRUE(
SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req)
.ok());
- EXPECT_TRUE(req.message().find("Hello") == 0);
+ EXPECT_TRUE(req.message().find("Hello") == 0u);
}
if (methods->QueryInterceptionHookPoint(
experimental::InterceptionHookPoints::PRE_SEND_CLOSE)) {
@@ -308,7 +541,7 @@ class LoggingInterceptor : public experimental::Interceptor {
experimental::InterceptionHookPoints::POST_RECV_MESSAGE)) {
EchoResponse* resp =
static_cast<EchoResponse*>(methods->GetRecvMessage());
- EXPECT_TRUE(resp->message().find("Hello") == 0);
+ EXPECT_TRUE(resp->message().find("Hello") == 0u);
}
if (methods->QueryInterceptionHookPoint(
experimental::InterceptionHookPoints::POST_RECV_STATUS)) {
@@ -546,6 +779,62 @@ TEST_F(ClientInterceptorsStreamingEnd2endTest, ServerStreamingTest) {
EXPECT_EQ(DummyInterceptor::GetNumTimesRun(), 20);
}
+TEST_F(ClientInterceptorsStreamingEnd2endTest, ClientStreamingHijackingTest) {
+ ChannelArguments args;
+ std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
+ creators;
+ creators.push_back(
+ std::unique_ptr<ClientStreamingRpcHijackingInterceptorFactory>(
+ new ClientStreamingRpcHijackingInterceptorFactory()));
+ auto channel = experimental::CreateCustomChannelWithInterceptors(
+ server_address_, InsecureChannelCredentials(), args, std::move(creators));
+
+ auto stub = grpc::testing::EchoTestService::NewStub(channel);
+ ClientContext ctx;
+ EchoRequest req;
+ EchoResponse resp;
+ req.mutable_param()->set_echo_metadata(true);
+ req.set_message("Hello");
+ string expected_resp = "";
+ auto writer = stub->RequestStream(&ctx, &resp);
+ for (int i = 0; i < 10; i++) {
+ EXPECT_TRUE(writer->Write(req));
+ expected_resp += "Hello";
+ }
+ // The interceptor will reject the 11th message
+ writer->Write(req);
+ Status s = writer->Finish();
+ EXPECT_EQ(s.ok(), false);
+ EXPECT_TRUE(ClientStreamingRpcHijackingInterceptor::GotFailedSend());
+}
+
+TEST_F(ClientInterceptorsStreamingEnd2endTest, ServerStreamingHijackingTest) {
+ ChannelArguments args;
+ DummyInterceptor::Reset();
+ std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
+ creators;
+ creators.push_back(
+ std::unique_ptr<ServerStreamingRpcHijackingInterceptorFactory>(
+ new ServerStreamingRpcHijackingInterceptorFactory()));
+ auto channel = experimental::CreateCustomChannelWithInterceptors(
+ server_address_, InsecureChannelCredentials(), args, std::move(creators));
+ MakeServerStreamingCall(channel);
+ EXPECT_TRUE(ServerStreamingRpcHijackingInterceptor::GotFailedMessage());
+}
+
+TEST_F(ClientInterceptorsStreamingEnd2endTest, BidiStreamingHijackingTest) {
+ ChannelArguments args;
+ DummyInterceptor::Reset();
+ std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
+ creators;
+ creators.push_back(
+ std::unique_ptr<BidiStreamingRpcHijackingInterceptorFactory>(
+ new BidiStreamingRpcHijackingInterceptorFactory()));
+ auto channel = experimental::CreateCustomChannelWithInterceptors(
+ server_address_, InsecureChannelCredentials(), args, std::move(creators));
+ MakeBidiStreamingCall(channel);
+}
+
TEST_F(ClientInterceptorsStreamingEnd2endTest, BidiStreamingTest) {
ChannelArguments args;
DummyInterceptor::Reset();
diff --git a/test/cpp/end2end/interceptors_util.cc b/test/cpp/end2end/interceptors_util.cc
index e0ad7d1526..900f02b5f3 100644
--- a/test/cpp/end2end/interceptors_util.cc
+++ b/test/cpp/end2end/interceptors_util.cc
@@ -132,6 +132,16 @@ bool CheckMetadata(const std::multimap<grpc::string_ref, grpc::string_ref>& map,
return false;
}
+bool CheckMetadata(const std::multimap<grpc::string, grpc::string>& map,
+ const string& key, const string& value) {
+ for (const auto& pair : map) {
+ if (pair.first == key && pair.second == value) {
+ return true;
+ }
+ }
+ return false;
+}
+
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
CreateDummyClientInterceptors() {
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
diff --git a/test/cpp/end2end/interceptors_util.h b/test/cpp/end2end/interceptors_util.h
index 659e613d2e..419845e5f6 100644
--- a/test/cpp/end2end/interceptors_util.h
+++ b/test/cpp/end2end/interceptors_util.h
@@ -165,6 +165,9 @@ void MakeCallbackCall(const std::shared_ptr<Channel>& channel);
bool CheckMetadata(const std::multimap<grpc::string_ref, grpc::string_ref>& map,
const string& key, const string& value);
+bool CheckMetadata(const std::multimap<grpc::string, grpc::string>& map,
+ const string& key, const string& value);
+
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
CreateDummyClientInterceptors();
diff --git a/test/cpp/end2end/server_interceptors_end2end_test.cc b/test/cpp/end2end/server_interceptors_end2end_test.cc
index 53d8c4dc96..82f142ba91 100644
--- a/test/cpp/end2end/server_interceptors_end2end_test.cc
+++ b/test/cpp/end2end/server_interceptors_end2end_test.cc
@@ -73,7 +73,7 @@ class LoggingInterceptor : public experimental::Interceptor {
type == experimental::ServerRpcInfo::Type::BIDI_STREAMING));
}
- virtual void Intercept(experimental::InterceptorBatchMethods* methods) {
+ void Intercept(experimental::InterceptorBatchMethods* methods) override {
if (methods->QueryInterceptionHookPoint(
experimental::InterceptionHookPoints::PRE_SEND_INITIAL_METADATA)) {
auto* map = methods->GetSendInitialMetadata();
@@ -83,7 +83,7 @@ class LoggingInterceptor : public experimental::Interceptor {
if (methods->QueryInterceptionHookPoint(
experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
EchoRequest req;
- auto* buffer = methods->GetSendMessage();
+ auto* buffer = methods->GetSerializedSendMessage();
auto copied_buffer = *buffer;
EXPECT_TRUE(
SerializationTraits<EchoRequest>::Deserialize(&copied_buffer, &req)
@@ -142,6 +142,71 @@ class LoggingInterceptorFactory
}
};
+// Test if SendMessage function family works as expected for sync/callback apis
+class SyncSendMessageTester : public experimental::Interceptor {
+ public:
+ SyncSendMessageTester(experimental::ServerRpcInfo* info) {}
+
+ void Intercept(experimental::InterceptorBatchMethods* methods) override {
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
+ string old_msg =
+ static_cast<const EchoRequest*>(methods->GetSendMessage())->message();
+ EXPECT_EQ(old_msg.find("Hello"), 0u);
+ new_msg_.set_message("World" + old_msg);
+ methods->ModifySendMessage(&new_msg_);
+ }
+ methods->Proceed();
+ }
+
+ private:
+ EchoRequest new_msg_;
+};
+
+class SyncSendMessageTesterFactory
+ : public experimental::ServerInterceptorFactoryInterface {
+ public:
+ virtual experimental::Interceptor* CreateServerInterceptor(
+ experimental::ServerRpcInfo* info) override {
+ return new SyncSendMessageTester(info);
+ }
+};
+
+// Test if SendMessage function family works as expected for sync/callback apis
+class SyncSendMessageVerifier : public experimental::Interceptor {
+ public:
+ SyncSendMessageVerifier(experimental::ServerRpcInfo* info) {}
+
+ void Intercept(experimental::InterceptorBatchMethods* methods) override {
+ if (methods->QueryInterceptionHookPoint(
+ experimental::InterceptionHookPoints::PRE_SEND_MESSAGE)) {
+ // Make sure that the changes made in SyncSendMessageTester persisted
+ string old_msg =
+ static_cast<const EchoRequest*>(methods->GetSendMessage())->message();
+ EXPECT_EQ(old_msg.find("World"), 0u);
+
+ // Remove the "World" part of the string that we added earlier
+ new_msg_.set_message(old_msg.erase(0, 5));
+ methods->ModifySendMessage(&new_msg_);
+
+ // LoggingInterceptor verifies that changes got reverted
+ }
+ methods->Proceed();
+ }
+
+ private:
+ EchoRequest new_msg_;
+};
+
+class SyncSendMessageVerifierFactory
+ : public experimental::ServerInterceptorFactoryInterface {
+ public:
+ virtual experimental::Interceptor* CreateServerInterceptor(
+ experimental::ServerRpcInfo* info) override {
+ return new SyncSendMessageVerifier(info);
+ }
+};
+
void MakeBidiStreamingCall(const std::shared_ptr<Channel>& channel) {
auto stub = grpc::testing::EchoTestService::NewStub(channel);
ClientContext ctx;
@@ -175,6 +240,12 @@ class ServerInterceptorsEnd2endSyncUnaryTest : public ::testing::Test {
creators;
creators.push_back(
std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
+ new SyncSendMessageTesterFactory()));
+ creators.push_back(
+ std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
+ new SyncSendMessageVerifierFactory()));
+ creators.push_back(
+ std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
new LoggingInterceptorFactory()));
// Add 20 dummy interceptor factories and null interceptor factories
for (auto i = 0; i < 20; i++) {
@@ -215,6 +286,12 @@ class ServerInterceptorsEnd2endSyncStreamingTest : public ::testing::Test {
creators;
creators.push_back(
std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
+ new SyncSendMessageTesterFactory()));
+ creators.push_back(
+ std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
+ new SyncSendMessageVerifierFactory()));
+ creators.push_back(
+ std::unique_ptr<experimental::ServerInterceptorFactoryInterface>(
new LoggingInterceptorFactory()));
for (auto i = 0; i < 20; i++) {
creators.push_back(std::unique_ptr<DummyInterceptorFactory>(
diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc
index 8d12606434..125b1ce5c4 100644
--- a/test/cpp/microbenchmarks/bm_call_create.cc
+++ b/test/cpp/microbenchmarks/bm_call_create.cc
@@ -326,7 +326,7 @@ class FakeClientChannelFactory : public grpc_client_channel_factory {
static void NoRef(grpc_client_channel_factory* factory) {}
static void NoUnref(grpc_client_channel_factory* factory) {}
static grpc_subchannel* CreateSubchannel(grpc_client_channel_factory* factory,
- const grpc_subchannel_args* args) {
+ const grpc_channel_args* args) {
return nullptr;
}
static grpc_channel* CreateClientChannel(grpc_client_channel_factory* factory,
diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h
index 73f91eed2d..ceb5cdd710 100644
--- a/test/cpp/qps/client.h
+++ b/test/cpp/qps/client.h
@@ -236,58 +236,7 @@ class Client {
return 0;
}
- protected:
- bool closed_loop_;
- gpr_atm thread_pool_done_;
- double median_latency_collection_interval_seconds_; // In seconds
-
- void StartThreads(size_t num_threads) {
- gpr_atm_rel_store(&thread_pool_done_, static_cast<gpr_atm>(false));
- threads_remaining_ = num_threads;
- for (size_t i = 0; i < num_threads; i++) {
- threads_.emplace_back(new Thread(this, i));
- }
- }
-
- void EndThreads() {
- MaybeStartRequests();
- threads_.clear();
- }
-
- virtual void DestroyMultithreading() = 0;
-
- void SetupLoadTest(const ClientConfig& config, size_t num_threads) {
- // Set up the load distribution based on the number of threads
- const auto& load = config.load_params();
-
- std::unique_ptr<RandomDistInterface> random_dist;
- switch (load.load_case()) {
- case LoadParams::kClosedLoop:
- // Closed-loop doesn't use random dist at all
- break;
- case LoadParams::kPoisson:
- random_dist.reset(
- new ExpDist(load.poisson().offered_load() / num_threads));
- break;
- default:
- GPR_ASSERT(false);
- }
-
- // Set closed_loop_ based on whether or not random_dist is set
- if (!random_dist) {
- closed_loop_ = true;
- } else {
- closed_loop_ = false;
- // set up interarrival timer according to random dist
- interarrival_timer_.init(*random_dist, num_threads);
- const auto now = gpr_now(GPR_CLOCK_MONOTONIC);
- for (size_t i = 0; i < num_threads; i++) {
- next_time_.push_back(gpr_time_add(
- now,
- gpr_time_from_nanos(interarrival_timer_.next(i), GPR_TIMESPAN)));
- }
- }
- }
+ bool IsClosedLoop() { return closed_loop_; }
gpr_timespec NextIssueTime(int thread_idx) {
const gpr_timespec result = next_time_[thread_idx];
@@ -297,9 +246,9 @@ class Client {
GPR_TIMESPAN));
return result;
}
- std::function<gpr_timespec()> NextIssuer(int thread_idx) {
- return closed_loop_ ? std::function<gpr_timespec()>()
- : std::bind(&Client::NextIssueTime, this, thread_idx);
+
+ bool ThreadCompleted() {
+ return static_cast<bool>(gpr_atm_acq_load(&thread_pool_done_));
}
class Thread {
@@ -380,8 +329,62 @@ class Client {
double interval_start_time_;
};
- bool ThreadCompleted() {
- return static_cast<bool>(gpr_atm_acq_load(&thread_pool_done_));
+ protected:
+ bool closed_loop_;
+ gpr_atm thread_pool_done_;
+ double median_latency_collection_interval_seconds_; // In seconds
+
+ void StartThreads(size_t num_threads) {
+ gpr_atm_rel_store(&thread_pool_done_, static_cast<gpr_atm>(false));
+ threads_remaining_ = num_threads;
+ for (size_t i = 0; i < num_threads; i++) {
+ threads_.emplace_back(new Thread(this, i));
+ }
+ }
+
+ void EndThreads() {
+ MaybeStartRequests();
+ threads_.clear();
+ }
+
+ virtual void DestroyMultithreading() = 0;
+
+ void SetupLoadTest(const ClientConfig& config, size_t num_threads) {
+ // Set up the load distribution based on the number of threads
+ const auto& load = config.load_params();
+
+ std::unique_ptr<RandomDistInterface> random_dist;
+ switch (load.load_case()) {
+ case LoadParams::kClosedLoop:
+ // Closed-loop doesn't use random dist at all
+ break;
+ case LoadParams::kPoisson:
+ random_dist.reset(
+ new ExpDist(load.poisson().offered_load() / num_threads));
+ break;
+ default:
+ GPR_ASSERT(false);
+ }
+
+ // Set closed_loop_ based on whether or not random_dist is set
+ if (!random_dist) {
+ closed_loop_ = true;
+ } else {
+ closed_loop_ = false;
+ // set up interarrival timer according to random dist
+ interarrival_timer_.init(*random_dist, num_threads);
+ const auto now = gpr_now(GPR_CLOCK_MONOTONIC);
+ for (size_t i = 0; i < num_threads; i++) {
+ next_time_.push_back(gpr_time_add(
+ now,
+ gpr_time_from_nanos(interarrival_timer_.next(i), GPR_TIMESPAN)));
+ }
+ }
+ }
+
+ std::function<gpr_timespec()> NextIssuer(int thread_idx) {
+ return closed_loop_ ? std::function<gpr_timespec()>()
+ : std::bind(&Client::NextIssueTime, this, thread_idx);
}
virtual void ThreadFunc(size_t thread_idx, Client::Thread* t) = 0;
@@ -436,6 +439,7 @@ class ClientImpl : public Client {
config.payload_config());
}
virtual ~ClientImpl() {}
+ const RequestType* request() { return &request_; }
void WaitForChannelsToConnect() {
int connect_deadline_seconds = 10;
diff --git a/test/cpp/qps/client_callback.cc b/test/cpp/qps/client_callback.cc
index 87889e36dc..4a06325f2b 100644
--- a/test/cpp/qps/client_callback.cc
+++ b/test/cpp/qps/client_callback.cc
@@ -66,13 +66,35 @@ class CallbackClient
config, BenchmarkStubCreator) {
num_threads_ = NumThreads(config);
rpcs_done_ = 0;
- SetupLoadTest(config, num_threads_);
+
+ // Don't divide the fixed load among threads as the user threads
+ // only bootstrap the RPCs
+ SetupLoadTest(config, 1);
total_outstanding_rpcs_ =
config.client_channels() * config.outstanding_rpcs_per_channel();
}
virtual ~CallbackClient() {}
+ /**
+ * The main thread of the benchmark will be waiting on DestroyMultithreading.
+ * Increment the rpcs_done_ variable to signify that the Callback RPC
+ * after thread completion is done. When the last outstanding rpc increments
+ * the counter it should also signal the main thread's conditional variable.
+ */
+ void NotifyMainThreadOfThreadCompletion() {
+ std::lock_guard<std::mutex> l(shutdown_mu_);
+ rpcs_done_++;
+ if (rpcs_done_ == total_outstanding_rpcs_) {
+ shutdown_cv_.notify_one();
+ }
+ }
+
+ gpr_timespec NextRPCIssueTime() {
+ std::lock_guard<std::mutex> l(next_issue_time_mu_);
+ return Client::NextIssueTime(0);
+ }
+
protected:
size_t num_threads_;
size_t total_outstanding_rpcs_;
@@ -93,24 +115,9 @@ class CallbackClient
ThreadFuncImpl(t, thread_idx);
}
- virtual void ScheduleRpc(Thread* t, size_t thread_idx,
- size_t ctx_vector_idx) = 0;
-
- /**
- * The main thread of the benchmark will be waiting on DestroyMultithreading.
- * Increment the rpcs_done_ variable to signify that the Callback RPC
- * after thread completion is done. When the last outstanding rpc increments
- * the counter it should also signal the main thread's conditional variable.
- */
- void NotifyMainThreadOfThreadCompletion() {
- std::lock_guard<std::mutex> l(shutdown_mu_);
- rpcs_done_++;
- if (rpcs_done_ == total_outstanding_rpcs_) {
- shutdown_cv_.notify_one();
- }
- }
-
private:
+ std::mutex next_issue_time_mu_; // Used by next issue time
+
int NumThreads(const ClientConfig& config) {
int num_threads = config.async_client_threads();
if (num_threads <= 0) { // Use dynamic sizing
@@ -149,7 +156,7 @@ class CallbackUnaryClient final : public CallbackClient {
bool ThreadFuncImpl(Thread* t, size_t thread_idx) override {
for (size_t vector_idx = thread_idx; vector_idx < total_outstanding_rpcs_;
vector_idx += num_threads_) {
- ScheduleRpc(t, thread_idx, vector_idx);
+ ScheduleRpc(t, vector_idx);
}
return true;
}
@@ -157,26 +164,26 @@ class CallbackUnaryClient final : public CallbackClient {
void InitThreadFuncImpl(size_t thread_idx) override { return; }
private:
- void ScheduleRpc(Thread* t, size_t thread_idx, size_t vector_idx) override {
+ void ScheduleRpc(Thread* t, size_t vector_idx) {
if (!closed_loop_) {
- gpr_timespec next_issue_time = NextIssueTime(thread_idx);
+ gpr_timespec next_issue_time = NextRPCIssueTime();
// Start an alarm callback to run the internal callback after
// next_issue_time
ctx_[vector_idx]->alarm_.experimental().Set(
- next_issue_time, [this, t, thread_idx, vector_idx](bool ok) {
- IssueUnaryCallbackRpc(t, thread_idx, vector_idx);
+ next_issue_time, [this, t, vector_idx](bool ok) {
+ IssueUnaryCallbackRpc(t, vector_idx);
});
} else {
- IssueUnaryCallbackRpc(t, thread_idx, vector_idx);
+ IssueUnaryCallbackRpc(t, vector_idx);
}
}
- void IssueUnaryCallbackRpc(Thread* t, size_t thread_idx, size_t vector_idx) {
+ void IssueUnaryCallbackRpc(Thread* t, size_t vector_idx) {
GPR_TIMER_SCOPE("CallbackUnaryClient::ThreadFunc", 0);
double start = UsageTimer::Now();
ctx_[vector_idx]->stub_->experimental_async()->UnaryCall(
(&ctx_[vector_idx]->context_), &request_, &ctx_[vector_idx]->response_,
- [this, t, thread_idx, start, vector_idx](grpc::Status s) {
+ [this, t, start, vector_idx](grpc::Status s) {
// Update Histogram with data from the callback run
HistogramEntry entry;
if (s.ok()) {
@@ -193,17 +200,157 @@ class CallbackUnaryClient final : public CallbackClient {
ctx_[vector_idx].reset(
new CallbackClientRpcContext(ctx_[vector_idx]->stub_));
// Schedule a new RPC
- ScheduleRpc(t, thread_idx, vector_idx);
+ ScheduleRpc(t, vector_idx);
}
});
}
};
+class CallbackStreamingClient : public CallbackClient {
+ public:
+ CallbackStreamingClient(const ClientConfig& config)
+ : CallbackClient(config),
+ messages_per_stream_(config.messages_per_stream()) {
+ for (int ch = 0; ch < config.client_channels(); ch++) {
+ for (int i = 0; i < config.outstanding_rpcs_per_channel(); i++) {
+ ctx_.emplace_back(
+ new CallbackClientRpcContext(channels_[ch].get_stub()));
+ }
+ }
+ StartThreads(num_threads_);
+ }
+ ~CallbackStreamingClient() {}
+
+ void AddHistogramEntry(double start_, bool ok, Thread* thread_ptr) {
+ // Update Histogram with data from the callback run
+ HistogramEntry entry;
+ if (ok) {
+ entry.set_value((UsageTimer::Now() - start_) * 1e9);
+ }
+ thread_ptr->UpdateHistogram(&entry);
+ }
+
+ int messages_per_stream() { return messages_per_stream_; }
+
+ protected:
+ const int messages_per_stream_;
+};
+
+class CallbackStreamingPingPongClient : public CallbackStreamingClient {
+ public:
+ CallbackStreamingPingPongClient(const ClientConfig& config)
+ : CallbackStreamingClient(config) {}
+ ~CallbackStreamingPingPongClient() {}
+};
+
+class CallbackStreamingPingPongReactor final
+ : public grpc::experimental::ClientBidiReactor<SimpleRequest,
+ SimpleResponse> {
+ public:
+ CallbackStreamingPingPongReactor(
+ CallbackStreamingPingPongClient* client,
+ std::unique_ptr<CallbackClientRpcContext> ctx)
+ : client_(client), ctx_(std::move(ctx)), messages_issued_(0) {}
+
+ void StartNewRpc() {
+ if (client_->ThreadCompleted()) return;
+ start_ = UsageTimer::Now();
+ ctx_->stub_->experimental_async()->StreamingCall(&(ctx_->context_), this);
+ StartWrite(client_->request());
+ StartCall();
+ }
+
+ void OnWriteDone(bool ok) override {
+ if (!ok || client_->ThreadCompleted()) {
+ if (!ok) gpr_log(GPR_ERROR, "Error writing RPC");
+ StartWritesDone();
+ return;
+ }
+ StartRead(&ctx_->response_);
+ }
+
+ void OnReadDone(bool ok) override {
+ client_->AddHistogramEntry(start_, ok, thread_ptr_);
+
+ if (client_->ThreadCompleted() || !ok ||
+ (client_->messages_per_stream() != 0 &&
+ ++messages_issued_ >= client_->messages_per_stream())) {
+ if (!ok) {
+ gpr_log(GPR_ERROR, "Error reading RPC");
+ }
+ StartWritesDone();
+ return;
+ }
+ StartWrite(client_->request());
+ }
+
+ void OnDone(const Status& s) override {
+ if (client_->ThreadCompleted() || !s.ok()) {
+ client_->NotifyMainThreadOfThreadCompletion();
+ return;
+ }
+ ctx_.reset(new CallbackClientRpcContext(ctx_->stub_));
+ ScheduleRpc();
+ }
+
+ void ScheduleRpc() {
+ if (client_->ThreadCompleted()) return;
+
+ if (!client_->IsClosedLoop()) {
+ gpr_timespec next_issue_time = client_->NextRPCIssueTime();
+ // Start an alarm callback to run the internal callback after
+ // next_issue_time
+ ctx_->alarm_.experimental().Set(next_issue_time,
+ [this](bool ok) { StartNewRpc(); });
+ } else {
+ StartNewRpc();
+ }
+ }
+
+ void set_thread_ptr(Client::Thread* ptr) { thread_ptr_ = ptr; }
+
+ CallbackStreamingPingPongClient* client_;
+ std::unique_ptr<CallbackClientRpcContext> ctx_;
+ Client::Thread* thread_ptr_; // Needed to update histogram entries
+ double start_; // Track message start time
+ int messages_issued_; // Messages issued by this stream
+};
+
+class CallbackStreamingPingPongClientImpl final
+ : public CallbackStreamingPingPongClient {
+ public:
+ CallbackStreamingPingPongClientImpl(const ClientConfig& config)
+ : CallbackStreamingPingPongClient(config) {
+ for (size_t i = 0; i < total_outstanding_rpcs_; i++)
+ reactor_.emplace_back(
+ new CallbackStreamingPingPongReactor(this, std::move(ctx_[i])));
+ }
+ ~CallbackStreamingPingPongClientImpl() {}
+
+ bool ThreadFuncImpl(Client::Thread* t, size_t thread_idx) override {
+ for (size_t vector_idx = thread_idx; vector_idx < total_outstanding_rpcs_;
+ vector_idx += num_threads_) {
+ reactor_[vector_idx]->set_thread_ptr(t);
+ reactor_[vector_idx]->ScheduleRpc();
+ }
+ return true;
+ }
+
+ void InitThreadFuncImpl(size_t thread_idx) override {}
+
+ private:
+ std::vector<std::unique_ptr<CallbackStreamingPingPongReactor>> reactor_;
+};
+
+// TODO(mhaidry) : Implement Streaming from client, server and both ways
+
std::unique_ptr<Client> CreateCallbackClient(const ClientConfig& config) {
switch (config.rpc_type()) {
case UNARY:
return std::unique_ptr<Client>(new CallbackUnaryClient(config));
case STREAMING:
+ return std::unique_ptr<Client>(
+ new CallbackStreamingPingPongClientImpl(config));
case STREAMING_FROM_CLIENT:
case STREAMING_FROM_SERVER:
case STREAMING_BOTH_WAYS:
diff --git a/test/cpp/qps/gen_build_yaml.py b/test/cpp/qps/gen_build_yaml.py
index fb2caf5486..8ca0dc6a62 100755
--- a/test/cpp/qps/gen_build_yaml.py
+++ b/test/cpp/qps/gen_build_yaml.py
@@ -131,4 +131,4 @@ def generate_yaml():
}
-print(yaml.dump(generate_yaml())) \ No newline at end of file
+print(yaml.dump(generate_yaml()))
diff --git a/third_party/rake-compiler-dock/Dockerfile b/third_party/rake-compiler-dock/Dockerfile
index 06c721c39b..44eddc82e8 100644
--- a/third_party/rake-compiler-dock/Dockerfile
+++ b/third_party/rake-compiler-dock/Dockerfile
@@ -1,8 +1,7 @@
-FROM larskanis/rake-compiler-dock:0.6.2
+FROM larskanis/rake-compiler-dock-mri:0.7.0
RUN find / -name rbconfig.rb | while read f ; do sed -i 's/0x0501/0x0600/' $f ; done
RUN find / -name win32.h | while read f ; do sed -i 's/gettimeofday/rb_gettimeofday/' $f ; done
-RUN sed -i 's/defined.__MINGW64__.$/1/' /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h
RUN find / -name libwinpthread.dll.a | xargs rm
RUN find / -name libwinpthread-1.dll | xargs rm
RUN find / -name *msvcrt-ruby*.dll.a | while read f ; do n=`echo $f | sed s/.dll//` ; mv $f $n ; done
diff --git a/tools/distrib/build_ruby_environment_macos.sh b/tools/distrib/build_ruby_environment_macos.sh
index 9e3e3b46f8..c2c0dcde6b 100644
--- a/tools/distrib/build_ruby_environment_macos.sh
+++ b/tools/distrib/build_ruby_environment_macos.sh
@@ -49,7 +49,7 @@ EOF
MAKE="make -j8"
-for v in 2.5.0 2.4.0 2.3.0 2.2.2 2.1.6 2.0.0-p645 ; do
+for v in 2.6.0 2.5.0 2.4.0 2.3.0 2.2.2 ; do
ccache -c
rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin11 MAKE="$MAKE"
done
diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py
index 29b2127960..e5d9daef38 100644
--- a/tools/distrib/python/grpcio_tools/grpc_version.py
+++ b/tools/distrib/python/grpcio_tools/grpc_version.py
@@ -14,4 +14,4 @@
# AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!!
-VERSION = '1.18.0.dev0'
+VERSION = '1.19.0.dev0'
diff --git a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile
index c3d6e03f6a..b53ffc22d4 100644
--- a/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile
+++ b/tools/dockerfile/distribtest/ruby_centos6_x64/Dockerfile
@@ -19,10 +19,19 @@ RUN yum install -y curl
RUN yum install -y tar which
# Install rvm
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
+RUN curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.2
# Running the installation twice to work around docker issue when using overlay.
# https://github.com/docker/docker/issues/10180
-RUN (curl -sSL https://get.rvm.io | bash -s stable --ruby) || (curl -sSL https://get.rvm.io | bash -s stable --ruby)
+RUN (/bin/bash -l -c "rvm install ruby-2.2.10") || (/bin/bash -l -c "rvm install ruby-2.2.10")
+RUN /bin/bash -l -c "rvm use --default ruby-2.2.10"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document"
+
+RUN mkdir /var/local/jenkins
RUN /bin/bash -l -c "echo '. /etc/profile.d/rvm.sh' >> ~/.bashrc"
-RUN /bin/bash -l -c "gem install --update bundler"
diff --git a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile
index 73207e4210..72235bfba7 100644
--- a/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile
+++ b/tools/dockerfile/distribtest/ruby_centos7_x64/Dockerfile
@@ -14,6 +14,20 @@
FROM centos:7
-RUN yum install -y ruby
+RUN yum update && yum install -y curl tar which
-RUN gem install bundler
+# Install rvm
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
+RUN curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.2
+RUN /bin/bash -l -c "rvm install ruby-2.2.10"
+RUN /bin/bash -l -c "rvm use --default ruby-2.2.10"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document"
+
+RUN mkdir /var/local/jenkins
+
+RUN /bin/bash -l -c "echo '. /etc/profile.d/rvm.sh' >> ~/.bashrc"
diff --git a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile
index 200c5c2803..3d688a889f 100644
--- a/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile
+++ b/tools/dockerfile/distribtest/ruby_fedora20_x64/Dockerfile
@@ -14,6 +14,23 @@
FROM fedora:20
-RUN yum clean all && yum update -y && yum install -y ruby findutils
+# distro-sync and install openssl, per https://github.com/fedora-cloud/docker-brew-fedora/issues/19
+RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y openssl gnupg which findutils
-RUN gem install bundler
+# Install rvm
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
+RUN curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.2
+# Running the installation twice to work around docker issue when using overlay.
+# https://github.com/docker/docker/issues/10180
+RUN (/bin/bash -l -c "rvm install ruby-2.2.10") || (/bin/bash -l -c "rvm install ruby-2.2.10")
+RUN /bin/bash -l -c "rvm use --default ruby-2.2.10"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document"
+
+RUN mkdir /var/local/jenkins
+
+RUN /bin/bash -l -c "echo '. /etc/profile.d/rvm.sh' >> ~/.bashrc"
diff --git a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile
index e1177fd99a..8044adf15d 100644
--- a/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile
+++ b/tools/dockerfile/distribtest/ruby_fedora21_x64/Dockerfile
@@ -19,6 +19,21 @@ FROM fedora:21
# https://github.com/docker/docker/issues/10180
RUN yum install -y yum-plugin-ovl
-RUN yum clean all && yum update -y && yum install -y ruby findutils
+# distro-sync and install openssl, per https://github.com/fedora-cloud/docker-brew-fedora/issues/19
+RUN yum clean all && yum update -y && yum distro-sync -y && yum install -y openssl gnupg which findutils tar
-RUN gem install bundler
+# Install rvm
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
+RUN curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.2
+RUN /bin/bash -l -c "rvm install ruby-2.2.10"
+RUN /bin/bash -l -c "rvm use --default ruby-2.2.10"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document"
+
+RUN mkdir /var/local/jenkins
+
+RUN /bin/bash -l -c "echo '. /etc/profile.d/rvm.sh' >> ~/.bashrc"
diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile
new file mode 100644
index 0000000000..337fc3b5d8
--- /dev/null
+++ b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_2/Dockerfile
@@ -0,0 +1,40 @@
+# Copyright 2015 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.
+
+FROM debian:jessie
+
+# Install Git and basic packages.
+RUN apt-get update && apt-get install -y \
+ curl \
+ gcc && apt-get clean
+
+#==================
+# Ruby dependencies
+
+# Install rvm
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
+RUN \curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.2
+RUN /bin/bash -l -c "rvm install ruby-2.2.10"
+RUN /bin/bash -l -c "rvm use --default ruby-2.2.10"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.2.10' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document"
+
+RUN mkdir /var/local/jenkins
+
+# Define the default command.
+CMD ["bash"]
diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_3/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_3/Dockerfile
new file mode 100644
index 0000000000..9deff0661b
--- /dev/null
+++ b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_3/Dockerfile
@@ -0,0 +1,41 @@
+# Copyright 2015 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.
+
+FROM debian:jessie
+
+# Install Git and basic packages.
+RUN apt-get update && apt-get install -y \
+ curl \
+ gcc && apt-get clean
+
+#==================
+# Ruby dependencies
+
+# Install rvm
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
+RUN \curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.3
+RUN /bin/bash -l -c "rvm install ruby-2.3.8"
+RUN /bin/bash -l -c "rvm use --default ruby-2.3.8"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.3.8' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem update --system"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document"
+
+RUN mkdir /var/local/jenkins
+
+# Define the default command.
+CMD ["bash"]
diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_4/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_4/Dockerfile
new file mode 100644
index 0000000000..55b1b1e731
--- /dev/null
+++ b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_4/Dockerfile
@@ -0,0 +1,40 @@
+# Copyright 2015 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.
+
+FROM debian:jessie
+
+# Install Git and basic packages.
+RUN apt-get update && apt-get install -y \
+ curl \
+ gcc && apt-get clean
+
+#==================
+# Ruby dependencies
+
+# Install rvm
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
+RUN \curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.4
+RUN /bin/bash -l -c "rvm install ruby-2.4.5"
+RUN /bin/bash -l -c "rvm use --default ruby-2.4.5"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.4.5' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document"
+
+RUN mkdir /var/local/jenkins
+
+# Define the default command.
+CMD ["bash"]
diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_5/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_5/Dockerfile
new file mode 100644
index 0000000000..bed4b3a93e
--- /dev/null
+++ b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_5/Dockerfile
@@ -0,0 +1,40 @@
+# Copyright 2015 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.
+
+FROM debian:jessie
+
+# Install Git and basic packages.
+RUN apt-get update && apt-get install -y \
+ curl \
+ gcc && apt-get clean
+
+#==================
+# Ruby dependencies
+
+# Install rvm
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
+RUN \curl -sSL https://get.rvm.io | bash -s stable
+
+# Install Ruby 2.5
+RUN /bin/bash -l -c "rvm install ruby-2.5.3"
+RUN /bin/bash -l -c "rvm use --default ruby-2.5.3"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
+RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.5.3' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-document"
+
+RUN mkdir /var/local/jenkins
+
+# Define the default command.
+CMD ["bash"]
diff --git a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_0_0/Dockerfile b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_6/Dockerfile
index ff43c92c9e..af1839eba9 100644
--- a/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_0_0/Dockerfile
+++ b/tools/dockerfile/distribtest/ruby_jessie_x64_ruby_2_6/Dockerfile
@@ -23,16 +23,16 @@ RUN apt-get update && apt-get install -y \
# Ruby dependencies
# Install rvm
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN \curl -sSL https://get.rvm.io | bash -s stable
-# Install Ruby 2.1
-RUN /bin/bash -l -c "rvm install ruby-2.0"
-RUN /bin/bash -l -c "rvm use --default ruby-2.0"
-RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
+# Install Ruby 2.6
+RUN /bin/bash -l -c "rvm install ruby-2.6.0"
+RUN /bin/bash -l -c "rvm use --default ruby-2.6.0"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
-RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.0' >> ~/.bashrc"
-RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.6.0' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler --no-document"
RUN mkdir /var/local/jenkins
diff --git a/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile b/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile
index 7ec061ebe5..f247cc9ca5 100644
--- a/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile
+++ b/tools/dockerfile/grpc_artifact_linux_x64/Dockerfile
@@ -49,7 +49,7 @@ RUN apt-get update && apt-get install -y \
# Ruby dependencies
# Install rvm
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN \curl -sSL https://get.rvm.io | bash -s stable
# Install Ruby 2.1
@@ -58,7 +58,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.1"
RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
-RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-ri --no-rdoc"
##################
diff --git a/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile b/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile
index f81d8e5ba0..e403f75b59 100644
--- a/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile
+++ b/tools/dockerfile/grpc_artifact_linux_x86/Dockerfile
@@ -49,7 +49,7 @@ RUN apt-get update && apt-get install -y \
# Ruby dependencies
# Install rvm
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN \curl -sSL https://get.rvm.io | bash -s stable
# Install Ruby 2.1
@@ -58,7 +58,7 @@ RUN /bin/bash -l -c "rvm use --default ruby-2.1"
RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
-RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
+RUN /bin/bash -l -c "gem install bundler -v 1.17.3 --no-ri --no-rdoc"
##################
# C# dependencies (needed to build grpc_csharp_ext)
diff --git a/tools/dockerfile/interoptest/grpc_interop_go1.11/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_go1.11/Dockerfile
new file mode 100644
index 0000000000..0892bc3459
--- /dev/null
+++ b/tools/dockerfile/interoptest/grpc_interop_go1.11/Dockerfile
@@ -0,0 +1,36 @@
+# Copyright 2018 The 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.
+
+FROM golang:1.11
+
+# Using login shell removes Go from path, so we add it.
+RUN ln -s /usr/local/go/bin/go /usr/local/bin
+
+#====================
+# Python dependencies
+
+# Install dependencies
+
+RUN apt-get update && apt-get install -y \
+ python-all-dev \
+ python3-all-dev \
+ python-pip
+
+# Install Python packages from PyPI
+RUN pip install --upgrade pip==10.0.1
+RUN pip install virtualenv
+RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 twisted==17.5.0
+
+# Define the default command.
+CMD ["bash"]
diff --git a/tools/dockerfile/interoptest/grpc_interop_go1.11/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_go1.11/build_interop.sh
new file mode 100644
index 0000000000..b11ace3a4e
--- /dev/null
+++ b/tools/dockerfile/interoptest/grpc_interop_go1.11/build_interop.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+# Copyright 2015 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.
+#
+# Builds Go interop server and client in a base image.
+set -e
+
+# Clone just the grpc-go source code without any dependencies.
+# We are cloning from a local git repo that contains the right revision
+# to test instead of using "go get" to download from Github directly.
+git clone --recursive /var/local/jenkins/grpc-go src/google.golang.org/grpc
+
+# Get all gRPC Go dependencies
+(cd src/google.golang.org/grpc && make deps && make testdeps)
+
+# copy service account keys if available
+cp -r /var/local/jenkins/service_account $HOME || true
+
+# Build the interop client and server
+(cd src/google.golang.org/grpc/interop/client && go install)
+(cd src/google.golang.org/grpc/interop/server && go install)
+
diff --git a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
index 97c146bb53..1f6f03edd8 100644
--- a/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
+++ b/tools/dockerfile/interoptest/grpc_interop_ruby/Dockerfile
@@ -68,16 +68,16 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t
# Ruby dependencies
# Install rvm
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN \curl -sSL https://get.rvm.io | bash -s stable
-# Install Ruby 2.1
-RUN /bin/bash -l -c "rvm install ruby-2.1"
-RUN /bin/bash -l -c "rvm use --default ruby-2.1"
-RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
+# Install Ruby 2.5
+RUN /bin/bash -l -c "rvm install ruby-2.5"
+RUN /bin/bash -l -c "rvm use --default ruby-2.5"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
-RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
-RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.5' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler --no-document"
RUN mkdir /var/local/jenkins
diff --git a/tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh b/tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh
index b6b122ef0f..e71ad91499 100755
--- a/tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh
+++ b/tools/dockerfile/interoptest/grpc_interop_ruby/build_interop.sh
@@ -27,7 +27,7 @@ ${name}')
cp -r /var/local/jenkins/service_account $HOME || true
cd /var/local/git/grpc
-rvm --default use ruby-2.1
+rvm --default use ruby-2.5
# build Ruby interop client and server
-(cd src/ruby && gem update bundler && bundle && rake compile)
+(cd src/ruby && gem install bundler -v 1.17.3 && bundle && rake compile)
diff --git a/tools/dockerfile/test/ruby_jessie_x64/Dockerfile b/tools/dockerfile/test/ruby_jessie_x64/Dockerfile
index 321b501de2..cf6a5b254f 100644
--- a/tools/dockerfile/test/ruby_jessie_x64/Dockerfile
+++ b/tools/dockerfile/test/ruby_jessie_x64/Dockerfile
@@ -72,16 +72,16 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.5.2.post1 six==1.10.0 t
# Ruby dependencies
# Install rvm
-RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
RUN \curl -sSL https://get.rvm.io | bash -s stable
-# Install Ruby 2.1
-RUN /bin/bash -l -c "rvm install ruby-2.1"
-RUN /bin/bash -l -c "rvm use --default ruby-2.1"
-RUN /bin/bash -l -c "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc"
+# Install Ruby 2.5
+RUN /bin/bash -l -c "rvm install ruby-2.5"
+RUN /bin/bash -l -c "rvm use --default ruby-2.5"
+RUN /bin/bash -l -c "echo 'gem: --no-document' > ~/.gemrc"
RUN /bin/bash -l -c "echo 'export PATH=/usr/local/rvm/bin:$PATH' >> ~/.bashrc"
-RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.1' >> ~/.bashrc"
-RUN /bin/bash -l -c "gem install bundler --no-ri --no-rdoc"
+RUN /bin/bash -l -c "echo 'rvm --default use ruby-2.5' >> ~/.bashrc"
+RUN /bin/bash -l -c "gem install bundler --no-document"
RUN mkdir /var/local/jenkins
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index 1ab3a394b9..b0415fd4f6 100644
--- a/tools/doxygen/Doxyfile.c++
+++ b/tools/doxygen/Doxyfile.c++
@@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 1.18.0-dev
+PROJECT_NUMBER = 1.19.0-dev
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index 5f488d5194..a76a261d07 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++"
# could be handy for archiving the generated documentation or if some version
# control system is used.
-PROJECT_NUMBER = 1.18.0-dev
+PROJECT_NUMBER = 1.19.0-dev
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
@@ -1100,6 +1100,7 @@ src/core/lib/iomgr/ev_posix.h \
src/core/lib/iomgr/exec_ctx.h \
src/core/lib/iomgr/executor.h \
src/core/lib/iomgr/gethostname.h \
+src/core/lib/iomgr/grpc_if_nametoindex.h \
src/core/lib/iomgr/internal_errqueue.h \
src/core/lib/iomgr/iocp_windows.h \
src/core/lib/iomgr/iomgr.h \
diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal
index ba2eaecafd..38d17b6f21 100644
--- a/tools/doxygen/Doxyfile.core.internal
+++ b/tools/doxygen/Doxyfile.core.internal
@@ -1214,6 +1214,9 @@ src/core/lib/iomgr/gethostname.h \
src/core/lib/iomgr/gethostname_fallback.cc \
src/core/lib/iomgr/gethostname_host_name_max.cc \
src/core/lib/iomgr/gethostname_sysconf.cc \
+src/core/lib/iomgr/grpc_if_nametoindex.h \
+src/core/lib/iomgr/grpc_if_nametoindex_posix.cc \
+src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc \
src/core/lib/iomgr/internal_errqueue.cc \
src/core/lib/iomgr/internal_errqueue.h \
src/core/lib/iomgr/iocp_windows.cc \
diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc
index ce054ac259..632db5ae14 100644
--- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc
+++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc
@@ -42,7 +42,7 @@ source $HOME/.rvm/scripts/rvm
set -e # rvm commands are very verbose
time rvm install 2.5.0
rvm use 2.5.0 --default
-time gem install bundler --no-ri --no-doc
+time gem install bundler -v 1.17.3 --no-ri --no-doc
time gem install cocoapods --version 1.3.1 --no-ri --no-doc
time gem install rake-compiler --no-ri --no-doc
rvm osx-ssl-certs status all
diff --git a/tools/internal_ci/linux/grpc_interop_matrix.sh b/tools/internal_ci/linux/grpc_interop_matrix.sh
index a5220ea087..5f1f69db95 100755
--- a/tools/internal_ci/linux/grpc_interop_matrix.sh
+++ b/tools/internal_ci/linux/grpc_interop_matrix.sh
@@ -22,4 +22,15 @@ cd $(dirname $0)/../../..
source tools/internal_ci/helper_scripts/prepare_build_linux_rc
-tools/interop_matrix/run_interop_matrix_tests.py $RUN_TESTS_FLAGS
+# TODO(jtattermusch): Diagnose out of disk space problems. Remove once not needed.
+df -h
+
+tools/interop_matrix/run_interop_matrix_tests.py $RUN_TESTS_FLAGS || FAILED="true"
+
+# TODO(jtattermusch): Diagnose out of disk space problems. Remove once not needed.
+df -h
+
+if [ "$FAILED" != "" ]
+then
+ exit 1
+fi
diff --git a/tools/interop_matrix/client_matrix.py b/tools/interop_matrix/client_matrix.py
index c0b08a59b2..4964fd6167 100644
--- a/tools/interop_matrix/client_matrix.py
+++ b/tools/interop_matrix/client_matrix.py
@@ -35,6 +35,21 @@ def get_release_tag_name(release_info):
return release_info.keys()[0]
+def get_runtimes_for_lang_release(lang, release):
+ """Get list of valid runtimes for given release of lang."""
+ runtimes_to_skip = []
+ # see if any the lang release has "skip_runtime" annotation.
+ for release_info in LANG_RELEASE_MATRIX[lang]:
+ if get_release_tag_name(release_info) == release:
+ if release_info[release] is not None:
+ runtimes_to_skip = release_info[release].get('skip_runtime', [])
+ break
+ return [
+ runtime for runtime in LANG_RUNTIME_MATRIX[lang]
+ if runtime not in runtimes_to_skip
+ ]
+
+
def should_build_docker_interop_image_from_release_tag(lang):
if lang in ['go', 'java', 'node']:
return False
@@ -44,7 +59,7 @@ def should_build_docker_interop_image_from_release_tag(lang):
# Dictionary of runtimes per language
LANG_RUNTIME_MATRIX = {
'cxx': ['cxx'], # This is actually debian8.
- 'go': ['go1.7', 'go1.8'],
+ 'go': ['go1.7', 'go1.8', 'go1.11'],
'java': ['java_oracle8'],
'python': ['python'],
'node': ['node'],
@@ -110,52 +125,89 @@ LANG_RELEASE_MATRIX = {
],
'go': [
{
- 'v1.0.5': None
+ 'v1.0.5': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.2.1': None
+ 'v1.2.1': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.3.0': None
+ 'v1.3.0': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.4.2': None
+ 'v1.4.2': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.5.2': None
+ 'v1.5.2': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.6.0': None
+ 'v1.6.0': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.7.4': None
+ 'v1.7.4': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.8.2': None
+ 'v1.8.2': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.9.2': None
+ 'v1.9.2': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.10.1': None
+ 'v1.10.1': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.11.3': None
+ 'v1.11.3': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.12.2': None
+ 'v1.12.2': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.13.0': None
+ 'v1.13.0': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.14.0': None
+ 'v1.14.0': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.15.0': None
+ 'v1.15.0': {
+ 'skip_runtime': ['go1.11']
+ }
},
{
- 'v1.16.0': None
+ 'v1.16.0': {
+ 'skip_runtime': ['go1.11']
+ }
+ },
+ {
+ 'v1.17.0': {
+ 'skip_runtime': ['go1.7', 'go1.8']
+ }
},
],
'java': [
diff --git a/tools/interop_matrix/create_matrix_images.py b/tools/interop_matrix/create_matrix_images.py
index c2568efba0..cf61d46248 100755
--- a/tools/interop_matrix/create_matrix_images.py
+++ b/tools/interop_matrix/create_matrix_images.py
@@ -217,7 +217,7 @@ def build_all_images_for_release(lang, release):
}.get(lang, 'GRPC_ROOT')
env[var] = stack_base
- for runtime in client_matrix.LANG_RUNTIME_MATRIX[lang]:
+ for runtime in client_matrix.get_runtimes_for_lang_release(lang, release):
job = build_image_jobspec(runtime, env, release, stack_base)
docker_images.append(job.tag)
build_jobs.append(job)
diff --git a/tools/interop_matrix/run_interop_matrix_tests.py b/tools/interop_matrix/run_interop_matrix_tests.py
index 6cf2a9b036..dabb486523 100755
--- a/tools/interop_matrix/run_interop_matrix_tests.py
+++ b/tools/interop_matrix/run_interop_matrix_tests.py
@@ -113,13 +113,17 @@ def _get_test_images_for_lang(lang, release_arg, image_path_prefix):
return {}
releases = [release_arg]
- # Images tuples keyed by runtime.
+ # Image tuples keyed by runtime.
images = {}
- for runtime in client_matrix.LANG_RUNTIME_MATRIX[lang]:
- image_path = '%s/grpc_interop_%s' % (image_path_prefix, runtime)
- images[runtime] = [
- (tag, '%s:%s' % (image_path, tag)) for tag in releases
- ]
+ for tag in releases:
+ for runtime in client_matrix.get_runtimes_for_lang_release(lang, tag):
+ image_name = '%s/grpc_interop_%s:%s' % (image_path_prefix, runtime,
+ tag)
+ image_tuple = (tag, image_name)
+
+ if not images.has_key(runtime):
+ images[runtime] = []
+ images[runtime].append(image_tuple)
return images
@@ -232,10 +236,13 @@ def _run_tests_for_lang(lang, runtime, images, xml_report_tree):
images is a list of (<release-tag>, <image-full-path>) tuple.
"""
+ skip_tests = False
if not _pull_images_for_lang(lang, images):
jobset.message(
- 'FAILED', 'Image download failed. Exiting.', do_newline=True)
- return 1
+ 'FAILED',
+ 'Image download failed. Skipping tests for language "%s"' % lang,
+ do_newline=True)
+ skip_tests = True
total_num_failures = 0
for release, image in images:
@@ -246,17 +253,22 @@ def _run_tests_for_lang(lang, runtime, images, xml_report_tree):
if not job_spec_list:
jobset.message(
'FAILED', 'No test cases were found.', do_newline=True)
- return 1
+ total_num_failures += 1
+ continue
num_failures, resultset = jobset.run(
job_spec_list,
newline_on_success=True,
add_env={'docker_image': image},
- maxjobs=args.jobs)
+ maxjobs=args.jobs,
+ skip_jobs=skip_tests)
if args.bq_result_table and resultset:
upload_test_results.upload_interop_results_to_bq(
resultset, args.bq_result_table)
- if num_failures:
+ if skip_tests:
+ jobset.message('FAILED', 'Tests were skipped', do_newline=True)
+ total_num_failures += 1
+ elif num_failures:
jobset.message('FAILED', 'Some tests failed', do_newline=True)
total_num_failures += num_failures
else:
@@ -266,6 +278,8 @@ def _run_tests_for_lang(lang, runtime, images, xml_report_tree):
'grpc_interop_matrix', suite_name,
str(uuid.uuid4()))
+ # cleanup all downloaded docker images
+ for _, image in images:
if not args.keep:
_cleanup_docker_image(image)
diff --git a/tools/run_tests/artifacts/build_artifact_ruby.sh b/tools/run_tests/artifacts/build_artifact_ruby.sh
index c910374376..09423ce539 100755
--- a/tools/run_tests/artifacts/build_artifact_ruby.sh
+++ b/tools/run_tests/artifacts/build_artifact_ruby.sh
@@ -38,7 +38,7 @@ fi
set +ex
rvm use default
-gem install bundler --update
+gem install bundler -v 1.17.3
tools/run_tests/helper_scripts/bundle_install_wrapper.sh
diff --git a/tools/run_tests/artifacts/distribtest_targets.py b/tools/run_tests/artifacts/distribtest_targets.py
index e02f4bffcd..fd68a4dc74 100644
--- a/tools/run_tests/artifacts/distribtest_targets.py
+++ b/tools/run_tests/artifacts/distribtest_targets.py
@@ -336,9 +336,11 @@ def targets():
PythonDistribTest('linux', 'x64', 'ubuntu1404', source=True),
PythonDistribTest('linux', 'x64', 'ubuntu1604', source=True),
RubyDistribTest('linux', 'x64', 'wheezy'),
- RubyDistribTest('linux', 'x64', 'jessie'),
- RubyDistribTest('linux', 'x86', 'jessie'),
- RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_0_0'),
+ RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_2'),
+ RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_3'),
+ RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_4'),
+ RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_5'),
+ RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_6'),
RubyDistribTest('linux', 'x64', 'centos6'),
RubyDistribTest('linux', 'x64', 'centos7'),
RubyDistribTest('linux', 'x64', 'fedora20'),
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 8d1bca22be..1478ac2cd5 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -1731,6 +1731,22 @@
"headers": [],
"is_filegroup": false,
"language": "c",
+ "name": "parse_address_with_named_scope_id_test",
+ "src": [
+ "test/core/client_channel/parse_address_with_named_scope_id_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "grpc",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c",
"name": "percent_decode_fuzzer",
"src": [
"test/core/slice/percent_decode_fuzzer.cc"
@@ -1779,7 +1795,7 @@
"headers": [],
"is_filegroup": false,
"language": "c",
- "name": "resolve_address_posix_test",
+ "name": "resolve_address_using_ares_resolver_posix_test",
"src": [
"test/core/iomgr/resolve_address_posix_test.cc"
],
@@ -1811,6 +1827,22 @@
"headers": [],
"is_filegroup": false,
"language": "c",
+ "name": "resolve_address_using_native_resolver_posix_test",
+ "src": [
+ "test/core/iomgr/resolve_address_posix_test.cc"
+ ],
+ "third_party": false,
+ "type": "target"
+ },
+ {
+ "deps": [
+ "gpr",
+ "grpc",
+ "grpc_test_util"
+ ],
+ "headers": [],
+ "is_filegroup": false,
+ "language": "c",
"name": "resolve_address_using_native_resolver_test",
"src": [
"test/core/iomgr/resolve_address_test.cc"
@@ -9371,6 +9403,8 @@
"src/core/lib/iomgr/gethostname_fallback.cc",
"src/core/lib/iomgr/gethostname_host_name_max.cc",
"src/core/lib/iomgr/gethostname_sysconf.cc",
+ "src/core/lib/iomgr/grpc_if_nametoindex_posix.cc",
+ "src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc",
"src/core/lib/iomgr/internal_errqueue.cc",
"src/core/lib/iomgr/iocp_windows.cc",
"src/core/lib/iomgr/iomgr.cc",
@@ -9548,6 +9582,7 @@
"src/core/lib/iomgr/exec_ctx.h",
"src/core/lib/iomgr/executor.h",
"src/core/lib/iomgr/gethostname.h",
+ "src/core/lib/iomgr/grpc_if_nametoindex.h",
"src/core/lib/iomgr/internal_errqueue.h",
"src/core/lib/iomgr/iocp_windows.h",
"src/core/lib/iomgr/iomgr.h",
@@ -9701,6 +9736,7 @@
"src/core/lib/iomgr/exec_ctx.h",
"src/core/lib/iomgr/executor.h",
"src/core/lib/iomgr/gethostname.h",
+ "src/core/lib/iomgr/grpc_if_nametoindex.h",
"src/core/lib/iomgr/internal_errqueue.h",
"src/core/lib/iomgr/iocp_windows.h",
"src/core/lib/iomgr/iomgr.h",
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index e35d4db276..f2d0cab5ed 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -2063,6 +2063,28 @@
"ci_platforms": [
"linux",
"mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [],
+ "flaky": false,
+ "gtest": false,
+ "language": "c",
+ "name": "parse_address_with_named_scope_id_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "uses_polling": false
+ },
+ {
+ "args": [],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
"posix",
"windows"
],
@@ -2082,7 +2104,9 @@
"uses_polling": false
},
{
- "args": [],
+ "args": [
+ "--resolver=ares"
+ ],
"benchmark": false,
"ci_platforms": [
"linux",
@@ -2097,7 +2121,7 @@
"flaky": false,
"gtest": false,
"language": "c",
- "name": "resolve_address_posix_test",
+ "name": "resolve_address_using_ares_resolver_posix_test",
"platforms": [
"linux",
"mac",
@@ -2139,6 +2163,32 @@
"ci_platforms": [
"linux",
"mac",
+ "posix"
+ ],
+ "cpu_cost": 1.0,
+ "exclude_configs": [],
+ "exclude_iomgrs": [
+ "uv"
+ ],
+ "flaky": false,
+ "gtest": false,
+ "language": "c",
+ "name": "resolve_address_using_native_resolver_posix_test",
+ "platforms": [
+ "linux",
+ "mac",
+ "posix"
+ ],
+ "uses_polling": true
+ },
+ {
+ "args": [
+ "--resolver=native"
+ ],
+ "benchmark": false,
+ "ci_platforms": [
+ "linux",
+ "mac",
"posix",
"windows"
],
diff --git a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh
index 7ff877e830..1c48ed20ba 100755
--- a/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh
+++ b/tools/run_tests/helper_scripts/run_ruby_end2end_tests.sh
@@ -30,4 +30,6 @@ time ruby src/ruby/end2end/multiple_killed_watching_threads_driver.rb || EXIT_CO
time ruby src/ruby/end2end/load_grpc_with_gc_stress_driver.rb || EXIT_CODE=1
time ruby src/ruby/end2end/client_memory_usage_driver.rb || EXIT_CODE=1
time ruby src/ruby/end2end/package_with_underscore_checker.rb || EXIT_CODE=1
+time ruby src/ruby/end2end/graceful_sig_handling_driver.rb || EXIT_CODE=1
+time ruby src/ruby/end2end/graceful_sig_stop_driver.rb || EXIT_CODE=1
exit $EXIT_CODE