aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/boringssl/err_data.c510
-rw-r--r--src/compiler/cpp_generator.cc364
-rw-r--r--src/compiler/cpp_generator.h93
-rw-r--r--src/compiler/cpp_plugin.cc117
-rw-r--r--src/compiler/ruby_generator.cc4
-rw-r--r--src/compiler/ruby_generator_string-inl.h1
-rw-r--r--src/core/ext/census/grpc_plugin.c24
-rw-r--r--src/core/ext/client_config/client_config_plugin.c95
-rw-r--r--src/core/ext/client_config/parse_address.c137
-rw-r--r--src/core/ext/client_config/parse_address.h56
-rw-r--r--src/core/ext/client_config/subchannel.c20
-rw-r--r--src/core/ext/lb_policy/pick_first/pick_first.c2
-rw-r--r--src/core/ext/resolver/sockaddr/sockaddr_resolver.c99
-rw-r--r--src/core/ext/transport/chttp2/alpn/alpn.c (renamed from src/core/ext/transport/chttp2/transport/alpn.c)2
-rw-r--r--src/core/ext/transport/chttp2/alpn/alpn.h (renamed from src/core/ext/transport/chttp2/transport/alpn.h)6
-rw-r--r--src/core/ext/transport/chttp2/client/insecure/channel_create.c1
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_encoder.c20
-rw-r--r--src/core/ext/transport/chttp2/transport/bin_encoder.h2
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_plugin.c46
-rw-r--r--src/core/ext/transport/chttp2/transport/chttp2_transport.c24
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.c12
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_data.h3
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.c7
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.c12
-rw-r--r--src/core/ext/transport/chttp2/transport/parsing.c6
-rw-r--r--src/core/lib/channel/channel_args.c12
-rw-r--r--src/core/lib/channel/channel_stack_builder.c25
-rw-r--r--src/core/lib/channel/channel_stack_builder.h10
-rw-r--r--src/core/lib/http/parser.c13
-rw-r--r--src/core/lib/http/parser.h2
-rw-r--r--src/core/lib/iomgr/tcp_server_posix.c2
-rw-r--r--src/core/lib/iomgr/tcp_server_windows.c2
-rw-r--r--src/core/lib/iomgr/udp_server.c5
-rw-r--r--src/core/lib/iomgr/unix_sockets_posix.c16
-rw-r--r--src/core/lib/iomgr/unix_sockets_posix.h7
-rw-r--r--src/core/lib/iomgr/unix_sockets_posix_noop.c11
-rw-r--r--src/core/lib/profiling/basic_timers.c1
-rw-r--r--src/core/lib/security/credentials.c27
-rw-r--r--src/core/lib/security/security_connector.c36
-rw-r--r--src/core/lib/security/security_connector.h2
-rw-r--r--src/core/lib/support/alloc.c2
-rw-r--r--src/core/lib/support/log.c33
-rw-r--r--src/core/lib/support/log_linux.c1
-rw-r--r--src/core/lib/support/thd_posix.c1
-rw-r--r--src/core/lib/surface/byte_buffer.c6
-rw-r--r--src/core/lib/surface/call.c31
-rw-r--r--src/core/lib/surface/channel.c32
-rw-r--r--src/core/lib/surface/channel_init.c16
-rw-r--r--src/core/lib/surface/channel_init.h9
-rw-r--r--src/core/lib/surface/init.c73
-rw-r--r--src/core/lib/surface/server.c8
-rw-r--r--src/core/lib/transport/metadata.c47
-rw-r--r--src/core/lib/transport/metadata.h6
-rw-r--r--src/core/lib/transport/transport.h2
-rw-r--r--src/core/lib/tsi/fake_transport_security.c22
-rw-r--r--src/core/lib/tsi/ssl_transport_security.c123
-rw-r--r--src/core/lib/tsi/ssl_transport_security.h17
-rw-r--r--src/core/lib/tsi/transport_security.c38
-rw-r--r--src/core/lib/tsi/transport_security_interface.h9
-rw-r--r--src/core/plugin_registry/grpc_plugin_registry.c8
-rw-r--r--src/core/plugin_registry/grpc_unsecure_plugin_registry.c8
-rw-r--r--src/cpp/client/client_context.cc8
-rw-r--r--src/cpp/server/secure_server_credentials.cc8
-rw-r--r--src/cpp/server/server_context.cc13
-rw-r--r--src/csharp/.nuget/packages.config2
-rw-r--r--src/csharp/Grpc.Core.Tests/ChannelTest.cs4
-rw-r--r--src/csharp/Grpc.Core.Tests/ClientServerTest.cs10
-rw-r--r--src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs2
-rw-r--r--src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj30
-rw-r--r--src/csharp/Grpc.Core.Tests/HalfcloseTest.cs2
-rw-r--r--src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs2
-rw-r--r--src/csharp/Grpc.Core.Tests/MarshallingErrorsTest.cs8
-rw-r--r--src/csharp/Grpc.Core.Tests/NUnitMain.cs59
-rw-r--r--src/csharp/Grpc.Core.Tests/ResponseHeadersTest.cs2
-rw-r--r--src/csharp/Grpc.Core.Tests/SanityTest.cs28
-rw-r--r--src/csharp/Grpc.Core.Tests/packages.config5
-rw-r--r--src/csharp/Grpc.Core/Grpc.Core.csproj5
-rw-r--r--src/csharp/Grpc.Core/Grpc.Core.nuspec8
-rw-r--r--src/csharp/Grpc.Core/Grpc.Core.targets (renamed from src/csharp/grpc.native.csharp/grpc.native.csharp.targets)0
-rw-r--r--src/csharp/Grpc.Core/Internal/NativeExtension.cs27
-rw-r--r--src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs2
-rw-r--r--src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs24
-rw-r--r--src/csharp/Grpc.Core/Logging/ConsoleLogger.cs97
-rw-r--r--src/csharp/Grpc.Core/Logging/TextWriterLogger.cs176
-rw-r--r--src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj18
-rw-r--r--src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs2
-rw-r--r--src/csharp/Grpc.Examples.Tests/NUnitMain.cs59
-rw-r--r--src/csharp/Grpc.Examples.Tests/packages.config11
-rw-r--r--src/csharp/Grpc.Examples/Grpc.Examples.csproj3
-rw-r--r--src/csharp/Grpc.Examples/packages.config2
-rw-r--r--src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj25
-rw-r--r--src/csharp/Grpc.HealthCheck.Tests/NUnitMain.cs59
-rw-r--r--src/csharp/Grpc.HealthCheck.Tests/packages.config3
-rw-r--r--src/csharp/Grpc.IntegrationTesting/ClientRunners.cs1
-rw-r--r--src/csharp/Grpc.IntegrationTesting/Control.cs1684
-rw-r--r--src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs6
-rw-r--r--src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj47
-rw-r--r--src/csharp/Grpc.IntegrationTesting/HeaderInterceptorTest.cs113
-rw-r--r--src/csharp/Grpc.IntegrationTesting/InteropClient.cs8
-rw-r--r--src/csharp/Grpc.IntegrationTesting/Messages.cs121
-rw-r--r--src/csharp/Grpc.IntegrationTesting/NUnitMain.cs59
-rw-r--r--src/csharp/Grpc.IntegrationTesting/Test.cs8
-rw-r--r--src/csharp/Grpc.IntegrationTesting/TestCredentials.cs33
-rw-r--r--src/csharp/Grpc.IntegrationTesting/TestGrpc.cs25
-rw-r--r--src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs204
-rw-r--r--src/csharp/Grpc.IntegrationTesting/packages.config3
-rw-r--r--src/csharp/build_packages.bat13
-rw-r--r--src/csharp/ext/grpc_csharp_ext.c9
-rw-r--r--src/csharp/grpc.native.csharp/README.md22
-rw-r--r--src/csharp/tests.json22
-rw-r--r--src/node/ext/server_credentials.cc13
-rw-r--r--src/node/performance/worker.js2
-rw-r--r--src/node/performance/worker_service_impl.js3
-rw-r--r--src/node/stress/stress_client.js6
-rwxr-xr-xsrc/node/tools/bin/protoc.js54
-rw-r--r--src/node/tools/index.js (renamed from src/cpp/common/create_auth_context.h)13
-rw-r--r--src/node/tools/package.json38
-rw-r--r--src/php/ext/grpc/byte_buffer.c1
-rw-r--r--src/php/ext/grpc/call.c8
-rw-r--r--src/php/ext/grpc/server_credentials.c9
-rw-r--r--src/php/tests/bootstrap.php2
-rw-r--r--src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php3
-rw-r--r--src/php/tests/generated_code/math_client.php4
-rw-r--r--src/php/tests/unit_tests/CallCredentials3Test.php1
-rwxr-xr-xsrc/php/tests/unit_tests/CallTest.php3
-rw-r--r--src/php/tests/unit_tests/ChannelCredentialsTest.php2
-rw-r--r--src/php/tests/unit_tests/ChannelTest.php3
-rwxr-xr-xsrc/php/tests/unit_tests/EndToEndTest.php8
-rw-r--r--src/php/tests/unit_tests/ServerTest.php3
-rwxr-xr-xsrc/php/tests/unit_tests/TimevalTest.php15
-rwxr-xr-xsrc/proto/gen_build_yaml.py23
-rw-r--r--src/proto/grpc/binary_log/v1alpha/log.proto108
-rw-r--r--src/proto/grpc/testing/control.proto81
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi4
-rw-r--r--src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi7
-rw-r--r--src/python/grpcio/grpc/_cython/imports.generated.c6
-rw-r--r--src/python/grpcio/grpc/_cython/imports.generated.h9
-rw-r--r--src/python/grpcio/grpc_core_dependencies.py156
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.c6
-rw-r--r--src/ruby/ext/grpc/rb_grpc_imports.generated.h9
-rw-r--r--src/ruby/ext/grpc/rb_server_credentials.c24
-rw-r--r--src/ruby/lib/grpc/generic/client_stub.rb11
-rw-r--r--src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb28
-rw-r--r--src/ruby/qps/server.rb3
-rw-r--r--src/ruby/qps/src/proto/grpc/testing/control.rb55
-rw-r--r--src/ruby/qps/src/proto/grpc/testing/messages.rb4
-rwxr-xr-xsrc/ruby/qps/worker.rb4
-rw-r--r--src/ruby/spec/pb/duplicate/codegen_spec.rb71
148 files changed, 4011 insertions, 2197 deletions
diff --git a/src/boringssl/err_data.c b/src/boringssl/err_data.c
index 1a1d950419..d4cc08bd99 100644
--- a/src/boringssl/err_data.c
+++ b/src/boringssl/err_data.c
@@ -54,30 +54,30 @@ OPENSSL_COMPILE_ASSERT(ERR_LIB_USER == 32, library_values_changed_32);
OPENSSL_COMPILE_ASSERT(ERR_NUM_LIBS == 33, library_values_changed_num);
const uint32_t kOpenSSLReasonValues[] = {
- 0xc3207ba,
- 0xc3287d4,
- 0xc3307e3,
- 0xc3387f3,
- 0xc340802,
- 0xc34881b,
- 0xc350827,
- 0xc358844,
- 0xc360856,
- 0xc368864,
- 0xc370874,
- 0xc378881,
- 0xc380891,
- 0xc38889c,
- 0xc3908b2,
- 0xc3988c1,
- 0xc3a08d5,
- 0xc3a87c7,
+ 0xc3207ab,
+ 0xc3287c5,
+ 0xc3307d4,
+ 0xc3387e4,
+ 0xc3407f3,
+ 0xc34880c,
+ 0xc350818,
+ 0xc358835,
+ 0xc360847,
+ 0xc368855,
+ 0xc370865,
+ 0xc378872,
+ 0xc380882,
+ 0xc38888d,
+ 0xc3908a3,
+ 0xc3988b2,
+ 0xc3a08c6,
+ 0xc3a87b8,
0xc3b00b0,
- 0x10321478,
- 0x10329484,
- 0x1033149d,
- 0x103394b0,
- 0x10340de1,
+ 0x10321484,
+ 0x10329490,
+ 0x103314a9,
+ 0x103394bc,
+ 0x10340ded,
0x103494cf,
0x103514e4,
0x10359516,
@@ -97,7 +97,7 @@ const uint32_t kOpenSSLReasonValues[] = {
0x103c9658,
0x103d166f,
0x103d9682,
- 0x103e0b6c,
+ 0x103e0b5d,
0x103e96b3,
0x103f16c6,
0x103f96e0,
@@ -108,87 +108,91 @@ const uint32_t kOpenSSLReasonValues[] = {
0x10421747,
0x1042975b,
0x1043176d,
- 0x104385d0,
- 0x104408c1,
+ 0x104385c1,
+ 0x104408b2,
0x10449782,
0x10451799,
0x104597ae,
0x104617bc,
0x10469695,
0x104714f7,
- 0x104787c7,
+ 0x104787b8,
0x104800b0,
- 0x104894c3,
- 0x14320b4f,
- 0x14328b5d,
- 0x14330b6c,
- 0x14338b7e,
+ 0x10488b8c,
+ 0x14320b40,
+ 0x14328b4e,
+ 0x14330b5d,
+ 0x14338b6f,
0x18320083,
- 0x18328e47,
- 0x18340e75,
- 0x18348e89,
- 0x18358ec0,
- 0x18368eed,
- 0x18370f00,
- 0x18378f14,
- 0x18380f38,
- 0x18388f46,
- 0x18390f5c,
- 0x18398f70,
- 0x183a0f80,
- 0x183b0f90,
- 0x183b8fa5,
- 0x183c8fd0,
- 0x183d0fe4,
- 0x183d8ff4,
- 0x183e0b9b,
- 0x183e9001,
- 0x183f1013,
- 0x183f901e,
- 0x1840102e,
- 0x1840903f,
- 0x18411050,
- 0x18419062,
- 0x1842108b,
- 0x184290bd,
- 0x184310cc,
- 0x18451135,
- 0x1845914b,
- 0x18461166,
- 0x18468ed8,
- 0x184709d9,
+ 0x18328e53,
+ 0x18340e81,
+ 0x18348e95,
+ 0x18358ecc,
+ 0x18368ef9,
+ 0x18370f0c,
+ 0x18378f20,
+ 0x18380f44,
+ 0x18388f52,
+ 0x18390f68,
+ 0x18398f7c,
+ 0x183a0f8c,
+ 0x183b0f9c,
+ 0x183b8fb1,
+ 0x183c8fdc,
+ 0x183d0ff0,
+ 0x183d9000,
+ 0x183e0b98,
+ 0x183e900d,
+ 0x183f101f,
+ 0x183f902a,
+ 0x1840103a,
+ 0x1840904b,
+ 0x1841105c,
+ 0x1841906e,
+ 0x18421097,
+ 0x184290c9,
+ 0x184310d8,
+ 0x18451141,
+ 0x18459157,
+ 0x18461172,
+ 0x18468ee4,
+ 0x184709ca,
0x18478094,
- 0x18480fbc,
- 0x18489101,
- 0x18490e5d,
- 0x18498e9e,
- 0x184a119c,
- 0x184a9119,
- 0x184b10e0,
- 0x184b8e37,
- 0x184c10a4,
- 0x184c866b,
- 0x184d1181,
- 0x203211c3,
- 0x243211cf,
- 0x24328907,
- 0x243311e1,
- 0x243391ee,
- 0x243411fb,
- 0x2434920d,
- 0x2435121c,
- 0x24359239,
- 0x24361246,
- 0x24369254,
- 0x24371262,
- 0x24379270,
- 0x24381279,
- 0x24389286,
- 0x24391299,
- 0x28320b8f,
- 0x28328b9b,
- 0x28330b6c,
- 0x28338bae,
+ 0x18480fc8,
+ 0x1848910d,
+ 0x18490e69,
+ 0x18498eaa,
+ 0x184a11a8,
+ 0x184a9125,
+ 0x184b10ec,
+ 0x184b8e43,
+ 0x184c10b0,
+ 0x184c865c,
+ 0x184d118d,
+ 0x184d80b0,
+ 0x203211cf,
+ 0x243211db,
+ 0x243288f8,
+ 0x243311ed,
+ 0x243391fa,
+ 0x24341207,
+ 0x24349219,
+ 0x24351228,
+ 0x24359245,
+ 0x24361252,
+ 0x24369260,
+ 0x2437126e,
+ 0x2437927c,
+ 0x24381285,
+ 0x24389292,
+ 0x243912a5,
+ 0x28320b80,
+ 0x28328b98,
+ 0x28330b5d,
+ 0x28338bab,
+ 0x28340b8c,
+ 0x28348094,
+ 0x283500b0,
0x2c32281d,
0x2c32a82b,
0x2c33283d,
@@ -207,7 +211,7 @@ const uint32_t kOpenSSLReasonValues[] = {
0x2c39a917,
0x2c3a292b,
0x2c3aa93c,
- 0x2c3b1359,
+ 0x2c3b1365,
0x2c3ba94d,
0x2c3c2961,
0x2c3ca977,
@@ -219,12 +223,12 @@ const uint32_t kOpenSSLReasonValues[] = {
0x2c3faa09,
0x2c402a2c,
0x2c40aa4b,
- 0x2c4111c3,
+ 0x2c4111cf,
0x2c41aa5c,
0x2c422a6f,
- 0x2c429135,
+ 0x2c429141,
0x2c432a80,
- 0x2c4386a2,
+ 0x2c438693,
0x2c4429ad,
0x30320000,
0x30328015,
@@ -277,77 +281,79 @@ const uint32_t kOpenSSLReasonValues[] = {
0x304a03b4,
0x304a83c7,
0x304b03d2,
- 0x304b83e1,
- 0x304c03f2,
- 0x304c83fe,
- 0x304d0414,
- 0x304d8422,
- 0x304e0438,
- 0x304e844a,
- 0x304f045c,
- 0x304f846f,
- 0x30500482,
- 0x30508493,
- 0x305104a3,
- 0x305184bb,
- 0x305204d0,
- 0x305284e8,
- 0x305304fc,
- 0x30538514,
- 0x3054052d,
- 0x30548546,
- 0x30550563,
- 0x3055856e,
- 0x30560586,
- 0x30568596,
- 0x305705a7,
- 0x305785ba,
- 0x305805d0,
- 0x305885d9,
- 0x305905ee,
+ 0x304b83e3,
+ 0x304c03ef,
+ 0x304c8405,
+ 0x304d0413,
+ 0x304d8429,
+ 0x304e043b,
+ 0x304e844d,
+ 0x304f0460,
+ 0x304f8473,
+ 0x30500484,
+ 0x30508494,
+ 0x305104ac,
+ 0x305184c1,
+ 0x305204d9,
+ 0x305284ed,
+ 0x30530505,
+ 0x3053851e,
+ 0x30540537,
+ 0x30548554,
+ 0x3055055f,
+ 0x30558577,
+ 0x30560587,
+ 0x30568598,
+ 0x305705ab,
+ 0x305785c1,
+ 0x305805ca,
+ 0x305885df,
+ 0x305905f2,
0x30598601,
- 0x305a0610,
+ 0x305a0621,
0x305a8630,
- 0x305b063f,
- 0x305b864b,
- 0x305c066b,
- 0x305c8687,
- 0x305d0698,
- 0x305d86a2,
- 0x34320ac9,
- 0x34328add,
- 0x34330afa,
- 0x34338b0d,
- 0x34340b1c,
- 0x34348b39,
+ 0x305b063c,
+ 0x305b865c,
+ 0x305c0678,
+ 0x305c8689,
+ 0x305d0693,
+ 0x34320aba,
+ 0x34328ace,
+ 0x34330aeb,
+ 0x34338afe,
+ 0x34340b0d,
+ 0x34348b2a,
0x3c320083,
- 0x3c328bd8,
- 0x3c330bf1,
- 0x3c338c0c,
- 0x3c340c29,
- 0x3c348c44,
- 0x3c350c5f,
- 0x3c358c74,
- 0x3c360c8d,
- 0x3c368ca5,
- 0x3c370cb6,
- 0x3c378cc4,
- 0x3c380cd1,
- 0x3c388ce5,
- 0x3c390b9b,
- 0x3c398cf9,
- 0x3c3a0d0d,
- 0x3c3a8881,
- 0x3c3b0d1d,
- 0x3c3b8d38,
- 0x3c3c0d4a,
- 0x3c3c8d60,
- 0x3c3d0d6a,
- 0x3c3d8d7e,
- 0x3c3e0d8c,
- 0x3c3e8db1,
- 0x3c3f0bc4,
- 0x3c3f8d9a,
+ 0x3c328bd5,
+ 0x3c330bee,
+ 0x3c338c09,
+ 0x3c340c26,
+ 0x3c348c50,
+ 0x3c350c6b,
+ 0x3c358c80,
+ 0x3c360c99,
+ 0x3c368cb1,
+ 0x3c370cc2,
+ 0x3c378cd0,
+ 0x3c380cdd,
+ 0x3c388cf1,
+ 0x3c390b98,
+ 0x3c398d05,
+ 0x3c3a0d19,
+ 0x3c3a8872,
+ 0x3c3b0d29,
+ 0x3c3b8d44,
+ 0x3c3c0d56,
+ 0x3c3c8d6c,
+ 0x3c3d0d76,
+ 0x3c3d8d8a,
+ 0x3c3e0d98,
+ 0x3c3e8dbd,
+ 0x3c3f0bc1,
+ 0x3c3f8da6,
+ 0x3c400094,
+ 0x3c4080b0,
+ 0x3c410c41,
0x403217d3,
0x403297e9,
0x40331817,
@@ -362,7 +368,7 @@ const uint32_t kOpenSSLReasonValues[] = {
0x403798b8,
0x403818c3,
0x403898d5,
- 0x40390de1,
+ 0x40390ded,
0x403998e5,
0x403a18f8,
0x403a9919,
@@ -437,7 +443,7 @@ const uint32_t kOpenSSLReasonValues[] = {
0x405d1e9e,
0x405d9eb5,
0x405e1ed5,
- 0x405e8a17,
+ 0x405e8a08,
0x405f1ef6,
0x405f9f03,
0x40601f11,
@@ -474,18 +480,18 @@ const uint32_t kOpenSSLReasonValues[] = {
0x406fa60d,
0x40702620,
0x4070a63d,
- 0x40710782,
+ 0x40710773,
0x4071a64f,
0x40722662,
0x4072a67b,
0x40732693,
- 0x407390bd,
+ 0x407390c9,
0x407426a7,
0x4074a6c1,
0x407526d2,
0x4075a6e6,
0x407626f4,
- 0x40769286,
+ 0x40769292,
0x40772719,
0x4077a73b,
0x40782756,
@@ -528,48 +534,48 @@ const uint32_t kOpenSSLReasonValues[] = {
0x422c251d,
0x422ca4d8,
0x422d24b7,
- 0x443206ad,
- 0x443286bc,
- 0x443306c8,
- 0x443386d6,
- 0x443406e9,
- 0x443486fa,
- 0x44350701,
- 0x4435870b,
- 0x4436071e,
- 0x44368734,
- 0x44370746,
- 0x44378753,
- 0x44380762,
- 0x4438876a,
- 0x44390782,
- 0x44398790,
- 0x443a07a3,
- 0x4c3212b0,
- 0x4c3292c0,
- 0x4c3312d3,
- 0x4c3392f3,
+ 0x4432069e,
+ 0x443286ad,
+ 0x443306b9,
+ 0x443386c7,
+ 0x443406da,
+ 0x443486eb,
+ 0x443506f2,
+ 0x443586fc,
+ 0x4436070f,
+ 0x44368725,
+ 0x44370737,
+ 0x44378744,
+ 0x44380753,
+ 0x4438875b,
+ 0x44390773,
+ 0x44398781,
+ 0x443a0794,
+ 0x4c3212bc,
+ 0x4c3292cc,
+ 0x4c3312df,
+ 0x4c3392ff,
0x4c340094,
0x4c3480b0,
- 0x4c3512ff,
- 0x4c35930d,
- 0x4c361329,
- 0x4c36933c,
- 0x4c37134b,
- 0x4c379359,
- 0x4c38136e,
- 0x4c38937a,
- 0x4c39139a,
- 0x4c3993c4,
- 0x4c3a13dd,
- 0x4c3a93f6,
- 0x4c3b05d0,
- 0x4c3b940f,
- 0x4c3c1421,
- 0x4c3c9430,
- 0x4c3d10bd,
- 0x4c3d9449,
- 0x4c3e1456,
+ 0x4c35130b,
+ 0x4c359319,
+ 0x4c361335,
+ 0x4c369348,
+ 0x4c371357,
+ 0x4c379365,
+ 0x4c38137a,
+ 0x4c389386,
+ 0x4c3913a6,
+ 0x4c3993d0,
+ 0x4c3a13e9,
+ 0x4c3a9402,
+ 0x4c3b05c1,
+ 0x4c3b941b,
+ 0x4c3c142d,
+ 0x4c3c943c,
+ 0x4c3d10c9,
+ 0x4c3d9455,
+ 0x4c3e1462,
0x50322a92,
0x5032aaa1,
0x50332aac,
@@ -607,7 +613,7 @@ const uint32_t kOpenSSLReasonValues[] = {
0x50432d43,
0x5043ad53,
0x50442d62,
- 0x50448414,
+ 0x50448405,
0x50452d76,
0x5045ad94,
0x50462da7,
@@ -631,45 +637,45 @@ const uint32_t kOpenSSLReasonValues[] = {
0x504f2f62,
0x504faf79,
0x50502f88,
- 0x50508687,
+ 0x50508678,
0x50512f9b,
- 0x58320e1f,
- 0x68320de1,
- 0x68328b9b,
- 0x68330bae,
- 0x68338def,
- 0x68340dff,
+ 0x58320e2b,
+ 0x68320ded,
+ 0x68328b98,
+ 0x68330bab,
+ 0x68338dfb,
+ 0x68340e0b,
0x683480b0,
- 0x6c320dbd,
- 0x6c328b7e,
- 0x6c330dc8,
- 0x7432098d,
- 0x783208f2,
- 0x78328907,
- 0x78330913,
+ 0x6c320dc9,
+ 0x6c328b6f,
+ 0x6c330dd4,
+ 0x7432097e,
+ 0x783208e3,
+ 0x783288f8,
+ 0x78330904,
0x78338083,
- 0x78340922,
- 0x78348937,
- 0x78350956,
- 0x78358978,
- 0x7836098d,
- 0x783689a3,
- 0x783709b3,
- 0x783789c6,
- 0x783809d9,
- 0x783889eb,
- 0x783909f8,
- 0x78398a17,
- 0x783a0a2c,
- 0x783a8a3a,
- 0x783b0a44,
- 0x783b8a58,
- 0x783c0a6f,
- 0x783c8a84,
- 0x783d0a9b,
- 0x783d8ab0,
- 0x783e0a06,
- 0x7c3211b2,
+ 0x78340913,
+ 0x78348928,
+ 0x78350947,
+ 0x78358969,
+ 0x7836097e,
+ 0x78368994,
+ 0x783709a4,
+ 0x783789b7,
+ 0x783809ca,
+ 0x783889dc,
+ 0x783909e9,
+ 0x78398a08,
+ 0x783a0a1d,
+ 0x783a8a2b,
+ 0x783b0a35,
+ 0x783b8a49,
+ 0x783c0a60,
+ 0x783c8a75,
+ 0x783d0a8c,
+ 0x783d8aa1,
+ 0x783e09f7,
+ 0x7c3211be,
};
const size_t kOpenSSLReasonValuesLen = sizeof(kOpenSSLReasonValues) / sizeof(kOpenSSLReasonValues[0]);
@@ -725,7 +731,6 @@ const char kOpenSSLReasonStringData[] =
"INVALID_UNIVERSALSTRING_LENGTH\0"
"INVALID_UTF8STRING\0"
"LIST_ERROR\0"
- "MALLOC_FAILURE\0"
"MISSING_ASN1_EOS\0"
"MISSING_EOC\0"
"MISSING_SECOND_NUMBER\0"
@@ -833,6 +838,7 @@ const char kOpenSSLReasonStringData[] =
"MODULUS_TOO_LARGE\0"
"NO_PRIVATE_VALUE\0"
"BAD_Q_VALUE\0"
+ "BAD_VERSION\0"
"MISSING_PARAMETERS\0"
"NEED_NEW_SETUP_VALUES\0"
"BIGNUM_OUT_OF_RANGE\0"
@@ -840,6 +846,7 @@ const char kOpenSSLReasonStringData[] =
"D2I_ECPKPARAMETERS_FAILURE\0"
"EC_GROUP_NEW_BY_NAME_FAILURE\0"
"GROUP2PKPARAMETERS_FAILURE\0"
+ "GROUP_MISMATCH\0"
"I2D_ECPKPARAMETERS_FAILURE\0"
"INCOMPATIBLE_OBJECTS\0"
"INVALID_COMPRESSED_POINT\0"
@@ -948,7 +955,6 @@ const char kOpenSSLReasonStringData[] =
"BAD_FIXED_HEADER_DECRYPT\0"
"BAD_PAD_BYTE_COUNT\0"
"BAD_RSA_PARAMETERS\0"
- "BAD_VERSION\0"
"BLOCK_TYPE_IS_NOT_01\0"
"BN_NOT_INITIALIZED\0"
"CANNOT_RECOVER_MULTI_PRIME_KEY\0"
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 08b1123a51..b133699306 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -34,9 +34,6 @@
#include <map>
#include "src/compiler/cpp_generator.h"
-#include "src/compiler/cpp_generator_helpers.h"
-
-#include "src/compiler/config.h"
#include <sstream>
@@ -50,22 +47,6 @@ grpc::string as_string(T x) {
return out.str();
}
-bool NoStreaming(const grpc::protobuf::MethodDescriptor *method) {
- return !method->client_streaming() && !method->server_streaming();
-}
-
-bool ClientOnlyStreaming(const grpc::protobuf::MethodDescriptor *method) {
- return method->client_streaming() && !method->server_streaming();
-}
-
-bool ServerOnlyStreaming(const grpc::protobuf::MethodDescriptor *method) {
- return !method->client_streaming() && method->server_streaming();
-}
-
-bool BidiStreaming(const grpc::protobuf::MethodDescriptor *method) {
- return method->client_streaming() && method->server_streaming();
-}
-
grpc::string FilenameIdentifier(const grpc::string &filename) {
grpc::string result;
for (unsigned i = 0; i < filename.size(); i++) {
@@ -86,7 +67,7 @@ grpc::string FilenameIdentifier(const grpc::string &filename) {
template<class T, size_t N>
T *array_end(T (&array)[N]) { return array + N; }
-void PrintIncludes(grpc::protobuf::io::Printer *printer, const std::vector<grpc::string>& headers, const Parameters &params) {
+void PrintIncludes(Printer *printer, const std::vector<grpc::string>& headers, const Parameters &params) {
std::map<grpc::string, grpc::string> vars;
vars["l"] = params.use_system_headers ? '<' : '"';
@@ -105,39 +86,36 @@ void PrintIncludes(grpc::protobuf::io::Printer *printer, const std::vector<grpc:
}
}
-grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params) {
+grpc::string GetHeaderPrologue(File *file, const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
- grpc::protobuf::io::StringOutputStream output_stream(&output);
- grpc::protobuf::io::Printer printer(&output_stream, '$');
+ auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- vars["filename"] = file->name();
- vars["filename_identifier"] = FilenameIdentifier(file->name());
- vars["filename_base"] = grpc_generator::StripProto(file->name());
+ vars["filename"] = file->filename();
+ vars["filename_identifier"] = FilenameIdentifier(file->filename());
+ vars["filename_base"] = file->filename_without_ext();
- printer.Print(vars, "// Generated by the gRPC protobuf plugin.\n");
- printer.Print(vars,
+ printer->Print(vars, "// Generated by the gRPC protobuf plugin.\n");
+ printer->Print(vars,
"// If you make any local change, they will be lost.\n");
- printer.Print(vars, "// source: $filename$\n");
- printer.Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n");
- printer.Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n");
- printer.Print(vars, "\n");
- printer.Print(vars, "#include \"$filename_base$.pb.h\"\n");
- printer.Print(vars, "\n");
+ printer->Print(vars, "// source: $filename$\n");
+ printer->Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n");
+ printer->Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n");
+ printer->Print(vars, "\n");
+ printer->Print(vars, "#include \"$filename_base$.pb.h\"\n");
+ printer->Print(vars, "\n");
}
return output;
}
-grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetHeaderIncludes(File *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
- grpc::protobuf::io::StringOutputStream output_stream(&output);
- grpc::protobuf::io::Printer printer(&output_stream, '$');
+ auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
static const char *headers_strs[] = {
@@ -151,42 +129,38 @@ grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
"grpc++/impl/codegen/sync_stream.h"
};
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
- PrintIncludes(&printer, headers, params);
- printer.Print(vars, "\n");
- printer.Print(vars, "namespace grpc {\n");
- printer.Print(vars, "class CompletionQueue;\n");
- printer.Print(vars, "class Channel;\n");
- printer.Print(vars, "class RpcService;\n");
- printer.Print(vars, "class ServerCompletionQueue;\n");
- printer.Print(vars, "class ServerContext;\n");
- printer.Print(vars, "} // namespace grpc\n\n");
+ PrintIncludes(printer.get(), headers, params);
+ printer->Print(vars, "\n");
+ printer->Print(vars, "namespace grpc {\n");
+ printer->Print(vars, "class CompletionQueue;\n");
+ printer->Print(vars, "class Channel;\n");
+ printer->Print(vars, "class RpcService;\n");
+ printer->Print(vars, "class ServerCompletionQueue;\n");
+ printer->Print(vars, "class ServerContext;\n");
+ printer->Print(vars, "} // namespace grpc\n\n");
if (!file->package().empty()) {
- std::vector<grpc::string> parts =
- grpc_generator::tokenize(file->package(), ".");
+ std::vector<grpc::string> parts = file->package_parts();
for (auto part = parts.begin(); part != parts.end(); part++) {
vars["part"] = *part;
- printer.Print(vars, "namespace $part$ {\n");
+ printer->Print(vars, "namespace $part$ {\n");
}
- printer.Print(vars, "\n");
+ printer->Print(vars, "\n");
}
}
return output;
}
void PrintHeaderClientMethodInterfaces(
- grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::MethodDescriptor *method,
+ Printer *printer, const Method *method,
std::map<grpc::string, grpc::string> *vars, bool is_public) {
(*vars)["Method"] = method->name();
- (*vars)["Request"] =
- grpc_cpp_generator::ClassName(method->input_type(), true);
- (*vars)["Response"] =
- grpc_cpp_generator::ClassName(method->output_type(), true);
+ (*vars)["Request"] = method->input_type_name();
+ (*vars)["Response"] = method->output_type_name();
if (is_public) {
- if (NoStreaming(method)) {
+ if (method->NoStreaming()) {
printer->Print(
*vars,
"virtual ::grpc::Status $Method$(::grpc::ClientContext* context, "
@@ -204,7 +178,7 @@ void PrintHeaderClientMethodInterfaces(
"Async$Method$Raw(context, request, cq));\n");
printer->Outdent();
printer->Print("}\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(
*vars,
"std::unique_ptr< ::grpc::ClientWriterInterface< $Request$>>"
@@ -230,7 +204,7 @@ void PrintHeaderClientMethodInterfaces(
"Async$Method$Raw(context, response, cq, tag));\n");
printer->Outdent();
printer->Print("}\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(
*vars,
"std::unique_ptr< ::grpc::ClientReaderInterface< $Response$>>"
@@ -256,7 +230,7 @@ void PrintHeaderClientMethodInterfaces(
"Async$Method$Raw(context, request, cq, tag));\n");
printer->Outdent();
printer->Print("}\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(*vars,
"std::unique_ptr< ::grpc::ClientReaderWriterInterface< "
"$Request$, $Response$>> "
@@ -285,14 +259,14 @@ void PrintHeaderClientMethodInterfaces(
printer->Print("}\n");
}
} else {
- if (NoStreaming(method)) {
+ if (method->NoStreaming()) {
printer->Print(
*vars,
"virtual ::grpc::ClientAsyncResponseReaderInterface< $Response$>* "
"Async$Method$Raw(::grpc::ClientContext* context, "
"const $Request$& request, "
"::grpc::CompletionQueue* cq) = 0;\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(
*vars,
"virtual ::grpc::ClientWriterInterface< $Request$>*"
@@ -303,7 +277,7 @@ void PrintHeaderClientMethodInterfaces(
" Async$Method$Raw(::grpc::ClientContext* context, "
"$Response$* response, "
"::grpc::CompletionQueue* cq, void* tag) = 0;\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(
*vars,
"virtual ::grpc::ClientReaderInterface< $Response$>* $Method$Raw("
@@ -314,7 +288,7 @@ void PrintHeaderClientMethodInterfaces(
"Async$Method$Raw("
"::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag) = 0;\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(*vars,
"virtual ::grpc::ClientReaderWriterInterface< $Request$, "
"$Response$>* "
@@ -328,17 +302,15 @@ void PrintHeaderClientMethodInterfaces(
}
}
-void PrintHeaderClientMethod(grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::MethodDescriptor *method,
+void PrintHeaderClientMethod(Printer *printer,
+ const Method *method,
std::map<grpc::string, grpc::string> *vars,
bool is_public) {
(*vars)["Method"] = method->name();
- (*vars)["Request"] =
- grpc_cpp_generator::ClassName(method->input_type(), true);
- (*vars)["Response"] =
- grpc_cpp_generator::ClassName(method->output_type(), true);
+ (*vars)["Request"] = method->input_type_name();
+ (*vars)["Response"] = method->output_type_name();
if (is_public) {
- if (NoStreaming(method)) {
+ if (method->NoStreaming()) {
printer->Print(
*vars,
"::grpc::Status $Method$(::grpc::ClientContext* context, "
@@ -356,7 +328,7 @@ void PrintHeaderClientMethod(grpc::protobuf::io::Printer *printer,
"Async$Method$Raw(context, request, cq));\n");
printer->Outdent();
printer->Print("}\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(
*vars,
"std::unique_ptr< ::grpc::ClientWriter< $Request$>>"
@@ -380,7 +352,7 @@ void PrintHeaderClientMethod(grpc::protobuf::io::Printer *printer,
"Async$Method$Raw(context, response, cq, tag));\n");
printer->Outdent();
printer->Print("}\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(
*vars,
"std::unique_ptr< ::grpc::ClientReader< $Response$>>"
@@ -406,7 +378,7 @@ void PrintHeaderClientMethod(grpc::protobuf::io::Printer *printer,
"Async$Method$Raw(context, request, cq, tag));\n");
printer->Outdent();
printer->Print("}\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(
*vars,
"std::unique_ptr< ::grpc::ClientReaderWriter< $Request$, $Response$>>"
@@ -432,13 +404,13 @@ void PrintHeaderClientMethod(grpc::protobuf::io::Printer *printer,
printer->Print("}\n");
}
} else {
- if (NoStreaming(method)) {
+ if (method->NoStreaming()) {
printer->Print(*vars,
"::grpc::ClientAsyncResponseReader< $Response$>* "
"Async$Method$Raw(::grpc::ClientContext* context, "
"const $Request$& request, "
"::grpc::CompletionQueue* cq) GRPC_OVERRIDE;\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(*vars,
"::grpc::ClientWriter< $Request$>* $Method$Raw("
"::grpc::ClientContext* context, $Response$* response) "
@@ -448,7 +420,7 @@ void PrintHeaderClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::ClientAsyncWriter< $Request$>* Async$Method$Raw("
"::grpc::ClientContext* context, $Response$* response, "
"::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(*vars,
"::grpc::ClientReader< $Response$>* $Method$Raw("
"::grpc::ClientContext* context, const $Request$& request)"
@@ -458,7 +430,7 @@ void PrintHeaderClientMethod(grpc::protobuf::io::Printer *printer,
"::grpc::ClientAsyncReader< $Response$>* Async$Method$Raw("
"::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE;\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(
*vars,
"::grpc::ClientReaderWriter< $Request$, $Response$>* "
@@ -472,38 +444,34 @@ void PrintHeaderClientMethod(grpc::protobuf::io::Printer *printer,
}
}
-void PrintHeaderClientMethodData(grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::MethodDescriptor *method,
+void PrintHeaderClientMethodData(Printer *printer, const Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
printer->Print(*vars, "const ::grpc::RpcMethod rpcmethod_$Method$_;\n");
}
-void PrintHeaderServerMethodSync(grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::MethodDescriptor *method,
+void PrintHeaderServerMethodSync(Printer *printer, const Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
- (*vars)["Request"] =
- grpc_cpp_generator::ClassName(method->input_type(), true);
- (*vars)["Response"] =
- grpc_cpp_generator::ClassName(method->output_type(), true);
- if (NoStreaming(method)) {
+ (*vars)["Request"] = method->input_type_name();
+ (*vars)["Response"] = method->output_type_name();
+ if (method->NoStreaming()) {
printer->Print(*vars,
"virtual ::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, "
"$Response$* response);\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(*vars,
"virtual ::grpc::Status $Method$("
"::grpc::ServerContext* context, "
"::grpc::ServerReader< $Request$>* reader, "
"$Response$* response);\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(*vars,
"virtual ::grpc::Status $Method$("
"::grpc::ServerContext* context, const $Request$* request, "
"::grpc::ServerWriter< $Response$>* writer);\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(
*vars,
"virtual ::grpc::Status $Method$("
@@ -514,20 +482,18 @@ void PrintHeaderServerMethodSync(grpc::protobuf::io::Printer *printer,
}
void PrintHeaderServerMethodAsync(
- grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::MethodDescriptor *method,
+ Printer *printer,
+ const Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
- (*vars)["Request"] =
- grpc_cpp_generator::ClassName(method->input_type(), true);
- (*vars)["Response"] =
- grpc_cpp_generator::ClassName(method->output_type(), true);
+ (*vars)["Request"] = method->input_type_name();
+ (*vars)["Response"] = method->output_type_name();
printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(*vars,
"class WithAsyncMethod_$Method$ : public BaseClass {\n");
printer->Print(
" private:\n"
- " void BaseClassMustBeDerivedFromService(Service *service) {}\n");
+ " void BaseClassMustBeDerivedFromService(const Service *service) {}\n");
printer->Print(" public:\n");
printer->Indent();
printer->Print(*vars,
@@ -538,7 +504,7 @@ void PrintHeaderServerMethodAsync(
"~WithAsyncMethod_$Method$() GRPC_OVERRIDE {\n"
" BaseClassMustBeDerivedFromService(this);\n"
"}\n");
- if (NoStreaming(method)) {
+ if (method->NoStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
@@ -559,7 +525,7 @@ void PrintHeaderServerMethodAsync(
" ::grpc::Service::RequestAsyncUnary($Idx$, context, "
"request, response, new_call_cq, notification_cq, tag);\n");
printer->Print("}\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
@@ -581,7 +547,7 @@ void PrintHeaderServerMethodAsync(
" ::grpc::Service::RequestAsyncClientStreaming($Idx$, "
"context, reader, new_call_cq, notification_cq, tag);\n");
printer->Print("}\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
@@ -604,7 +570,7 @@ void PrintHeaderServerMethodAsync(
" ::grpc::Service::RequestAsyncServerStreaming($Idx$, "
"context, request, writer, new_call_cq, notification_cq, tag);\n");
printer->Print("}\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
@@ -632,20 +598,18 @@ void PrintHeaderServerMethodAsync(
}
void PrintHeaderServerMethodGeneric(
- grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::MethodDescriptor *method,
+ Printer *printer,
+ const Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
- (*vars)["Request"] =
- grpc_cpp_generator::ClassName(method->input_type(), true);
- (*vars)["Response"] =
- grpc_cpp_generator::ClassName(method->output_type(), true);
+ (*vars)["Request"] = method->input_type_name();
+ (*vars)["Response"] = method->output_type_name();
printer->Print(*vars, "template <class BaseClass>\n");
printer->Print(*vars,
"class WithGenericMethod_$Method$ : public BaseClass {\n");
printer->Print(
" private:\n"
- " void BaseClassMustBeDerivedFromService(Service *service) {}\n");
+ " void BaseClassMustBeDerivedFromService(const Service *service) {}\n");
printer->Print(" public:\n");
printer->Indent();
printer->Print(*vars,
@@ -656,7 +620,7 @@ void PrintHeaderServerMethodGeneric(
"~WithGenericMethod_$Method$() GRPC_OVERRIDE {\n"
" BaseClassMustBeDerivedFromService(this);\n"
"}\n");
- if (NoStreaming(method)) {
+ if (method->NoStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
@@ -666,7 +630,7 @@ void PrintHeaderServerMethodGeneric(
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
@@ -677,7 +641,7 @@ void PrintHeaderServerMethodGeneric(
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
@@ -688,7 +652,7 @@ void PrintHeaderServerMethodGeneric(
" abort();\n"
" return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n"
"}\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(
*vars,
"// disable synchronous version of this method\n"
@@ -704,8 +668,8 @@ void PrintHeaderServerMethodGeneric(
printer->Print(*vars, "};\n");
}
-void PrintHeaderService(grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::ServiceDescriptor *service,
+void PrintHeaderService(Printer *printer,
+ const Service *service,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Service"] = service->name();
@@ -721,13 +685,13 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
printer->Indent();
printer->Print("virtual ~StubInterface() {}\n");
for (int i = 0; i < service->method_count(); ++i) {
- PrintHeaderClientMethodInterfaces(printer, service->method(i), vars, true);
+ PrintHeaderClientMethodInterfaces(printer, service->method(i).get(), vars, true);
}
printer->Outdent();
printer->Print("private:\n");
printer->Indent();
for (int i = 0; i < service->method_count(); ++i) {
- PrintHeaderClientMethodInterfaces(printer, service->method(i), vars, false);
+ PrintHeaderClientMethodInterfaces(printer, service->method(i).get(), vars, false);
}
printer->Outdent();
printer->Print("};\n");
@@ -737,17 +701,17 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
printer->Indent();
printer->Print("Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);\n");
for (int i = 0; i < service->method_count(); ++i) {
- PrintHeaderClientMethod(printer, service->method(i), vars, true);
+ PrintHeaderClientMethod(printer, service->method(i).get(), vars, true);
}
printer->Outdent();
printer->Print("\n private:\n");
printer->Indent();
printer->Print("std::shared_ptr< ::grpc::ChannelInterface> channel_;\n");
for (int i = 0; i < service->method_count(); ++i) {
- PrintHeaderClientMethod(printer, service->method(i), vars, false);
+ PrintHeaderClientMethod(printer, service->method(i).get(), vars, false);
}
for (int i = 0; i < service->method_count(); ++i) {
- PrintHeaderClientMethodData(printer, service->method(i), vars);
+ PrintHeaderClientMethodData(printer, service->method(i).get(), vars);
}
printer->Outdent();
printer->Print("};\n");
@@ -766,7 +730,7 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
printer->Print("Service();\n");
printer->Print("virtual ~Service();\n");
for (int i = 0; i < service->method_count(); ++i) {
- PrintHeaderServerMethodSync(printer, service->method(i), vars);
+ PrintHeaderServerMethodSync(printer, service->method(i).get(), vars);
}
printer->Outdent();
printer->Print("};\n");
@@ -774,13 +738,13 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
// Server side - Asynchronous
for (int i = 0; i < service->method_count(); ++i) {
(*vars)["Idx"] = as_string(i);
- PrintHeaderServerMethodAsync(printer, service->method(i), vars);
+ PrintHeaderServerMethodAsync(printer, service->method(i).get(), vars);
}
printer->Print("typedef ");
for (int i = 0; i < service->method_count(); ++i) {
- (*vars)["method_name"] = service->method(i)->name();
+ (*vars)["method_name"] = service->method(i).get()->name();
printer->Print(*vars, "WithAsyncMethod_$method_name$<");
}
printer->Print("Service");
@@ -792,20 +756,19 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer,
// Server side - Generic
for (int i = 0; i < service->method_count(); ++i) {
(*vars)["Idx"] = as_string(i);
- PrintHeaderServerMethodGeneric(printer, service->method(i), vars);
+ PrintHeaderServerMethodGeneric(printer, service->method(i).get(), vars);
}
printer->Outdent();
printer->Print("};\n");
}
-grpc::string GetHeaderServices(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetHeaderServices(File *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
- grpc::protobuf::io::StringOutputStream output_stream(&output);
- grpc::protobuf::io::Printer printer(&output_stream, '$');
+ auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
// Package string is empty or ends with a dot. It is used to fully qualify
// method names.
@@ -816,80 +779,76 @@ grpc::string GetHeaderServices(const grpc::protobuf::FileDescriptor *file,
if (!params.services_namespace.empty()) {
vars["services_namespace"] = params.services_namespace;
- printer.Print(vars, "\nnamespace $services_namespace$ {\n\n");
+ printer->Print(vars, "\nnamespace $services_namespace$ {\n\n");
}
for (int i = 0; i < file->service_count(); ++i) {
- PrintHeaderService(&printer, file->service(i), &vars);
- printer.Print("\n");
+ PrintHeaderService(printer.get(), file->service(i).get(), &vars);
+ printer->Print("\n");
}
if (!params.services_namespace.empty()) {
- printer.Print(vars, "} // namespace $services_namespace$\n\n");
+ printer->Print(vars, "} // namespace $services_namespace$\n\n");
}
}
return output;
}
-grpc::string GetHeaderEpilogue(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetHeaderEpilogue(File *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
- grpc::protobuf::io::StringOutputStream output_stream(&output);
- grpc::protobuf::io::Printer printer(&output_stream, '$');
+ auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- vars["filename"] = file->name();
- vars["filename_identifier"] = FilenameIdentifier(file->name());
+ vars["filename"] = file->filename();
+ vars["filename_identifier"] = FilenameIdentifier(file->filename());
if (!file->package().empty()) {
- std::vector<grpc::string> parts =
- grpc_generator::tokenize(file->package(), ".");
+ std::vector<grpc::string> parts = file->package_parts();
for (auto part = parts.rbegin(); part != parts.rend(); part++) {
vars["part"] = *part;
- printer.Print(vars, "} // namespace $part$\n");
+ printer->Print(vars, "} // namespace $part$\n");
}
- printer.Print(vars, "\n");
+ printer->Print(vars, "\n");
}
- printer.Print(vars, "\n");
- printer.Print(vars, "#endif // GRPC_$filename_identifier$__INCLUDED\n");
+ printer->Print(vars, "\n");
+ printer->Print(vars, "#endif // GRPC_$filename_identifier$__INCLUDED\n");
}
return output;
}
-grpc::string GetSourcePrologue(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetSourcePrologue(File *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
- grpc::protobuf::io::StringOutputStream output_stream(&output);
- grpc::protobuf::io::Printer printer(&output_stream, '$');
+ auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
- vars["filename"] = file->name();
- vars["filename_base"] = grpc_generator::StripProto(file->name());
+ vars["filename"] = file->filename();
+ vars["filename_base"] = file->filename_without_ext();
- printer.Print(vars, "// Generated by the gRPC protobuf plugin.\n");
- printer.Print(vars,
+ printer->Print(vars, "// Generated by the gRPC protobuf plugin.\n");
+ printer->Print(vars,
"// If you make any local change, they will be lost.\n");
- printer.Print(vars, "// source: $filename$\n\n");
- printer.Print(vars, "#include \"$filename_base$.pb.h\"\n");
- printer.Print(vars, "#include \"$filename_base$.grpc.pb.h\"\n");
- printer.Print(vars, "\n");
+ printer->Print(vars, "// source: $filename$\n\n");
+ printer->Print(vars, "#include \"$filename_base$.pb.h\"\n");
+ printer->Print(vars, "#include \"$filename_base$.grpc.pb.h\"\n");
+ printer->Print(vars, "\n");
}
return output;
}
-grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetSourceIncludes(File *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
- grpc::protobuf::io::StringOutputStream output_stream(&output);
- grpc::protobuf::io::Printer printer(&output_stream, '$');
+ auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
static const char *headers_strs[] = {
@@ -903,32 +862,29 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
"grpc++/impl/codegen/sync_stream.h"
};
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
- PrintIncludes(&printer, headers, params);
+ PrintIncludes(printer.get(), headers, params);
if (!file->package().empty()) {
- std::vector<grpc::string> parts =
- grpc_generator::tokenize(file->package(), ".");
+ std::vector<grpc::string> parts = file->package_parts();
for (auto part = parts.begin(); part != parts.end(); part++) {
vars["part"] = *part;
- printer.Print(vars, "namespace $part$ {\n");
+ printer->Print(vars, "namespace $part$ {\n");
}
}
- printer.Print(vars, "\n");
+ printer->Print(vars, "\n");
}
return output;
}
-void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::MethodDescriptor *method,
+void PrintSourceClientMethod(Printer *printer,
+ const Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
- (*vars)["Request"] =
- grpc_cpp_generator::ClassName(method->input_type(), true);
- (*vars)["Response"] =
- grpc_cpp_generator::ClassName(method->output_type(), true);
- if (NoStreaming(method)) {
+ (*vars)["Request"] = method->input_type_name();
+ (*vars)["Response"] = method->output_type_name();
+ if (method->NoStreaming()) {
printer->Print(*vars,
"::grpc::Status $ns$$Service$::Stub::$Method$("
"::grpc::ClientContext* context, "
@@ -951,7 +907,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"rpcmethod_$Method$_, "
"context, request);\n"
"}\n\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(*vars,
"::grpc::ClientWriter< $Request$>* "
"$ns$$Service$::Stub::$Method$Raw("
@@ -973,7 +929,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"rpcmethod_$Method$_, "
"context, response, tag);\n"
"}\n\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(
*vars,
"::grpc::ClientReader< $Response$>* "
@@ -996,7 +952,7 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
"rpcmethod_$Method$_, "
"context, request, tag);\n"
"}\n\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(
*vars,
"::grpc::ClientReaderWriter< $Request$, $Response$>* "
@@ -1023,15 +979,13 @@ void PrintSourceClientMethod(grpc::protobuf::io::Printer *printer,
}
}
-void PrintSourceServerMethod(grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::MethodDescriptor *method,
+void PrintSourceServerMethod(Printer *printer,
+ const Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
- (*vars)["Request"] =
- grpc_cpp_generator::ClassName(method->input_type(), true);
- (*vars)["Response"] =
- grpc_cpp_generator::ClassName(method->output_type(), true);
- if (NoStreaming(method)) {
+ (*vars)["Request"] = method->input_type_name();
+ (*vars)["Response"] = method->output_type_name();
+ if (method->NoStreaming()) {
printer->Print(*vars,
"::grpc::Status $ns$$Service$::Service::$Method$("
"::grpc::ServerContext* context, "
@@ -1043,7 +997,7 @@ void PrintSourceServerMethod(grpc::protobuf::io::Printer *printer,
" return ::grpc::Status("
"::grpc::StatusCode::UNIMPLEMENTED, \"\");\n");
printer->Print("}\n\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(*vars,
"::grpc::Status $ns$$Service$::Service::$Method$("
"::grpc::ServerContext* context, "
@@ -1056,7 +1010,7 @@ void PrintSourceServerMethod(grpc::protobuf::io::Printer *printer,
" return ::grpc::Status("
"::grpc::StatusCode::UNIMPLEMENTED, \"\");\n");
printer->Print("}\n\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(*vars,
"::grpc::Status $ns$$Service$::Service::$Method$("
"::grpc::ServerContext* context, "
@@ -1069,7 +1023,7 @@ void PrintSourceServerMethod(grpc::protobuf::io::Printer *printer,
" return ::grpc::Status("
"::grpc::StatusCode::UNIMPLEMENTED, \"\");\n");
printer->Print("}\n\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(*vars,
"::grpc::Status $ns$$Service$::Service::$Method$("
"::grpc::ServerContext* context, "
@@ -1084,15 +1038,15 @@ void PrintSourceServerMethod(grpc::protobuf::io::Printer *printer,
}
}
-void PrintSourceService(grpc::protobuf::io::Printer *printer,
- const grpc::protobuf::ServiceDescriptor *service,
+void PrintSourceService(Printer *printer,
+ const Service *service,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Service"] = service->name();
printer->Print(*vars,
"static const char* $prefix$$Service$_method_names[] = {\n");
for (int i = 0; i < service->method_count(); ++i) {
- (*vars)["Method"] = service->method(i)->name();
+ (*vars)["Method"] = service->method(i).get()->name();
printer->Print(*vars, " \"/$Package$$Service$/$Method$\",\n");
}
printer->Print(*vars, "};\n\n");
@@ -1111,14 +1065,14 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
printer->Indent();
printer->Print(": channel_(channel)");
for (int i = 0; i < service->method_count(); ++i) {
- const grpc::protobuf::MethodDescriptor *method = service->method(i);
+ auto method = service->method(i);
(*vars)["Method"] = method->name();
(*vars)["Idx"] = as_string(i);
- if (NoStreaming(method)) {
+ if (method->NoStreaming()) {
(*vars)["StreamingType"] = "NORMAL_RPC";
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
(*vars)["StreamingType"] = "CLIENT_STREAMING";
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
(*vars)["StreamingType"] = "SERVER_STREAMING";
} else {
(*vars)["StreamingType"] = "BIDI_STREAMING";
@@ -1135,21 +1089,19 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
for (int i = 0; i < service->method_count(); ++i) {
(*vars)["Idx"] = as_string(i);
- PrintSourceClientMethod(printer, service->method(i), vars);
+ PrintSourceClientMethod(printer, service->method(i).get(), vars);
}
printer->Print(*vars, "$ns$$Service$::Service::Service() {\n");
printer->Indent();
printer->Print(*vars, "(void)$prefix$$Service$_method_names;\n");
for (int i = 0; i < service->method_count(); ++i) {
- const grpc::protobuf::MethodDescriptor *method = service->method(i);
+ auto method = service->method(i);
(*vars)["Idx"] = as_string(i);
(*vars)["Method"] = method->name();
- (*vars)["Request"] =
- grpc_cpp_generator::ClassName(method->input_type(), true);
- (*vars)["Response"] =
- grpc_cpp_generator::ClassName(method->output_type(), true);
- if (NoStreaming(method)) {
+ (*vars)["Request"] = method->input_type_name();
+ (*vars)["Response"] = method->output_type_name();
+ if (method->NoStreaming()) {
printer->Print(
*vars,
"AddMethod(new ::grpc::RpcServiceMethod(\n"
@@ -1159,7 +1111,7 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
"$Request$, "
"$Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
- } else if (ClientOnlyStreaming(method)) {
+ } else if (method->ClientOnlyStreaming()) {
printer->Print(
*vars,
"AddMethod(new ::grpc::RpcServiceMethod(\n"
@@ -1168,7 +1120,7 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
" new ::grpc::ClientStreamingHandler< "
"$ns$$Service$::Service, $Request$, $Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
- } else if (ServerOnlyStreaming(method)) {
+ } else if (method->ServerOnlyStreaming()) {
printer->Print(
*vars,
"AddMethod(new ::grpc::RpcServiceMethod(\n"
@@ -1177,7 +1129,7 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
" new ::grpc::ServerStreamingHandler< "
"$ns$$Service$::Service, $Request$, $Response$>(\n"
" std::mem_fn(&$ns$$Service$::Service::$Method$), this)));\n");
- } else if (BidiStreaming(method)) {
+ } else if (method->BidiStreaming()) {
printer->Print(
*vars,
"AddMethod(new ::grpc::RpcServiceMethod(\n"
@@ -1195,17 +1147,16 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer,
"}\n\n");
for (int i = 0; i < service->method_count(); ++i) {
(*vars)["Idx"] = as_string(i);
- PrintSourceServerMethod(printer, service->method(i), vars);
+ PrintSourceServerMethod(printer, service->method(i).get(), vars);
}
}
-grpc::string GetSourceServices(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetSourceServices(File *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
- grpc::protobuf::io::StringOutputStream output_stream(&output);
- grpc::protobuf::io::Printer printer(&output_stream, '$');
+ auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
// Package string is empty or ends with a dot. It is used to fully qualify
// method names.
@@ -1222,20 +1173,19 @@ grpc::string GetSourceServices(const grpc::protobuf::FileDescriptor *file,
}
for (int i = 0; i < file->service_count(); ++i) {
- PrintSourceService(&printer, file->service(i), &vars);
- printer.Print("\n");
+ PrintSourceService(printer.get(), file->service(i).get(), &vars);
+ printer->Print("\n");
}
}
return output;
}
-grpc::string GetSourceEpilogue(const grpc::protobuf::FileDescriptor *file,
+grpc::string GetSourceEpilogue(File *file,
const Parameters &params) {
grpc::string temp;
if (!file->package().empty()) {
- std::vector<grpc::string> parts =
- grpc_generator::tokenize(file->package(), ".");
+ std::vector<grpc::string> parts = file->package_parts();
for (auto part = parts.begin(); part != parts.end(); part++) {
temp.append("} // namespace ");
diff --git a/src/compiler/cpp_generator.h b/src/compiler/cpp_generator.h
index 03621c8794..99a60a2eae 100644
--- a/src/compiler/cpp_generator.h
+++ b/src/compiler/cpp_generator.h
@@ -34,7 +34,23 @@
#ifndef GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
#define GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H
-#include "src/compiler/config.h"
+// cpp_generator.h/.cc do not directly depend on GRPC/ProtoBuf, such that they
+// can be used to generate code for other serialization systems, such as
+// FlatBuffers.
+
+#include <memory>
+#include <vector>
+
+#ifndef GRPC_CUSTOM_STRING
+#include <string>
+#define GRPC_CUSTOM_STRING std::string
+#endif
+
+namespace grpc {
+
+typedef GRPC_CUSTOM_STRING string;
+
+} // namespace grpc
namespace grpc_cpp_generator {
@@ -48,37 +64,80 @@ struct Parameters {
grpc::string grpc_search_path;
};
+// An abstract interface representing a method.
+struct Method {
+ virtual ~Method() {}
+
+ virtual grpc::string name() const = 0;
+
+ virtual grpc::string input_type_name() const = 0;
+ virtual grpc::string output_type_name() const = 0;
+
+ virtual bool NoStreaming() const = 0;
+ virtual bool ClientOnlyStreaming() const = 0;
+ virtual bool ServerOnlyStreaming() const = 0;
+ virtual bool BidiStreaming() const = 0;
+};
+
+// An abstract interface representing a service.
+struct Service {
+ virtual ~Service() {}
+
+ virtual grpc::string name() const = 0;
+
+ virtual int method_count() const = 0;
+ virtual std::unique_ptr<const Method> method(int i) const = 0;
+};
+
+struct Printer {
+ virtual ~Printer() {}
+
+ virtual void Print(const std::map<grpc::string, grpc::string> &vars,
+ const char *template_string) = 0;
+ virtual void Print(const char *string) = 0;
+ virtual void Indent() = 0;
+ virtual void Outdent() = 0;
+};
+
+// An interface that allows the source generated to be output using various
+// libraries/idls/serializers.
+struct File {
+ virtual ~File() {}
+
+ virtual grpc::string filename() const = 0;
+ virtual grpc::string filename_without_ext() const = 0;
+ virtual grpc::string package() const = 0;
+ virtual std::vector<grpc::string> package_parts() const = 0;
+
+ virtual int service_count() const = 0;
+ virtual std::unique_ptr<const Service> service(int i) const = 0;
+
+ virtual std::unique_ptr<Printer> CreatePrinter(grpc::string *str) const = 0;
+};
+
// Return the prologue of the generated header file.
-grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params);
+grpc::string GetHeaderPrologue(File *file, const Parameters &params);
// Return the includes needed for generated header file.
-grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params);
+grpc::string GetHeaderIncludes(File *file, const Parameters &params);
// Return the includes needed for generated source file.
-grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params);
+grpc::string GetSourceIncludes(File *file, const Parameters &params);
// Return the epilogue of the generated header file.
-grpc::string GetHeaderEpilogue(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params);
+grpc::string GetHeaderEpilogue(File *file, const Parameters &params);
// Return the prologue of the generated source file.
-grpc::string GetSourcePrologue(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params);
+grpc::string GetSourcePrologue(File *file, const Parameters &params);
// Return the services for generated header file.
-grpc::string GetHeaderServices(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params);
+grpc::string GetHeaderServices(File *file, const Parameters &params);
// Return the services for generated source file.
-grpc::string GetSourceServices(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params);
+grpc::string GetSourceServices(File *file, const Parameters &params);
// Return the epilogue of the generated source file.
-grpc::string GetSourceEpilogue(const grpc::protobuf::FileDescriptor *file,
- const Parameters &params);
+grpc::string GetSourceEpilogue(File *file, const Parameters &params);
} // namespace grpc_cpp_generator
diff --git a/src/compiler/cpp_plugin.cc b/src/compiler/cpp_plugin.cc
index 92a9ba7549..f703c6453d 100644
--- a/src/compiler/cpp_plugin.cc
+++ b/src/compiler/cpp_plugin.cc
@@ -41,6 +41,105 @@
#include "src/compiler/cpp_generator.h"
#include "src/compiler/cpp_generator_helpers.h"
+class ProtoBufMethod : public grpc_cpp_generator::Method {
+ public:
+ ProtoBufMethod(const grpc::protobuf::MethodDescriptor *method)
+ : method_(method) {}
+
+ grpc::string name() const { return method_->name(); }
+
+ grpc::string input_type_name() const {
+ return grpc_cpp_generator::ClassName(method_->input_type(), true);
+ }
+ grpc::string output_type_name() const {
+ return grpc_cpp_generator::ClassName(method_->output_type(), true);
+ }
+
+ bool NoStreaming() const {
+ return !method_->client_streaming() && !method_->server_streaming();
+ }
+
+ bool ClientOnlyStreaming() const {
+ return method_->client_streaming() && !method_->server_streaming();
+ }
+
+ bool ServerOnlyStreaming() const {
+ return !method_->client_streaming() && method_->server_streaming();
+ }
+
+ bool BidiStreaming() const {
+ return method_->client_streaming() && method_->server_streaming();
+ }
+
+ private:
+ const grpc::protobuf::MethodDescriptor *method_;
+};
+
+class ProtoBufService : public grpc_cpp_generator::Service {
+ public:
+ ProtoBufService(const grpc::protobuf::ServiceDescriptor *service)
+ : service_(service) {}
+
+ grpc::string name() const { return service_->name(); }
+
+ int method_count() const { return service_->method_count(); };
+ std::unique_ptr<const grpc_cpp_generator::Method> method(int i) const {
+ return std::unique_ptr<const grpc_cpp_generator::Method>(
+ new ProtoBufMethod(service_->method(i)));
+ };
+
+ private:
+ const grpc::protobuf::ServiceDescriptor *service_;
+};
+
+class ProtoBufPrinter : public grpc_cpp_generator::Printer {
+ public:
+ ProtoBufPrinter(grpc::string *str)
+ : output_stream_(str), printer_(&output_stream_, '$') {}
+
+ void Print(const std::map<grpc::string, grpc::string> &vars,
+ const char *string_template) {
+ printer_.Print(vars, string_template);
+ }
+
+ void Print(const char *string) { printer_.Print(string); }
+ void Indent() { printer_.Indent(); }
+ void Outdent() { printer_.Outdent(); }
+
+ private:
+ grpc::protobuf::io::StringOutputStream output_stream_;
+ grpc::protobuf::io::Printer printer_;
+};
+
+class ProtoBufFile : public grpc_cpp_generator::File {
+ public:
+ ProtoBufFile(const grpc::protobuf::FileDescriptor *file) : file_(file) {}
+
+ grpc::string filename() const { return file_->name(); }
+ grpc::string filename_without_ext() const {
+ return grpc_generator::StripProto(filename());
+ }
+
+ grpc::string package() const { return file_->package(); }
+ std::vector<grpc::string> package_parts() const {
+ return grpc_generator::tokenize(package(), ".");
+ }
+
+ int service_count() const { return file_->service_count(); };
+ std::unique_ptr<const grpc_cpp_generator::Service> service(int i) const {
+ return std::unique_ptr<const grpc_cpp_generator::Service> (
+ new ProtoBufService(file_->service(i)));
+ }
+
+ std::unique_ptr<grpc_cpp_generator::Printer> CreatePrinter(grpc::string *str) const {
+ return std::unique_ptr<grpc_cpp_generator::Printer>(
+ new ProtoBufPrinter(str));
+ }
+
+ private:
+ const grpc::protobuf::FileDescriptor *file_;
+};
+
class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
public:
CppGrpcGenerator() {}
@@ -61,6 +160,8 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
grpc_cpp_generator::Parameters generator_parameters;
generator_parameters.use_system_headers = true;
+ ProtoBufFile pbfile(file);
+
if (!parameter.empty()) {
std::vector<grpc::string> parameters_list =
grpc_generator::tokenize(parameter, ",");
@@ -92,10 +193,10 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
grpc::string file_name = grpc_generator::StripProto(file->name());
grpc::string header_code =
- grpc_cpp_generator::GetHeaderPrologue(file, generator_parameters) +
- grpc_cpp_generator::GetHeaderIncludes(file, generator_parameters) +
- grpc_cpp_generator::GetHeaderServices(file, generator_parameters) +
- grpc_cpp_generator::GetHeaderEpilogue(file, generator_parameters);
+ grpc_cpp_generator::GetHeaderPrologue(&pbfile, generator_parameters) +
+ grpc_cpp_generator::GetHeaderIncludes(&pbfile, generator_parameters) +
+ grpc_cpp_generator::GetHeaderServices(&pbfile, generator_parameters) +
+ grpc_cpp_generator::GetHeaderEpilogue(&pbfile, generator_parameters);
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> header_output(
context->Open(file_name + ".grpc.pb.h"));
grpc::protobuf::io::CodedOutputStream header_coded_out(
@@ -103,10 +204,10 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
header_coded_out.WriteRaw(header_code.data(), header_code.size());
grpc::string source_code =
- grpc_cpp_generator::GetSourcePrologue(file, generator_parameters) +
- grpc_cpp_generator::GetSourceIncludes(file, generator_parameters) +
- grpc_cpp_generator::GetSourceServices(file, generator_parameters) +
- grpc_cpp_generator::GetSourceEpilogue(file, generator_parameters);
+ grpc_cpp_generator::GetSourcePrologue(&pbfile, generator_parameters) +
+ grpc_cpp_generator::GetSourceIncludes(&pbfile, generator_parameters) +
+ grpc_cpp_generator::GetSourceServices(&pbfile, generator_parameters) +
+ grpc_cpp_generator::GetSourceEpilogue(&pbfile, generator_parameters);
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> source_output(
context->Open(file_name + ".grpc.pb.cc"));
grpc::protobuf::io::CodedOutputStream source_coded_out(
diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc
index 299137519f..5ac56ad289 100644
--- a/src/compiler/ruby_generator.cc
+++ b/src/compiler/ruby_generator.cc
@@ -55,11 +55,11 @@ namespace {
// Prints out the method using the ruby gRPC DSL.
void PrintMethod(const MethodDescriptor *method, const grpc::string &package,
Printer *out) {
- grpc::string input_type = RubyTypeOf(method->input_type()->name(), package);
+ grpc::string input_type = RubyTypeOf(method->input_type()->full_name(), package);
if (method->client_streaming()) {
input_type = "stream(" + input_type + ")";
}
- grpc::string output_type = RubyTypeOf(method->output_type()->name(), package);
+ grpc::string output_type = RubyTypeOf(method->output_type()->full_name(), package);
if (method->server_streaming()) {
output_type = "stream(" + output_type + ")";
}
diff --git a/src/compiler/ruby_generator_string-inl.h b/src/compiler/ruby_generator_string-inl.h
index 8da3a88da2..d1ad871c1a 100644
--- a/src/compiler/ruby_generator_string-inl.h
+++ b/src/compiler/ruby_generator_string-inl.h
@@ -115,6 +115,7 @@ inline grpc::string RubyTypeOf(const grpc::string &a_type,
return res;
} else {
std::vector<grpc::string> prefixes_and_type = Split(res, '.');
+ res.clear();
for (unsigned int i = 0; i < prefixes_and_type.size(); ++i) {
if (i != 0) {
res += "::"; // switch '.' to the ruby module delim
diff --git a/src/core/ext/census/grpc_plugin.c b/src/core/ext/census/grpc_plugin.c
index 0f15ecb2c2..e43ceafd0c 100644
--- a/src/core/ext/census/grpc_plugin.c
+++ b/src/core/ext/census/grpc_plugin.c
@@ -32,6 +32,7 @@
*/
#include <limits.h>
+#include <string.h>
#include <grpc/census.h>
@@ -39,13 +40,24 @@
#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/surface/channel_init.h"
+static bool is_census_enabled(const grpc_channel_args *a) {
+ size_t i;
+ if (a == NULL) return 0;
+ for (i = 0; i < a->num_args; i++) {
+ if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_CENSUS)) {
+ return a->args[i].value.integer != 0 && census_enabled();
+ }
+ }
+ return census_enabled();
+}
+
static bool maybe_add_census_filter(grpc_channel_stack_builder *builder,
- void *arg_must_be_null) {
+ void *arg) {
const grpc_channel_args *args =
grpc_channel_stack_builder_get_channel_arguments(builder);
- if (grpc_channel_args_is_census_enabled(args)) {
+ if (is_census_enabled(args)) {
return grpc_channel_stack_builder_prepend_filter(
- builder, &grpc_client_census_filter, NULL, NULL);
+ builder, (const grpc_channel_filter *)arg, NULL, NULL);
}
return true;
}
@@ -60,9 +72,11 @@ void census_grpc_plugin_init(void) {
}
}
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
- maybe_add_census_filter, NULL);
+ maybe_add_census_filter,
+ (void *)&grpc_client_census_filter);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
- maybe_add_census_filter, NULL);
+ maybe_add_census_filter,
+ (void *)&grpc_server_census_filter);
}
void census_grpc_plugin_shutdown(void) { census_shutdown(); }
diff --git a/src/core/ext/client_config/client_config_plugin.c b/src/core/ext/client_config/client_config_plugin.c
new file mode 100644
index 0000000000..5e31613420
--- /dev/null
+++ b/src/core/ext/client_config/client_config_plugin.c
@@ -0,0 +1,95 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <limits.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <grpc/support/alloc.h>
+
+#include "src/core/ext/client_config/client_channel.h"
+#include "src/core/ext/client_config/lb_policy_registry.h"
+#include "src/core/ext/client_config/resolver_registry.h"
+#include "src/core/ext/client_config/subchannel_index.h"
+#include "src/core/lib/surface/channel_init.h"
+
+#ifndef GRPC_DEFAULT_NAME_PREFIX
+#define GRPC_DEFAULT_NAME_PREFIX "dns:///"
+#endif
+
+static bool append_filter(grpc_channel_stack_builder *builder, void *arg) {
+ return grpc_channel_stack_builder_append_filter(
+ builder, (const grpc_channel_filter *)arg, NULL, NULL);
+}
+
+static bool set_default_host_if_unset(grpc_channel_stack_builder *builder,
+ void *unused) {
+ const grpc_channel_args *args =
+ grpc_channel_stack_builder_get_channel_arguments(builder);
+ for (size_t i = 0; i < args->num_args; i++) {
+ if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY) ||
+ 0 == strcmp(args->args[i].key, GRPC_SSL_TARGET_NAME_OVERRIDE_ARG)) {
+ return true;
+ }
+ }
+ char *default_authority = grpc_get_default_authority(
+ grpc_channel_stack_builder_get_target(builder));
+ if (default_authority != NULL) {
+ grpc_arg arg;
+ arg.type = GRPC_ARG_STRING;
+ arg.key = GRPC_ARG_DEFAULT_AUTHORITY;
+ arg.value.string = default_authority;
+ grpc_channel_args *new_args = grpc_channel_args_copy_and_add(args, &arg, 1);
+ grpc_channel_stack_builder_set_channel_arguments(builder, new_args);
+ gpr_free(default_authority);
+ grpc_channel_args_destroy(new_args);
+ }
+ return true;
+}
+
+void grpc_client_config_init(void) {
+ grpc_lb_policy_registry_init();
+ grpc_resolver_registry_init(GRPC_DEFAULT_NAME_PREFIX);
+ grpc_subchannel_index_init();
+ grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MIN,
+ set_default_host_if_unset, NULL);
+ grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, append_filter,
+ (void *)&grpc_client_channel_filter);
+}
+
+void grpc_client_config_shutdown(void) {
+ grpc_subchannel_index_shutdown();
+ grpc_channel_init_shutdown();
+ grpc_resolver_registry_shutdown();
+ grpc_lb_policy_registry_shutdown();
+}
diff --git a/src/core/ext/client_config/parse_address.c b/src/core/ext/client_config/parse_address.c
new file mode 100644
index 0000000000..8b4abe24a6
--- /dev/null
+++ b/src/core/ext/client_config/parse_address.c
@@ -0,0 +1,137 @@
+/*
+ *
+ * Copyright 2016, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "src/core/ext/client_config/parse_address.h"
+
+#include <stdio.h>
+#include <string.h>
+#ifdef GPR_HAVE_UNIX_SOCKET
+#include <sys/un.h>
+#endif
+
+#include <grpc/support/alloc.h>
+#include <grpc/support/host_port.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+#ifdef GPR_HAVE_UNIX_SOCKET
+int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
+ struct sockaddr_un *un = (struct sockaddr_un *)addr;
+
+ un->sun_family = AF_UNIX;
+ strcpy(un->sun_path, uri->path);
+ *len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
+
+ return 1;
+}
+#endif
+
+int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
+ const char *host_port = uri->path;
+ char *host;
+ char *port;
+ int port_num;
+ int result = 0;
+ struct sockaddr_in *in = (struct sockaddr_in *)addr;
+
+ if (*host_port == '/') ++host_port;
+ if (!gpr_split_host_port(host_port, &host, &port)) {
+ return 0;
+ }
+
+ memset(in, 0, sizeof(*in));
+ *len = sizeof(*in);
+ in->sin_family = AF_INET;
+ if (inet_pton(AF_INET, host, &in->sin_addr) == 0) {
+ gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host);
+ goto done;
+ }
+
+ if (port != NULL) {
+ if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 ||
+ port_num > 65535) {
+ gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port);
+ goto done;
+ }
+ in->sin_port = htons((uint16_t)port_num);
+ } else {
+ gpr_log(GPR_ERROR, "no port given for ipv4 scheme");
+ goto done;
+ }
+
+ result = 1;
+done:
+ gpr_free(host);
+ gpr_free(port);
+ return result;
+}
+
+int parse_ipv6(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
+ const char *host_port = uri->path;
+ char *host;
+ char *port;
+ int port_num;
+ int result = 0;
+ struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr;
+
+ if (*host_port == '/') ++host_port;
+ if (!gpr_split_host_port(host_port, &host, &port)) {
+ return 0;
+ }
+
+ memset(in6, 0, sizeof(*in6));
+ *len = sizeof(*in6);
+ in6->sin6_family = AF_INET6;
+ if (inet_pton(AF_INET6, host, &in6->sin6_addr) == 0) {
+ gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host);
+ goto done;
+ }
+
+ if (port != NULL) {
+ if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 ||
+ port_num > 65535) {
+ gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port);
+ goto done;
+ }
+ in6->sin6_port = htons((uint16_t)port_num);
+ } else {
+ gpr_log(GPR_ERROR, "no port given for ipv6 scheme");
+ goto done;
+ }
+
+ result = 1;
+done:
+ gpr_free(host);
+ gpr_free(port);
+ return result;
+}
diff --git a/src/core/ext/client_config/parse_address.h b/src/core/ext/client_config/parse_address.h
new file mode 100644
index 0000000000..74c86f4d93
--- /dev/null
+++ b/src/core/ext/client_config/parse_address.h
@@ -0,0 +1,56 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef GRPC_CORE_EXT_CLIENT_CONFIG_PARSE_ADDRESS_H
+#define GRPC_CORE_EXT_CLIENT_CONFIG_PARSE_ADDRESS_H
+
+#include <stddef.h>
+
+#include "src/core/ext/client_config/uri_parser.h"
+#include "src/core/lib/iomgr/sockaddr.h"
+
+#ifdef GPR_HAVE_UNIX_SOCKET
+/** Populate \a addr and \a len from \a uri, whose path is expected to contain a
+ * unix socket path. Returns true upon success. */
+int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len);
+#endif
+
+/** Populate /a addr and \a len from \a uri, whose path is expected to contain a
+ * host:port pair. Returns true upon success. */
+int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len);
+
+/** Populate /a addr and \a len from \a uri, whose path is expected to contain a
+ * host:port pair. Returns true upon success. */
+int parse_ipv6(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len);
+
+#endif /* GRPC_CORE_EXT_CLIENT_CONFIG_PARSE_ADDRESS_H */
diff --git a/src/core/ext/client_config/subchannel.c b/src/core/ext/client_config/subchannel.c
index 20cf245a5b..125a291f21 100644
--- a/src/core/ext/client_config/subchannel.c
+++ b/src/core/ext/client_config/subchannel.c
@@ -546,9 +546,20 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
state_watcher *sw_subchannel;
/* construct channel stack */
- con = grpc_channel_init_create_stack(
- exec_ctx, GRPC_CLIENT_SUBCHANNEL, 0, c->connecting_result.channel_args, 1,
- connection_destroy, NULL, c->connecting_result.transport);
+ grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
+ grpc_channel_stack_builder_set_channel_arguments(
+ builder, c->connecting_result.channel_args);
+ grpc_channel_stack_builder_set_transport(builder,
+ c->connecting_result.transport);
+
+ if (grpc_channel_init_create_stack(exec_ctx, builder,
+ GRPC_CLIENT_SUBCHANNEL)) {
+ con = grpc_channel_stack_builder_finish(exec_ctx, builder, 0, 1,
+ connection_destroy, NULL);
+ } else {
+ grpc_channel_stack_builder_destroy(builder);
+ abort(); /* TODO(ctiller): what to do here (previously we just crashed) */
+ }
stk = CHANNEL_STACK_FROM_CONNECTION(con);
memset(&c->connecting_result, 0, sizeof(c->connecting_result));
@@ -576,7 +587,8 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(gpr_atm_rel_cas(&c->connected_subchannel, 0, (gpr_atm)con));
c->connecting = 0;
- /* setup subchannel watching connected subchannel for changes; subchannel ref
+ /* setup subchannel watching connected subchannel for changes; subchannel
+ ref
for connecting is donated
to the state watcher */
GRPC_SUBCHANNEL_WEAK_REF(c, "state_watcher");
diff --git a/src/core/ext/lb_policy/pick_first/pick_first.c b/src/core/ext/lb_policy/pick_first/pick_first.c
index 5926f9d70b..0d215cd196 100644
--- a/src/core/ext/lb_policy/pick_first/pick_first.c
+++ b/src/core/ext/lb_policy/pick_first/pick_first.c
@@ -109,7 +109,7 @@ static void pf_shutdown(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
if (selected != NULL) {
grpc_connected_subchannel_notify_on_state_change(
exec_ctx, selected, NULL, NULL, &p->connectivity_changed);
- } else {
+ } else if (p->num_subchannels > 0) {
grpc_subchannel_notify_on_state_change(
exec_ctx, p->subchannels[p->checking_subchannel], NULL, NULL,
&p->connectivity_changed);
diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
index 1f14b40e18..a4fa9acf22 100644
--- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
+++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
@@ -41,6 +41,7 @@
#include <grpc/support/string_util.h>
#include "src/core/ext/client_config/lb_policy_registry.h"
+#include "src/core/ext/client_config/parse_address.h"
#include "src/core/ext/client_config/resolver_registry.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/unix_sockets_posix.h"
@@ -162,87 +163,12 @@ static char *ipv6_get_default_authority(grpc_resolver_factory *factory,
return ip_get_default_authority(uri);
}
-static int parse_ipv4(grpc_uri *uri, struct sockaddr_storage *addr,
- size_t *len) {
- const char *host_port = uri->path;
- char *host;
- char *port;
- int port_num;
- int result = 0;
- struct sockaddr_in *in = (struct sockaddr_in *)addr;
-
- if (*host_port == '/') ++host_port;
- if (!gpr_split_host_port(host_port, &host, &port)) {
- return 0;
- }
-
- memset(in, 0, sizeof(*in));
- *len = sizeof(*in);
- in->sin_family = AF_INET;
- if (inet_pton(AF_INET, host, &in->sin_addr) == 0) {
- gpr_log(GPR_ERROR, "invalid ipv4 address: '%s'", host);
- goto done;
- }
-
- if (port != NULL) {
- if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 ||
- port_num > 65535) {
- gpr_log(GPR_ERROR, "invalid ipv4 port: '%s'", port);
- goto done;
- }
- in->sin_port = htons((uint16_t)port_num);
- } else {
- gpr_log(GPR_ERROR, "no port given for ipv4 scheme");
- goto done;
- }
-
- result = 1;
-done:
- gpr_free(host);
- gpr_free(port);
- return result;
-}
-
-static int parse_ipv6(grpc_uri *uri, struct sockaddr_storage *addr,
- size_t *len) {
- const char *host_port = uri->path;
- char *host;
- char *port;
- int port_num;
- int result = 0;
- struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr;
-
- if (*host_port == '/') ++host_port;
- if (!gpr_split_host_port(host_port, &host, &port)) {
- return 0;
- }
-
- memset(in6, 0, sizeof(*in6));
- *len = sizeof(*in6);
- in6->sin6_family = AF_INET6;
- if (inet_pton(AF_INET6, host, &in6->sin6_addr) == 0) {
- gpr_log(GPR_ERROR, "invalid ipv6 address: '%s'", host);
- goto done;
- }
-
- if (port != NULL) {
- if (sscanf(port, "%d", &port_num) != 1 || port_num < 0 ||
- port_num > 65535) {
- gpr_log(GPR_ERROR, "invalid ipv6 port: '%s'", port);
- goto done;
- }
- in6->sin6_port = htons((uint16_t)port_num);
- } else {
- gpr_log(GPR_ERROR, "no port given for ipv6 scheme");
- goto done;
- }
-
- result = 1;
-done:
- gpr_free(host);
- gpr_free(port);
- return result;
+#ifdef GPR_HAVE_UNIX_SOCKET
+char *unix_get_default_authority(grpc_resolver_factory *factory,
+ grpc_uri *uri) {
+ return gpr_strdup("localhost");
}
+#endif
static void do_nothing(void *ignored) {}
@@ -334,23 +260,22 @@ static void sockaddr_factory_ref(grpc_resolver_factory *factory) {}
static void sockaddr_factory_unref(grpc_resolver_factory *factory) {}
-#define DECL_FACTORY(name, prefix) \
+#define DECL_FACTORY(name) \
static grpc_resolver *name##_factory_create_resolver( \
grpc_resolver_factory *factory, grpc_resolver_args *args) { \
- return sockaddr_create(args, "pick_first", prefix##parse_##name); \
+ return sockaddr_create(args, "pick_first", parse_##name); \
} \
static const grpc_resolver_factory_vtable name##_factory_vtable = { \
sockaddr_factory_ref, sockaddr_factory_unref, \
- name##_factory_create_resolver, prefix##name##_get_default_authority, \
- #name}; \
+ name##_factory_create_resolver, name##_get_default_authority, #name}; \
static grpc_resolver_factory name##_resolver_factory = { \
&name##_factory_vtable}
#ifdef GPR_HAVE_UNIX_SOCKET
-DECL_FACTORY(unix, grpc_);
+DECL_FACTORY(unix);
#endif
-DECL_FACTORY(ipv4, );
-DECL_FACTORY(ipv6, );
+DECL_FACTORY(ipv4);
+DECL_FACTORY(ipv6);
void grpc_resolver_sockaddr_init(void) {
grpc_register_resolver_type(&ipv4_resolver_factory);
diff --git a/src/core/ext/transport/chttp2/transport/alpn.c b/src/core/ext/transport/chttp2/alpn/alpn.c
index 4271d08ded..48b0217265 100644
--- a/src/core/ext/transport/chttp2/transport/alpn.c
+++ b/src/core/ext/transport/chttp2/alpn/alpn.c
@@ -31,7 +31,7 @@
*
*/
-#include "src/core/ext/transport/chttp2/transport/alpn.h"
+#include "src/core/ext/transport/chttp2/alpn/alpn.h"
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
diff --git a/src/core/ext/transport/chttp2/transport/alpn.h b/src/core/ext/transport/chttp2/alpn/alpn.h
index 08a6f039f4..1316770f11 100644
--- a/src/core/ext/transport/chttp2/transport/alpn.h
+++ b/src/core/ext/transport/chttp2/alpn/alpn.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_ALPN_H
-#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_ALPN_H
+#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H
+#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H
#include <string.h>
@@ -46,4 +46,4 @@ size_t grpc_chttp2_num_alpn_versions(void);
* grpc_chttp2_num_alpn_versions()) */
const char *grpc_chttp2_get_alpn_version_index(size_t i);
-#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_ALPN_H */
+#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */
diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.c
index 5484438f0a..0ed115793b 100644
--- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c
+++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.c
@@ -40,7 +40,6 @@
#include <grpc/support/slice.h>
#include <grpc/support/slice_buffer.h>
-#include "src/core/ext/census/grpc_filter.h"
#include "src/core/ext/client_config/client_channel.h"
#include "src/core/ext/client_config/resolver_registry.h"
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.c b/src/core/ext/transport/chttp2/transport/bin_encoder.c
index 71c634e39b..1b43c28be1 100644
--- a/src/core/ext/transport/chttp2/transport/bin_encoder.c
+++ b/src/core/ext/transport/chttp2/transport/bin_encoder.c
@@ -175,7 +175,7 @@ static void enc_add1(huff_out *out, uint8_t a) {
enc_flush_some(out);
}
-gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
+gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input) {
size_t input_length = GPR_SLICE_LENGTH(input);
size_t input_triplets = input_length / 3;
size_t tail_case = input_length % 3;
@@ -194,9 +194,13 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
/* encode full triplets */
for (i = 0; i < input_triplets; i++) {
- enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4) | (in[1] >> 4));
- enc_add2(&out, (uint8_t)((in[1] & 0xf) << 2) | (in[2] >> 6),
- (uint8_t)(in[2] & 0x3f));
+ const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4);
+ const uint8_t high_to_low = in[1] >> 4;
+ enc_add2(&out, in[0] >> 2, low_to_high | high_to_low);
+
+ const uint8_t a = (uint8_t)((in[1] & 0xf) << 2);
+ const uint8_t b = (in[2] >> 6);
+ enc_add2(&out, a | b, in[2] & 0x3f);
in += 3;
}
@@ -208,12 +212,14 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
enc_add2(&out, in[0] >> 2, (uint8_t)((in[0] & 0x3) << 4));
in += 1;
break;
- case 2:
- enc_add2(&out, in[0] >> 2,
- (uint8_t)((in[0] & 0x3) << 4) | (uint8_t)(in[1] >> 4));
+ case 2: {
+ const uint8_t low_to_high = (uint8_t)((in[0] & 0x3) << 4);
+ const uint8_t high_to_low = in[1] >> 4;
+ enc_add2(&out, in[0] >> 2, low_to_high | high_to_low);
enc_add1(&out, (uint8_t)((in[1] & 0xf) << 2));
in += 2;
break;
+ }
}
if (out.temp_length) {
diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h
index 660f114ebc..61ebbafa9a 100644
--- a/src/core/ext/transport/chttp2/transport/bin_encoder.h
+++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h
@@ -49,6 +49,6 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input);
gpr_slice y = grpc_chttp2_huffman_compress(x);
gpr_slice_unref(x);
return y; */
-gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input);
+gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.c b/src/core/ext/transport/chttp2/transport/chttp2_plugin.c
new file mode 100644
index 0000000000..bd87253ed3
--- /dev/null
+++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.c
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
+#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
+#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/transport/metadata.h"
+
+void grpc_chttp2_plugin_init(void) {
+ grpc_chttp2_base64_encode_and_huffman_compress =
+ grpc_chttp2_base64_encode_and_huffman_compress_impl;
+ grpc_register_tracer("http", &grpc_http_trace);
+ grpc_register_tracer("flowctl", &grpc_flowctl_trace);
+}
+
+void grpc_chttp2_plugin_shutdown(void) {}
diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
index 62f0c53e0d..01507f5ca6 100644
--- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c
+++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c
@@ -1147,16 +1147,22 @@ static void cancel_from_api(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport_global *transport_global,
grpc_chttp2_stream_global *stream_global,
grpc_status_code status) {
- if (stream_global->id != 0) {
- gpr_slice_buffer_add(
- &transport_global->qbuf,
- grpc_chttp2_rst_stream_create(
- stream_global->id,
- (uint32_t)grpc_chttp2_grpc_status_to_http2_error(status),
- &stream_global->stats.outgoing));
+ if (!stream_global->read_closed || !stream_global->write_closed) {
+ if (stream_global->id != 0) {
+ gpr_slice_buffer_add(
+ &transport_global->qbuf,
+ grpc_chttp2_rst_stream_create(
+ stream_global->id,
+ (uint32_t)grpc_chttp2_grpc_status_to_http2_error(status),
+ &stream_global->stats.outgoing));
+ }
+ grpc_chttp2_fake_status(exec_ctx, transport_global, stream_global, status,
+ NULL);
+ }
+ if (status != GRPC_STATUS_OK && !stream_global->seen_error) {
+ stream_global->seen_error = 1;
+ grpc_chttp2_list_add_check_read_ops(transport_global, stream_global);
}
- grpc_chttp2_fake_status(exec_ctx, transport_global, stream_global, status,
- NULL);
grpc_chttp2_mark_stream_closed(exec_ctx, transport_global, stream_global, 1,
1);
}
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.c b/src/core/ext/transport/chttp2/transport/frame_data.c
index 9c301d1608..3a6d80e0a3 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.c
+++ b/src/core/ext/transport/chttp2/transport/frame_data.c
@@ -159,7 +159,10 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
}
switch (p->state) {
- fh_0:
+ case GRPC_CHTTP2_DATA_ERROR:
+ p->state = GRPC_CHTTP2_DATA_ERROR;
+ return GRPC_CHTTP2_STREAM_ERROR;
+ fh_0:
case GRPC_CHTTP2_DATA_FH_0:
stream_parsing->stats.incoming.framing_bytes++;
p->frame_type = *cur;
@@ -172,6 +175,7 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
break;
default:
gpr_log(GPR_ERROR, "Bad GRPC frame type 0x%02x", p->frame_type);
+ p->state = GRPC_CHTTP2_DATA_ERROR;
return GRPC_CHTTP2_STREAM_ERROR;
}
if (++cur == end) {
@@ -218,13 +222,11 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
message_flags, &p->incoming_frames);
/* fallthrough */
case GRPC_CHTTP2_DATA_FRAME:
+ grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
+ stream_parsing);
if (cur == end) {
- grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
- stream_parsing);
return GRPC_CHTTP2_PARSE_OK;
}
- grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
- stream_parsing);
uint32_t remaining = (uint32_t)(end - cur);
if (remaining == p->frame_size) {
stream_parsing->stats.incoming.data_bytes += p->frame_size;
diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h
index 2ff32963d6..af71f483a2 100644
--- a/src/core/ext/transport/chttp2/transport/frame_data.h
+++ b/src/core/ext/transport/chttp2/transport/frame_data.h
@@ -49,7 +49,8 @@ typedef enum {
GRPC_CHTTP2_DATA_FH_2,
GRPC_CHTTP2_DATA_FH_3,
GRPC_CHTTP2_DATA_FH_4,
- GRPC_CHTTP2_DATA_FRAME
+ GRPC_CHTTP2_DATA_FRAME,
+ GRPC_CHTTP2_DATA_ERROR
} grpc_chttp2_stream_state;
typedef struct grpc_chttp2_incoming_byte_stream
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c
index 807cb5c8f4..555027c866 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c
@@ -49,6 +49,7 @@
#include "src/core/ext/transport/chttp2/transport/hpack_table.h"
#include "src/core/ext/transport/chttp2/transport/timeout_encoding.h"
#include "src/core/ext/transport/chttp2/transport/varint.h"
+#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/static_metadata.h"
#define HASH_FRAGMENT_1(x) ((x)&255)
@@ -182,8 +183,7 @@ static void add_elem(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem) {
uint32_t key_hash = elem->key->hash;
uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, elem->value->hash);
uint32_t new_index = c->tail_remote_index + c->table_elems + 1;
- size_t elem_size = 32 + GPR_SLICE_LENGTH(elem->key->slice) +
- GPR_SLICE_LENGTH(elem->value->slice);
+ size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
GPR_ASSERT(elem_size < 65536);
@@ -399,8 +399,7 @@ static void hpack_enc(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem,
}
/* should this elem be in the table? */
- decoder_space_usage = 32 + GPR_SLICE_LENGTH(elem->key->slice) +
- GPR_SLICE_LENGTH(elem->value->slice);
+ decoder_space_usage = grpc_mdelem_get_size_in_hpack_table(elem);
should_add_elem = decoder_space_usage < MAX_DECODER_SPACE_USAGE &&
c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >=
c->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.c
index a36d2fc382..93c3e6d8b4 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.c
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.c
@@ -638,6 +638,10 @@ static int on_hdr(grpc_chttp2_hpack_parser *p, grpc_mdelem *md,
return 0;
}
}
+ if (p->on_header == NULL) {
+ grpc_mdelem_unref(md);
+ return 0;
+ }
p->on_header(p->on_header_user_data, md);
return 1;
}
@@ -1382,12 +1386,8 @@ static int parse_value_string_with_literal_key(grpc_chttp2_hpack_parser *p,
/* PUBLIC INTERFACE */
-static void on_header_not_set(void *user_data, grpc_mdelem *md) {
- GPR_UNREACHABLE_CODE(return );
-}
-
void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser *p) {
- p->on_header = on_header_not_set;
+ p->on_header = NULL;
p->on_header_user_data = NULL;
p->state = parse_begin;
p->key.str = NULL;
@@ -1455,7 +1455,7 @@ grpc_chttp2_parse_error grpc_chttp2_header_parser_parse(
stream_parsing->received_close = 1;
}
}
- parser->on_header = on_header_not_set;
+ parser->on_header = NULL;
parser->on_header_user_data = NULL;
parser->is_boundary = 0xde;
parser->is_eof = 0xde;
diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c
index c754c6005e..e827a43f7a 100644
--- a/src/core/ext/transport/chttp2/transport/parsing.c
+++ b/src/core/ext/transport/chttp2/transport/parsing.c
@@ -112,7 +112,7 @@ void grpc_chttp2_publish_reads(
GOAWAY last-grpc_chttp2_stream-id=0 in this case. */
if (!transport_parsing->is_client) {
transport_global->last_incoming_stream_id =
- transport_parsing->incoming_stream_id;
+ transport_parsing->last_incoming_stream_id;
}
/* update global settings */
@@ -371,7 +371,9 @@ int grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
if (!init_frame_parser(exec_ctx, transport_parsing)) {
return 0;
}
- if (transport_parsing->incoming_stream_id) {
+ if (transport_parsing->incoming_stream_id != 0 &&
+ transport_parsing->incoming_stream_id >
+ transport_parsing->last_incoming_stream_id) {
transport_parsing->last_incoming_stream_id =
transport_parsing->incoming_stream_id;
}
diff --git a/src/core/lib/channel/channel_args.c b/src/core/lib/channel/channel_args.c
index b7393b988d..28d2d78d00 100644
--- a/src/core/lib/channel/channel_args.c
+++ b/src/core/lib/channel/channel_args.c
@@ -35,7 +35,6 @@
#include <grpc/grpc.h>
#include "src/core/lib/support/string.h"
-#include <grpc/census.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -165,17 +164,6 @@ void grpc_channel_args_destroy(grpc_channel_args *a) {
gpr_free(a);
}
-int grpc_channel_args_is_census_enabled(const grpc_channel_args *a) {
- size_t i;
- if (a == NULL) return 0;
- for (i = 0; i < a->num_args; i++) {
- if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_CENSUS)) {
- return a->args[i].value.integer != 0 && census_enabled();
- }
- }
- return census_enabled();
-}
-
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
const grpc_channel_args *a) {
size_t i;
diff --git a/src/core/lib/channel/channel_stack_builder.c b/src/core/lib/channel/channel_stack_builder.c
index 1ce0c4e07f..a8646c9565 100644
--- a/src/core/lib/channel/channel_stack_builder.c
+++ b/src/core/lib/channel/channel_stack_builder.c
@@ -36,6 +36,7 @@
#include <string.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
int grpc_trace_channel_stack_builder = 0;
@@ -52,8 +53,9 @@ struct grpc_channel_stack_builder {
filter_node begin;
filter_node end;
// various set/get-able parameters
- const grpc_channel_args *args;
+ grpc_channel_args *args;
grpc_transport *transport;
+ char *target;
const char *name;
};
@@ -76,6 +78,17 @@ grpc_channel_stack_builder *grpc_channel_stack_builder_create(void) {
return b;
}
+void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder *b,
+ const char *target) {
+ gpr_free(b->target);
+ b->target = gpr_strdup(target);
+}
+
+const char *grpc_channel_stack_builder_get_target(
+ grpc_channel_stack_builder *b) {
+ return b->target;
+}
+
static grpc_channel_stack_builder_iterator *create_iterator_at_filter_node(
grpc_channel_stack_builder *builder, filter_node *node) {
grpc_channel_stack_builder_iterator *it = gpr_malloc(sizeof(*it));
@@ -126,8 +139,10 @@ void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder *builder,
void grpc_channel_stack_builder_set_channel_arguments(
grpc_channel_stack_builder *builder, const grpc_channel_args *args) {
- GPR_ASSERT(builder->args == NULL);
- builder->args = args;
+ if (builder->args != NULL) {
+ grpc_channel_args_destroy(builder->args);
+ }
+ builder->args = grpc_channel_args_copy(args);
}
void grpc_channel_stack_builder_set_transport(
@@ -205,6 +220,10 @@ void grpc_channel_stack_builder_destroy(grpc_channel_stack_builder *builder) {
gpr_free(p);
p = next;
}
+ if (builder->args != NULL) {
+ grpc_channel_args_destroy(builder->args);
+ }
+ gpr_free(builder->target);
gpr_free(builder);
}
diff --git a/src/core/lib/channel/channel_stack_builder.h b/src/core/lib/channel/channel_stack_builder.h
index 8532c4462a..0e6bfd9aa6 100644
--- a/src/core/lib/channel/channel_stack_builder.h
+++ b/src/core/lib/channel/channel_stack_builder.h
@@ -52,6 +52,13 @@ grpc_channel_stack_builder *grpc_channel_stack_builder_create(void);
void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder *builder,
const char *name);
+/// Set the target uri
+void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder *b,
+ const char *target);
+
+const char *grpc_channel_stack_builder_get_target(
+ grpc_channel_stack_builder *b);
+
/// Attach \a transport to the builder (does not take ownership)
void grpc_channel_stack_builder_set_transport(
grpc_channel_stack_builder *builder, grpc_transport *transport);
@@ -60,8 +67,7 @@ void grpc_channel_stack_builder_set_transport(
grpc_transport *grpc_channel_stack_builder_get_transport(
grpc_channel_stack_builder *builder);
-/// Set channel arguments: \a args must continue to exist until after
-/// grpc_channel_stack_builder_finish returns
+/// Set channel arguments: copies args
void grpc_channel_stack_builder_set_channel_arguments(
grpc_channel_stack_builder *builder, const grpc_channel_args *args);
diff --git a/src/core/lib/http/parser.c b/src/core/lib/http/parser.c
index 01d17fb623..921c772453 100644
--- a/src/core/lib/http/parser.c
+++ b/src/core/lib/http/parser.c
@@ -39,7 +39,7 @@
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
-extern int grpc_http_trace;
+int grpc_http1_trace = 0;
static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1);
@@ -74,7 +74,7 @@ static int handle_response_line(grpc_http_parser *parser) {
return 1;
error:
- if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing response line");
+ if (grpc_http1_trace) gpr_log(GPR_ERROR, "Failed parsing response line");
return 0;
}
@@ -127,7 +127,7 @@ static int handle_request_line(grpc_http_parser *parser) {
return 1;
error:
- if (grpc_http_trace) gpr_log(GPR_ERROR, "Failed parsing request line");
+ if (grpc_http1_trace) gpr_log(GPR_ERROR, "Failed parsing request line");
return 0;
}
@@ -152,7 +152,7 @@ static int add_header(grpc_http_parser *parser) {
GPR_ASSERT(cur != end);
if (*cur == ' ' || *cur == '\t') {
- if (grpc_http_trace)
+ if (grpc_http1_trace)
gpr_log(GPR_ERROR, "Continued header lines not supported yet");
goto error;
}
@@ -161,7 +161,8 @@ static int add_header(grpc_http_parser *parser) {
cur++;
}
if (cur == end) {
- if (grpc_http_trace) gpr_log(GPR_ERROR, "Didn't find ':' in header string");
+ if (grpc_http1_trace)
+ gpr_log(GPR_ERROR, "Didn't find ':' in header string");
goto error;
}
GPR_ASSERT(cur >= beg);
@@ -252,7 +253,7 @@ static int addbyte(grpc_http_parser *parser, uint8_t byte) {
case GRPC_HTTP_FIRST_LINE:
case GRPC_HTTP_HEADERS:
if (parser->cur_line_length >= GRPC_HTTP_PARSER_MAX_HEADER_LENGTH) {
- if (grpc_http_trace)
+ if (grpc_http1_trace)
gpr_log(GPR_ERROR, "HTTP client max line length (%d) exceeded",
GRPC_HTTP_PARSER_MAX_HEADER_LENGTH);
return 0;
diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h
index 8bd73f649a..42fa5181b8 100644
--- a/src/core/lib/http/parser.h
+++ b/src/core/lib/http/parser.h
@@ -113,4 +113,6 @@ void grpc_http_parser_destroy(grpc_http_parser *parser);
int grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice);
int grpc_http_parser_eof(grpc_http_parser *parser);
+extern int grpc_http1_trace;
+
#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */
diff --git a/src/core/lib/iomgr/tcp_server_posix.c b/src/core/lib/iomgr/tcp_server_posix.c
index cfb5251684..aaeb384f6e 100644
--- a/src/core/lib/iomgr/tcp_server_posix.c
+++ b/src/core/lib/iomgr/tcp_server_posix.c
@@ -450,7 +450,7 @@ int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
&sockname_len)) {
port = grpc_sockaddr_get_port((struct sockaddr *)&sockname_temp);
if (port > 0) {
- allocated_addr = malloc(addr_len);
+ allocated_addr = gpr_malloc(addr_len);
memcpy(allocated_addr, addr, addr_len);
grpc_sockaddr_set_port(allocated_addr, port);
addr = allocated_addr;
diff --git a/src/core/lib/iomgr/tcp_server_windows.c b/src/core/lib/iomgr/tcp_server_windows.c
index 9f9d7dcb54..6940dec7b0 100644
--- a/src/core/lib/iomgr/tcp_server_windows.c
+++ b/src/core/lib/iomgr/tcp_server_windows.c
@@ -467,7 +467,7 @@ int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
(struct sockaddr *)&sockname_temp, &sockname_len)) {
port = grpc_sockaddr_get_port((struct sockaddr *)&sockname_temp);
if (port > 0) {
- allocated_addr = malloc(addr_len);
+ allocated_addr = gpr_malloc(addr_len);
memcpy(allocated_addr, addr, addr_len);
grpc_sockaddr_set_port(allocated_addr, port);
addr = allocated_addr;
diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c
index a0b9709be5..df6cf956d9 100644
--- a/src/core/lib/iomgr/udp_server.c
+++ b/src/core/lib/iomgr/udp_server.c
@@ -166,7 +166,6 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
if (s->nports) {
for (i = 0; i < s->nports; i++) {
server_port *sp = &s->ports[i];
- grpc_unlink_if_unix_domain_socket(&sp->addr.sockaddr);
sp->destroyed_closure.cb = destroyed_port;
sp->destroyed_closure.cb_arg = s;
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
@@ -317,8 +316,6 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
socklen_t sockname_len;
int port;
- grpc_unlink_if_unix_domain_socket((struct sockaddr *)addr);
-
/* Check if this is a wildcard port, and if so, try to keep the port the same
as some previously created listener. */
if (grpc_sockaddr_get_port(addr) == 0) {
@@ -328,7 +325,7 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
&sockname_len)) {
port = grpc_sockaddr_get_port((struct sockaddr *)&sockname_temp);
if (port > 0) {
- allocated_addr = malloc(addr_len);
+ allocated_addr = gpr_malloc(addr_len);
memcpy(allocated_addr, addr, addr_len);
grpc_sockaddr_set_port(allocated_addr, port);
addr = allocated_addr;
diff --git a/src/core/lib/iomgr/unix_sockets_posix.c b/src/core/lib/iomgr/unix_sockets_posix.c
index 42e44989e0..5767c852df 100644
--- a/src/core/lib/iomgr/unix_sockets_posix.c
+++ b/src/core/lib/iomgr/unix_sockets_posix.c
@@ -41,6 +41,7 @@
#include <sys/un.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
void grpc_create_socketpair_if_unix(int sv[2]) {
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
@@ -75,21 +76,6 @@ void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr) {
}
}
-int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
- struct sockaddr_un *un = (struct sockaddr_un *)addr;
-
- un->sun_family = AF_UNIX;
- strcpy(un->sun_path, uri->path);
- *len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
-
- return 1;
-}
-
-char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri) {
- return gpr_strdup("localhost");
-}
-
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return NULL;
diff --git a/src/core/lib/iomgr/unix_sockets_posix.h b/src/core/lib/iomgr/unix_sockets_posix.h
index 22d6af5044..6758c498e5 100644
--- a/src/core/lib/iomgr/unix_sockets_posix.h
+++ b/src/core/lib/iomgr/unix_sockets_posix.h
@@ -38,8 +38,6 @@
#include <grpc/support/string_util.h>
-#include "src/core/ext/client_config/resolver_factory.h"
-#include "src/core/ext/client_config/uri_parser.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/sockaddr.h"
@@ -51,11 +49,6 @@ int grpc_is_unix_socket(const struct sockaddr *addr);
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr);
-int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len);
-
-char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri);
-
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr);
#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */
diff --git a/src/core/lib/iomgr/unix_sockets_posix_noop.c b/src/core/lib/iomgr/unix_sockets_posix_noop.c
index 43e006e15e..d30952789f 100644
--- a/src/core/lib/iomgr/unix_sockets_posix_noop.c
+++ b/src/core/lib/iomgr/unix_sockets_posix_noop.c
@@ -35,6 +35,8 @@
#ifndef GPR_HAVE_UNIX_SOCKET
+#include <grpc/support/log.h>
+
void grpc_create_socketpair_if_unix(int sv[2]) {
// TODO: Either implement this for the non-Unix socket case or make
// sure that it is never called in any such case. Until then, leave an
@@ -50,15 +52,6 @@ int grpc_is_unix_socket(const struct sockaddr *addr) { return false; }
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr) {}
-int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
- return 0;
-}
-
-char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
- grpc_uri *uri) {
- return NULL;
-}
-
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
return NULL;
}
diff --git a/src/core/lib/profiling/basic_timers.c b/src/core/lib/profiling/basic_timers.c
index 93e0b99e90..50082cd7ee 100644
--- a/src/core/lib/profiling/basic_timers.c
+++ b/src/core/lib/profiling/basic_timers.c
@@ -208,6 +208,7 @@ static void init_output() {
}
static void rotate_log() {
+ /* Using malloc here, as this code could end up being called by gpr_malloc */
gpr_timer_log *new = malloc(sizeof(*new));
gpr_once_init(&g_once_init, init_output);
new->num_entries = 0;
diff --git a/src/core/lib/security/credentials.c b/src/core/lib/security/credentials.c
index 2c7d31519c..fd5ad3589b 100644
--- a/src/core/lib/security/credentials.c
+++ b/src/core/lib/security/credentials.c
@@ -338,10 +338,11 @@ static void ssl_build_config(const char *pem_root_certs,
static void ssl_build_server_config(
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
- size_t num_key_cert_pairs, int force_client_auth,
+ size_t num_key_cert_pairs,
+ grpc_ssl_client_certificate_request_type client_certificate_request,
grpc_ssl_server_config *config) {
size_t i;
- config->force_client_auth = force_client_auth;
+ config->client_certificate_request = client_certificate_request;
if (pem_root_certs != NULL) {
ssl_copy_key_material(pem_root_certs, &config->pem_root_certs,
&config->pem_root_certs_size);
@@ -391,21 +392,35 @@ grpc_channel_credentials *grpc_ssl_credentials_create(
grpc_server_credentials *grpc_ssl_server_credentials_create(
const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
size_t num_key_cert_pairs, int force_client_auth, void *reserved) {
+ return grpc_ssl_server_credentials_create_ex(
+ pem_root_certs, pem_key_cert_pairs, num_key_cert_pairs,
+ force_client_auth
+ ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ reserved);
+}
+
+grpc_server_credentials *grpc_ssl_server_credentials_create_ex(
+ const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
+ size_t num_key_cert_pairs,
+ grpc_ssl_client_certificate_request_type client_certificate_request,
+ void *reserved) {
grpc_ssl_server_credentials *c =
gpr_malloc(sizeof(grpc_ssl_server_credentials));
GRPC_API_TRACE(
- "grpc_ssl_server_credentials_create("
+ "grpc_ssl_server_credentials_create_ex("
"pem_root_certs=%s, pem_key_cert_pairs=%p, num_key_cert_pairs=%lu, "
- "force_client_auth=%d, reserved=%p)",
+ "client_certificate_request=%d, reserved=%p)",
5, (pem_root_certs, pem_key_cert_pairs, (unsigned long)num_key_cert_pairs,
- force_client_auth, reserved));
+ client_certificate_request, reserved));
GPR_ASSERT(reserved == NULL);
memset(c, 0, sizeof(grpc_ssl_server_credentials));
c->base.type = GRPC_CHANNEL_CREDENTIALS_TYPE_SSL;
gpr_ref_init(&c->base.refcount, 1);
c->base.vtable = &ssl_server_vtable;
ssl_build_server_config(pem_root_certs, pem_key_cert_pairs,
- num_key_cert_pairs, force_client_auth, &c->config);
+ num_key_cert_pairs, client_certificate_request,
+ &c->config);
return &c->base;
}
diff --git a/src/core/lib/security/security_connector.c b/src/core/lib/security/security_connector.c
index 4d8c5dd82d..2d2023bdf5 100644
--- a/src/core/lib/security/security_connector.c
+++ b/src/core/lib/security/security_connector.c
@@ -42,7 +42,7 @@
#include <grpc/support/slice_buffer.h>
#include <grpc/support/string_util.h>
-#include "src/core/ext/transport/chttp2/transport/alpn.h"
+#include "src/core/ext/transport/chttp2/alpn/alpn.h"
#include "src/core/lib/security/credentials.h"
#include "src/core/lib/security/handshake.h"
#include "src/core/lib/security/secure_endpoint.h"
@@ -668,6 +668,31 @@ gpr_slice grpc_get_default_ssl_roots_for_testing(void) {
return compute_default_pem_root_certs_once();
}
+static tsi_client_certificate_request_type
+get_tsi_client_certificate_request_type(
+ grpc_ssl_client_certificate_request_type grpc_request_type) {
+ switch (grpc_request_type) {
+ case GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE:
+ return TSI_DONT_REQUEST_CLIENT_CERTIFICATE;
+
+ case GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
+ return TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY;
+
+ case GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY:
+ return TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY;
+
+ case GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
+ return TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY;
+
+ case GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY:
+ return TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY;
+
+ default:
+ // Is this a sane default
+ return TSI_DONT_REQUEST_CLIENT_CERTIFICATE;
+ }
+}
+
size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs) {
/* TODO(jboeuf@google.com): Maybe revisit the approach which consists in
loading all the roots once for the lifetime of the process. */
@@ -782,15 +807,16 @@ grpc_security_status grpc_ssl_server_security_connector_create(
gpr_ref_init(&c->base.base.refcount, 1);
c->base.base.url_scheme = GRPC_SSL_URL_SCHEME;
c->base.base.vtable = &ssl_server_vtable;
- result = tsi_create_ssl_server_handshaker_factory(
+ result = tsi_create_ssl_server_handshaker_factory_ex(
(const unsigned char **)config->pem_private_keys,
config->pem_private_keys_sizes,
(const unsigned char **)config->pem_cert_chains,
config->pem_cert_chains_sizes, config->num_key_cert_pairs,
config->pem_root_certs, config->pem_root_certs_size,
- config->force_client_auth, ssl_cipher_suites(), alpn_protocol_strings,
- alpn_protocol_string_lengths, (uint16_t)num_alpn_protocols,
- &c->handshaker_factory);
+ get_tsi_client_certificate_request_type(
+ config->client_certificate_request),
+ ssl_cipher_suites(), alpn_protocol_strings, alpn_protocol_string_lengths,
+ (uint16_t)num_alpn_protocols, &c->handshaker_factory);
if (result != TSI_OK) {
gpr_log(GPR_ERROR, "Handshaker factory creation failed with %s.",
tsi_result_to_string(result));
diff --git a/src/core/lib/security/security_connector.h b/src/core/lib/security/security_connector.h
index c9e262b1ad..2c893cd5e9 100644
--- a/src/core/lib/security/security_connector.h
+++ b/src/core/lib/security/security_connector.h
@@ -241,7 +241,7 @@ typedef struct {
size_t num_key_cert_pairs;
unsigned char *pem_root_certs;
size_t pem_root_certs_size;
- int force_client_auth;
+ grpc_ssl_client_certificate_request_type client_certificate_request;
} grpc_ssl_server_config;
/* Creates an SSL server_security_connector.
diff --git a/src/core/lib/support/alloc.c b/src/core/lib/support/alloc.c
index 020917f79c..618c3f6acd 100644
--- a/src/core/lib/support/alloc.c
+++ b/src/core/lib/support/alloc.c
@@ -53,6 +53,7 @@ void gpr_set_allocation_functions(gpr_allocation_functions functions) {
void *gpr_malloc(size_t size) {
void *p;
+ if (size == 0) return NULL;
GPR_TIMER_BEGIN("gpr_malloc", 0);
p = g_alloc_functions.malloc_fn(size);
if (!p) {
@@ -69,6 +70,7 @@ void gpr_free(void *p) {
}
void *gpr_realloc(void *p, size_t size) {
+ if ((size == 0) && (p == NULL)) return NULL;
GPR_TIMER_BEGIN("gpr_realloc", 0);
p = g_alloc_functions.realloc_fn(p, size);
if (!p) {
diff --git a/src/core/lib/support/log.c b/src/core/lib/support/log.c
index 04156a5b1f..882abf673c 100644
--- a/src/core/lib/support/log.c
+++ b/src/core/lib/support/log.c
@@ -31,14 +31,20 @@
*
*/
+#include <grpc/support/alloc.h>
+#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
+#include "src/core/lib/support/env.h"
+#include "src/core/lib/support/string.h"
+
#include <stdio.h>
#include <string.h>
extern void gpr_default_log(gpr_log_func_args *args);
static gpr_log_func g_log_func = gpr_default_log;
+static gpr_atm g_min_severity_to_print = GPR_LOG_VERBOSITY_UNSET;
const char *gpr_log_severity_string(gpr_log_severity severity) {
switch (severity) {
@@ -54,6 +60,9 @@ const char *gpr_log_severity_string(gpr_log_severity severity) {
void gpr_log_message(const char *file, int line, gpr_log_severity severity,
const char *message) {
+ if ((gpr_atm)severity < gpr_atm_no_barrier_load(&g_min_severity_to_print))
+ return;
+
gpr_log_func_args lfargs;
memset(&lfargs, 0, sizeof(lfargs));
lfargs.file = file;
@@ -63,4 +72,28 @@ void gpr_log_message(const char *file, int line, gpr_log_severity severity,
g_log_func(&lfargs);
}
+void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print) {
+ gpr_atm_no_barrier_store(&g_min_severity_to_print,
+ (gpr_atm)min_severity_to_print);
+}
+
+void gpr_log_verbosity_init() {
+ char *verbosity = gpr_getenv("GRPC_VERBOSITY");
+ if (verbosity == NULL) return;
+
+ gpr_atm min_severity_to_print = GPR_LOG_VERBOSITY_UNSET;
+ if (strcmp(verbosity, "DEBUG") == 0) {
+ min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_DEBUG;
+ } else if (strcmp(verbosity, "INFO") == 0) {
+ min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_INFO;
+ } else if (strcmp(verbosity, "ERROR") == 0) {
+ min_severity_to_print = (gpr_atm)GPR_LOG_SEVERITY_ERROR;
+ }
+ gpr_free(verbosity);
+ if ((gpr_atm_no_barrier_load(&g_min_severity_to_print)) ==
+ GPR_LOG_VERBOSITY_UNSET) {
+ gpr_atm_no_barrier_store(&g_min_severity_to_print, min_severity_to_print);
+ }
+}
+
void gpr_set_log_function(gpr_log_func f) { g_log_func = f; }
diff --git a/src/core/lib/support/log_linux.c b/src/core/lib/support/log_linux.c
index 6d4b63bbe0..ff3febb38e 100644
--- a/src/core/lib/support/log_linux.c
+++ b/src/core/lib/support/log_linux.c
@@ -68,6 +68,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
}
va_end(args);
gpr_log_message(file, line, severity, message);
+ /* message has been allocated by vasprintf above, and needs free */
free(message);
}
diff --git a/src/core/lib/support/thd_posix.c b/src/core/lib/support/thd_posix.c
index 89832e3ce1..2fc23bffaf 100644
--- a/src/core/lib/support/thd_posix.c
+++ b/src/core/lib/support/thd_posix.c
@@ -81,6 +81,7 @@ int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
thread_started = (pthread_create(&p, &attr, &thread_body, a) == 0);
GPR_ASSERT(pthread_attr_destroy(&attr) == 0);
if (!thread_started) {
+ /* don't use gpr_free, as this was allocated using malloc (see above) */
free(a);
}
*t = (gpr_thd_id)p;
diff --git a/src/core/lib/surface/byte_buffer.c b/src/core/lib/surface/byte_buffer.c
index fb39c4531d..a093a37af3 100644
--- a/src/core/lib/surface/byte_buffer.c
+++ b/src/core/lib/surface/byte_buffer.c
@@ -44,7 +44,7 @@ grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices,
grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create(
gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression) {
size_t i;
- grpc_byte_buffer *bb = malloc(sizeof(grpc_byte_buffer));
+ grpc_byte_buffer *bb = gpr_malloc(sizeof(grpc_byte_buffer));
bb->type = GRPC_BB_RAW;
bb->data.raw.compression = compression;
gpr_slice_buffer_init(&bb->data.raw.slice_buffer);
@@ -57,7 +57,7 @@ grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create(
grpc_byte_buffer *grpc_raw_byte_buffer_from_reader(
grpc_byte_buffer_reader *reader) {
- grpc_byte_buffer *bb = malloc(sizeof(grpc_byte_buffer));
+ grpc_byte_buffer *bb = gpr_malloc(sizeof(grpc_byte_buffer));
gpr_slice slice;
bb->type = GRPC_BB_RAW;
bb->data.raw.compression = GRPC_COMPRESS_NONE;
@@ -85,7 +85,7 @@ void grpc_byte_buffer_destroy(grpc_byte_buffer *bb) {
gpr_slice_buffer_destroy(&bb->data.raw.slice_buffer);
break;
}
- free(bb);
+ gpr_free(bb);
}
size_t grpc_byte_buffer_length(grpc_byte_buffer *bb) {
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index ba94852f9a..6581bbd3d1 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -1074,24 +1074,29 @@ static void receiving_initial_metadata_ready(grpc_exec_ctx *exec_ctx,
gpr_mu_lock(&call->mu);
- grpc_metadata_batch *md =
- &call->metadata_batch[1 /* is_receiving */][0 /* is_trailing */];
- grpc_metadata_batch_filter(md, recv_initial_filter, call);
- call->has_initial_md_been_received = true;
-
- if (gpr_time_cmp(md->deadline, gpr_inf_future(md->deadline.clock_type)) !=
- 0 &&
- !call->is_client) {
- GPR_TIMER_BEGIN("set_deadline_alarm", 0);
- set_deadline_alarm(exec_ctx, call, md->deadline);
- GPR_TIMER_END("set_deadline_alarm", 0);
+ if (!success) {
+ bctl->success = false;
+ } else {
+ grpc_metadata_batch *md =
+ &call->metadata_batch[1 /* is_receiving */][0 /* is_trailing */];
+ grpc_metadata_batch_filter(md, recv_initial_filter, call);
+
+ if (gpr_time_cmp(md->deadline, gpr_inf_future(md->deadline.clock_type)) !=
+ 0 &&
+ !call->is_client) {
+ GPR_TIMER_BEGIN("set_deadline_alarm", 0);
+ set_deadline_alarm(exec_ctx, call, md->deadline);
+ GPR_TIMER_END("set_deadline_alarm", 0);
+ }
}
+ call->has_initial_md_been_received = true;
if (call->saved_receiving_stream_ready_ctx.bctlp != NULL) {
grpc_closure *saved_rsr_closure = grpc_closure_create(
receiving_stream_ready, call->saved_receiving_stream_ready_ctx.bctlp);
- grpc_exec_ctx_enqueue(exec_ctx, saved_rsr_closure,
- call->saved_receiving_stream_ready_ctx.success, NULL);
+ grpc_exec_ctx_enqueue(
+ exec_ctx, saved_rsr_closure,
+ call->saved_receiving_stream_ready_ctx.success && success, NULL);
call->saved_receiving_stream_ready_ctx.bctlp = NULL;
}
diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c
index 332f504507..b6b760b5d8 100644
--- a/src/core/lib/surface/channel.c
+++ b/src/core/lib/surface/channel.c
@@ -40,7 +40,6 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
-#include "src/core/ext/client_config/resolver_registry.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/surface/api_trace.h"
@@ -84,14 +83,26 @@ struct grpc_channel {
static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg, bool success);
grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
- const grpc_channel_args *args,
+ const grpc_channel_args *input_args,
grpc_channel_stack_type channel_stack_type,
grpc_transport *optional_transport) {
bool is_client = grpc_channel_stack_type_is_client(channel_stack_type);
- grpc_channel *channel = grpc_channel_init_create_stack(
- exec_ctx, channel_stack_type, sizeof(grpc_channel), args, 1,
- destroy_channel, NULL, optional_transport);
+ grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
+ grpc_channel_stack_builder_set_channel_arguments(builder, input_args);
+ grpc_channel_stack_builder_set_target(builder, target);
+ grpc_channel_stack_builder_set_transport(builder, optional_transport);
+ grpc_channel *channel;
+ grpc_channel_args *args;
+ if (!grpc_channel_init_create_stack(exec_ctx, builder, channel_stack_type)) {
+ grpc_channel_stack_builder_destroy(builder);
+ return NULL;
+ } else {
+ args = grpc_channel_args_copy(
+ grpc_channel_stack_builder_get_channel_arguments(builder));
+ channel = grpc_channel_stack_builder_finish(
+ exec_ctx, builder, sizeof(grpc_channel), 1, destroy_channel, NULL);
+ }
memset(channel, 0, sizeof(*channel));
channel->target = gpr_strdup(target);
@@ -142,16 +153,7 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
}
}
}
- }
-
- if (channel->is_client && channel->default_authority == NULL &&
- target != NULL) {
- char *default_authority = grpc_get_default_authority(target);
- if (default_authority) {
- channel->default_authority =
- grpc_mdelem_from_strings(":authority", default_authority);
- }
- gpr_free(default_authority);
+ grpc_channel_args_destroy(args);
}
return channel;
diff --git a/src/core/lib/surface/channel_init.c b/src/core/lib/surface/channel_init.c
index fc69f61f77..0627b34479 100644
--- a/src/core/lib/surface/channel_init.c
+++ b/src/core/lib/surface/channel_init.c
@@ -122,25 +122,19 @@ static const char *name_for_type(grpc_channel_stack_type type) {
GPR_UNREACHABLE_CODE(return "UNKNOWN");
}
-void *grpc_channel_init_create_stack(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_type type, size_t prefix_bytes,
- const grpc_channel_args *args, int initial_refs, grpc_iomgr_cb_func destroy,
- void *destroy_arg, grpc_transport *transport) {
+bool grpc_channel_init_create_stack(grpc_exec_ctx *exec_ctx,
+ grpc_channel_stack_builder *builder,
+ grpc_channel_stack_type type) {
GPR_ASSERT(g_finalized);
- grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
grpc_channel_stack_builder_set_name(builder, name_for_type(type));
- grpc_channel_stack_builder_set_channel_arguments(builder, args);
- grpc_channel_stack_builder_set_transport(builder, transport);
for (size_t i = 0; i < g_slots[type].num_slots; i++) {
const stage_slot *slot = &g_slots[type].slots[i];
if (!slot->fn(builder, slot->arg)) {
- grpc_channel_stack_builder_destroy(builder);
- return NULL;
+ return false;
}
}
- return grpc_channel_stack_builder_finish(exec_ctx, builder, prefix_bytes,
- initial_refs, destroy, destroy_arg);
+ return true;
}
diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h
index a4d8271ca6..3a18a61ddb 100644
--- a/src/core/lib/surface/channel_init.h
+++ b/src/core/lib/surface/channel_init.h
@@ -38,6 +38,8 @@
#include "src/core/lib/surface/channel_stack_type.h"
#include "src/core/lib/transport/transport.h"
+#define GRPC_CHANNEL_INIT_BUILTIN_PRIORITY 10000
+
/// This module provides a way for plugins (and the grpc core library itself)
/// to register mutators for channel stacks.
/// It also provides a universal entry path to run those mutators to build
@@ -78,9 +80,8 @@ void grpc_channel_init_shutdown(void);
/// \a optional_transport is either NULL or a constructed transport object
/// Returns a pointer to the base of the memory allocated (the actual channel
/// stack object will be prefix_bytes past that pointer)
-void *grpc_channel_init_create_stack(
- grpc_exec_ctx *exec_ctx, grpc_channel_stack_type type, size_t prefix_bytes,
- const grpc_channel_args *args, int initial_refs, grpc_iomgr_cb_func destroy,
- void *destroy_arg, grpc_transport *optional_transport);
+bool grpc_channel_init_create_stack(grpc_exec_ctx *exec_ctx,
+ grpc_channel_stack_builder *builder,
+ grpc_channel_stack_type type);
#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H */
diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c
index f221d8db35..03f379aba8 100644
--- a/src/core/lib/surface/init.c
+++ b/src/core/lib/surface/init.c
@@ -38,19 +38,15 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
#include <grpc/support/time.h>
-#include "src/core/ext/client_config/client_channel.h"
-#include "src/core/ext/client_config/lb_policy_registry.h"
-#include "src/core/ext/client_config/resolver_registry.h"
-#include "src/core/ext/client_config/subchannel.h"
-#include "src/core/ext/client_config/subchannel_index.h"
-#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/channel/compress_filter.h"
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/channel/http_client_filter.h"
#include "src/core/lib/channel/http_server_filter.h"
#include "src/core/lib/debug/trace.h"
+#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/profiling/timers.h"
@@ -65,10 +61,6 @@
#include "src/core/lib/transport/connectivity_state.h"
#include "src/core/lib/transport/transport_impl.h"
-#ifndef GRPC_DEFAULT_NAME_PREFIX
-#define GRPC_DEFAULT_NAME_PREFIX "dns:///"
-#endif
-
/* (generated) built in registry of plugins */
extern void grpc_register_built_in_plugins(void);
@@ -79,6 +71,7 @@ static gpr_mu g_init_mu;
static int g_initializations;
static void do_basic_init(void) {
+ gpr_log_verbosity_init();
gpr_mu_init(&g_init_mu);
grpc_register_built_in_plugins();
g_initializations = 0;
@@ -105,31 +98,35 @@ static bool maybe_add_http_filter(grpc_channel_stack_builder *builder,
}
static void register_builtin_channel_init() {
- grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, prepend_filter,
- (void *)&grpc_compress_filter);
- grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
- prepend_filter,
- (void *)&grpc_compress_filter);
- grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter,
- (void *)&grpc_compress_filter);
- grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX,
- maybe_add_http_filter,
- (void *)&grpc_http_client_filter);
- grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX,
+ grpc_channel_init_register_stage(
+ GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter,
+ (void *)&grpc_compress_filter);
+ grpc_channel_init_register_stage(
+ GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
+ prepend_filter, (void *)&grpc_compress_filter);
+ grpc_channel_init_register_stage(
+ GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter,
+ (void *)&grpc_compress_filter);
+ grpc_channel_init_register_stage(
+ GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
+ maybe_add_http_filter, (void *)&grpc_http_client_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
+ GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
grpc_add_connected_filter, NULL);
- grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
- maybe_add_http_filter,
- (void *)&grpc_http_client_filter);
- grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
+ grpc_channel_init_register_stage(
+ GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
+ maybe_add_http_filter, (void *)&grpc_http_client_filter);
+ grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL,
+ GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
grpc_add_connected_filter, NULL);
- grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
- maybe_add_http_filter,
- (void *)&grpc_http_server_filter);
- grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
+ grpc_channel_init_register_stage(
+ GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
+ maybe_add_http_filter, (void *)&grpc_http_server_filter);
+ grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL,
+ GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
grpc_add_connected_filter, NULL);
- grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, append_filter,
- (void *)&grpc_client_channel_filter);
- grpc_channel_init_register_stage(GRPC_CLIENT_LAME_CHANNEL, INT_MAX,
+ grpc_channel_init_register_stage(GRPC_CLIENT_LAME_CHANNEL,
+ GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
append_filter, (void *)&grpc_lame_filter);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter,
(void *)&grpc_server_top_filter);
@@ -161,22 +158,18 @@ void grpc_init(void) {
gpr_time_init();
grpc_mdctx_global_init();
grpc_channel_init_init();
- grpc_lb_policy_registry_init();
- grpc_resolver_registry_init(GRPC_DEFAULT_NAME_PREFIX);
grpc_register_tracer("api", &grpc_api_trace);
grpc_register_tracer("channel", &grpc_trace_channel);
- grpc_register_tracer("http", &grpc_http_trace);
- grpc_register_tracer("flowctl", &grpc_flowctl_trace);
grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace);
grpc_register_tracer("channel_stack_builder",
&grpc_trace_channel_stack_builder);
+ grpc_register_tracer("http1", &grpc_http1_trace);
grpc_security_pre_init();
grpc_iomgr_init();
grpc_executor_init();
grpc_tracer_init("GRPC_TRACE");
gpr_timers_global_init();
grpc_cq_global_init();
- grpc_subchannel_index_init();
for (i = 0; i < g_number_of_plugins; i++) {
if (g_all_of_the_plugins[i].init != NULL) {
g_all_of_the_plugins[i].init();
@@ -201,17 +194,13 @@ void grpc_shutdown(void) {
grpc_executor_shutdown();
grpc_cq_global_shutdown();
grpc_iomgr_shutdown();
- grpc_subchannel_index_shutdown();
gpr_timers_global_destroy();
grpc_tracer_shutdown();
- grpc_resolver_registry_shutdown();
- grpc_lb_policy_registry_shutdown();
- for (i = 0; i < g_number_of_plugins; i++) {
+ for (i = g_number_of_plugins; i >= 0; i--) {
if (g_all_of_the_plugins[i].destroy != NULL) {
g_all_of_the_plugins[i].destroy();
}
}
- grpc_channel_init_shutdown();
grpc_mdctx_global_shutdown();
}
gpr_mu_unlock(&g_init_mu);
diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c
index 37cc2bd101..ad8ee8c7a9 100644
--- a/src/core/lib/surface/server.c
+++ b/src/core/lib/surface/server.c
@@ -685,10 +685,14 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) {
grpc_call_element *elem = user_data;
call_data *calld = elem->call_data;
if (md->key == GRPC_MDSTR_PATH) {
- calld->path = GRPC_MDSTR_REF(md->value);
+ if (calld->path == NULL) {
+ calld->path = GRPC_MDSTR_REF(md->value);
+ }
return NULL;
} else if (md->key == GRPC_MDSTR_AUTHORITY) {
- calld->host = GRPC_MDSTR_REF(md->value);
+ if (calld->host == NULL) {
+ calld->host = GRPC_MDSTR_REF(md->value);
+ }
return NULL;
}
return md;
diff --git a/src/core/lib/transport/metadata.c b/src/core/lib/transport/metadata.c
index 2b1d32d55e..779efbb97d 100644
--- a/src/core/lib/transport/metadata.c
+++ b/src/core/lib/transport/metadata.c
@@ -38,19 +38,21 @@
#include <string.h>
#include <grpc/compression.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include <grpc/support/time.h>
-#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/support/murmur_hash.h"
#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/static_metadata.h"
+gpr_slice (*grpc_chttp2_base64_encode_and_huffman_compress)(gpr_slice input);
+
/* There are two kinds of mdelem and mdstr instances.
* Static instances are declared in static_metadata.{h,c} and
* are initialized by grpc_mdctx_global_init().
@@ -79,6 +81,7 @@
typedef void (*destroy_user_data_func)(void *user_data);
+#define SIZE_IN_DECODER_TABLE_NOT_SET -1
/* Shadow structure for grpc_mdstr for non-static values */
typedef struct internal_string {
/* must be byte compatible with grpc_mdstr */
@@ -93,6 +96,8 @@ typedef struct internal_string {
gpr_slice base64_and_huffman;
+ gpr_atm size_in_decoder_table;
+
struct internal_string *bucket_next;
} internal_string;
@@ -242,6 +247,12 @@ void grpc_mdctx_global_shutdown(void) {
if (shard->count != 0) {
gpr_log(GPR_DEBUG, "WARNING: %d metadata strings were leaked",
shard->count);
+ for (size_t j = 0; j < shard->capacity; j++) {
+ for (internal_string *s = shard->strs[j]; s; s = s->bucket_next) {
+ gpr_log(GPR_DEBUG, "LEAKED: %s",
+ grpc_mdstr_as_c_string((grpc_mdstr *)s));
+ }
+ }
if (grpc_iomgr_abort_on_leaks()) {
abort();
}
@@ -407,6 +418,7 @@ grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *buf, size_t length) {
}
s->has_base64_and_huffman_encoded = 0;
s->hash = hash;
+ s->size_in_decoder_table = SIZE_IN_DECODER_TABLE_NOT_SET;
s->bucket_next = shard->strs[idx];
shard->strs[idx] = s;
@@ -576,6 +588,39 @@ grpc_mdelem *grpc_mdelem_from_string_and_buffer(const char *key,
grpc_mdstr_from_string(key), grpc_mdstr_from_buffer(value, value_length));
}
+static size_t get_base64_encoded_size(size_t raw_length) {
+ static const uint8_t tail_xtra[3] = {0, 2, 3};
+ return raw_length / 3 * 4 + tail_xtra[raw_length % 3];
+}
+
+size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem *elem) {
+ size_t overhead_and_key = 32 + GPR_SLICE_LENGTH(elem->key->slice);
+ size_t value_len = GPR_SLICE_LENGTH(elem->value->slice);
+ if (is_mdstr_static(elem->value)) {
+ if (grpc_is_binary_header(
+ (const char *)GPR_SLICE_START_PTR(elem->key->slice),
+ GPR_SLICE_LENGTH(elem->key->slice))) {
+ return overhead_and_key + get_base64_encoded_size(value_len);
+ } else {
+ return overhead_and_key + value_len;
+ }
+ } else {
+ internal_string *is = (internal_string *)elem->value;
+ gpr_atm current_size = gpr_atm_acq_load(&is->size_in_decoder_table);
+ if (current_size == SIZE_IN_DECODER_TABLE_NOT_SET) {
+ if (grpc_is_binary_header(
+ (const char *)GPR_SLICE_START_PTR(elem->key->slice),
+ GPR_SLICE_LENGTH(elem->key->slice))) {
+ current_size = (gpr_atm)get_base64_encoded_size(value_len);
+ } else {
+ current_size = (gpr_atm)value_len;
+ }
+ gpr_atm_rel_store(&is->size_in_decoder_table, current_size);
+ }
+ return overhead_and_key + (size_t)current_size;
+ }
+}
+
grpc_mdelem *grpc_mdelem_ref(grpc_mdelem *gmd DEBUG_ARGS) {
internal_metadata *md = (internal_metadata *)gmd;
if (is_mdelem_static(gmd)) return gmd;
diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h
index 6a02437fdf..e29e8df2c9 100644
--- a/src/core/lib/transport/metadata.h
+++ b/src/core/lib/transport/metadata.h
@@ -110,6 +110,8 @@ grpc_mdelem *grpc_mdelem_from_string_and_buffer(const char *key,
const uint8_t *value,
size_t value_length);
+size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem *elem);
+
/* Mutator and accessor for grpc_mdelem user data. The destructor function
is used as a type tag and is checked during user_data fetch. */
void *grpc_mdelem_get_user_data(grpc_mdelem *md,
@@ -153,4 +155,8 @@ int grpc_mdstr_is_bin_suffixed(grpc_mdstr *s);
void grpc_mdctx_global_init(void);
void grpc_mdctx_global_shutdown(void);
+/* Implementation provided by chttp2_transport */
+extern gpr_slice (*grpc_chttp2_base64_encode_and_huffman_compress)(
+ gpr_slice input);
+
#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_H */
diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h
index bb1120ee3a..1eb446312b 100644
--- a/src/core/lib/transport/transport.h
+++ b/src/core/lib/transport/transport.h
@@ -50,7 +50,7 @@ typedef struct grpc_transport grpc_transport;
for a stream. */
typedef struct grpc_stream grpc_stream;
-/*#define GRPC_STREAM_REFCOUNT_DEBUG*/
+//#define GRPC_STREAM_REFCOUNT_DEBUG
typedef struct grpc_stream_refcount {
gpr_refcount refs;
diff --git a/src/core/lib/tsi/fake_transport_security.c b/src/core/lib/tsi/fake_transport_security.c
index 4b045b8cd9..0e20d6fd71 100644
--- a/src/core/lib/tsi/fake_transport_security.c
+++ b/src/core/lib/tsi/fake_transport_security.c
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <string.h>
+#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/useful.h>
@@ -134,12 +135,12 @@ static void tsi_fake_frame_reset(tsi_fake_frame *frame, int needs_draining) {
static int tsi_fake_frame_ensure_size(tsi_fake_frame *frame) {
if (frame->data == NULL) {
frame->allocated_size = frame->size;
- frame->data = malloc(frame->allocated_size);
+ frame->data = gpr_malloc(frame->allocated_size);
if (frame->data == NULL) return 0;
} else if (frame->size > frame->allocated_size) {
- unsigned char *new_data = realloc(frame->data, frame->size);
+ unsigned char *new_data = gpr_realloc(frame->data, frame->size);
if (new_data == NULL) {
- free(frame->data);
+ gpr_free(frame->data);
frame->data = NULL;
return 0;
}
@@ -160,7 +161,7 @@ static tsi_result fill_frame_from_bytes(const unsigned char *incoming_bytes,
if (frame->needs_draining) return TSI_INTERNAL_ERROR;
if (frame->data == NULL) {
frame->allocated_size = TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE;
- frame->data = malloc(frame->allocated_size);
+ frame->data = gpr_malloc(frame->allocated_size);
if (frame->data == NULL) return TSI_OUT_OF_RESOURCES;
}
@@ -226,7 +227,7 @@ static tsi_result bytes_to_frame(unsigned char *bytes, size_t bytes_size,
}
static void tsi_fake_frame_destruct(tsi_fake_frame *frame) {
- if (frame->data != NULL) free(frame->data);
+ if (frame->data != NULL) gpr_free(frame->data);
}
/* --- tsi_frame_protector methods implementation. ---*/
@@ -366,7 +367,7 @@ static void fake_protector_destroy(tsi_frame_protector *self) {
tsi_fake_frame_protector *impl = (tsi_fake_frame_protector *)self;
tsi_fake_frame_destruct(&impl->protect_frame);
tsi_fake_frame_destruct(&impl->unprotect_frame);
- free(self);
+ gpr_free(self);
}
static const tsi_frame_protector_vtable frame_protector_vtable = {
@@ -488,7 +489,7 @@ static void fake_handshaker_destroy(tsi_handshaker *self) {
tsi_fake_handshaker *impl = (tsi_fake_handshaker *)self;
tsi_fake_frame_destruct(&impl->incoming);
tsi_fake_frame_destruct(&impl->outgoing);
- free(self);
+ gpr_free(self);
}
static const tsi_handshaker_vtable handshaker_vtable = {
@@ -501,7 +502,8 @@ static const tsi_handshaker_vtable handshaker_vtable = {
};
tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
- tsi_fake_handshaker *impl = calloc(1, sizeof(tsi_fake_handshaker));
+ tsi_fake_handshaker *impl = gpr_malloc(sizeof(*impl));
+ memset(impl, 0, sizeof(*impl));
impl->base.vtable = &handshaker_vtable;
impl->is_client = is_client;
impl->result = TSI_HANDSHAKE_IN_PROGRESS;
@@ -517,8 +519,8 @@ tsi_handshaker *tsi_create_fake_handshaker(int is_client) {
tsi_frame_protector *tsi_create_fake_protector(
size_t *max_protected_frame_size) {
- tsi_fake_frame_protector *impl = calloc(1, sizeof(tsi_fake_frame_protector));
- if (impl == NULL) return NULL;
+ tsi_fake_frame_protector *impl = gpr_malloc(sizeof(*impl));
+ memset(impl, 0, sizeof(*impl));
impl->max_frame_size = (max_protected_frame_size == NULL)
? TSI_FAKE_DEFAULT_FRAME_SIZE
: *max_protected_frame_size;
diff --git a/src/core/lib/tsi/ssl_transport_security.c b/src/core/lib/tsi/ssl_transport_security.c
index d98b3e1558..e91c6316e7 100644
--- a/src/core/lib/tsi/ssl_transport_security.c
+++ b/src/core/lib/tsi/ssl_transport_security.c
@@ -45,6 +45,7 @@
#include <arpa/inet.h>
#endif
+#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
@@ -148,8 +149,7 @@ static void init_openssl(void) {
OpenSSL_add_all_algorithms();
num_locks = CRYPTO_num_locks();
GPR_ASSERT(num_locks > 0);
- openssl_mutexes = malloc((size_t)num_locks * sizeof(gpr_mu));
- GPR_ASSERT(openssl_mutexes != NULL);
+ openssl_mutexes = gpr_malloc((size_t)num_locks * sizeof(gpr_mu));
for (i = 0; i < CRYPTO_num_locks(); i++) {
gpr_mu_init(&openssl_mutexes[i]);
}
@@ -701,7 +701,7 @@ static tsi_result build_alpn_protocol_name_list(
}
*protocol_name_list_length += (size_t)alpn_protocols_lengths[i] + 1;
}
- *protocol_name_list = malloc(*protocol_name_list_length);
+ *protocol_name_list = gpr_malloc(*protocol_name_list_length);
if (*protocol_name_list == NULL) return TSI_OUT_OF_RESOURCES;
current = *protocol_name_list;
for (i = 0; i < num_alpn_protocols; i++) {
@@ -718,6 +718,14 @@ static tsi_result build_alpn_protocol_name_list(
return TSI_OK;
}
+// The verification callback is used for clients that don't really care about
+// the server's certificate, but we need to pull it anyway, in case a higher
+// layer wants to look at it. In this case the verification may fail, but
+// we don't really care.
+static int NullVerifyCallback(int preverify_ok, X509_STORE_CTX *ctx) {
+ return 1;
+}
+
/* --- tsi_frame_protector methods implementation. ---*/
static tsi_result ssl_protector_protect(tsi_frame_protector *self,
@@ -852,9 +860,9 @@ static tsi_result ssl_protector_unprotect(
static void ssl_protector_destroy(tsi_frame_protector *self) {
tsi_ssl_frame_protector *impl = (tsi_ssl_frame_protector *)self;
- if (impl->buffer != NULL) free(impl->buffer);
+ if (impl->buffer != NULL) gpr_free(impl->buffer);
if (impl->ssl != NULL) SSL_free(impl->ssl);
- free(self);
+ gpr_free(self);
}
static const tsi_frame_protector_vtable frame_protector_vtable = {
@@ -966,8 +974,9 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker *self,
if (alpn_selected != NULL) {
size_t i;
tsi_peer_property *new_properties =
- calloc(1, sizeof(tsi_peer_property) * (peer->property_count + 1));
- if (new_properties == NULL) return TSI_OUT_OF_RESOURCES;
+ gpr_malloc(sizeof(*new_properties) * (peer->property_count + 1));
+ memset(new_properties, 0,
+ sizeof(*new_properties) * (peer->property_count + 1));
for (i = 0; i < peer->property_count; i++) {
new_properties[i] = peer->properties[i];
}
@@ -975,10 +984,10 @@ static tsi_result ssl_handshaker_extract_peer(tsi_handshaker *self,
TSI_SSL_ALPN_SELECTED_PROTOCOL, (const char *)alpn_selected,
alpn_selected_len, &new_properties[peer->property_count]);
if (result != TSI_OK) {
- free(new_properties);
+ gpr_free(new_properties);
return result;
}
- if (peer->properties != NULL) free(peer->properties);
+ if (peer->properties != NULL) gpr_free(peer->properties);
peer->property_count++;
peer->properties = new_properties;
}
@@ -991,11 +1000,8 @@ static tsi_result ssl_handshaker_create_frame_protector(
size_t actual_max_output_protected_frame_size =
TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND;
tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
- tsi_ssl_frame_protector *protector_impl =
- calloc(1, sizeof(tsi_ssl_frame_protector));
- if (protector_impl == NULL) {
- return TSI_OUT_OF_RESOURCES;
- }
+ tsi_ssl_frame_protector *protector_impl = gpr_malloc(sizeof(*protector_impl));
+ memset(protector_impl, 0, sizeof(*protector_impl));
if (max_output_protected_frame_size != NULL) {
if (*max_output_protected_frame_size >
@@ -1011,11 +1017,11 @@ static tsi_result ssl_handshaker_create_frame_protector(
}
protector_impl->buffer_size =
actual_max_output_protected_frame_size - TSI_SSL_MAX_PROTECTION_OVERHEAD;
- protector_impl->buffer = malloc(protector_impl->buffer_size);
+ protector_impl->buffer = gpr_malloc(protector_impl->buffer_size);
if (protector_impl->buffer == NULL) {
gpr_log(GPR_ERROR,
"Could not allocated buffer for tsi_ssl_frame_protector.");
- free(protector_impl);
+ gpr_free(protector_impl);
return TSI_INTERNAL_ERROR;
}
@@ -1034,7 +1040,7 @@ static tsi_result ssl_handshaker_create_frame_protector(
static void ssl_handshaker_destroy(tsi_handshaker *self) {
tsi_ssl_handshaker *impl = (tsi_ssl_handshaker *)self;
SSL_free(impl->ssl); /* The BIO objects are owned by ssl */
- free(impl);
+ gpr_free(impl);
}
static const tsi_handshaker_vtable handshaker_vtable = {
@@ -1111,11 +1117,8 @@ static tsi_result create_tsi_ssl_handshaker(SSL_CTX *ctx, int is_client,
SSL_set_accept_state(ssl);
}
- impl = calloc(1, sizeof(tsi_ssl_handshaker));
- if (impl == NULL) {
- SSL_free(ssl);
- return TSI_OUT_OF_RESOURCES;
- }
+ impl = gpr_malloc(sizeof(*impl));
+ memset(impl, 0, sizeof(*impl));
impl->ssl = ssl;
impl->into_ssl = into_ssl;
impl->from_ssl = from_ssl;
@@ -1167,8 +1170,8 @@ static void ssl_client_handshaker_factory_destroy(
tsi_ssl_client_handshaker_factory *impl =
(tsi_ssl_client_handshaker_factory *)self;
if (impl->ssl_context != NULL) SSL_CTX_free(impl->ssl_context);
- if (impl->alpn_protocol_list != NULL) free(impl->alpn_protocol_list);
- free(impl);
+ if (impl->alpn_protocol_list != NULL) gpr_free(impl->alpn_protocol_list);
+ gpr_free(impl);
}
static int client_handshaker_factory_npn_callback(SSL *ssl, unsigned char **out,
@@ -1209,12 +1212,12 @@ static void ssl_server_handshaker_factory_destroy(
tsi_peer_destruct(&impl->ssl_context_x509_subject_names[i]);
}
}
- if (impl->ssl_contexts != NULL) free(impl->ssl_contexts);
+ if (impl->ssl_contexts != NULL) gpr_free(impl->ssl_contexts);
if (impl->ssl_context_x509_subject_names != NULL) {
- free(impl->ssl_context_x509_subject_names);
+ gpr_free(impl->ssl_context_x509_subject_names);
}
- if (impl->alpn_protocol_list != NULL) free(impl->alpn_protocol_list);
- free(impl);
+ if (impl->alpn_protocol_list != NULL) gpr_free(impl->alpn_protocol_list);
+ gpr_free(impl);
}
static int does_entry_match_name(const char *entry, size_t entry_length,
@@ -1333,11 +1336,8 @@ tsi_result tsi_create_ssl_client_handshaker_factory(
return TSI_INVALID_ARGUMENT;
}
- impl = calloc(1, sizeof(tsi_ssl_client_handshaker_factory));
- if (impl == NULL) {
- SSL_CTX_free(ssl_context);
- return TSI_OUT_OF_RESOURCES;
- }
+ impl = gpr_malloc(sizeof(*impl));
+ memset(impl, 0, sizeof(*impl));
impl->ssl_context = ssl_context;
do {
@@ -1398,6 +1398,26 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
const char *cipher_list, const unsigned char **alpn_protocols,
const unsigned char *alpn_protocols_lengths, uint16_t num_alpn_protocols,
tsi_ssl_handshaker_factory **factory) {
+ return tsi_create_ssl_server_handshaker_factory_ex(
+ pem_private_keys, pem_private_keys_sizes, pem_cert_chains,
+ pem_cert_chains_sizes, key_cert_pair_count, pem_client_root_certs,
+ pem_client_root_certs_size,
+ force_client_auth ? TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ : TSI_DONT_REQUEST_CLIENT_CERTIFICATE,
+ cipher_list, alpn_protocols, alpn_protocols_lengths, num_alpn_protocols,
+ factory);
+}
+
+tsi_result tsi_create_ssl_server_handshaker_factory_ex(
+ const unsigned char **pem_private_keys,
+ const size_t *pem_private_keys_sizes, const unsigned char **pem_cert_chains,
+ const size_t *pem_cert_chains_sizes, size_t key_cert_pair_count,
+ const unsigned char *pem_client_root_certs,
+ size_t pem_client_root_certs_size,
+ tsi_client_certificate_request_type client_certificate_request,
+ const char *cipher_list, const unsigned char **alpn_protocols,
+ const unsigned char *alpn_protocols_lengths, uint16_t num_alpn_protocols,
+ tsi_ssl_handshaker_factory **factory) {
tsi_ssl_server_handshaker_factory *impl = NULL;
tsi_result result = TSI_OK;
size_t i = 0;
@@ -1411,14 +1431,17 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
return TSI_INVALID_ARGUMENT;
}
- impl = calloc(1, sizeof(tsi_ssl_server_handshaker_factory));
- if (impl == NULL) return TSI_OUT_OF_RESOURCES;
+ impl = gpr_malloc(sizeof(*impl));
+ memset(impl, 0, sizeof(*impl));
impl->base.create_handshaker =
ssl_server_handshaker_factory_create_handshaker;
impl->base.destroy = ssl_server_handshaker_factory_destroy;
- impl->ssl_contexts = calloc(key_cert_pair_count, sizeof(SSL_CTX *));
+ impl->ssl_contexts = gpr_malloc(key_cert_pair_count * sizeof(SSL_CTX *));
+ memset(impl->ssl_contexts, 0, key_cert_pair_count * sizeof(SSL_CTX *));
impl->ssl_context_x509_subject_names =
- calloc(key_cert_pair_count, sizeof(tsi_peer));
+ gpr_malloc(key_cert_pair_count * sizeof(tsi_peer));
+ memset(impl->ssl_context_x509_subject_names, 0,
+ key_cert_pair_count * sizeof(tsi_peer));
if (impl->ssl_contexts == NULL ||
impl->ssl_context_x509_subject_names == NULL) {
tsi_ssl_handshaker_factory_destroy(&impl->base);
@@ -1450,7 +1473,6 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
if (result != TSI_OK) break;
if (pem_client_root_certs != NULL) {
- int flags = SSL_VERIFY_PEER;
STACK_OF(X509_NAME) *root_names = NULL;
result = ssl_ctx_load_verification_certs(
impl->ssl_contexts[i], pem_client_root_certs,
@@ -1460,8 +1482,29 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
break;
}
SSL_CTX_set_client_CA_list(impl->ssl_contexts[i], root_names);
- if (force_client_auth) flags |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
- SSL_CTX_set_verify(impl->ssl_contexts[i], flags, NULL);
+ switch (client_certificate_request) {
+ case TSI_DONT_REQUEST_CLIENT_CERTIFICATE:
+ SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_NONE, NULL);
+ break;
+ case TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
+ SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER,
+ NullVerifyCallback);
+ break;
+ case TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY:
+ SSL_CTX_set_verify(impl->ssl_contexts[i], SSL_VERIFY_PEER, NULL);
+ break;
+ case TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY:
+ SSL_CTX_set_verify(
+ impl->ssl_contexts[i],
+ SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
+ NullVerifyCallback);
+ break;
+ case TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY:
+ SSL_CTX_set_verify(
+ impl->ssl_contexts[i],
+ SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
+ break;
+ }
/* TODO(jboeuf): Add revocation verification. */
}
diff --git a/src/core/lib/tsi/ssl_transport_security.h b/src/core/lib/tsi/ssl_transport_security.h
index 211c8f9656..7407246118 100644
--- a/src/core/lib/tsi/ssl_transport_security.h
+++ b/src/core/lib/tsi/ssl_transport_security.h
@@ -142,6 +142,23 @@ tsi_result tsi_create_ssl_server_handshaker_factory(
const unsigned char *alpn_protocols_lengths, uint16_t num_alpn_protocols,
tsi_ssl_handshaker_factory **factory);
+/* Same as tsi_create_ssl_server_handshaker_factory method except uses
+ tsi_client_certificate_request_type to support more ways to handle client
+ certificate authentication.
+ - client_certificate_request, if set to non-zero will force the client to
+ authenticate with an SSL cert. Note that this option is ignored if
+ pem_client_root_certs is NULL or pem_client_roots_certs_size is 0 */
+tsi_result tsi_create_ssl_server_handshaker_factory_ex(
+ const unsigned char **pem_private_keys,
+ const size_t *pem_private_keys_sizes, const unsigned char **pem_cert_chains,
+ const size_t *pem_cert_chains_sizes, size_t key_cert_pair_count,
+ const unsigned char *pem_client_root_certs,
+ size_t pem_client_root_certs_size,
+ tsi_client_certificate_request_type client_certificate_request,
+ const char *cipher_suites, const unsigned char **alpn_protocols,
+ const unsigned char *alpn_protocols_lengths, uint16_t num_alpn_protocols,
+ tsi_ssl_handshaker_factory **factory);
+
/* Creates a handshaker.
- self is the factory from which the handshaker will be created.
- server_name_indication indicates the name of the server the client is
diff --git a/src/core/lib/tsi/transport_security.c b/src/core/lib/tsi/transport_security.c
index 861fc791bc..830cf09584 100644
--- a/src/core/lib/tsi/transport_security.c
+++ b/src/core/lib/tsi/transport_security.c
@@ -33,6 +33,9 @@
#include "src/core/lib/tsi/transport_security.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
+
#include <stdlib.h>
#include <string.h>
@@ -40,19 +43,6 @@
int tsi_tracing_enabled = 0;
-/* --- Utils. --- */
-
-char *tsi_strdup(const char *src) {
- char *dst;
- size_t len;
- if (!src) return NULL;
- len = strlen(src) + 1;
- dst = malloc(len);
- if (!dst) return NULL;
- memcpy(dst, src, len);
- return dst;
-}
-
/* --- tsi_result common implementation. --- */
const char *tsi_result_to_string(tsi_result result) {
@@ -214,15 +204,15 @@ static void tsi_peer_destroy_list_property(tsi_peer_property *children,
for (i = 0; i < child_count; i++) {
tsi_peer_property_destruct(&children[i]);
}
- free(children);
+ gpr_free(children);
}
void tsi_peer_property_destruct(tsi_peer_property *property) {
if (property->name != NULL) {
- free(property->name);
+ gpr_free(property->name);
}
if (property->value.data != NULL) {
- free(property->value.data);
+ gpr_free(property->value.data);
}
*property = tsi_init_peer_property(); /* Reset everything to 0. */
}
@@ -239,16 +229,10 @@ void tsi_peer_destruct(tsi_peer *self) {
tsi_result tsi_construct_allocated_string_peer_property(
const char *name, size_t value_length, tsi_peer_property *property) {
*property = tsi_init_peer_property();
- if (name != NULL) {
- property->name = tsi_strdup(name);
- if (property->name == NULL) return TSI_OUT_OF_RESOURCES;
- }
+ if (name != NULL) property->name = gpr_strdup(name);
if (value_length > 0) {
- property->value.data = calloc(1, value_length);
- if (property->value.data == NULL) {
- tsi_peer_property_destruct(property);
- return TSI_OUT_OF_RESOURCES;
- }
+ property->value.data = gpr_malloc(value_length);
+ memset(property->value.data, 0, value_length);
property->value.length = value_length;
}
return TSI_OK;
@@ -276,8 +260,8 @@ tsi_result tsi_construct_string_peer_property(const char *name,
tsi_result tsi_construct_peer(size_t property_count, tsi_peer *peer) {
memset(peer, 0, sizeof(tsi_peer));
if (property_count > 0) {
- peer->properties = calloc(property_count, sizeof(tsi_peer_property));
- if (peer->properties == NULL) return TSI_OUT_OF_RESOURCES;
+ peer->properties = gpr_malloc(property_count * sizeof(tsi_peer_property));
+ memset(peer->properties, 0, property_count * sizeof(tsi_peer_property));
peer->property_count = property_count;
}
return TSI_OK;
diff --git a/src/core/lib/tsi/transport_security_interface.h b/src/core/lib/tsi/transport_security_interface.h
index d81ec0963a..3e8c9d7ffe 100644
--- a/src/core/lib/tsi/transport_security_interface.h
+++ b/src/core/lib/tsi/transport_security_interface.h
@@ -59,6 +59,15 @@ typedef enum {
TSI_OUT_OF_RESOURCES = 12
} tsi_result;
+typedef enum {
+ // Default option
+ TSI_DONT_REQUEST_CLIENT_CERTIFICATE,
+ TSI_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY,
+ TSI_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY,
+ TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY,
+ TSI_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY,
+} tsi_client_certificate_request_type;
+
const char *tsi_result_to_string(tsi_result result);
/* --- tsi tracing --- */
diff --git a/src/core/plugin_registry/grpc_plugin_registry.c b/src/core/plugin_registry/grpc_plugin_registry.c
index 79df85516e..822aa6d8b7 100644
--- a/src/core/plugin_registry/grpc_plugin_registry.c
+++ b/src/core/plugin_registry/grpc_plugin_registry.c
@@ -33,6 +33,10 @@
#include <grpc/grpc.h>
+extern void grpc_chttp2_plugin_init(void);
+extern void grpc_chttp2_plugin_shutdown(void);
+extern void grpc_client_config_init(void);
+extern void grpc_client_config_shutdown(void);
extern void grpc_lb_policy_pick_first_init(void);
extern void grpc_lb_policy_pick_first_shutdown(void);
extern void grpc_lb_policy_round_robin_init(void);
@@ -45,6 +49,10 @@ extern void census_grpc_plugin_init(void);
extern void census_grpc_plugin_shutdown(void);
void grpc_register_built_in_plugins(void) {
+ grpc_register_plugin(grpc_chttp2_plugin_init,
+ grpc_chttp2_plugin_shutdown);
+ grpc_register_plugin(grpc_client_config_init,
+ grpc_client_config_shutdown);
grpc_register_plugin(grpc_lb_policy_pick_first_init,
grpc_lb_policy_pick_first_shutdown);
grpc_register_plugin(grpc_lb_policy_round_robin_init,
diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c
index b3786c927d..a6108ae7a9 100644
--- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c
+++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c
@@ -33,6 +33,10 @@
#include <grpc/grpc.h>
+extern void grpc_chttp2_plugin_init(void);
+extern void grpc_chttp2_plugin_shutdown(void);
+extern void grpc_client_config_init(void);
+extern void grpc_client_config_shutdown(void);
extern void grpc_resolver_dns_native_init(void);
extern void grpc_resolver_dns_native_shutdown(void);
extern void grpc_resolver_sockaddr_init(void);
@@ -45,6 +49,10 @@ extern void census_grpc_plugin_init(void);
extern void census_grpc_plugin_shutdown(void);
void grpc_register_built_in_plugins(void) {
+ grpc_register_plugin(grpc_chttp2_plugin_init,
+ grpc_chttp2_plugin_shutdown);
+ grpc_register_plugin(grpc_client_config_init,
+ grpc_client_config_shutdown);
grpc_register_plugin(grpc_resolver_dns_native_init,
grpc_resolver_dns_native_shutdown);
grpc_register_plugin(grpc_resolver_sockaddr_init,
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index c277d7ebe8..32c7794ade 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -42,7 +42,6 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/compress_filter.h"
-#include "src/cpp/common/create_auth_context.h"
namespace grpc {
@@ -116,13 +115,6 @@ void ClientContext::set_compression_algorithm(
AddMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name);
}
-std::shared_ptr<const AuthContext> ClientContext::auth_context() const {
- if (auth_context_.get() == nullptr) {
- auth_context_ = CreateAuthContext(call_);
- }
- return auth_context_;
-}
-
void ClientContext::TryCancel() {
grpc::unique_lock<grpc::mutex> lock(mu_);
if (call_) {
diff --git a/src/cpp/server/secure_server_credentials.cc b/src/cpp/server/secure_server_credentials.cc
index d472667a7e..33bdc2a1f4 100644
--- a/src/cpp/server/secure_server_credentials.cc
+++ b/src/cpp/server/secure_server_credentials.cc
@@ -130,10 +130,14 @@ std::shared_ptr<ServerCredentials> SslServerCredentials(
key_cert_pair->cert_chain.c_str()};
pem_key_cert_pairs.push_back(p);
}
- grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create(
+ grpc_server_credentials* c_creds = grpc_ssl_server_credentials_create_ex(
options.pem_root_certs.empty() ? nullptr : options.pem_root_certs.c_str(),
pem_key_cert_pairs.empty() ? nullptr : &pem_key_cert_pairs[0],
- pem_key_cert_pairs.size(), options.force_client_auth, nullptr);
+ pem_key_cert_pairs.size(),
+ options.force_client_auth
+ ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ : options.client_certificate_request,
+ nullptr);
return std::shared_ptr<ServerCredentials>(
new SecureServerCredentials(c_creds));
}
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index e05a7df28a..204fef1b09 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -44,7 +44,6 @@
#include "src/core/lib/channel/compress_filter.h"
#include "src/core/lib/surface/call.h"
-#include "src/cpp/common/create_auth_context.h"
namespace grpc {
@@ -214,18 +213,6 @@ void ServerContext::set_compression_algorithm(
AddInitialMetadata(GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, algorithm_name);
}
-void ServerContext::set_call(grpc_call* call) {
- call_ = call;
- auth_context_ = CreateAuthContext(call);
-}
-
-std::shared_ptr<const AuthContext> ServerContext::auth_context() const {
- if (auth_context_.get() == nullptr) {
- auth_context_ = CreateAuthContext(call_);
- }
- return auth_context_;
-}
-
grpc::string ServerContext::peer() const {
grpc::string peer;
if (call_) {
diff --git a/src/csharp/.nuget/packages.config b/src/csharp/.nuget/packages.config
index acb43ae4b3..6154b3561f 100644
--- a/src/csharp/.nuget/packages.config
+++ b/src/csharp/.nuget/packages.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="NUnit.Runners" version="2.6.4" />
+ <package id="NUnit.ConsoleRunner" version="3.2.0" />
<package id="OpenCover" version="4.6.519" />
<package id="ReportGenerator" version="2.4.4.0" />
</packages> \ No newline at end of file
diff --git a/src/csharp/Grpc.Core.Tests/ChannelTest.cs b/src/csharp/Grpc.Core.Tests/ChannelTest.cs
index ed0ec14df5..6330f50fae 100644
--- a/src/csharp/Grpc.Core.Tests/ChannelTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ChannelTest.cs
@@ -70,7 +70,7 @@ namespace Grpc.Core.Tests
public void WaitForStateChangedAsync_InvalidArgument()
{
var channel = new Channel("localhost", ChannelCredentials.Insecure);
- Assert.Throws(typeof(ArgumentException), () => channel.WaitForStateChangedAsync(ChannelState.FatalFailure));
+ Assert.ThrowsAsync(typeof(ArgumentException), async () => await channel.WaitForStateChangedAsync(ChannelState.FatalFailure));
channel.ShutdownAsync().Wait();
}
@@ -87,7 +87,7 @@ namespace Grpc.Core.Tests
{
var channel = new Channel("localhost", ChannelCredentials.Insecure);
channel.ShutdownAsync().Wait();
- Assert.Throws(typeof(InvalidOperationException), () => channel.ShutdownAsync().GetAwaiter().GetResult());
+ Assert.ThrowsAsync(typeof(InvalidOperationException), async () => await channel.ShutdownAsync());
}
}
}
diff --git a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
index 77f6a63156..6c13a4fa48 100644
--- a/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ClientServerTest.cs
@@ -93,7 +93,7 @@ namespace Grpc.Core.Tests
var ex = Assert.Throws<RpcException>(() => Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "abc"));
Assert.AreEqual(StatusCode.Unknown, ex.Status.StatusCode);
- var ex2 = Assert.Throws<RpcException>(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc"));
+ var ex2 = Assert.ThrowsAsync<RpcException>(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc"));
Assert.AreEqual(StatusCode.Unknown, ex2.Status.StatusCode);
}
@@ -108,7 +108,7 @@ namespace Grpc.Core.Tests
var ex = Assert.Throws<RpcException>(() => Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "abc"));
Assert.AreEqual(StatusCode.Unauthenticated, ex.Status.StatusCode);
- var ex2 = Assert.Throws<RpcException>(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc"));
+ var ex2 = Assert.ThrowsAsync<RpcException>(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc"));
Assert.AreEqual(StatusCode.Unauthenticated, ex2.Status.StatusCode);
}
@@ -124,7 +124,7 @@ namespace Grpc.Core.Tests
var ex = Assert.Throws<RpcException>(() => Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "abc"));
Assert.AreEqual(StatusCode.Unauthenticated, ex.Status.StatusCode);
- var ex2 = Assert.Throws<RpcException>(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc"));
+ var ex2 = Assert.ThrowsAsync<RpcException>(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "abc"));
Assert.AreEqual(StatusCode.Unauthenticated, ex2.Status.StatusCode);
}
@@ -204,7 +204,7 @@ namespace Grpc.Core.Tests
await barrier.Task; // make sure the handler has started.
cts.Cancel();
- var ex = Assert.Throws<RpcException>(async () => await call.ResponseAsync);
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseAsync);
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
}
@@ -290,7 +290,7 @@ namespace Grpc.Core.Tests
return request;
});
- Assert.Throws(typeof(TaskCanceledException),
+ Assert.ThrowsAsync(typeof(TaskCanceledException),
async () => await channel.WaitForStateChangedAsync(channel.State, DateTime.UtcNow.AddMilliseconds(10)));
var stateChangedTask = channel.WaitForStateChangedAsync(channel.State);
diff --git a/src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs b/src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs
index 90c510ec61..cec8c7ce6b 100644
--- a/src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ContextPropagationTest.cs
@@ -105,7 +105,7 @@ namespace Grpc.Core.Tests
var parentCall = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall(new CallOptions(cancellationToken: cts.Token)));
await readyToCancelTcs.Task;
cts.Cancel();
- Assert.Throws(typeof(RpcException), async () => await parentCall);
+ Assert.ThrowsAsync(typeof(RpcException), async () => await parentCall);
Assert.AreEqual("CHILD_CALL_CANCELLED", await successTcs.Task);
}
diff --git a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj
index 3bfd49b10f..0cd059c232 100644
--- a/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj
+++ b/src/csharp/Grpc.Core.Tests/Grpc.Core.Tests.csproj
@@ -4,7 +4,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{86EC5CB4-4EA2-40A2-8057-86542A0353BB}</ProjectGuid>
- <OutputType>Library</OutputType>
+ <OutputType>Exe</OutputType>
<RootNamespace>Grpc.Core.Tests</RootNamespace>
<AssemblyName>Grpc.Core.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
@@ -35,29 +35,18 @@
<AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
- <Reference Include="nunit.core">
- <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.dll</HintPath>
- <Private>False</Private>
- </Reference>
- <Reference Include="nunit.core.interfaces">
- <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.core.interfaces.dll</HintPath>
- <Private>False</Private>
- </Reference>
+ <Reference Include="System" />
<Reference Include="nunit.framework">
- <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
+ <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="nunit.util">
- <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\nunit.util.dll</HintPath>
- <Private>False</Private>
+ <Reference Include="System.Interactive.Async">
+ <HintPath>..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
- <Reference Include="NUnit.VisualStudio.TestAdapter">
- <HintPath>..\packages\NUnitTestAdapter.2.0.0\lib\NUnit.VisualStudio.TestAdapter.dll</HintPath>
- <Private>False</Private>
+ <Reference Include="nunitlite">
+ <HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath>
</Reference>
- <Reference Include="System" />
- <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
+ <Reference Include="Newtonsoft.Json">
+ <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -94,6 +83,7 @@
<Compile Include="PerformanceTest.cs" />
<Compile Include="SanityTest.cs" />
<Compile Include="HalfcloseTest.cs" />
+ <Compile Include="NUnitMain.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
diff --git a/src/csharp/Grpc.Core.Tests/HalfcloseTest.cs b/src/csharp/Grpc.Core.Tests/HalfcloseTest.cs
index fe6edb858b..b4cb451d94 100644
--- a/src/csharp/Grpc.Core.Tests/HalfcloseTest.cs
+++ b/src/csharp/Grpc.Core.Tests/HalfcloseTest.cs
@@ -91,7 +91,7 @@ namespace Grpc.Core.Tests
await call.RequestStream.CompleteAsync();
// Second attempt to close from client is not allowed.
- Assert.Throws(typeof(InvalidOperationException), async () => await call.RequestStream.CompleteAsync());
+ Assert.ThrowsAsync(typeof(InvalidOperationException), async () => await call.RequestStream.CompleteAsync());
}
}
}
diff --git a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
index 543f6375df..60530d3250 100644
--- a/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
+++ b/src/csharp/Grpc.Core.Tests/Internal/AsyncCallTest.cs
@@ -84,7 +84,7 @@ namespace Grpc.Core.Internal.Tests
Assert.AreEqual(StatusCode.Internal, asyncCall.GetStatus().StatusCode);
Assert.IsNull(asyncCall.GetTrailers());
- var ex = Assert.Throws<RpcException>(() => resultTask.GetAwaiter().GetResult());
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await resultTask);
Assert.AreEqual(StatusCode.Internal, ex.Status.StatusCode);
}
diff --git a/src/csharp/Grpc.Core.Tests/MarshallingErrorsTest.cs b/src/csharp/Grpc.Core.Tests/MarshallingErrorsTest.cs
index 37fb36946a..0663e77d1e 100644
--- a/src/csharp/Grpc.Core.Tests/MarshallingErrorsTest.cs
+++ b/src/csharp/Grpc.Core.Tests/MarshallingErrorsTest.cs
@@ -112,7 +112,7 @@ namespace Grpc.Core.Tests
});
var call = Calls.AsyncServerStreamingCall(helper.CreateServerStreamingCall(), "REQUEST");
- var ex = Assert.Throws<RpcException>(async () => await call.ResponseStream.MoveNext());
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.MoveNext());
Assert.AreEqual(StatusCode.Internal, ex.Status.StatusCode);
}
@@ -134,7 +134,7 @@ namespace Grpc.Core.Tests
{
helper.ClientStreamingHandler = new ClientStreamingServerMethod<string, string>(async (requestStream, context) =>
{
- Assert.Throws<IOException>(async () => await requestStream.MoveNext());
+ Assert.ThrowsAsync<IOException>(async () => await requestStream.MoveNext());
return "RESPONSE";
});
@@ -153,7 +153,7 @@ namespace Grpc.Core.Tests
[Test]
public void RequestSerializationError_AsyncUnary()
{
- Assert.Throws<IOException>(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "UNSERIALIZABLE_VALUE"));
+ Assert.ThrowsAsync<IOException>(async () => await Calls.AsyncUnaryCall(helper.CreateUnaryCall(), "UNSERIALIZABLE_VALUE"));
}
[Test]
@@ -166,7 +166,7 @@ namespace Grpc.Core.Tests
});
var call = Calls.AsyncClientStreamingCall(helper.CreateClientStreamingCall());
await call.RequestStream.WriteAsync("A");
- Assert.Throws<IOException>(async () => await call.RequestStream.WriteAsync("UNSERIALIZABLE_VALUE"));
+ Assert.ThrowsAsync<IOException>(async () => await call.RequestStream.WriteAsync("UNSERIALIZABLE_VALUE"));
await call.RequestStream.WriteAsync("B");
await call.RequestStream.CompleteAsync();
diff --git a/src/csharp/Grpc.Core.Tests/NUnitMain.cs b/src/csharp/Grpc.Core.Tests/NUnitMain.cs
new file mode 100644
index 0000000000..9c1d7bf3c8
--- /dev/null
+++ b/src/csharp/Grpc.Core.Tests/NUnitMain.cs
@@ -0,0 +1,59 @@
+#region Copyright notice and license
+
+// Copyright 2016, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#endregion
+
+using System;
+using System.Reflection;
+using Grpc.Core;
+using Grpc.Core.Logging;
+using NUnit.Common;
+using NUnitLite;
+
+namespace Grpc.Core.Tests
+{
+ /// <summary>
+ /// Provides entry point for NUnitLite
+ /// </summary>
+ public class NUnitMain
+ {
+ public static int Main(string[] args)
+ {
+ // Make logger immune to NUnit capturing stdout and stderr to workaround https://github.com/nunit/nunit/issues/1406.
+ GrpcEnvironment.SetLogger(new TextWriterLogger(Console.Error));
+#if DOTNET5_4
+ return new AutoRun(typeof(NUnitMain).GetTypeInfo().Assembly).Execute(args, new ExtendedTextWrapper(Console.Out), Console.In);
+#else
+ return new AutoRun().Execute(args);
+#endif
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Core.Tests/ResponseHeadersTest.cs b/src/csharp/Grpc.Core.Tests/ResponseHeadersTest.cs
index a1648f3671..772beadd4a 100644
--- a/src/csharp/Grpc.Core.Tests/ResponseHeadersTest.cs
+++ b/src/csharp/Grpc.Core.Tests/ResponseHeadersTest.cs
@@ -155,7 +155,7 @@ namespace Grpc.Core.Tests
{
helper.UnaryHandler = new UnaryServerMethod<string, string>(async (request, context) =>
{
- Assert.Throws(typeof(ArgumentNullException), async () => await context.WriteResponseHeadersAsync(null));
+ Assert.ThrowsAsync(typeof(ArgumentNullException), async () => await context.WriteResponseHeadersAsync(null));
return "PASS";
});
diff --git a/src/csharp/Grpc.Core.Tests/SanityTest.cs b/src/csharp/Grpc.Core.Tests/SanityTest.cs
index 343ab1e85a..3830f0cbac 100644
--- a/src/csharp/Grpc.Core.Tests/SanityTest.cs
+++ b/src/csharp/Grpc.Core.Tests/SanityTest.cs
@@ -38,6 +38,7 @@ using System.Reflection;
using Grpc.Core;
using Grpc.Core.Internal;
using Grpc.Core.Utils;
+using Newtonsoft.Json;
using NUnit.Framework;
namespace Grpc.Core.Tests
@@ -55,27 +56,23 @@ namespace Grpc.Core.Tests
[Test]
public void TestsJsonUpToDate()
{
- var testClasses = DiscoverAllTestClasses();
- string testsJson = GetTestsJson();
+ var discoveredTests = DiscoverAllTestClasses();
+ string discoveredTestsJson = JsonConvert.SerializeObject(discoveredTests, Formatting.Indented);
- // we don't have a JSON parser at hand, but check that the test class
- // name is contained in the file instead.
- foreach (var className in testClasses) {
- Assert.IsTrue(testsJson.Contains(className),
- string.Format("Test class \"{0}\" is missing in C# tests.json file", className));
- }
+ Assert.AreEqual(discoveredTestsJson, ReadTestsJson());
}
/// <summary>
/// Gets list of all test classes obtained by inspecting all the test assemblies.
/// </summary>
- private List<string> DiscoverAllTestClasses()
+ private Dictionary<string, List<string>> DiscoverAllTestClasses()
{
var assemblies = GetTestAssemblies();
- var testClasses = new List<string>();
+ var testsByAssembly = new Dictionary<string, List<string>>();
foreach (var assembly in assemblies)
{
+ var testClasses = new List<string>();
foreach (var t in assembly.GetTypes())
{
foreach (var m in t.GetMethods())
@@ -89,16 +86,19 @@ namespace Grpc.Core.Tests
}
}
+ testClasses.Sort();
+ testsByAssembly.Add(assembly.GetName().Name, testClasses);
}
- testClasses.Sort();
- return testClasses;
+ return testsByAssembly;
}
- private string GetTestsJson()
+ /// <summary>
+ /// Reads contents of tests.json file.
+ /// </summary>
+ private string ReadTestsJson()
{
var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var testsJsonFile = Path.Combine(assemblyDir, "..", "..", "..", "tests.json");
-
return File.ReadAllText(testsJsonFile);
}
diff --git a/src/csharp/Grpc.Core.Tests/packages.config b/src/csharp/Grpc.Core.Tests/packages.config
index 610831dfe1..aa7d951fdc 100644
--- a/src/csharp/Grpc.Core.Tests/packages.config
+++ b/src/csharp/Grpc.Core.Tests/packages.config
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Ix-Async" version="1.2.5" targetFramework="net45" />
- <package id="NUnit" version="2.6.4" targetFramework="net45" />
- <package id="NUnitTestAdapter" version="2.0.0" targetFramework="net45" />
+ <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
+ <package id="NUnit" version="3.2.0" targetFramework="net45" />
+ <package id="NUnitLite" version="3.2.0" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj
index 251a688946..95077a6ca5 100644
--- a/src/csharp/Grpc.Core/Grpc.Core.csproj
+++ b/src/csharp/Grpc.Core/Grpc.Core.csproj
@@ -58,6 +58,7 @@
<Compile Include="IServerStreamWriter.cs" />
<Compile Include="IAsyncStreamWriter.cs" />
<Compile Include="IAsyncStreamReader.cs" />
+ <Compile Include="Logging\TextWriterLogger.cs" />
<Compile Include="Logging\NullLogger.cs" />
<Compile Include="ServerPort.cs" />
<Compile Include="Version.cs" />
@@ -140,9 +141,7 @@
</ItemGroup>
<Import Project="NativeDeps.targets" />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <ItemGroup>
- <Folder Include="Resources\" />
- </ItemGroup>
+ <ItemGroup />
<ItemGroup>
<EmbeddedResource Include="..\..\..\etc\roots.pem">
<Link>Resources\roots.pem</Link>
diff --git a/src/csharp/Grpc.Core/Grpc.Core.nuspec b/src/csharp/Grpc.Core/Grpc.Core.nuspec
index 49bccb050e..0ada0049c2 100644
--- a/src/csharp/Grpc.Core/Grpc.Core.nuspec
+++ b/src/csharp/Grpc.Core/Grpc.Core.nuspec
@@ -16,7 +16,6 @@
<tags>gRPC RPC Protocol HTTP/2</tags>
<dependencies>
<dependency id="Ix-Async" version="1.2.5" />
- <dependency id="grpc.native.csharp" version="$version$" />
</dependencies>
</metadata>
<files>
@@ -24,5 +23,12 @@
<file src="bin/ReleaseSigned/Grpc.Core.pdb" target="lib/net45" />
<file src="bin/ReleaseSigned/Grpc.Core.xml" target="lib/net45" />
<file src="**\*.cs" target="src" />
+ <file src="Grpc.Core.targets" target="\build\net45\Grpc.Core.targets" />
+ <file src="windows_x86/grpc_csharp_ext.dll" target="/build/native/bin/windows_x86/grpc_csharp_ext.dll" />
+ <file src="windows_x64/grpc_csharp_ext.dll" target="/build/native/bin/windows_x64/grpc_csharp_ext.dll" />
+ <file src="linux_x86/libgrpc_csharp_ext.so" target="/build/native/bin/linux_x86/libgrpc_csharp_ext.so" />
+ <file src="linux_x64/libgrpc_csharp_ext.so" target="/build/native/bin/linux_x64/libgrpc_csharp_ext.so" />
+ <file src="macosx_x86/libgrpc_csharp_ext.dylib" target="/build/native/bin/macosx_x86/libgrpc_csharp_ext.dylib" />
+ <file src="macosx_x64/libgrpc_csharp_ext.dylib" target="/build/native/bin/macosx_x64/libgrpc_csharp_ext.dylib" />
</files>
</package>
diff --git a/src/csharp/grpc.native.csharp/grpc.native.csharp.targets b/src/csharp/Grpc.Core/Grpc.Core.targets
index 501fc50548..501fc50548 100644
--- a/src/csharp/grpc.native.csharp/grpc.native.csharp.targets
+++ b/src/csharp/Grpc.Core/Grpc.Core.targets
diff --git a/src/csharp/Grpc.Core/Internal/NativeExtension.cs b/src/csharp/Grpc.Core/Internal/NativeExtension.cs
index bff1e56582..b45ba19c24 100644
--- a/src/csharp/Grpc.Core/Internal/NativeExtension.cs
+++ b/src/csharp/Grpc.Core/Internal/NativeExtension.cs
@@ -32,7 +32,6 @@
#endregion
using System;
-using System.Globalization;
using System.IO;
using System.Reflection;
@@ -46,6 +45,7 @@ namespace Grpc.Core.Internal
internal sealed class NativeExtension
{
const string NativeLibrariesDir = "nativelibs";
+ const string DnxStyleNativeLibrariesDir = "../../build/native/bin/";
static readonly ILogger Logger = GrpcEnvironment.Logger.ForType<NativeExtension>();
static readonly object staticLock = new object();
@@ -100,31 +100,48 @@ namespace Grpc.Core.Internal
// TODO: allow customizing path to native extension (possibly through exposing a GrpcEnvironment property).
var libraryFlavor = string.Format("{0}_{1}", GetPlatformString(), GetArchitectureString());
- var fullPath = Path.Combine(Path.GetDirectoryName(GetAssemblyPath()),
- NativeLibrariesDir, libraryFlavor, GetNativeLibraryFilename());
- return new UnmanagedLibrary(fullPath);
+
+ var assemblyDirectory = Path.GetDirectoryName(GetAssemblyPath());
+
+ // With old-style VS projects, the native libraries get copied using a .targets rule to the build output folder
+ // alongside the compiled assembly.
+ var classicPath = Path.Combine(assemblyDirectory, NativeLibrariesDir, libraryFlavor, GetNativeLibraryFilename());
+
+ // DNX-style project.json projects will use Grpc.Core assembly directly in the location where it got restored
+ // by nuget. We locate the native libraries based on known structure of Grpc.Core nuget package.
+ var dnxStylePath = Path.Combine(assemblyDirectory, DnxStyleNativeLibrariesDir, libraryFlavor, GetNativeLibraryFilename());
+
+ return new UnmanagedLibrary(new string[] {classicPath, dnxStylePath});
}
private static string GetAssemblyPath()
{
var assembly = typeof(NativeExtension).GetTypeInfo().Assembly;
-
+#if DOTNET5_4
+ // Assembly.EscapedCodeBase does not exit under CoreCLR, but assemblies imported from a nuget package
+ // don't seem to be shadowed by DNX-based projects at all.
+ return assembly.Location;
+#else
// If assembly is shadowed (e.g. in a webapp), EscapedCodeBase is pointing
// to the original location of the assembly, and Location is pointing
// to the shadow copy. We care about the original location because
// the native dlls don't get shadowed.
+
var escapedCodeBase = assembly.EscapedCodeBase;
if (IsFileUri(escapedCodeBase))
{
return new Uri(escapedCodeBase).LocalPath;
}
return assembly.Location;
+#endif
}
+#if !DOTNET5_4
private static bool IsFileUri(string uri)
{
return uri.ToLowerInvariant().StartsWith(Uri.UriSchemeFile);
}
+#endif
private static string GetPlatformString()
{
diff --git a/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs b/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
index 0e4d9070d3..26af6311d5 100644
--- a/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
+++ b/src/csharp/Grpc.Core/Internal/NativeMetadataCredentialsPlugin.cs
@@ -87,7 +87,7 @@ namespace Grpc.Core.Internal
}
}
- private async void StartGetMetadata(AuthInterceptorContext context, IntPtr callbackPtr, IntPtr userDataPtr)
+ private async Task StartGetMetadata(AuthInterceptorContext context, IntPtr callbackPtr, IntPtr userDataPtr)
{
try
{
diff --git a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
index 47308f8c9e..5a80746101 100644
--- a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
+++ b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs
@@ -32,8 +32,6 @@
#endregion
using System;
-using System.Collections.Concurrent;
-using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -63,14 +61,9 @@ namespace Grpc.Core.Internal
readonly string libraryPath;
readonly IntPtr handle;
- public UnmanagedLibrary(string libraryPath)
+ public UnmanagedLibrary(string[] libraryPathAlternatives)
{
- this.libraryPath = GrpcPreconditions.CheckNotNull(libraryPath);
-
- if (!File.Exists(this.libraryPath))
- {
- throw new FileNotFoundException("Error loading native library. File does not exist.", this.libraryPath);
- }
+ this.libraryPath = FirstValidLibraryPath(libraryPathAlternatives);
Logger.Debug("Attempting to load native library \"{0}\"", this.libraryPath);
@@ -139,6 +132,19 @@ namespace Grpc.Core.Internal
throw new InvalidOperationException("Unsupported platform.");
}
+ private static string FirstValidLibraryPath(string[] libraryPathAlternatives)
+ {
+ GrpcPreconditions.CheckArgument(libraryPathAlternatives.Length > 0, "libraryPathAlternatives cannot be empty.");
+ foreach (var path in libraryPathAlternatives)
+ {
+ if (File.Exists(path))
+ {
+ return path;
+ }
+ }
+ throw new FileNotFoundException(String.Format("Error loading native library. Not found in any of the possible locations {0}", libraryPathAlternatives));
+ }
+
private static class Windows
{
[DllImport("kernel32.dll")]
diff --git a/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs b/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs
index da74e55a95..5e8dced641 100644
--- a/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs
+++ b/src/csharp/Grpc.Core/Logging/ConsoleLogger.cs
@@ -38,117 +38,28 @@ using System.Globalization;
namespace Grpc.Core.Logging
{
/// <summary>Logger that logs to System.Console.</summary>
- public class ConsoleLogger : ILogger
+ public class ConsoleLogger : TextWriterLogger
{
- // Format similar enough to C core log format except nanosecond precision is not supported.
- const string DateTimeFormatString = "MMdd HH:mm:ss.ffffff";
-
- readonly Type forType;
- readonly string forTypeString;
-
/// <summary>Creates a console logger not associated to any specific type.</summary>
public ConsoleLogger() : this(null)
{
}
/// <summary>Creates a console logger that logs messsage specific for given type.</summary>
- private ConsoleLogger(Type forType)
+ private ConsoleLogger(Type forType) : base(() => Console.Error, forType)
{
- this.forType = forType;
- if (forType != null)
- {
- var namespaceStr = forType.Namespace ?? "";
- if (namespaceStr.Length > 0)
- {
- namespaceStr += ".";
- }
- this.forTypeString = namespaceStr + forType.Name + " ";
- }
- else
- {
- this.forTypeString = "";
- }
}
/// <summary>
/// Returns a logger associated with the specified type.
/// </summary>
- public ILogger ForType<T>()
+ public override ILogger ForType<T>()
{
- if (typeof(T) == forType)
+ if (typeof(T) == AssociatedType)
{
return this;
}
return new ConsoleLogger(typeof(T));
}
-
- /// <summary>Logs a message with severity Debug.</summary>
- public void Debug(string message)
- {
- Log("D", message);
- }
-
- /// <summary>Logs a formatted message with severity Debug.</summary>
- public void Debug(string format, params object[] formatArgs)
- {
- Debug(string.Format(format, formatArgs));
- }
-
- /// <summary>Logs a message with severity Info.</summary>
- public void Info(string message)
- {
- Log("I", message);
- }
-
- /// <summary>Logs a formatted message with severity Info.</summary>
- public void Info(string format, params object[] formatArgs)
- {
- Info(string.Format(format, formatArgs));
- }
-
- /// <summary>Logs a message with severity Warning.</summary>
- public void Warning(string message)
- {
- Log("W", message);
- }
-
- /// <summary>Logs a formatted message with severity Warning.</summary>
- public void Warning(string format, params object[] formatArgs)
- {
- Warning(string.Format(format, formatArgs));
- }
-
- /// <summary>Logs a message and an associated exception with severity Warning.</summary>
- public void Warning(Exception exception, string message)
- {
- Warning(message + " " + exception);
- }
-
- /// <summary>Logs a message with severity Error.</summary>
- public void Error(string message)
- {
- Log("E", message);
- }
-
- /// <summary>Logs a formatted message with severity Error.</summary>
- public void Error(string format, params object[] formatArgs)
- {
- Error(string.Format(format, formatArgs));
- }
-
- /// <summary>Logs a message and an associated exception with severity Error.</summary>
- public void Error(Exception exception, string message)
- {
- Error(message + " " + exception);
- }
-
- private void Log(string severityString, string message)
- {
- Console.Error.WriteLine("{0}{1} {2}{3}",
- severityString,
- DateTime.Now.ToString(DateTimeFormatString, CultureInfo.InvariantCulture),
- forTypeString,
- message);
- }
}
}
diff --git a/src/csharp/Grpc.Core/Logging/TextWriterLogger.cs b/src/csharp/Grpc.Core/Logging/TextWriterLogger.cs
new file mode 100644
index 0000000000..397320ddff
--- /dev/null
+++ b/src/csharp/Grpc.Core/Logging/TextWriterLogger.cs
@@ -0,0 +1,176 @@
+#region Copyright notice and license
+
+// Copyright 2015, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using Grpc.Core.Utils;
+
+namespace Grpc.Core.Logging
+{
+ /// <summary>Logger that logs to an arbitrary <c>System.IO.TextWriter</c>.</summary>
+ public class TextWriterLogger : ILogger
+ {
+ // Format similar enough to C core log format except nanosecond precision is not supported.
+ const string DateTimeFormatString = "MMdd HH:mm:ss.ffffff";
+
+ readonly Func<TextWriter> textWriterProvider;
+ readonly Type forType;
+ readonly string forTypeString;
+
+ /// <summary>
+ /// Creates a console logger not associated to any specific type and writes to given <c>System.IO.TextWriter</c>.
+ /// User is responsible for providing an instance of TextWriter that is thread-safe.
+ /// </summary>
+ public TextWriterLogger(TextWriter textWriter) : this(() => textWriter)
+ {
+ GrpcPreconditions.CheckNotNull(textWriter);
+ }
+
+ /// <summary>
+ /// Creates a console logger not associated to any specific type and writes to a <c>System.IO.TextWriter</c> obtained from given provider.
+ /// User is responsible for providing an instance of TextWriter that is thread-safe.
+ /// </summary>
+ public TextWriterLogger(Func<TextWriter> textWriterProvider) : this(textWriterProvider, null)
+ {
+ }
+
+ /// <summary>Creates a console logger that logs messsage specific for given type.</summary>
+ protected TextWriterLogger(Func<TextWriter> textWriterProvider, Type forType)
+ {
+ this.textWriterProvider = GrpcPreconditions.CheckNotNull(textWriterProvider);
+ this.forType = forType;
+ if (forType != null)
+ {
+ var namespaceStr = forType.Namespace ?? "";
+ if (namespaceStr.Length > 0)
+ {
+ namespaceStr += ".";
+ }
+ this.forTypeString = namespaceStr + forType.Name + " ";
+ }
+ else
+ {
+ this.forTypeString = "";
+ }
+ }
+
+ /// <summary>
+ /// Returns a logger associated with the specified type.
+ /// </summary>
+ public virtual ILogger ForType<T>()
+ {
+ if (typeof(T) == forType)
+ {
+ return this;
+ }
+ return new TextWriterLogger(this.textWriterProvider, typeof(T));
+ }
+
+ /// <summary>Logs a message with severity Debug.</summary>
+ public void Debug(string message)
+ {
+ Log("D", message);
+ }
+
+ /// <summary>Logs a formatted message with severity Debug.</summary>
+ public void Debug(string format, params object[] formatArgs)
+ {
+ Debug(string.Format(format, formatArgs));
+ }
+
+ /// <summary>Logs a message with severity Info.</summary>
+ public void Info(string message)
+ {
+ Log("I", message);
+ }
+
+ /// <summary>Logs a formatted message with severity Info.</summary>
+ public void Info(string format, params object[] formatArgs)
+ {
+ Info(string.Format(format, formatArgs));
+ }
+
+ /// <summary>Logs a message with severity Warning.</summary>
+ public void Warning(string message)
+ {
+ Log("W", message);
+ }
+
+ /// <summary>Logs a formatted message with severity Warning.</summary>
+ public void Warning(string format, params object[] formatArgs)
+ {
+ Warning(string.Format(format, formatArgs));
+ }
+
+ /// <summary>Logs a message and an associated exception with severity Warning.</summary>
+ public void Warning(Exception exception, string message)
+ {
+ Warning(message + " " + exception);
+ }
+
+ /// <summary>Logs a message with severity Error.</summary>
+ public void Error(string message)
+ {
+ Log("E", message);
+ }
+
+ /// <summary>Logs a formatted message with severity Error.</summary>
+ public void Error(string format, params object[] formatArgs)
+ {
+ Error(string.Format(format, formatArgs));
+ }
+
+ /// <summary>Logs a message and an associated exception with severity Error.</summary>
+ public void Error(Exception exception, string message)
+ {
+ Error(message + " " + exception);
+ }
+
+ /// <summary>Gets the type associated with this logger.</summary>
+ protected Type AssociatedType
+ {
+ get { return forType; }
+ }
+
+ private void Log(string severityString, string message)
+ {
+ textWriterProvider().WriteLine("{0}{1} {2}{3}",
+ severityString,
+ DateTime.Now.ToString(DateTimeFormatString, CultureInfo.InvariantCulture),
+ forTypeString,
+ message);
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj b/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj
index 9aeab059f9..cfe668b6be 100644
--- a/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj
+++ b/src/csharp/Grpc.Examples.Tests/Grpc.Examples.Tests.csproj
@@ -3,10 +3,8 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>10.0.0</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{143B1C29-C442-4BE0-BF3F-A8F92288AC9F}</ProjectGuid>
- <OutputType>Library</OutputType>
+ <OutputType>Exe</OutputType>
<RootNamespace>Grpc.Examples.Tests</RootNamespace>
<AssemblyName>Grpc.Examples.Tests</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
@@ -37,18 +35,19 @@
<AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="System" />
+ <Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
- <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
+ <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="System" />
- <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
+ <Reference Include="nunitlite">
+ <HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs">
@@ -56,6 +55,7 @@
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="MathClientServerTests.cs" />
+ <Compile Include="NUnitMain.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
diff --git a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
index 290d42808e..875202b950 100644
--- a/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
+++ b/src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
@@ -149,7 +149,7 @@ namespace Math.Tests
using (var call = client.Fib(new FibArgs { Limit = 0 },
deadline: DateTime.UtcNow.AddMilliseconds(500)))
{
- var ex = Assert.Throws<RpcException>(async () => await call.ResponseStream.ToListAsync());
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.ToListAsync());
// We can't guarantee the status code always DeadlineExceeded. See issue #2685.
Assert.Contains(ex.Status.StatusCode, new[] { StatusCode.DeadlineExceeded, StatusCode.Internal });
diff --git a/src/csharp/Grpc.Examples.Tests/NUnitMain.cs b/src/csharp/Grpc.Examples.Tests/NUnitMain.cs
new file mode 100644
index 0000000000..ea87802766
--- /dev/null
+++ b/src/csharp/Grpc.Examples.Tests/NUnitMain.cs
@@ -0,0 +1,59 @@
+#region Copyright notice and license
+
+// Copyright 2016, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#endregion
+
+using System;
+using System.Reflection;
+using Grpc.Core;
+using Grpc.Core.Logging;
+using NUnit.Common;
+using NUnitLite;
+
+namespace Grpc.Examples.Tests
+{
+ /// <summary>
+ /// Provides entry point for NUnitLite
+ /// </summary>
+ public class NUnitMain
+ {
+ public static int Main(string[] args)
+ {
+ // Make logger immune to NUnit capturing stdout and stderr to workaround https://github.com/nunit/nunit/issues/1406.
+ GrpcEnvironment.SetLogger(new TextWriterLogger(Console.Error));
+#if DOTNET5_4
+ return new AutoRun(typeof(NUnitMain).GetTypeInfo().Assembly).Execute(args, new ExtendedTextWrapper(Console.Out), Console.In);
+#else
+ return new AutoRun().Execute(args);
+#endif
+ }
+ }
+}
diff --git a/src/csharp/Grpc.Examples.Tests/packages.config b/src/csharp/Grpc.Examples.Tests/packages.config
index ed30d2d428..ce030f9d77 100644
--- a/src/csharp/Grpc.Examples.Tests/packages.config
+++ b/src/csharp/Grpc.Examples.Tests/packages.config
@@ -1,6 +1,7 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
- <package id="Ix-Async" version="1.2.5" targetFramework="net45" />
- <package id="NUnit" version="2.6.4" targetFramework="net45" />
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
+ <package id="Ix-Async" version="1.2.5" targetFramework="net45" />
+ <package id="NUnit" version="3.2.0" targetFramework="net45" />
+ <package id="NUnitLite" version="3.2.0" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/src/csharp/Grpc.Examples/Grpc.Examples.csproj b/src/csharp/Grpc.Examples/Grpc.Examples.csproj
index 15b04c8d8b..f0a0aa3a26 100644
--- a/src/csharp/Grpc.Examples/Grpc.Examples.csproj
+++ b/src/csharp/Grpc.Examples/Grpc.Examples.csproj
@@ -41,6 +41,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Data.Linq" />
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
diff --git a/src/csharp/Grpc.Examples/packages.config b/src/csharp/Grpc.Examples/packages.config
index dfb8304ad1..a424cd2ea0 100644
--- a/src/csharp/Grpc.Examples/packages.config
+++ b/src/csharp/Grpc.Examples/packages.config
@@ -2,5 +2,5 @@
<packages>
<package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
<package id="Ix-Async" version="1.2.5" targetFramework="net45" />
- <package id="NUnit" version="2.6.4" targetFramework="net45" />
+ <package id="NUnit" version="3.2.0" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj b/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj
index bb6488b4f1..0bea9c03e7 100644
--- a/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj
+++ b/src/csharp/Grpc.HealthCheck.Tests/Grpc.HealthCheck.Tests.csproj
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F8C6D937-C44B-4EE3-A431-B0FBAEACE47D}</ProjectGuid>
- <OutputType>Library</OutputType>
+ <OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Grpc.HealthCheck.Tests</RootNamespace>
<AssemblyName>Grpc.HealthCheck.Tests</AssemblyName>
@@ -37,13 +37,6 @@
<AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
- <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
- </Reference>
- <Reference Include="nunit.framework">
- <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -51,6 +44,15 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
+ <Reference Include="Google.Protobuf">
+ <HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
+ </Reference>
+ <Reference Include="nunit.framework">
+ <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath>
+ </Reference>
+ <Reference Include="nunitlite">
+ <HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs">
@@ -59,14 +61,15 @@
<Compile Include="HealthServiceImplTest.cs" />
<Compile Include="HealthClientServerTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="NUnitMain.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Grpc.Core\Grpc.Core.csproj">
- <Project>{ccc4440e-49f7-4790-b0af-feabb0837ae7}</Project>
+ <Project>{CCC4440E-49F7-4790-B0AF-FEABB0837AE7}</Project>
<Name>Grpc.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Grpc.HealthCheck\Grpc.HealthCheck.csproj">
- <Project>{aa5e328a-8835-49d7-98ed-c29f2b3049f0}</Project>
+ <Project>{AA5E328A-8835-49D7-98ED-C29F2B3049F0}</Project>
<Name>Grpc.HealthCheck</Name>
</ProjectReference>
</ItemGroup>
diff --git a/src/csharp/Grpc.HealthCheck.Tests/NUnitMain.cs b/src/csharp/Grpc.HealthCheck.Tests/NUnitMain.cs
new file mode 100644
index 0000000000..0820523f35
--- /dev/null
+++ b/src/csharp/Grpc.HealthCheck.Tests/NUnitMain.cs
@@ -0,0 +1,59 @@
+#region Copyright notice and license
+
+// Copyright 2016, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#endregion
+
+using System;
+using System.Reflection;
+using Grpc.Core;
+using Grpc.Core.Logging;
+using NUnit.Common;
+using NUnitLite;
+
+namespace Grpc.HealthCheck.Tests
+{
+ /// <summary>
+ /// Provides entry point for NUnitLite
+ /// </summary>
+ public class NUnitMain
+ {
+ public static int Main(string[] args)
+ {
+ // Make logger immune to NUnit capturing stdout and stderr to workaround https://github.com/nunit/nunit/issues/1406.
+ GrpcEnvironment.SetLogger(new TextWriterLogger(Console.Error));
+#if DOTNET5_4
+ return new AutoRun(typeof(NUnitMain).GetTypeInfo().Assembly).Execute(args, new ExtendedTextWrapper(Console.Out), Console.In);
+#else
+ return new AutoRun().Execute(args);
+#endif
+ }
+ }
+}
diff --git a/src/csharp/Grpc.HealthCheck.Tests/packages.config b/src/csharp/Grpc.HealthCheck.Tests/packages.config
index 4728093979..8066d8fceb 100644
--- a/src/csharp/Grpc.HealthCheck.Tests/packages.config
+++ b/src/csharp/Grpc.HealthCheck.Tests/packages.config
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.Protobuf" version="3.0.0-beta2" targetFramework="net45" />
- <package id="NUnit" version="2.6.4" targetFramework="net45" />
+ <package id="NUnit" version="3.2.0" targetFramework="net45" />
+ <package id="NUnitLite" version="3.2.0" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
index f954ca5f34..b4572756f2 100644
--- a/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
+++ b/src/csharp/Grpc.IntegrationTesting/ClientRunners.cs
@@ -129,6 +129,7 @@ namespace Grpc.IntegrationTesting
public ClientRunnerImpl(List<Channel> channels, ClientType clientType, RpcType rpcType, int outstandingRpcsPerChannel, LoadParams loadParams, PayloadConfig payloadConfig, HistogramParams histogramParams)
{
GrpcPreconditions.CheckArgument(outstandingRpcsPerChannel > 0, "outstandingRpcsPerChannel");
+ GrpcPreconditions.CheckNotNull(histogramParams, "histogramParams");
this.channels = new List<Channel>(channels);
this.clientType = clientType;
this.rpcType = rpcType;
diff --git a/src/csharp/Grpc.IntegrationTesting/Control.cs b/src/csharp/Grpc.IntegrationTesting/Control.cs
index 291bc75397..003d2428fa 100644
--- a/src/csharp/Grpc.IntegrationTesting/Control.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Control.cs
@@ -26,58 +26,67 @@ namespace Grpc.Testing {
"CiRzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL2NvbnRyb2wucHJvdG8SDGdycGMu",
"dGVzdGluZxolc3JjL3Byb3RvL2dycGMvdGVzdGluZy9wYXlsb2Fkcy5wcm90",
"bxoic3JjL3Byb3RvL2dycGMvdGVzdGluZy9zdGF0cy5wcm90byIlCg1Qb2lz",
- "c29uUGFyYW1zEhQKDG9mZmVyZWRfbG9hZBgBIAEoASJBCg1Vbmlmb3JtUGFy",
- "YW1zEhcKD2ludGVyYXJyaXZhbF9sbxgBIAEoARIXCg9pbnRlcmFycml2YWxf",
- "aGkYAiABKAEiKwoTRGV0ZXJtaW5pc3RpY1BhcmFtcxIUCgxvZmZlcmVkX2xv",
- "YWQYASABKAEiOAoMUGFyZXRvUGFyYW1zEhkKEWludGVyYXJyaXZhbF9iYXNl",
- "GAEgASgBEg0KBWFscGhhGAIgASgBIhIKEENsb3NlZExvb3BQYXJhbXMijgIK",
- "CkxvYWRQYXJhbXMSNQoLY2xvc2VkX2xvb3AYASABKAsyHi5ncnBjLnRlc3Rp",
- "bmcuQ2xvc2VkTG9vcFBhcmFtc0gAEi4KB3BvaXNzb24YAiABKAsyGy5ncnBj",
- "LnRlc3RpbmcuUG9pc3NvblBhcmFtc0gAEi4KB3VuaWZvcm0YAyABKAsyGy5n",
- "cnBjLnRlc3RpbmcuVW5pZm9ybVBhcmFtc0gAEjMKBmRldGVybRgEIAEoCzIh",
- "LmdycGMudGVzdGluZy5EZXRlcm1pbmlzdGljUGFyYW1zSAASLAoGcGFyZXRv",
- "GAUgASgLMhouZ3JwYy50ZXN0aW5nLlBhcmV0b1BhcmFtc0gAQgYKBGxvYWQi",
- "QwoOU2VjdXJpdHlQYXJhbXMSEwoLdXNlX3Rlc3RfY2EYASABKAgSHAoUc2Vy",
- "dmVyX2hvc3Rfb3ZlcnJpZGUYAiABKAki1gMKDENsaWVudENvbmZpZxIWCg5z",
- "ZXJ2ZXJfdGFyZ2V0cxgBIAMoCRItCgtjbGllbnRfdHlwZRgCIAEoDjIYLmdy",
- "cGMudGVzdGluZy5DbGllbnRUeXBlEjUKD3NlY3VyaXR5X3BhcmFtcxgDIAEo",
- "CzIcLmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIkChxvdXRzdGFuZGlu",
- "Z19ycGNzX3Blcl9jaGFubmVsGAQgASgFEhcKD2NsaWVudF9jaGFubmVscxgF",
- "IAEoBRIcChRhc3luY19jbGllbnRfdGhyZWFkcxgHIAEoBRInCghycGNfdHlw",
- "ZRgIIAEoDjIVLmdycGMudGVzdGluZy5ScGNUeXBlEi0KC2xvYWRfcGFyYW1z",
- "GAogASgLMhguZ3JwYy50ZXN0aW5nLkxvYWRQYXJhbXMSMwoOcGF5bG9hZF9j",
- "b25maWcYCyABKAsyGy5ncnBjLnRlc3RpbmcuUGF5bG9hZENvbmZpZxI3ChBo",
- "aXN0b2dyYW1fcGFyYW1zGAwgASgLMh0uZ3JwYy50ZXN0aW5nLkhpc3RvZ3Jh",
- "bVBhcmFtcxIRCgljb3JlX2xpc3QYDSADKAUSEgoKY29yZV9saW1pdBgOIAEo",
- "BSI4CgxDbGllbnRTdGF0dXMSKAoFc3RhdHMYASABKAsyGS5ncnBjLnRlc3Rp",
- "bmcuQ2xpZW50U3RhdHMiFQoETWFyaxINCgVyZXNldBgBIAEoCCJoCgpDbGll",
- "bnRBcmdzEisKBXNldHVwGAEgASgLMhouZ3JwYy50ZXN0aW5nLkNsaWVudENv",
- "bmZpZ0gAEiIKBG1hcmsYAiABKAsyEi5ncnBjLnRlc3RpbmcuTWFya0gAQgkK",
- "B2FyZ3R5cGUi/AEKDFNlcnZlckNvbmZpZxItCgtzZXJ2ZXJfdHlwZRgBIAEo",
- "DjIYLmdycGMudGVzdGluZy5TZXJ2ZXJUeXBlEjUKD3NlY3VyaXR5X3BhcmFt",
- "cxgCIAEoCzIcLmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIMCgRwb3J0",
- "GAQgASgFEhwKFGFzeW5jX3NlcnZlcl90aHJlYWRzGAcgASgFEhIKCmNvcmVf",
- "bGltaXQYCCABKAUSMwoOcGF5bG9hZF9jb25maWcYCSABKAsyGy5ncnBjLnRl",
- "c3RpbmcuUGF5bG9hZENvbmZpZxIRCgljb3JlX2xpc3QYCiADKAUiaAoKU2Vy",
- "dmVyQXJncxIrCgVzZXR1cBgBIAEoCzIaLmdycGMudGVzdGluZy5TZXJ2ZXJD",
- "b25maWdIABIiCgRtYXJrGAIgASgLMhIuZ3JwYy50ZXN0aW5nLk1hcmtIAEIJ",
- "Cgdhcmd0eXBlIlUKDFNlcnZlclN0YXR1cxIoCgVzdGF0cxgBIAEoCzIZLmdy",
- "cGMudGVzdGluZy5TZXJ2ZXJTdGF0cxIMCgRwb3J0GAIgASgFEg0KBWNvcmVz",
- "GAMgASgFIg0KC0NvcmVSZXF1ZXN0Ih0KDENvcmVSZXNwb25zZRINCgVjb3Jl",
- "cxgBIAEoBSIGCgRWb2lkKi8KCkNsaWVudFR5cGUSDwoLU1lOQ19DTElFTlQQ",
- "ABIQCgxBU1lOQ19DTElFTlQQASpJCgpTZXJ2ZXJUeXBlEg8KC1NZTkNfU0VS",
- "VkVSEAASEAoMQVNZTkNfU0VSVkVSEAESGAoUQVNZTkNfR0VORVJJQ19TRVJW",
- "RVIQAiojCgdScGNUeXBlEgkKBVVOQVJZEAASDQoJU1RSRUFNSU5HEAFiBnBy",
- "b3RvMw=="));
+ "c29uUGFyYW1zEhQKDG9mZmVyZWRfbG9hZBgBIAEoASISChBDbG9zZWRMb29w",
+ "UGFyYW1zInsKCkxvYWRQYXJhbXMSNQoLY2xvc2VkX2xvb3AYASABKAsyHi5n",
+ "cnBjLnRlc3RpbmcuQ2xvc2VkTG9vcFBhcmFtc0gAEi4KB3BvaXNzb24YAiAB",
+ "KAsyGy5ncnBjLnRlc3RpbmcuUG9pc3NvblBhcmFtc0gAQgYKBGxvYWQiQwoO",
+ "U2VjdXJpdHlQYXJhbXMSEwoLdXNlX3Rlc3RfY2EYASABKAgSHAoUc2VydmVy",
+ "X2hvc3Rfb3ZlcnJpZGUYAiABKAki1gMKDENsaWVudENvbmZpZxIWCg5zZXJ2",
+ "ZXJfdGFyZ2V0cxgBIAMoCRItCgtjbGllbnRfdHlwZRgCIAEoDjIYLmdycGMu",
+ "dGVzdGluZy5DbGllbnRUeXBlEjUKD3NlY3VyaXR5X3BhcmFtcxgDIAEoCzIc",
+ "LmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIkChxvdXRzdGFuZGluZ19y",
+ "cGNzX3Blcl9jaGFubmVsGAQgASgFEhcKD2NsaWVudF9jaGFubmVscxgFIAEo",
+ "BRIcChRhc3luY19jbGllbnRfdGhyZWFkcxgHIAEoBRInCghycGNfdHlwZRgI",
+ "IAEoDjIVLmdycGMudGVzdGluZy5ScGNUeXBlEi0KC2xvYWRfcGFyYW1zGAog",
+ "ASgLMhguZ3JwYy50ZXN0aW5nLkxvYWRQYXJhbXMSMwoOcGF5bG9hZF9jb25m",
+ "aWcYCyABKAsyGy5ncnBjLnRlc3RpbmcuUGF5bG9hZENvbmZpZxI3ChBoaXN0",
+ "b2dyYW1fcGFyYW1zGAwgASgLMh0uZ3JwYy50ZXN0aW5nLkhpc3RvZ3JhbVBh",
+ "cmFtcxIRCgljb3JlX2xpc3QYDSADKAUSEgoKY29yZV9saW1pdBgOIAEoBSI4",
+ "CgxDbGllbnRTdGF0dXMSKAoFc3RhdHMYASABKAsyGS5ncnBjLnRlc3Rpbmcu",
+ "Q2xpZW50U3RhdHMiFQoETWFyaxINCgVyZXNldBgBIAEoCCJoCgpDbGllbnRB",
+ "cmdzEisKBXNldHVwGAEgASgLMhouZ3JwYy50ZXN0aW5nLkNsaWVudENvbmZp",
+ "Z0gAEiIKBG1hcmsYAiABKAsyEi5ncnBjLnRlc3RpbmcuTWFya0gAQgkKB2Fy",
+ "Z3R5cGUi/AEKDFNlcnZlckNvbmZpZxItCgtzZXJ2ZXJfdHlwZRgBIAEoDjIY",
+ "LmdycGMudGVzdGluZy5TZXJ2ZXJUeXBlEjUKD3NlY3VyaXR5X3BhcmFtcxgC",
+ "IAEoCzIcLmdycGMudGVzdGluZy5TZWN1cml0eVBhcmFtcxIMCgRwb3J0GAQg",
+ "ASgFEhwKFGFzeW5jX3NlcnZlcl90aHJlYWRzGAcgASgFEhIKCmNvcmVfbGlt",
+ "aXQYCCABKAUSMwoOcGF5bG9hZF9jb25maWcYCSABKAsyGy5ncnBjLnRlc3Rp",
+ "bmcuUGF5bG9hZENvbmZpZxIRCgljb3JlX2xpc3QYCiADKAUiaAoKU2VydmVy",
+ "QXJncxIrCgVzZXR1cBgBIAEoCzIaLmdycGMudGVzdGluZy5TZXJ2ZXJDb25m",
+ "aWdIABIiCgRtYXJrGAIgASgLMhIuZ3JwYy50ZXN0aW5nLk1hcmtIAEIJCgdh",
+ "cmd0eXBlIlUKDFNlcnZlclN0YXR1cxIoCgVzdGF0cxgBIAEoCzIZLmdycGMu",
+ "dGVzdGluZy5TZXJ2ZXJTdGF0cxIMCgRwb3J0GAIgASgFEg0KBWNvcmVzGAMg",
+ "ASgFIg0KC0NvcmVSZXF1ZXN0Ih0KDENvcmVSZXNwb25zZRINCgVjb3JlcxgB",
+ "IAEoBSIGCgRWb2lkIv0BCghTY2VuYXJpbxIMCgRuYW1lGAEgASgJEjEKDWNs",
+ "aWVudF9jb25maWcYAiABKAsyGi5ncnBjLnRlc3RpbmcuQ2xpZW50Q29uZmln",
+ "EhMKC251bV9jbGllbnRzGAMgASgFEjEKDXNlcnZlcl9jb25maWcYBCABKAsy",
+ "Gi5ncnBjLnRlc3RpbmcuU2VydmVyQ29uZmlnEhMKC251bV9zZXJ2ZXJzGAUg",
+ "ASgFEhYKDndhcm11cF9zZWNvbmRzGAYgASgFEhkKEWJlbmNobWFya19zZWNv",
+ "bmRzGAcgASgFEiAKGHNwYXduX2xvY2FsX3dvcmtlcl9jb3VudBgIIAEoBSI2",
+ "CglTY2VuYXJpb3MSKQoJc2NlbmFyaW9zGAEgAygLMhYuZ3JwYy50ZXN0aW5n",
+ "LlNjZW5hcmlvIpICChVTY2VuYXJpb1Jlc3VsdFN1bW1hcnkSCwoDcXBzGAEg",
+ "ASgBEhsKE3Fwc19wZXJfc2VydmVyX2NvcmUYAiABKAESGgoSc2VydmVyX3N5",
+ "c3RlbV90aW1lGAMgASgBEhgKEHNlcnZlcl91c2VyX3RpbWUYBCABKAESGgoS",
+ "Y2xpZW50X3N5c3RlbV90aW1lGAUgASgBEhgKEGNsaWVudF91c2VyX3RpbWUY",
+ "BiABKAESEgoKbGF0ZW5jeV81MBgHIAEoARISCgpsYXRlbmN5XzkwGAggASgB",
+ "EhIKCmxhdGVuY3lfOTUYCSABKAESEgoKbGF0ZW5jeV85ORgKIAEoARITCgts",
+ "YXRlbmN5Xzk5ORgLIAEoASKYAgoOU2NlbmFyaW9SZXN1bHQSKAoIc2NlbmFy",
+ "aW8YASABKAsyFi5ncnBjLnRlc3RpbmcuU2NlbmFyaW8SLgoJbGF0ZW5jaWVz",
+ "GAIgASgLMhsuZ3JwYy50ZXN0aW5nLkhpc3RvZ3JhbURhdGESLwoMY2xpZW50",
+ "X3N0YXRzGAMgAygLMhkuZ3JwYy50ZXN0aW5nLkNsaWVudFN0YXRzEi8KDHNl",
+ "cnZlcl9zdGF0cxgEIAMoCzIZLmdycGMudGVzdGluZy5TZXJ2ZXJTdGF0cxIU",
+ "CgxzZXJ2ZXJfY29yZXMYBSADKAUSNAoHc3VtbWFyeRgGIAEoCzIjLmdycGMu",
+ "dGVzdGluZy5TY2VuYXJpb1Jlc3VsdFN1bW1hcnkqLwoKQ2xpZW50VHlwZRIP",
+ "CgtTWU5DX0NMSUVOVBAAEhAKDEFTWU5DX0NMSUVOVBABKkkKClNlcnZlclR5",
+ "cGUSDwoLU1lOQ19TRVJWRVIQABIQCgxBU1lOQ19TRVJWRVIQARIYChRBU1lO",
+ "Q19HRU5FUklDX1NFUlZFUhACKiMKB1JwY1R5cGUSCQoFVU5BUlkQABINCglT",
+ "VFJFQU1JTkcQAWIGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Grpc.Testing.PayloadsReflection.Descriptor, global::Grpc.Testing.StatsReflection.Descriptor, },
new pbr::GeneratedCodeInfo(new[] {typeof(global::Grpc.Testing.ClientType), typeof(global::Grpc.Testing.ServerType), typeof(global::Grpc.Testing.RpcType), }, new pbr::GeneratedCodeInfo[] {
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.PoissonParams), global::Grpc.Testing.PoissonParams.Parser, new[]{ "OfferedLoad" }, null, null, null),
- new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.UniformParams), global::Grpc.Testing.UniformParams.Parser, new[]{ "InterarrivalLo", "InterarrivalHi" }, null, null, null),
- new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.DeterministicParams), global::Grpc.Testing.DeterministicParams.Parser, new[]{ "OfferedLoad" }, null, null, null),
- new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ParetoParams), global::Grpc.Testing.ParetoParams.Parser, new[]{ "InterarrivalBase", "Alpha" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClosedLoopParams), global::Grpc.Testing.ClosedLoopParams.Parser, null, null, null, null),
- new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.LoadParams), global::Grpc.Testing.LoadParams.Parser, new[]{ "ClosedLoop", "Poisson", "Uniform", "Determ", "Pareto" }, new[]{ "Load" }, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.LoadParams), global::Grpc.Testing.LoadParams.Parser, new[]{ "ClosedLoop", "Poisson" }, new[]{ "Load" }, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.SecurityParams), global::Grpc.Testing.SecurityParams.Parser, new[]{ "UseTestCa", "ServerHostOverride" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientConfig), global::Grpc.Testing.ClientConfig.Parser, new[]{ "ServerTargets", "ClientType", "SecurityParams", "OutstandingRpcsPerChannel", "ClientChannels", "AsyncClientThreads", "RpcType", "LoadParams", "PayloadConfig", "HistogramParams", "CoreList", "CoreLimit" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ClientStatus), global::Grpc.Testing.ClientStatus.Parser, new[]{ "Stats" }, null, null, null),
@@ -88,7 +97,11 @@ namespace Grpc.Testing {
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ServerStatus), global::Grpc.Testing.ServerStatus.Parser, new[]{ "Stats", "Port", "Cores" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.CoreRequest), global::Grpc.Testing.CoreRequest.Parser, null, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.CoreResponse), global::Grpc.Testing.CoreResponse.Parser, new[]{ "Cores" }, null, null, null),
- new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Void), global::Grpc.Testing.Void.Parser, null, null, null, null)
+ new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Void), global::Grpc.Testing.Void.Parser, null, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Scenario), global::Grpc.Testing.Scenario.Parser, new[]{ "Name", "ClientConfig", "NumClients", "ServerConfig", "NumServers", "WarmupSeconds", "BenchmarkSeconds", "SpawnLocalWorkerCount" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.Scenarios), global::Grpc.Testing.Scenarios.Parser, new[]{ "Scenarios_" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ScenarioResultSummary), global::Grpc.Testing.ScenarioResultSummary.Parser, new[]{ "Qps", "QpsPerServerCore", "ServerSystemTime", "ServerUserTime", "ClientSystemTime", "ClientUserTime", "Latency50", "Latency90", "Latency95", "Latency99", "Latency999" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ScenarioResult), global::Grpc.Testing.ScenarioResult.Parser, new[]{ "Scenario", "Latencies", "ClientStats", "ServerStats", "ServerCores", "Summary" }, null, null, null)
}));
}
#endregion
@@ -224,369 +237,6 @@ namespace Grpc.Testing {
}
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class UniformParams : pb::IMessage<UniformParams> {
- private static readonly pb::MessageParser<UniformParams> _parser = new pb::MessageParser<UniformParams>(() => new UniformParams());
- public static pb::MessageParser<UniformParams> Parser { get { return _parser; } }
-
- public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[1]; }
- }
-
- pbr::MessageDescriptor pb::IMessage.Descriptor {
- get { return Descriptor; }
- }
-
- public UniformParams() {
- OnConstruction();
- }
-
- partial void OnConstruction();
-
- public UniformParams(UniformParams other) : this() {
- interarrivalLo_ = other.interarrivalLo_;
- interarrivalHi_ = other.interarrivalHi_;
- }
-
- public UniformParams Clone() {
- return new UniformParams(this);
- }
-
- /// <summary>Field number for the "interarrival_lo" field.</summary>
- public const int InterarrivalLoFieldNumber = 1;
- private double interarrivalLo_;
- public double InterarrivalLo {
- get { return interarrivalLo_; }
- set {
- interarrivalLo_ = value;
- }
- }
-
- /// <summary>Field number for the "interarrival_hi" field.</summary>
- public const int InterarrivalHiFieldNumber = 2;
- private double interarrivalHi_;
- public double InterarrivalHi {
- get { return interarrivalHi_; }
- set {
- interarrivalHi_ = value;
- }
- }
-
- public override bool Equals(object other) {
- return Equals(other as UniformParams);
- }
-
- public bool Equals(UniformParams other) {
- if (ReferenceEquals(other, null)) {
- return false;
- }
- if (ReferenceEquals(other, this)) {
- return true;
- }
- if (InterarrivalLo != other.InterarrivalLo) return false;
- if (InterarrivalHi != other.InterarrivalHi) return false;
- return true;
- }
-
- public override int GetHashCode() {
- int hash = 1;
- if (InterarrivalLo != 0D) hash ^= InterarrivalLo.GetHashCode();
- if (InterarrivalHi != 0D) hash ^= InterarrivalHi.GetHashCode();
- return hash;
- }
-
- public override string ToString() {
- return pb::JsonFormatter.ToDiagnosticString(this);
- }
-
- public void WriteTo(pb::CodedOutputStream output) {
- if (InterarrivalLo != 0D) {
- output.WriteRawTag(9);
- output.WriteDouble(InterarrivalLo);
- }
- if (InterarrivalHi != 0D) {
- output.WriteRawTag(17);
- output.WriteDouble(InterarrivalHi);
- }
- }
-
- public int CalculateSize() {
- int size = 0;
- if (InterarrivalLo != 0D) {
- size += 1 + 8;
- }
- if (InterarrivalHi != 0D) {
- size += 1 + 8;
- }
- return size;
- }
-
- public void MergeFrom(UniformParams other) {
- if (other == null) {
- return;
- }
- if (other.InterarrivalLo != 0D) {
- InterarrivalLo = other.InterarrivalLo;
- }
- if (other.InterarrivalHi != 0D) {
- InterarrivalHi = other.InterarrivalHi;
- }
- }
-
- public void MergeFrom(pb::CodedInputStream input) {
- uint tag;
- while ((tag = input.ReadTag()) != 0) {
- switch(tag) {
- default:
- input.SkipLastField();
- break;
- case 9: {
- InterarrivalLo = input.ReadDouble();
- break;
- }
- case 17: {
- InterarrivalHi = input.ReadDouble();
- break;
- }
- }
- }
- }
-
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class DeterministicParams : pb::IMessage<DeterministicParams> {
- private static readonly pb::MessageParser<DeterministicParams> _parser = new pb::MessageParser<DeterministicParams>(() => new DeterministicParams());
- public static pb::MessageParser<DeterministicParams> Parser { get { return _parser; } }
-
- public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[2]; }
- }
-
- pbr::MessageDescriptor pb::IMessage.Descriptor {
- get { return Descriptor; }
- }
-
- public DeterministicParams() {
- OnConstruction();
- }
-
- partial void OnConstruction();
-
- public DeterministicParams(DeterministicParams other) : this() {
- offeredLoad_ = other.offeredLoad_;
- }
-
- public DeterministicParams Clone() {
- return new DeterministicParams(this);
- }
-
- /// <summary>Field number for the "offered_load" field.</summary>
- public const int OfferedLoadFieldNumber = 1;
- private double offeredLoad_;
- public double OfferedLoad {
- get { return offeredLoad_; }
- set {
- offeredLoad_ = value;
- }
- }
-
- public override bool Equals(object other) {
- return Equals(other as DeterministicParams);
- }
-
- public bool Equals(DeterministicParams other) {
- if (ReferenceEquals(other, null)) {
- return false;
- }
- if (ReferenceEquals(other, this)) {
- return true;
- }
- if (OfferedLoad != other.OfferedLoad) return false;
- return true;
- }
-
- public override int GetHashCode() {
- int hash = 1;
- if (OfferedLoad != 0D) hash ^= OfferedLoad.GetHashCode();
- return hash;
- }
-
- public override string ToString() {
- return pb::JsonFormatter.ToDiagnosticString(this);
- }
-
- public void WriteTo(pb::CodedOutputStream output) {
- if (OfferedLoad != 0D) {
- output.WriteRawTag(9);
- output.WriteDouble(OfferedLoad);
- }
- }
-
- public int CalculateSize() {
- int size = 0;
- if (OfferedLoad != 0D) {
- size += 1 + 8;
- }
- return size;
- }
-
- public void MergeFrom(DeterministicParams other) {
- if (other == null) {
- return;
- }
- if (other.OfferedLoad != 0D) {
- OfferedLoad = other.OfferedLoad;
- }
- }
-
- public void MergeFrom(pb::CodedInputStream input) {
- uint tag;
- while ((tag = input.ReadTag()) != 0) {
- switch(tag) {
- default:
- input.SkipLastField();
- break;
- case 9: {
- OfferedLoad = input.ReadDouble();
- break;
- }
- }
- }
- }
-
- }
-
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- public sealed partial class ParetoParams : pb::IMessage<ParetoParams> {
- private static readonly pb::MessageParser<ParetoParams> _parser = new pb::MessageParser<ParetoParams>(() => new ParetoParams());
- public static pb::MessageParser<ParetoParams> Parser { get { return _parser; } }
-
- public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[3]; }
- }
-
- pbr::MessageDescriptor pb::IMessage.Descriptor {
- get { return Descriptor; }
- }
-
- public ParetoParams() {
- OnConstruction();
- }
-
- partial void OnConstruction();
-
- public ParetoParams(ParetoParams other) : this() {
- interarrivalBase_ = other.interarrivalBase_;
- alpha_ = other.alpha_;
- }
-
- public ParetoParams Clone() {
- return new ParetoParams(this);
- }
-
- /// <summary>Field number for the "interarrival_base" field.</summary>
- public const int InterarrivalBaseFieldNumber = 1;
- private double interarrivalBase_;
- public double InterarrivalBase {
- get { return interarrivalBase_; }
- set {
- interarrivalBase_ = value;
- }
- }
-
- /// <summary>Field number for the "alpha" field.</summary>
- public const int AlphaFieldNumber = 2;
- private double alpha_;
- public double Alpha {
- get { return alpha_; }
- set {
- alpha_ = value;
- }
- }
-
- public override bool Equals(object other) {
- return Equals(other as ParetoParams);
- }
-
- public bool Equals(ParetoParams other) {
- if (ReferenceEquals(other, null)) {
- return false;
- }
- if (ReferenceEquals(other, this)) {
- return true;
- }
- if (InterarrivalBase != other.InterarrivalBase) return false;
- if (Alpha != other.Alpha) return false;
- return true;
- }
-
- public override int GetHashCode() {
- int hash = 1;
- if (InterarrivalBase != 0D) hash ^= InterarrivalBase.GetHashCode();
- if (Alpha != 0D) hash ^= Alpha.GetHashCode();
- return hash;
- }
-
- public override string ToString() {
- return pb::JsonFormatter.ToDiagnosticString(this);
- }
-
- public void WriteTo(pb::CodedOutputStream output) {
- if (InterarrivalBase != 0D) {
- output.WriteRawTag(9);
- output.WriteDouble(InterarrivalBase);
- }
- if (Alpha != 0D) {
- output.WriteRawTag(17);
- output.WriteDouble(Alpha);
- }
- }
-
- public int CalculateSize() {
- int size = 0;
- if (InterarrivalBase != 0D) {
- size += 1 + 8;
- }
- if (Alpha != 0D) {
- size += 1 + 8;
- }
- return size;
- }
-
- public void MergeFrom(ParetoParams other) {
- if (other == null) {
- return;
- }
- if (other.InterarrivalBase != 0D) {
- InterarrivalBase = other.InterarrivalBase;
- }
- if (other.Alpha != 0D) {
- Alpha = other.Alpha;
- }
- }
-
- public void MergeFrom(pb::CodedInputStream input) {
- uint tag;
- while ((tag = input.ReadTag()) != 0) {
- switch(tag) {
- default:
- input.SkipLastField();
- break;
- case 9: {
- InterarrivalBase = input.ReadDouble();
- break;
- }
- case 17: {
- Alpha = input.ReadDouble();
- break;
- }
- }
- }
- }
-
- }
-
/// <summary>
/// Once an RPC finishes, immediately start a new one.
/// No configuration parameters needed.
@@ -597,7 +247,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<ClosedLoopParams> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[4]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[1]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -673,7 +323,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<LoadParams> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[5]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[2]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -694,15 +344,6 @@ namespace Grpc.Testing {
case LoadOneofCase.Poisson:
Poisson = other.Poisson.Clone();
break;
- case LoadOneofCase.Uniform:
- Uniform = other.Uniform.Clone();
- break;
- case LoadOneofCase.Determ:
- Determ = other.Determ.Clone();
- break;
- case LoadOneofCase.Pareto:
- Pareto = other.Pareto.Clone();
- break;
}
}
@@ -731,45 +372,12 @@ namespace Grpc.Testing {
}
}
- /// <summary>Field number for the "uniform" field.</summary>
- public const int UniformFieldNumber = 3;
- public global::Grpc.Testing.UniformParams Uniform {
- get { return loadCase_ == LoadOneofCase.Uniform ? (global::Grpc.Testing.UniformParams) load_ : null; }
- set {
- load_ = value;
- loadCase_ = value == null ? LoadOneofCase.None : LoadOneofCase.Uniform;
- }
- }
-
- /// <summary>Field number for the "determ" field.</summary>
- public const int DetermFieldNumber = 4;
- public global::Grpc.Testing.DeterministicParams Determ {
- get { return loadCase_ == LoadOneofCase.Determ ? (global::Grpc.Testing.DeterministicParams) load_ : null; }
- set {
- load_ = value;
- loadCase_ = value == null ? LoadOneofCase.None : LoadOneofCase.Determ;
- }
- }
-
- /// <summary>Field number for the "pareto" field.</summary>
- public const int ParetoFieldNumber = 5;
- public global::Grpc.Testing.ParetoParams Pareto {
- get { return loadCase_ == LoadOneofCase.Pareto ? (global::Grpc.Testing.ParetoParams) load_ : null; }
- set {
- load_ = value;
- loadCase_ = value == null ? LoadOneofCase.None : LoadOneofCase.Pareto;
- }
- }
-
private object load_;
/// <summary>Enum of possible cases for the "load" oneof.</summary>
public enum LoadOneofCase {
None = 0,
ClosedLoop = 1,
Poisson = 2,
- Uniform = 3,
- Determ = 4,
- Pareto = 5,
}
private LoadOneofCase loadCase_ = LoadOneofCase.None;
public LoadOneofCase LoadCase {
@@ -794,9 +402,6 @@ namespace Grpc.Testing {
}
if (!object.Equals(ClosedLoop, other.ClosedLoop)) return false;
if (!object.Equals(Poisson, other.Poisson)) return false;
- if (!object.Equals(Uniform, other.Uniform)) return false;
- if (!object.Equals(Determ, other.Determ)) return false;
- if (!object.Equals(Pareto, other.Pareto)) return false;
if (LoadCase != other.LoadCase) return false;
return true;
}
@@ -805,9 +410,6 @@ namespace Grpc.Testing {
int hash = 1;
if (loadCase_ == LoadOneofCase.ClosedLoop) hash ^= ClosedLoop.GetHashCode();
if (loadCase_ == LoadOneofCase.Poisson) hash ^= Poisson.GetHashCode();
- if (loadCase_ == LoadOneofCase.Uniform) hash ^= Uniform.GetHashCode();
- if (loadCase_ == LoadOneofCase.Determ) hash ^= Determ.GetHashCode();
- if (loadCase_ == LoadOneofCase.Pareto) hash ^= Pareto.GetHashCode();
hash ^= (int) loadCase_;
return hash;
}
@@ -825,18 +427,6 @@ namespace Grpc.Testing {
output.WriteRawTag(18);
output.WriteMessage(Poisson);
}
- if (loadCase_ == LoadOneofCase.Uniform) {
- output.WriteRawTag(26);
- output.WriteMessage(Uniform);
- }
- if (loadCase_ == LoadOneofCase.Determ) {
- output.WriteRawTag(34);
- output.WriteMessage(Determ);
- }
- if (loadCase_ == LoadOneofCase.Pareto) {
- output.WriteRawTag(42);
- output.WriteMessage(Pareto);
- }
}
public int CalculateSize() {
@@ -847,15 +437,6 @@ namespace Grpc.Testing {
if (loadCase_ == LoadOneofCase.Poisson) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Poisson);
}
- if (loadCase_ == LoadOneofCase.Uniform) {
- size += 1 + pb::CodedOutputStream.ComputeMessageSize(Uniform);
- }
- if (loadCase_ == LoadOneofCase.Determ) {
- size += 1 + pb::CodedOutputStream.ComputeMessageSize(Determ);
- }
- if (loadCase_ == LoadOneofCase.Pareto) {
- size += 1 + pb::CodedOutputStream.ComputeMessageSize(Pareto);
- }
return size;
}
@@ -870,15 +451,6 @@ namespace Grpc.Testing {
case LoadOneofCase.Poisson:
Poisson = other.Poisson;
break;
- case LoadOneofCase.Uniform:
- Uniform = other.Uniform;
- break;
- case LoadOneofCase.Determ:
- Determ = other.Determ;
- break;
- case LoadOneofCase.Pareto:
- Pareto = other.Pareto;
- break;
}
}
@@ -908,33 +480,6 @@ namespace Grpc.Testing {
Poisson = subBuilder;
break;
}
- case 26: {
- global::Grpc.Testing.UniformParams subBuilder = new global::Grpc.Testing.UniformParams();
- if (loadCase_ == LoadOneofCase.Uniform) {
- subBuilder.MergeFrom(Uniform);
- }
- input.ReadMessage(subBuilder);
- Uniform = subBuilder;
- break;
- }
- case 34: {
- global::Grpc.Testing.DeterministicParams subBuilder = new global::Grpc.Testing.DeterministicParams();
- if (loadCase_ == LoadOneofCase.Determ) {
- subBuilder.MergeFrom(Determ);
- }
- input.ReadMessage(subBuilder);
- Determ = subBuilder;
- break;
- }
- case 42: {
- global::Grpc.Testing.ParetoParams subBuilder = new global::Grpc.Testing.ParetoParams();
- if (loadCase_ == LoadOneofCase.Pareto) {
- subBuilder.MergeFrom(Pareto);
- }
- input.ReadMessage(subBuilder);
- Pareto = subBuilder;
- break;
- }
}
}
}
@@ -950,7 +495,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<SecurityParams> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[6]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[3]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -1080,7 +625,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<ClientConfig> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[7]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[4]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -1509,7 +1054,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<ClientStatus> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[8]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[5]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -1621,7 +1166,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<Mark> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[9]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[6]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -1727,7 +1272,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<ClientArgs> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[10]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[7]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -1896,7 +1441,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<ServerConfig> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[11]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[8]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -2181,7 +1726,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<ServerArgs> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[12]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[9]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -2350,7 +1895,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<ServerStatus> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[13]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[10]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -2519,7 +2064,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<CoreRequest> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[14]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[11]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -2595,7 +2140,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<CoreResponse> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[15]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[12]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -2701,7 +2246,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<Void> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[16]; }
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[13]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
@@ -2771,6 +2316,1087 @@ namespace Grpc.Testing {
}
+ /// <summary>
+ /// A single performance scenario: input to qps_json_driver
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public sealed partial class Scenario : pb::IMessage<Scenario> {
+ private static readonly pb::MessageParser<Scenario> _parser = new pb::MessageParser<Scenario>(() => new Scenario());
+ public static pb::MessageParser<Scenario> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[14]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public Scenario() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public Scenario(Scenario other) : this() {
+ name_ = other.name_;
+ ClientConfig = other.clientConfig_ != null ? other.ClientConfig.Clone() : null;
+ numClients_ = other.numClients_;
+ ServerConfig = other.serverConfig_ != null ? other.ServerConfig.Clone() : null;
+ numServers_ = other.numServers_;
+ warmupSeconds_ = other.warmupSeconds_;
+ benchmarkSeconds_ = other.benchmarkSeconds_;
+ spawnLocalWorkerCount_ = other.spawnLocalWorkerCount_;
+ }
+
+ public Scenario Clone() {
+ return new Scenario(this);
+ }
+
+ /// <summary>Field number for the "name" field.</summary>
+ public const int NameFieldNumber = 1;
+ private string name_ = "";
+ /// <summary>
+ /// Human readable name for this scenario
+ /// </summary>
+ public string Name {
+ get { return name_; }
+ set {
+ name_ = pb::Preconditions.CheckNotNull(value, "value");
+ }
+ }
+
+ /// <summary>Field number for the "client_config" field.</summary>
+ public const int ClientConfigFieldNumber = 2;
+ private global::Grpc.Testing.ClientConfig clientConfig_;
+ /// <summary>
+ /// Client configuration
+ /// </summary>
+ public global::Grpc.Testing.ClientConfig ClientConfig {
+ get { return clientConfig_; }
+ set {
+ clientConfig_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "num_clients" field.</summary>
+ public const int NumClientsFieldNumber = 3;
+ private int numClients_;
+ /// <summary>
+ /// Number of clients to start for the test
+ /// </summary>
+ public int NumClients {
+ get { return numClients_; }
+ set {
+ numClients_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "server_config" field.</summary>
+ public const int ServerConfigFieldNumber = 4;
+ private global::Grpc.Testing.ServerConfig serverConfig_;
+ /// <summary>
+ /// Server configuration
+ /// </summary>
+ public global::Grpc.Testing.ServerConfig ServerConfig {
+ get { return serverConfig_; }
+ set {
+ serverConfig_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "num_servers" field.</summary>
+ public const int NumServersFieldNumber = 5;
+ private int numServers_;
+ /// <summary>
+ /// Number of servers to start for the test
+ /// </summary>
+ public int NumServers {
+ get { return numServers_; }
+ set {
+ numServers_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "warmup_seconds" field.</summary>
+ public const int WarmupSecondsFieldNumber = 6;
+ private int warmupSeconds_;
+ /// <summary>
+ /// Warmup period, in seconds
+ /// </summary>
+ public int WarmupSeconds {
+ get { return warmupSeconds_; }
+ set {
+ warmupSeconds_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "benchmark_seconds" field.</summary>
+ public const int BenchmarkSecondsFieldNumber = 7;
+ private int benchmarkSeconds_;
+ /// <summary>
+ /// Benchmark time, in seconds
+ /// </summary>
+ public int BenchmarkSeconds {
+ get { return benchmarkSeconds_; }
+ set {
+ benchmarkSeconds_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "spawn_local_worker_count" field.</summary>
+ public const int SpawnLocalWorkerCountFieldNumber = 8;
+ private int spawnLocalWorkerCount_;
+ /// <summary>
+ /// Number of workers to spawn locally (usually zero)
+ /// </summary>
+ public int SpawnLocalWorkerCount {
+ get { return spawnLocalWorkerCount_; }
+ set {
+ spawnLocalWorkerCount_ = value;
+ }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as Scenario);
+ }
+
+ public bool Equals(Scenario other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Name != other.Name) return false;
+ if (!object.Equals(ClientConfig, other.ClientConfig)) return false;
+ if (NumClients != other.NumClients) return false;
+ if (!object.Equals(ServerConfig, other.ServerConfig)) return false;
+ if (NumServers != other.NumServers) return false;
+ if (WarmupSeconds != other.WarmupSeconds) return false;
+ if (BenchmarkSeconds != other.BenchmarkSeconds) return false;
+ if (SpawnLocalWorkerCount != other.SpawnLocalWorkerCount) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Name.Length != 0) hash ^= Name.GetHashCode();
+ if (clientConfig_ != null) hash ^= ClientConfig.GetHashCode();
+ if (NumClients != 0) hash ^= NumClients.GetHashCode();
+ if (serverConfig_ != null) hash ^= ServerConfig.GetHashCode();
+ if (NumServers != 0) hash ^= NumServers.GetHashCode();
+ if (WarmupSeconds != 0) hash ^= WarmupSeconds.GetHashCode();
+ if (BenchmarkSeconds != 0) hash ^= BenchmarkSeconds.GetHashCode();
+ if (SpawnLocalWorkerCount != 0) hash ^= SpawnLocalWorkerCount.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Name.Length != 0) {
+ output.WriteRawTag(10);
+ output.WriteString(Name);
+ }
+ if (clientConfig_ != null) {
+ output.WriteRawTag(18);
+ output.WriteMessage(ClientConfig);
+ }
+ if (NumClients != 0) {
+ output.WriteRawTag(24);
+ output.WriteInt32(NumClients);
+ }
+ if (serverConfig_ != null) {
+ output.WriteRawTag(34);
+ output.WriteMessage(ServerConfig);
+ }
+ if (NumServers != 0) {
+ output.WriteRawTag(40);
+ output.WriteInt32(NumServers);
+ }
+ if (WarmupSeconds != 0) {
+ output.WriteRawTag(48);
+ output.WriteInt32(WarmupSeconds);
+ }
+ if (BenchmarkSeconds != 0) {
+ output.WriteRawTag(56);
+ output.WriteInt32(BenchmarkSeconds);
+ }
+ if (SpawnLocalWorkerCount != 0) {
+ output.WriteRawTag(64);
+ output.WriteInt32(SpawnLocalWorkerCount);
+ }
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ if (Name.Length != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
+ }
+ if (clientConfig_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(ClientConfig);
+ }
+ if (NumClients != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(NumClients);
+ }
+ if (serverConfig_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(ServerConfig);
+ }
+ if (NumServers != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(NumServers);
+ }
+ if (WarmupSeconds != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(WarmupSeconds);
+ }
+ if (BenchmarkSeconds != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(BenchmarkSeconds);
+ }
+ if (SpawnLocalWorkerCount != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(SpawnLocalWorkerCount);
+ }
+ return size;
+ }
+
+ public void MergeFrom(Scenario other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Name.Length != 0) {
+ Name = other.Name;
+ }
+ if (other.clientConfig_ != null) {
+ if (clientConfig_ == null) {
+ clientConfig_ = new global::Grpc.Testing.ClientConfig();
+ }
+ ClientConfig.MergeFrom(other.ClientConfig);
+ }
+ if (other.NumClients != 0) {
+ NumClients = other.NumClients;
+ }
+ if (other.serverConfig_ != null) {
+ if (serverConfig_ == null) {
+ serverConfig_ = new global::Grpc.Testing.ServerConfig();
+ }
+ ServerConfig.MergeFrom(other.ServerConfig);
+ }
+ if (other.NumServers != 0) {
+ NumServers = other.NumServers;
+ }
+ if (other.WarmupSeconds != 0) {
+ WarmupSeconds = other.WarmupSeconds;
+ }
+ if (other.BenchmarkSeconds != 0) {
+ BenchmarkSeconds = other.BenchmarkSeconds;
+ }
+ if (other.SpawnLocalWorkerCount != 0) {
+ SpawnLocalWorkerCount = other.SpawnLocalWorkerCount;
+ }
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ Name = input.ReadString();
+ break;
+ }
+ case 18: {
+ if (clientConfig_ == null) {
+ clientConfig_ = new global::Grpc.Testing.ClientConfig();
+ }
+ input.ReadMessage(clientConfig_);
+ break;
+ }
+ case 24: {
+ NumClients = input.ReadInt32();
+ break;
+ }
+ case 34: {
+ if (serverConfig_ == null) {
+ serverConfig_ = new global::Grpc.Testing.ServerConfig();
+ }
+ input.ReadMessage(serverConfig_);
+ break;
+ }
+ case 40: {
+ NumServers = input.ReadInt32();
+ break;
+ }
+ case 48: {
+ WarmupSeconds = input.ReadInt32();
+ break;
+ }
+ case 56: {
+ BenchmarkSeconds = input.ReadInt32();
+ break;
+ }
+ case 64: {
+ SpawnLocalWorkerCount = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// A set of scenarios to be run with qps_json_driver
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public sealed partial class Scenarios : pb::IMessage<Scenarios> {
+ private static readonly pb::MessageParser<Scenarios> _parser = new pb::MessageParser<Scenarios>(() => new Scenarios());
+ public static pb::MessageParser<Scenarios> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[15]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public Scenarios() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public Scenarios(Scenarios other) : this() {
+ scenarios_ = other.scenarios_.Clone();
+ }
+
+ public Scenarios Clone() {
+ return new Scenarios(this);
+ }
+
+ /// <summary>Field number for the "scenarios" field.</summary>
+ public const int Scenarios_FieldNumber = 1;
+ private static readonly pb::FieldCodec<global::Grpc.Testing.Scenario> _repeated_scenarios_codec
+ = pb::FieldCodec.ForMessage(10, global::Grpc.Testing.Scenario.Parser);
+ private readonly pbc::RepeatedField<global::Grpc.Testing.Scenario> scenarios_ = new pbc::RepeatedField<global::Grpc.Testing.Scenario>();
+ public pbc::RepeatedField<global::Grpc.Testing.Scenario> Scenarios_ {
+ get { return scenarios_; }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as Scenarios);
+ }
+
+ public bool Equals(Scenarios other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if(!scenarios_.Equals(other.scenarios_)) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ hash ^= scenarios_.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ scenarios_.WriteTo(output, _repeated_scenarios_codec);
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ size += scenarios_.CalculateSize(_repeated_scenarios_codec);
+ return size;
+ }
+
+ public void MergeFrom(Scenarios other) {
+ if (other == null) {
+ return;
+ }
+ scenarios_.Add(other.scenarios_);
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ scenarios_.AddEntriesFrom(input, _repeated_scenarios_codec);
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Basic summary that can be computed from ClientStats and ServerStats
+ /// once the scenario has finished.
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public sealed partial class ScenarioResultSummary : pb::IMessage<ScenarioResultSummary> {
+ private static readonly pb::MessageParser<ScenarioResultSummary> _parser = new pb::MessageParser<ScenarioResultSummary>(() => new ScenarioResultSummary());
+ public static pb::MessageParser<ScenarioResultSummary> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[16]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public ScenarioResultSummary() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public ScenarioResultSummary(ScenarioResultSummary other) : this() {
+ qps_ = other.qps_;
+ qpsPerServerCore_ = other.qpsPerServerCore_;
+ serverSystemTime_ = other.serverSystemTime_;
+ serverUserTime_ = other.serverUserTime_;
+ clientSystemTime_ = other.clientSystemTime_;
+ clientUserTime_ = other.clientUserTime_;
+ latency50_ = other.latency50_;
+ latency90_ = other.latency90_;
+ latency95_ = other.latency95_;
+ latency99_ = other.latency99_;
+ latency999_ = other.latency999_;
+ }
+
+ public ScenarioResultSummary Clone() {
+ return new ScenarioResultSummary(this);
+ }
+
+ /// <summary>Field number for the "qps" field.</summary>
+ public const int QpsFieldNumber = 1;
+ private double qps_;
+ /// <summary>
+ /// Total number of operations per second over all clients.
+ /// </summary>
+ public double Qps {
+ get { return qps_; }
+ set {
+ qps_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "qps_per_server_core" field.</summary>
+ public const int QpsPerServerCoreFieldNumber = 2;
+ private double qpsPerServerCore_;
+ /// <summary>
+ /// QPS per one server core.
+ /// </summary>
+ public double QpsPerServerCore {
+ get { return qpsPerServerCore_; }
+ set {
+ qpsPerServerCore_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "server_system_time" field.</summary>
+ public const int ServerSystemTimeFieldNumber = 3;
+ private double serverSystemTime_;
+ /// <summary>
+ /// server load based on system_time (0.85 => 85%)
+ /// </summary>
+ public double ServerSystemTime {
+ get { return serverSystemTime_; }
+ set {
+ serverSystemTime_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "server_user_time" field.</summary>
+ public const int ServerUserTimeFieldNumber = 4;
+ private double serverUserTime_;
+ /// <summary>
+ /// server load based on user_time (0.85 => 85%)
+ /// </summary>
+ public double ServerUserTime {
+ get { return serverUserTime_; }
+ set {
+ serverUserTime_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "client_system_time" field.</summary>
+ public const int ClientSystemTimeFieldNumber = 5;
+ private double clientSystemTime_;
+ /// <summary>
+ /// client load based on system_time (0.85 => 85%)
+ /// </summary>
+ public double ClientSystemTime {
+ get { return clientSystemTime_; }
+ set {
+ clientSystemTime_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "client_user_time" field.</summary>
+ public const int ClientUserTimeFieldNumber = 6;
+ private double clientUserTime_;
+ /// <summary>
+ /// client load based on user_time (0.85 => 85%)
+ /// </summary>
+ public double ClientUserTime {
+ get { return clientUserTime_; }
+ set {
+ clientUserTime_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "latency_50" field.</summary>
+ public const int Latency50FieldNumber = 7;
+ private double latency50_;
+ /// <summary>
+ /// X% latency percentiles (in nanoseconds)
+ /// </summary>
+ public double Latency50 {
+ get { return latency50_; }
+ set {
+ latency50_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "latency_90" field.</summary>
+ public const int Latency90FieldNumber = 8;
+ private double latency90_;
+ public double Latency90 {
+ get { return latency90_; }
+ set {
+ latency90_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "latency_95" field.</summary>
+ public const int Latency95FieldNumber = 9;
+ private double latency95_;
+ public double Latency95 {
+ get { return latency95_; }
+ set {
+ latency95_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "latency_99" field.</summary>
+ public const int Latency99FieldNumber = 10;
+ private double latency99_;
+ public double Latency99 {
+ get { return latency99_; }
+ set {
+ latency99_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "latency_999" field.</summary>
+ public const int Latency999FieldNumber = 11;
+ private double latency999_;
+ public double Latency999 {
+ get { return latency999_; }
+ set {
+ latency999_ = value;
+ }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as ScenarioResultSummary);
+ }
+
+ public bool Equals(ScenarioResultSummary other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (Qps != other.Qps) return false;
+ if (QpsPerServerCore != other.QpsPerServerCore) return false;
+ if (ServerSystemTime != other.ServerSystemTime) return false;
+ if (ServerUserTime != other.ServerUserTime) return false;
+ if (ClientSystemTime != other.ClientSystemTime) return false;
+ if (ClientUserTime != other.ClientUserTime) return false;
+ if (Latency50 != other.Latency50) return false;
+ if (Latency90 != other.Latency90) return false;
+ if (Latency95 != other.Latency95) return false;
+ if (Latency99 != other.Latency99) return false;
+ if (Latency999 != other.Latency999) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ if (Qps != 0D) hash ^= Qps.GetHashCode();
+ if (QpsPerServerCore != 0D) hash ^= QpsPerServerCore.GetHashCode();
+ if (ServerSystemTime != 0D) hash ^= ServerSystemTime.GetHashCode();
+ if (ServerUserTime != 0D) hash ^= ServerUserTime.GetHashCode();
+ if (ClientSystemTime != 0D) hash ^= ClientSystemTime.GetHashCode();
+ if (ClientUserTime != 0D) hash ^= ClientUserTime.GetHashCode();
+ if (Latency50 != 0D) hash ^= Latency50.GetHashCode();
+ if (Latency90 != 0D) hash ^= Latency90.GetHashCode();
+ if (Latency95 != 0D) hash ^= Latency95.GetHashCode();
+ if (Latency99 != 0D) hash ^= Latency99.GetHashCode();
+ if (Latency999 != 0D) hash ^= Latency999.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (Qps != 0D) {
+ output.WriteRawTag(9);
+ output.WriteDouble(Qps);
+ }
+ if (QpsPerServerCore != 0D) {
+ output.WriteRawTag(17);
+ output.WriteDouble(QpsPerServerCore);
+ }
+ if (ServerSystemTime != 0D) {
+ output.WriteRawTag(25);
+ output.WriteDouble(ServerSystemTime);
+ }
+ if (ServerUserTime != 0D) {
+ output.WriteRawTag(33);
+ output.WriteDouble(ServerUserTime);
+ }
+ if (ClientSystemTime != 0D) {
+ output.WriteRawTag(41);
+ output.WriteDouble(ClientSystemTime);
+ }
+ if (ClientUserTime != 0D) {
+ output.WriteRawTag(49);
+ output.WriteDouble(ClientUserTime);
+ }
+ if (Latency50 != 0D) {
+ output.WriteRawTag(57);
+ output.WriteDouble(Latency50);
+ }
+ if (Latency90 != 0D) {
+ output.WriteRawTag(65);
+ output.WriteDouble(Latency90);
+ }
+ if (Latency95 != 0D) {
+ output.WriteRawTag(73);
+ output.WriteDouble(Latency95);
+ }
+ if (Latency99 != 0D) {
+ output.WriteRawTag(81);
+ output.WriteDouble(Latency99);
+ }
+ if (Latency999 != 0D) {
+ output.WriteRawTag(89);
+ output.WriteDouble(Latency999);
+ }
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ if (Qps != 0D) {
+ size += 1 + 8;
+ }
+ if (QpsPerServerCore != 0D) {
+ size += 1 + 8;
+ }
+ if (ServerSystemTime != 0D) {
+ size += 1 + 8;
+ }
+ if (ServerUserTime != 0D) {
+ size += 1 + 8;
+ }
+ if (ClientSystemTime != 0D) {
+ size += 1 + 8;
+ }
+ if (ClientUserTime != 0D) {
+ size += 1 + 8;
+ }
+ if (Latency50 != 0D) {
+ size += 1 + 8;
+ }
+ if (Latency90 != 0D) {
+ size += 1 + 8;
+ }
+ if (Latency95 != 0D) {
+ size += 1 + 8;
+ }
+ if (Latency99 != 0D) {
+ size += 1 + 8;
+ }
+ if (Latency999 != 0D) {
+ size += 1 + 8;
+ }
+ return size;
+ }
+
+ public void MergeFrom(ScenarioResultSummary other) {
+ if (other == null) {
+ return;
+ }
+ if (other.Qps != 0D) {
+ Qps = other.Qps;
+ }
+ if (other.QpsPerServerCore != 0D) {
+ QpsPerServerCore = other.QpsPerServerCore;
+ }
+ if (other.ServerSystemTime != 0D) {
+ ServerSystemTime = other.ServerSystemTime;
+ }
+ if (other.ServerUserTime != 0D) {
+ ServerUserTime = other.ServerUserTime;
+ }
+ if (other.ClientSystemTime != 0D) {
+ ClientSystemTime = other.ClientSystemTime;
+ }
+ if (other.ClientUserTime != 0D) {
+ ClientUserTime = other.ClientUserTime;
+ }
+ if (other.Latency50 != 0D) {
+ Latency50 = other.Latency50;
+ }
+ if (other.Latency90 != 0D) {
+ Latency90 = other.Latency90;
+ }
+ if (other.Latency95 != 0D) {
+ Latency95 = other.Latency95;
+ }
+ if (other.Latency99 != 0D) {
+ Latency99 = other.Latency99;
+ }
+ if (other.Latency999 != 0D) {
+ Latency999 = other.Latency999;
+ }
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 9: {
+ Qps = input.ReadDouble();
+ break;
+ }
+ case 17: {
+ QpsPerServerCore = input.ReadDouble();
+ break;
+ }
+ case 25: {
+ ServerSystemTime = input.ReadDouble();
+ break;
+ }
+ case 33: {
+ ServerUserTime = input.ReadDouble();
+ break;
+ }
+ case 41: {
+ ClientSystemTime = input.ReadDouble();
+ break;
+ }
+ case 49: {
+ ClientUserTime = input.ReadDouble();
+ break;
+ }
+ case 57: {
+ Latency50 = input.ReadDouble();
+ break;
+ }
+ case 65: {
+ Latency90 = input.ReadDouble();
+ break;
+ }
+ case 73: {
+ Latency95 = input.ReadDouble();
+ break;
+ }
+ case 81: {
+ Latency99 = input.ReadDouble();
+ break;
+ }
+ case 89: {
+ Latency999 = input.ReadDouble();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// Results of a single benchmark scenario.
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public sealed partial class ScenarioResult : pb::IMessage<ScenarioResult> {
+ private static readonly pb::MessageParser<ScenarioResult> _parser = new pb::MessageParser<ScenarioResult>(() => new ScenarioResult());
+ public static pb::MessageParser<ScenarioResult> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Testing.ControlReflection.Descriptor.MessageTypes[17]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public ScenarioResult() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public ScenarioResult(ScenarioResult other) : this() {
+ Scenario = other.scenario_ != null ? other.Scenario.Clone() : null;
+ Latencies = other.latencies_ != null ? other.Latencies.Clone() : null;
+ clientStats_ = other.clientStats_.Clone();
+ serverStats_ = other.serverStats_.Clone();
+ serverCores_ = other.serverCores_.Clone();
+ Summary = other.summary_ != null ? other.Summary.Clone() : null;
+ }
+
+ public ScenarioResult Clone() {
+ return new ScenarioResult(this);
+ }
+
+ /// <summary>Field number for the "scenario" field.</summary>
+ public const int ScenarioFieldNumber = 1;
+ private global::Grpc.Testing.Scenario scenario_;
+ /// <summary>
+ /// Inputs used to run the scenario.
+ /// </summary>
+ public global::Grpc.Testing.Scenario Scenario {
+ get { return scenario_; }
+ set {
+ scenario_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "latencies" field.</summary>
+ public const int LatenciesFieldNumber = 2;
+ private global::Grpc.Testing.HistogramData latencies_;
+ /// <summary>
+ /// Histograms from all clients merged into one histogram.
+ /// </summary>
+ public global::Grpc.Testing.HistogramData Latencies {
+ get { return latencies_; }
+ set {
+ latencies_ = value;
+ }
+ }
+
+ /// <summary>Field number for the "client_stats" field.</summary>
+ public const int ClientStatsFieldNumber = 3;
+ private static readonly pb::FieldCodec<global::Grpc.Testing.ClientStats> _repeated_clientStats_codec
+ = pb::FieldCodec.ForMessage(26, global::Grpc.Testing.ClientStats.Parser);
+ private readonly pbc::RepeatedField<global::Grpc.Testing.ClientStats> clientStats_ = new pbc::RepeatedField<global::Grpc.Testing.ClientStats>();
+ /// <summary>
+ /// Client stats for each client
+ /// </summary>
+ public pbc::RepeatedField<global::Grpc.Testing.ClientStats> ClientStats {
+ get { return clientStats_; }
+ }
+
+ /// <summary>Field number for the "server_stats" field.</summary>
+ public const int ServerStatsFieldNumber = 4;
+ private static readonly pb::FieldCodec<global::Grpc.Testing.ServerStats> _repeated_serverStats_codec
+ = pb::FieldCodec.ForMessage(34, global::Grpc.Testing.ServerStats.Parser);
+ private readonly pbc::RepeatedField<global::Grpc.Testing.ServerStats> serverStats_ = new pbc::RepeatedField<global::Grpc.Testing.ServerStats>();
+ /// <summary>
+ /// Server stats for each server
+ /// </summary>
+ public pbc::RepeatedField<global::Grpc.Testing.ServerStats> ServerStats {
+ get { return serverStats_; }
+ }
+
+ /// <summary>Field number for the "server_cores" field.</summary>
+ public const int ServerCoresFieldNumber = 5;
+ private static readonly pb::FieldCodec<int> _repeated_serverCores_codec
+ = pb::FieldCodec.ForInt32(42);
+ private readonly pbc::RepeatedField<int> serverCores_ = new pbc::RepeatedField<int>();
+ /// <summary>
+ /// Number of cores available to each server
+ /// </summary>
+ public pbc::RepeatedField<int> ServerCores {
+ get { return serverCores_; }
+ }
+
+ /// <summary>Field number for the "summary" field.</summary>
+ public const int SummaryFieldNumber = 6;
+ private global::Grpc.Testing.ScenarioResultSummary summary_;
+ /// <summary>
+ /// An after-the-fact computed summary
+ /// </summary>
+ public global::Grpc.Testing.ScenarioResultSummary Summary {
+ get { return summary_; }
+ set {
+ summary_ = value;
+ }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as ScenarioResult);
+ }
+
+ public bool Equals(ScenarioResult other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (!object.Equals(Scenario, other.Scenario)) return false;
+ if (!object.Equals(Latencies, other.Latencies)) return false;
+ if(!clientStats_.Equals(other.clientStats_)) return false;
+ if(!serverStats_.Equals(other.serverStats_)) return false;
+ if(!serverCores_.Equals(other.serverCores_)) return false;
+ if (!object.Equals(Summary, other.Summary)) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ if (scenario_ != null) hash ^= Scenario.GetHashCode();
+ if (latencies_ != null) hash ^= Latencies.GetHashCode();
+ hash ^= clientStats_.GetHashCode();
+ hash ^= serverStats_.GetHashCode();
+ hash ^= serverCores_.GetHashCode();
+ if (summary_ != null) hash ^= Summary.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (scenario_ != null) {
+ output.WriteRawTag(10);
+ output.WriteMessage(Scenario);
+ }
+ if (latencies_ != null) {
+ output.WriteRawTag(18);
+ output.WriteMessage(Latencies);
+ }
+ clientStats_.WriteTo(output, _repeated_clientStats_codec);
+ serverStats_.WriteTo(output, _repeated_serverStats_codec);
+ serverCores_.WriteTo(output, _repeated_serverCores_codec);
+ if (summary_ != null) {
+ output.WriteRawTag(50);
+ output.WriteMessage(Summary);
+ }
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ if (scenario_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Scenario);
+ }
+ if (latencies_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Latencies);
+ }
+ size += clientStats_.CalculateSize(_repeated_clientStats_codec);
+ size += serverStats_.CalculateSize(_repeated_serverStats_codec);
+ size += serverCores_.CalculateSize(_repeated_serverCores_codec);
+ if (summary_ != null) {
+ size += 1 + pb::CodedOutputStream.ComputeMessageSize(Summary);
+ }
+ return size;
+ }
+
+ public void MergeFrom(ScenarioResult other) {
+ if (other == null) {
+ return;
+ }
+ if (other.scenario_ != null) {
+ if (scenario_ == null) {
+ scenario_ = new global::Grpc.Testing.Scenario();
+ }
+ Scenario.MergeFrom(other.Scenario);
+ }
+ if (other.latencies_ != null) {
+ if (latencies_ == null) {
+ latencies_ = new global::Grpc.Testing.HistogramData();
+ }
+ Latencies.MergeFrom(other.Latencies);
+ }
+ clientStats_.Add(other.clientStats_);
+ serverStats_.Add(other.serverStats_);
+ serverCores_.Add(other.serverCores_);
+ if (other.summary_ != null) {
+ if (summary_ == null) {
+ summary_ = new global::Grpc.Testing.ScenarioResultSummary();
+ }
+ Summary.MergeFrom(other.Summary);
+ }
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 10: {
+ if (scenario_ == null) {
+ scenario_ = new global::Grpc.Testing.Scenario();
+ }
+ input.ReadMessage(scenario_);
+ break;
+ }
+ case 18: {
+ if (latencies_ == null) {
+ latencies_ = new global::Grpc.Testing.HistogramData();
+ }
+ input.ReadMessage(latencies_);
+ break;
+ }
+ case 26: {
+ clientStats_.AddEntriesFrom(input, _repeated_clientStats_codec);
+ break;
+ }
+ case 34: {
+ serverStats_.AddEntriesFrom(input, _repeated_serverStats_codec);
+ break;
+ }
+ case 42:
+ case 40: {
+ serverCores_.AddEntriesFrom(input, _repeated_serverCores_codec);
+ break;
+ }
+ case 50: {
+ if (summary_ == null) {
+ summary_ = new global::Grpc.Testing.ScenarioResultSummary();
+ }
+ input.ReadMessage(summary_);
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
#endregion
}
diff --git a/src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs b/src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs
index 99aa729030..5fd0e14e78 100644
--- a/src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs
+++ b/src/csharp/Grpc.IntegrationTesting/GeneratedServiceBaseTest.cs
@@ -84,7 +84,7 @@ namespace Grpc.IntegrationTesting
{
var call = client.StreamingInputCall();
- var ex = Assert.Throws<RpcException>(async () => await call);
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call);
Assert.AreEqual(StatusCode.Unimplemented, ex.Status.StatusCode);
}
@@ -93,7 +93,7 @@ namespace Grpc.IntegrationTesting
{
var call = client.StreamingOutputCall(new StreamingOutputCallRequest());
- var ex = Assert.Throws<RpcException>(async () => await call.ResponseStream.MoveNext());
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.MoveNext());
Assert.AreEqual(StatusCode.Unimplemented, ex.Status.StatusCode);
}
@@ -102,7 +102,7 @@ namespace Grpc.IntegrationTesting
{
var call = client.FullDuplexCall();
- var ex = Assert.Throws<RpcException>(async () => await call.ResponseStream.MoveNext());
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.MoveNext());
Assert.AreEqual(StatusCode.Unimplemented, ex.Status.StatusCode);
}
diff --git a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj
index 7ea80b11f0..c16d0e5c5d 100644
--- a/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj
+++ b/src/csharp/Grpc.IntegrationTesting/Grpc.IntegrationTesting.csproj
@@ -4,7 +4,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C61154BA-DD4A-4838-8420-0162A28925E0}</ProjectGuid>
- <OutputType>Library</OutputType>
+ <OutputType>Exe</OutputType>
<RootNamespace>Grpc.IntegrationTesting</RootNamespace>
<AssemblyName>Grpc.IntegrationTesting</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
@@ -38,47 +38,43 @@
<AssemblyOriginatorKeyFile>..\keys\Grpc.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
- <Reference Include="BouncyCastle.Crypto, Version=1.7.4137.9688, Culture=neutral, PublicKeyToken=a4292a325f69b123, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll</HintPath>
- </Reference>
<Reference Include="CommandLine">
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
</Reference>
- <Reference Include="Google.Apis.Auth, Version=1.11.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="Moq">
+ <HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Net" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Net.Http.WebRequest" />
+ <Reference Include="BouncyCastle.Crypto">
+ <HintPath>..\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll</HintPath>
+ </Reference>
+ <Reference Include="Google.Apis.Auth">
<HintPath>..\packages\Google.Apis.Auth.1.11.1\lib\net45\Google.Apis.Auth.dll</HintPath>
</Reference>
- <Reference Include="Google.Apis.Auth.PlatformServices, Version=1.11.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="Google.Apis.Auth.PlatformServices">
<HintPath>..\packages\Google.Apis.Auth.1.11.1\lib\net45\Google.Apis.Auth.PlatformServices.dll</HintPath>
</Reference>
- <Reference Include="Google.Apis.Core, Version=1.11.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="Google.Apis.Core">
<HintPath>..\packages\Google.Apis.Core.1.11.1\lib\net45\Google.Apis.Core.dll</HintPath>
</Reference>
- <Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="Google.Protobuf">
<HintPath>..\packages\Google.Protobuf.3.0.0-beta2\lib\portable-net45+netcore45+wpa81+wp8\Google.Protobuf.dll</HintPath>
</Reference>
- <Reference Include="Moq">
- <HintPath>..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath>
- </Reference>
- <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework">
- <HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
+ <HintPath>..\packages\NUnit.3.2.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
- <Reference Include="System" />
- <Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
+ <Reference Include="System.Interactive.Async">
<HintPath>..\packages\Ix-Async.1.2.5\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
- <Reference Include="System.Net" />
- <Reference Include="System.Net.Http" />
- <Reference Include="System.Net.Http.WebRequest" />
+ <Reference Include="nunitlite">
+ <HintPath>..\packages\NUnitLite.3.2.0\lib\net45\nunitlite.dll</HintPath>
+ </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Grpc.Core\Version.cs">
@@ -116,6 +112,7 @@
<Compile Include="GeneratedServiceBaseTest.cs" />
<Compile Include="GeneratedClientTest.cs" />
<Compile Include="InterarrivalTimers.cs" />
+ <Compile Include="NUnitMain.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
diff --git a/src/csharp/Grpc.IntegrationTesting/HeaderInterceptorTest.cs b/src/csharp/Grpc.IntegrationTesting/HeaderInterceptorTest.cs
deleted file mode 100644
index 1d758b7540..0000000000
--- a/src/csharp/Grpc.IntegrationTesting/HeaderInterceptorTest.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-#region Copyright notice and license
-
-// Copyright 2015, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Grpc.Core;
-using Grpc.Core.Utils;
-using Grpc.Testing;
-using NUnit.Framework;
-
-namespace Grpc.IntegrationTesting
-{
- public class HeaderInterceptorTest
- {
- const string Host = "localhost";
- Server server;
- Channel channel;
- TestService.TestServiceClient client;
-
- [TestFixtureSetUp]
- public void Init()
- {
- server = new Server
- {
- Services = { TestService.BindService(new TestServiceImpl()) },
- Ports = { { Host, ServerPort.PickUnused, ServerCredentials.Insecure } }
- };
- server.Start();
-
- channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure);
- client = TestService.NewClient(channel);
- }
-
- [TestFixtureTearDown]
- public void Cleanup()
- {
- channel.ShutdownAsync().Wait();
- server.ShutdownAsync().Wait();
- }
-
- [Test]
- public async Task HeaderInterceptor_CreateMetadata()
- {
- var key = "x-grpc-test-echo-initial";
- client.HeaderInterceptor = new HeaderInterceptor((method, metadata) =>
- {
- metadata.Add(key, "ABC");
- });
-
- var call = client.UnaryCallAsync(new SimpleRequest());
- await call;
-
- var responseHeaders = await call.ResponseHeadersAsync;
- Assert.AreEqual("ABC", responseHeaders.First((entry) => entry.Key == key).Value);
- }
-
- [Test]
- public async Task HeaderInterceptor_AppendMetadata()
- {
- var initialKey = "x-grpc-test-echo-initial";
- var trailingKey = "x-grpc-test-echo-trailing-bin";
-
- client.HeaderInterceptor = new HeaderInterceptor((method, metadata) =>
- {
- metadata.Add(initialKey, "ABC");
- });
-
- var headers = new Metadata
- {
- { trailingKey, new byte[] {0xaa} }
- };
- var call = client.UnaryCallAsync(new SimpleRequest(), headers: headers);
- await call;
-
- var responseHeaders = await call.ResponseHeadersAsync;
- Assert.AreEqual("ABC", responseHeaders.First((entry) => entry.Key == initialKey).Value);
- CollectionAssert.AreEqual(new byte[] {0xaa}, call.GetTrailers().First((entry) => entry.Key == trailingKey).ValueBytes);
- }
- }
-}
diff --git a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
index 7ca5221936..5436517960 100644
--- a/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
+++ b/src/csharp/Grpc.IntegrationTesting/InteropClient.cs
@@ -445,7 +445,7 @@ namespace Grpc.IntegrationTesting
await Task.Delay(1000);
cts.Cancel();
- var ex = Assert.Throws<RpcException>(async () => await call.ResponseAsync);
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseAsync);
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
}
Console.WriteLine("Passed!");
@@ -471,7 +471,7 @@ namespace Grpc.IntegrationTesting
cts.Cancel();
- var ex = Assert.Throws<RpcException>(async () => await call.ResponseStream.MoveNext());
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.MoveNext());
Assert.AreEqual(StatusCode.Cancelled, ex.Status.StatusCode);
}
Console.WriteLine("Passed!");
@@ -493,7 +493,7 @@ namespace Grpc.IntegrationTesting
// Deadline was reached before write has started. Eat the exception and continue.
}
- var ex = Assert.Throws<RpcException>(async () => await call.ResponseStream.MoveNext());
+ var ex = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.MoveNext());
Assert.AreEqual(StatusCode.DeadlineExceeded, ex.Status.StatusCode);
}
Console.WriteLine("Passed!");
@@ -572,7 +572,7 @@ namespace Grpc.IntegrationTesting
await call.RequestStream.WriteAsync(request);
await call.RequestStream.CompleteAsync();
- var e = Assert.Throws<RpcException>(async () => await call.ResponseStream.ToListAsync());
+ var e = Assert.ThrowsAsync<RpcException>(async () => await call.ResponseStream.ToListAsync());
Assert.AreEqual(StatusCode.Unknown, e.Status.StatusCode);
Assert.AreEqual(echoStatus.Message, e.Status.Detail);
}
diff --git a/src/csharp/Grpc.IntegrationTesting/Messages.cs b/src/csharp/Grpc.IntegrationTesting/Messages.cs
index 7ca47860f6..fcff475941 100644
--- a/src/csharp/Grpc.IntegrationTesting/Messages.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Messages.cs
@@ -47,11 +47,12 @@ namespace Grpc.Testing {
"c3Npb24YBiABKA4yHS5ncnBjLnRlc3RpbmcuQ29tcHJlc3Npb25UeXBlEjEK",
"D3Jlc3BvbnNlX3N0YXR1cxgHIAEoCzIYLmdycGMudGVzdGluZy5FY2hvU3Rh",
"dHVzIkUKG1N0cmVhbWluZ091dHB1dENhbGxSZXNwb25zZRImCgdwYXlsb2Fk",
- "GAEgASgLMhUuZ3JwYy50ZXN0aW5nLlBheWxvYWQiMwoNUmVjb25uZWN0SW5m",
- "bxIOCgZwYXNzZWQYASABKAgSEgoKYmFja29mZl9tcxgCIAMoBSo/CgtQYXls",
- "b2FkVHlwZRIQCgxDT01QUkVTU0FCTEUQABISCg5VTkNPTVBSRVNTQUJMRRAB",
- "EgoKBlJBTkRPTRACKjIKD0NvbXByZXNzaW9uVHlwZRIICgROT05FEAASCAoE",
- "R1pJUBABEgsKB0RFRkxBVEUQAmIGcHJvdG8z"));
+ "GAEgASgLMhUuZ3JwYy50ZXN0aW5nLlBheWxvYWQiMwoPUmVjb25uZWN0UGFy",
+ "YW1zEiAKGG1heF9yZWNvbm5lY3RfYmFja29mZl9tcxgBIAEoBSIzCg1SZWNv",
+ "bm5lY3RJbmZvEg4KBnBhc3NlZBgBIAEoCBISCgpiYWNrb2ZmX21zGAIgAygF",
+ "Kj8KC1BheWxvYWRUeXBlEhAKDENPTVBSRVNTQUJMRRAAEhIKDlVOQ09NUFJF",
+ "U1NBQkxFEAESCgoGUkFORE9NEAIqMgoPQ29tcHJlc3Npb25UeXBlEggKBE5P",
+ "TkUQABIICgRHWklQEAESCwoHREVGTEFURRACYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedCodeInfo(new[] {typeof(global::Grpc.Testing.PayloadType), typeof(global::Grpc.Testing.CompressionType), }, new pbr::GeneratedCodeInfo[] {
@@ -64,6 +65,7 @@ namespace Grpc.Testing {
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ResponseParameters), global::Grpc.Testing.ResponseParameters.Parser, new[]{ "Size", "IntervalUs" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.StreamingOutputCallRequest), global::Grpc.Testing.StreamingOutputCallRequest.Parser, new[]{ "ResponseType", "ResponseParameters", "Payload", "ResponseCompression", "ResponseStatus" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.StreamingOutputCallResponse), global::Grpc.Testing.StreamingOutputCallResponse.Parser, new[]{ "Payload" }, null, null, null),
+ new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ReconnectParams), global::Grpc.Testing.ReconnectParams.Parser, new[]{ "MaxReconnectBackoffMs" }, null, null, null),
new pbr::GeneratedCodeInfo(typeof(global::Grpc.Testing.ReconnectInfo), global::Grpc.Testing.ReconnectInfo.Parser, new[]{ "Passed", "BackoffMs" }, null, null, null)
}));
}
@@ -1574,6 +1576,113 @@ namespace Grpc.Testing {
/// <summary>
/// For reconnect interop test only.
+ /// Client tells server what reconnection parameters it used.
+ /// </summary>
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ public sealed partial class ReconnectParams : pb::IMessage<ReconnectParams> {
+ private static readonly pb::MessageParser<ReconnectParams> _parser = new pb::MessageParser<ReconnectParams>(() => new ReconnectParams());
+ public static pb::MessageParser<ReconnectParams> Parser { get { return _parser; } }
+
+ public static pbr::MessageDescriptor Descriptor {
+ get { return global::Grpc.Testing.MessagesReflection.Descriptor.MessageTypes[9]; }
+ }
+
+ pbr::MessageDescriptor pb::IMessage.Descriptor {
+ get { return Descriptor; }
+ }
+
+ public ReconnectParams() {
+ OnConstruction();
+ }
+
+ partial void OnConstruction();
+
+ public ReconnectParams(ReconnectParams other) : this() {
+ maxReconnectBackoffMs_ = other.maxReconnectBackoffMs_;
+ }
+
+ public ReconnectParams Clone() {
+ return new ReconnectParams(this);
+ }
+
+ /// <summary>Field number for the "max_reconnect_backoff_ms" field.</summary>
+ public const int MaxReconnectBackoffMsFieldNumber = 1;
+ private int maxReconnectBackoffMs_;
+ public int MaxReconnectBackoffMs {
+ get { return maxReconnectBackoffMs_; }
+ set {
+ maxReconnectBackoffMs_ = value;
+ }
+ }
+
+ public override bool Equals(object other) {
+ return Equals(other as ReconnectParams);
+ }
+
+ public bool Equals(ReconnectParams other) {
+ if (ReferenceEquals(other, null)) {
+ return false;
+ }
+ if (ReferenceEquals(other, this)) {
+ return true;
+ }
+ if (MaxReconnectBackoffMs != other.MaxReconnectBackoffMs) return false;
+ return true;
+ }
+
+ public override int GetHashCode() {
+ int hash = 1;
+ if (MaxReconnectBackoffMs != 0) hash ^= MaxReconnectBackoffMs.GetHashCode();
+ return hash;
+ }
+
+ public override string ToString() {
+ return pb::JsonFormatter.ToDiagnosticString(this);
+ }
+
+ public void WriteTo(pb::CodedOutputStream output) {
+ if (MaxReconnectBackoffMs != 0) {
+ output.WriteRawTag(8);
+ output.WriteInt32(MaxReconnectBackoffMs);
+ }
+ }
+
+ public int CalculateSize() {
+ int size = 0;
+ if (MaxReconnectBackoffMs != 0) {
+ size += 1 + pb::CodedOutputStream.ComputeInt32Size(MaxReconnectBackoffMs);
+ }
+ return size;
+ }
+
+ public void MergeFrom(ReconnectParams other) {
+ if (other == null) {
+ return;
+ }
+ if (other.MaxReconnectBackoffMs != 0) {
+ MaxReconnectBackoffMs = other.MaxReconnectBackoffMs;
+ }
+ }
+
+ public void MergeFrom(pb::CodedInputStream input) {
+ uint tag;
+ while ((tag = input.ReadTag()) != 0) {
+ switch(tag) {
+ default:
+ input.SkipLastField();
+ break;
+ case 8: {
+ MaxReconnectBackoffMs = input.ReadInt32();
+ break;
+ }
+ }
+ }
+ }
+
+ }
+
+ /// <summary>
+ /// For reconnect interop test only.
/// Server tells client whether its reconnects are following the spec and the
/// reconnect backoffs it saw.
/// </summary>
@@ -1583,7 +1692,7 @@ namespace Grpc.Testing {
public static pb::MessageParser<ReconnectInfo> Parser { get { return _parser; } }
public static pbr::MessageDescriptor Descriptor {
- get { return global::Grpc.Testing.MessagesReflection.Descriptor.MessageTypes[9]; }
+ get { return global::Grpc.Testing.MessagesReflection.Descriptor.MessageTypes[10]; }
}
pbr::MessageDescriptor pb::IMessage.Descriptor {
diff --git a/src/csharp/Grpc.IntegrationTesting/NUnitMain.cs b/src/csharp/Grpc.IntegrationTesting/NUnitMain.cs
new file mode 100644
index 0000000000..d8902de08f
--- /dev/null
+++ b/src/csharp/Grpc.IntegrationTesting/NUnitMain.cs
@@ -0,0 +1,59 @@
+#region Copyright notice and license
+
+// Copyright 2016, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#endregion
+
+using System;
+using System.Reflection;
+using Grpc.Core;
+using Grpc.Core.Logging;
+using NUnit.Common;
+using NUnitLite;
+
+namespace Grpc.IntegrationTesting
+{
+ /// <summary>
+ /// Provides entry point for NUnitLite
+ /// </summary>
+ public class NUnitMain
+ {
+ public static int Main(string[] args)
+ {
+ // Make logger immune to NUnit capturing stdout and stderr to workaround https://github.com/nunit/nunit/issues/1406.
+ GrpcEnvironment.SetLogger(new TextWriterLogger(Console.Error));
+#if DOTNET5_4
+ return new AutoRun(typeof(NUnitMain).GetTypeInfo().Assembly).Execute(args, new ExtendedTextWrapper(Console.Out), Console.In);
+#else
+ return new AutoRun().Execute(args);
+#endif
+ }
+ }
+}
diff --git a/src/csharp/Grpc.IntegrationTesting/Test.cs b/src/csharp/Grpc.IntegrationTesting/Test.cs
index 91e0a1e04c..363f6444ec 100644
--- a/src/csharp/Grpc.IntegrationTesting/Test.cs
+++ b/src/csharp/Grpc.IntegrationTesting/Test.cs
@@ -40,10 +40,10 @@ namespace Grpc.Testing {
"bWluZ091dHB1dENhbGxSZXF1ZXN0GikuZ3JwYy50ZXN0aW5nLlN0cmVhbWlu",
"Z091dHB1dENhbGxSZXNwb25zZSgBMAEyVQoUVW5pbXBsZW1lbnRlZFNlcnZp",
"Y2USPQoRVW5pbXBsZW1lbnRlZENhbGwSEy5ncnBjLnRlc3RpbmcuRW1wdHka",
- "Ey5ncnBjLnRlc3RpbmcuRW1wdHkyfwoQUmVjb25uZWN0U2VydmljZRIxCgVT",
- "dGFydBITLmdycGMudGVzdGluZy5FbXB0eRoTLmdycGMudGVzdGluZy5FbXB0",
- "eRI4CgRTdG9wEhMuZ3JwYy50ZXN0aW5nLkVtcHR5GhsuZ3JwYy50ZXN0aW5n",
- "LlJlY29ubmVjdEluZm9iBnByb3RvMw=="));
+ "Ey5ncnBjLnRlc3RpbmcuRW1wdHkyiQEKEFJlY29ubmVjdFNlcnZpY2USOwoF",
+ "U3RhcnQSHS5ncnBjLnRlc3RpbmcuUmVjb25uZWN0UGFyYW1zGhMuZ3JwYy50",
+ "ZXN0aW5nLkVtcHR5EjgKBFN0b3ASEy5ncnBjLnRlc3RpbmcuRW1wdHkaGy5n",
+ "cnBjLnRlc3RpbmcuUmVjb25uZWN0SW5mb2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Grpc.Testing.EmptyReflection.Descriptor, global::Grpc.Testing.MessagesReflection.Descriptor, },
new pbr::GeneratedCodeInfo(null, null));
diff --git a/src/csharp/Grpc.IntegrationTesting/TestCredentials.cs b/src/csharp/Grpc.IntegrationTesting/TestCredentials.cs
index ce108d808b..774563d752 100644
--- a/src/csharp/Grpc.IntegrationTesting/TestCredentials.cs
+++ b/src/csharp/Grpc.IntegrationTesting/TestCredentials.cs
@@ -35,6 +35,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
+using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Grpc.Core;
@@ -50,9 +51,29 @@ namespace Grpc.IntegrationTesting
{
public const string DefaultHostOverride = "foo.test.google.fr";
- public const string ClientCertAuthorityPath = "data/ca.pem";
- public const string ServerCertChainPath = "data/server1.pem";
- public const string ServerPrivateKeyPath = "data/server1.key";
+ public static string ClientCertAuthorityPath
+ {
+ get
+ {
+ return GetPath("data/ca.pem");
+ }
+ }
+
+ public static string ServerCertChainPath
+ {
+ get
+ {
+ return GetPath("data/server1.pem");
+ }
+ }
+
+ public static string ServerPrivateKeyPath
+ {
+ get
+ {
+ return GetPath("data/server1.key");
+ }
+ }
public static SslCredentials CreateSslCredentials()
{
@@ -66,5 +87,11 @@ namespace Grpc.IntegrationTesting
File.ReadAllText(ServerPrivateKeyPath));
return new SslServerCredentials(new[] { keyCertPair });
}
+
+ private static string GetPath(string relativePath)
+ {
+ var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
+ return Path.Combine(assemblyDir, relativePath);
+ }
}
}
diff --git a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
index b84ec2d984..31746cbe71 100644
--- a/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
+++ b/src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
@@ -367,14 +367,15 @@ namespace Grpc.Testing {
{
static readonly string __ServiceName = "grpc.testing.ReconnectService";
+ static readonly Marshaller<global::Grpc.Testing.ReconnectParams> __Marshaller_ReconnectParams = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectParams.Parser.ParseFrom);
static readonly Marshaller<global::Grpc.Testing.Empty> __Marshaller_Empty = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Empty.Parser.ParseFrom);
static readonly Marshaller<global::Grpc.Testing.ReconnectInfo> __Marshaller_ReconnectInfo = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ReconnectInfo.Parser.ParseFrom);
- static readonly Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty> __Method_Start = new Method<global::Grpc.Testing.Empty, global::Grpc.Testing.Empty>(
+ static readonly Method<global::Grpc.Testing.ReconnectParams, global::Grpc.Testing.Empty> __Method_Start = new Method<global::Grpc.Testing.ReconnectParams, global::Grpc.Testing.Empty>(
MethodType.Unary,
__ServiceName,
"Start",
- __Marshaller_Empty,
+ __Marshaller_ReconnectParams,
__Marshaller_Empty);
static readonly Method<global::Grpc.Testing.Empty, global::Grpc.Testing.ReconnectInfo> __Method_Stop = new Method<global::Grpc.Testing.Empty, global::Grpc.Testing.ReconnectInfo>(
@@ -394,10 +395,10 @@ namespace Grpc.Testing {
[System.Obsolete("Client side interfaced will be removed in the next release. Use client class directly.")]
public interface IReconnectServiceClient
{
- global::Grpc.Testing.Empty Start(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
- global::Grpc.Testing.Empty Start(global::Grpc.Testing.Empty request, CallOptions options);
- AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
- AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.Empty request, CallOptions options);
+ global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, CallOptions options);
+ AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
+ AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.ReconnectParams request, CallOptions options);
global::Grpc.Testing.ReconnectInfo Stop(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
global::Grpc.Testing.ReconnectInfo Stop(global::Grpc.Testing.Empty request, CallOptions options);
AsyncUnaryCall<global::Grpc.Testing.ReconnectInfo> StopAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken));
@@ -408,14 +409,14 @@ namespace Grpc.Testing {
[System.Obsolete("Service implementations should inherit from the generated abstract base class instead.")]
public interface IReconnectService
{
- Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.Empty request, ServerCallContext context);
+ Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.ReconnectParams request, ServerCallContext context);
Task<global::Grpc.Testing.ReconnectInfo> Stop(global::Grpc.Testing.Empty request, ServerCallContext context);
}
// server-side abstract class
public abstract class ReconnectServiceBase
{
- public virtual Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.Empty request, ServerCallContext context)
+ public virtual Task<global::Grpc.Testing.Empty> Start(global::Grpc.Testing.ReconnectParams request, ServerCallContext context)
{
throw new RpcException(new Status(StatusCode.Unimplemented, ""));
}
@@ -445,19 +446,19 @@ namespace Grpc.Testing {
{
}
- public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
return Start(request, new CallOptions(headers, deadline, cancellationToken));
}
- public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.Empty request, CallOptions options)
+ public virtual global::Grpc.Testing.Empty Start(global::Grpc.Testing.ReconnectParams request, CallOptions options)
{
return CallInvoker.BlockingUnaryCall(__Method_Start, null, options, request);
}
- public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.Empty request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
+ public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.ReconnectParams request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{
return StartAsync(request, new CallOptions(headers, deadline, cancellationToken));
}
- public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.Empty request, CallOptions options)
+ public virtual AsyncUnaryCall<global::Grpc.Testing.Empty> StartAsync(global::Grpc.Testing.ReconnectParams request, CallOptions options)
{
return CallInvoker.AsyncUnaryCall(__Method_Start, null, options, request);
}
diff --git a/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs b/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs
deleted file mode 100644
index 9f14dad6c0..0000000000
--- a/src/csharp/Grpc.IntegrationTesting/TestServiceGrpc.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-#region Copyright notice and license
-
-// Copyright 2015, Google Inc.
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are
-// met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Grpc.Core;
-
-namespace grpc.testing
-{
- /// <summary>
- /// TestService (this is handwritten version of code that will normally be generated).
- /// </summary>
- public class TestServiceGrpc
- {
- static readonly string ServiceName = "/grpc.testing.TestService";
-
- static readonly Marshaller<Empty> EmptyMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), Empty.ParseFrom);
- static readonly Marshaller<SimpleRequest> SimpleRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), SimpleRequest.ParseFrom);
- static readonly Marshaller<SimpleResponse> SimpleResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), SimpleResponse.ParseFrom);
- static readonly Marshaller<StreamingOutputCallRequest> StreamingOutputCallRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingOutputCallRequest.ParseFrom);
- static readonly Marshaller<StreamingOutputCallResponse> StreamingOutputCallResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingOutputCallResponse.ParseFrom);
- static readonly Marshaller<StreamingInputCallRequest> StreamingInputCallRequestMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingInputCallRequest.ParseFrom);
- static readonly Marshaller<StreamingInputCallResponse> StreamingInputCallResponseMarshaller = Marshallers.Create((arg) => arg.ToByteArray(), StreamingInputCallResponse.ParseFrom);
-
- static readonly Method<Empty, Empty> EmptyCallMethod = new Method<Empty, Empty>(
- MethodType.Unary,
- "EmptyCall",
- EmptyMarshaller,
- EmptyMarshaller);
-
- static readonly Method<SimpleRequest, SimpleResponse> UnaryCallMethod = new Method<SimpleRequest, SimpleResponse>(
- MethodType.Unary,
- "UnaryCall",
- SimpleRequestMarshaller,
- SimpleResponseMarshaller);
-
- static readonly Method<StreamingOutputCallRequest, StreamingOutputCallResponse> StreamingOutputCallMethod = new Method<StreamingOutputCallRequest, StreamingOutputCallResponse>(
- MethodType.ServerStreaming,
- "StreamingOutputCall",
- StreamingOutputCallRequestMarshaller,
- StreamingOutputCallResponseMarshaller);
-
- static readonly Method<StreamingInputCallRequest, StreamingInputCallResponse> StreamingInputCallMethod = new Method<StreamingInputCallRequest, StreamingInputCallResponse>(
- MethodType.ClientStreaming,
- "StreamingInputCall",
- StreamingInputCallRequestMarshaller,
- StreamingInputCallResponseMarshaller);
-
- static readonly Method<StreamingOutputCallRequest, StreamingOutputCallResponse> FullDuplexCallMethod = new Method<StreamingOutputCallRequest, StreamingOutputCallResponse>(
- MethodType.DuplexStreaming,
- "FullDuplexCall",
- StreamingOutputCallRequestMarshaller,
- StreamingOutputCallResponseMarshaller);
-
- static readonly Method<StreamingOutputCallRequest, StreamingOutputCallResponse> HalfDuplexCallMethod = new Method<StreamingOutputCallRequest, StreamingOutputCallResponse>(
- MethodType.DuplexStreaming,
- "HalfDuplexCall",
- StreamingOutputCallRequestMarshaller,
- StreamingOutputCallResponseMarshaller);
-
- public interface ITestServiceClient
- {
- Empty EmptyCall(Empty request, CancellationToken token = default(CancellationToken));
-
- Task<Empty> EmptyCallAsync(Empty request, CancellationToken token = default(CancellationToken));
-
- SimpleResponse UnaryCall(SimpleRequest request, CancellationToken token = default(CancellationToken));
-
- Task<SimpleResponse> UnaryCallAsync(SimpleRequest request, CancellationToken token = default(CancellationToken));
-
- AsyncServerStreamingCall<StreamingOutputCallResponse> StreamingOutputCall(StreamingOutputCallRequest request, CancellationToken token = default(CancellationToken));
-
- AsyncClientStreamingCall<StreamingInputCallRequest, StreamingInputCallResponse> StreamingInputCall(CancellationToken token = default(CancellationToken));
-
- AsyncDuplexStreamingCall<StreamingOutputCallRequest, StreamingOutputCallResponse> FullDuplexCall(CancellationToken token = default(CancellationToken));
-
- AsyncDuplexStreamingCall<StreamingOutputCallRequest, StreamingOutputCallResponse> HalfDuplexCall(CancellationToken token = default(CancellationToken));
- }
-
- public class TestServiceClientStub : AbstractStub<TestServiceClientStub, StubConfiguration>, ITestServiceClient
- {
- public TestServiceClientStub(Channel channel) : base(channel, StubConfiguration.Default)
- {
- }
-
- public TestServiceClientStub(Channel channel, StubConfiguration config) : base(channel, config)
- {
- }
-
- public Empty EmptyCall(Empty request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(ServiceName, EmptyCallMethod);
- return Calls.BlockingUnaryCall(call, request, token);
- }
-
- public Task<Empty> EmptyCallAsync(Empty request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(ServiceName, EmptyCallMethod);
- return Calls.AsyncUnaryCall(call, request, token);
- }
-
- public SimpleResponse UnaryCall(SimpleRequest request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(ServiceName, UnaryCallMethod);
- return Calls.BlockingUnaryCall(call, request, token);
- }
-
- public Task<SimpleResponse> UnaryCallAsync(SimpleRequest request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(ServiceName, UnaryCallMethod);
- return Calls.AsyncUnaryCall(call, request, token);
- }
-
- public AsyncServerStreamingCall<StreamingOutputCallResponse> StreamingOutputCall(StreamingOutputCallRequest request, CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(ServiceName, StreamingOutputCallMethod);
- return Calls.AsyncServerStreamingCall(call, request, token);
- }
-
- public AsyncClientStreamingCall<StreamingInputCallRequest, StreamingInputCallResponse> StreamingInputCall(CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(ServiceName, StreamingInputCallMethod);
- return Calls.AsyncClientStreamingCall(call, token);
- }
-
- public AsyncDuplexStreamingCall<StreamingOutputCallRequest, StreamingOutputCallResponse> FullDuplexCall(CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(ServiceName, FullDuplexCallMethod);
- return Calls.AsyncDuplexStreamingCall(call, token);
- }
-
- public AsyncDuplexStreamingCall<StreamingOutputCallRequest, StreamingOutputCallResponse> HalfDuplexCall(CancellationToken token = default(CancellationToken))
- {
- var call = CreateCall(ServiceName, HalfDuplexCallMethod);
- return Calls.AsyncDuplexStreamingCall(call, token);
- }
- }
-
- // server-side interface
- public interface ITestService
- {
- Task<Empty> EmptyCall(ServerCallContext context, Empty request);
-
- Task<SimpleResponse> UnaryCall(ServerCallContext context, SimpleRequest request);
-
- Task StreamingOutputCall(ServerCallContext context, StreamingOutputCallRequest request, IServerStreamWriter<StreamingOutputCallResponse> responseStream);
-
- Task<StreamingInputCallResponse> StreamingInputCall(ServerCallContext context, IAsyncStreamReader<StreamingInputCallRequest> requestStream);
-
- Task FullDuplexCall(ServerCallContext context, IAsyncStreamReader<StreamingOutputCallRequest> requestStream, IServerStreamWriter<StreamingOutputCallResponse> responseStream);
-
- Task HalfDuplexCall(ServerCallContext context, IAsyncStreamReader<StreamingOutputCallRequest> requestStream, IServerStreamWriter<StreamingOutputCallResponse> responseStream);
- }
-
- public static ServerServiceDefinition BindService(ITestService serviceImpl)
- {
- return ServerServiceDefinition.CreateBuilder(ServiceName)
- .AddMethod(EmptyCallMethod, serviceImpl.EmptyCall)
- .AddMethod(UnaryCallMethod, serviceImpl.UnaryCall)
- .AddMethod(StreamingOutputCallMethod, serviceImpl.StreamingOutputCall)
- .AddMethod(StreamingInputCallMethod, serviceImpl.StreamingInputCall)
- .AddMethod(FullDuplexCallMethod, serviceImpl.FullDuplexCall)
- .AddMethod(HalfDuplexCallMethod, serviceImpl.HalfDuplexCall)
- .Build();
- }
-
- public static ITestServiceClient NewStub(Channel channel)
- {
- return new TestServiceClientStub(channel);
- }
- }
-}
diff --git a/src/csharp/Grpc.IntegrationTesting/packages.config b/src/csharp/Grpc.IntegrationTesting/packages.config
index 0ae8bf4e70..3fef67dca4 100644
--- a/src/csharp/Grpc.IntegrationTesting/packages.config
+++ b/src/csharp/Grpc.IntegrationTesting/packages.config
@@ -8,5 +8,6 @@
<package id="Ix-Async" version="1.2.5" targetFramework="net45" />
<package id="Moq" version="4.2.1510.2205" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
- <package id="NUnit" version="2.6.4" targetFramework="net45" />
+ <package id="NUnit" version="3.2.0" targetFramework="net45" />
+ <package id="NUnitLite" version="3.2.0" targetFramework="net45" />
</packages> \ No newline at end of file
diff --git a/src/csharp/build_packages.bat b/src/csharp/build_packages.bat
index 7c42a6d3fc..9a60be26b6 100644
--- a/src/csharp/build_packages.bat
+++ b/src/csharp/build_packages.bat
@@ -12,12 +12,12 @@ set NUGET=C:\nuget\nuget.exe
@rem Collect the artifacts built by the previous build step if running on Jenkins
@rem TODO(jtattermusch): is there a better way to do this?
-xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=windows\artifacts\* grpc.native.csharp\windows_x86\
-xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=windows\artifacts\* grpc.native.csharp\windows_x64\
-xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=linux\artifacts\* grpc.native.csharp\linux_x86\
-xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=linux\artifacts\* grpc.native.csharp\linux_x64\
-xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=macos\artifacts\* grpc.native.csharp\macosx_x86\
-xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=macos\artifacts\* grpc.native.csharp\macosx_x64\
+xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=windows\artifacts\* Grpc.Core\windows_x86\
+xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=windows\artifacts\* Grpc.Core\windows_x64\
+xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=linux\artifacts\* Grpc.Core\linux_x86\
+xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=linux\artifacts\* Grpc.Core\linux_x64\
+xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=macos\artifacts\* Grpc.Core\macosx_x86\
+xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=macos\artifacts\* Grpc.Core\macosx_x64\
@rem Collect protoc artifacts built by the previous build step
xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x86\
@@ -42,7 +42,6 @@ msbuild Grpc.sln /p:Configuration=ReleaseSigned || goto :error
endlocal
-%NUGET% pack grpc.native.csharp\grpc.native.csharp.nuspec -Version %VERSION% || goto :error
%NUGET% pack Grpc.Auth\Grpc.Auth.nuspec -Symbols -Version %VERSION% || goto :error
%NUGET% pack Grpc.Core\Grpc.Core.nuspec -Symbols -Version %VERSION% || goto :error
%NUGET% pack Grpc.HealthCheck\Grpc.HealthCheck.nuspec -Symbols -Version %VERSION_WITH_BETA% -Properties ProtobufVersion=%PROTOBUF_VERSION% || goto :error
diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c
index 8d769e5f6a..aeef8a79e9 100644
--- a/src/csharp/ext/grpc_csharp_ext.c
+++ b/src/csharp/ext/grpc_csharp_ext.c
@@ -911,9 +911,12 @@ grpcsharp_ssl_server_credentials_create(
key_cert_pairs[i].private_key = key_cert_pair_private_key_array[i];
}
}
- creds = grpc_ssl_server_credentials_create(pem_root_certs, key_cert_pairs,
- num_key_cert_pairs,
- force_client_auth, NULL);
+ creds = grpc_ssl_server_credentials_create_ex(
+ pem_root_certs, key_cert_pairs, num_key_cert_pairs,
+ force_client_auth
+ ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ NULL);
gpr_free(key_cert_pairs);
return creds;
}
diff --git a/src/csharp/grpc.native.csharp/README.md b/src/csharp/grpc.native.csharp/README.md
deleted file mode 100644
index 77f1cb9b1f..0000000000
--- a/src/csharp/grpc.native.csharp/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-gRPC Native Nuget package
-=========================
-
-Prerequisites
--------------
-
-NuGet binary
-
-Building the package
---------------------
-
-To build the native package, you need precompiled versions
-of grpc_csharp_ext library artifacts for Windows, Linux and Mac.
-In the normal gRPC release process, these are built by a Jenkins
-job and they are copied to the expected location before building
-the native nuget package is attempted.
-
-See tools/run_tests/build_artifacts.py for more details how
-precompiled artifacts are built.
-
-When building the native NuGet package, ignore the "Assembly outside lib folder"
-warnings (the DLLs are not assemblies, they are native libraries).
diff --git a/src/csharp/tests.json b/src/csharp/tests.json
index 718bfa3287..f733352a31 100644
--- a/src/csharp/tests.json
+++ b/src/csharp/tests.json
@@ -1,11 +1,5 @@
{
- "assemblies": [
- "Grpc.Core.Tests",
- "Grpc.Examples.Tests",
- "Grpc.HealthCheck.Tests",
- "Grpc.IntegrationTesting"
- ],
- "tests": [
+ "Grpc.Core.Tests": [
"Grpc.Core.Internal.Tests.AsyncCallTest",
"Grpc.Core.Internal.Tests.ChannelArgsSafeHandleTest",
"Grpc.Core.Internal.Tests.CompletionQueueEventTest",
@@ -32,13 +26,19 @@
"Grpc.Core.Tests.ServerTest",
"Grpc.Core.Tests.ShutdownTest",
"Grpc.Core.Tests.TimeoutsTest",
- "Grpc.Core.Tests.UserAgentStringTest",
- "Math.Tests.MathClientServerTest",
+ "Grpc.Core.Tests.UserAgentStringTest"
+ ],
+ "Grpc.Examples.Tests": [
+ "Math.Tests.MathClientServerTest"
+ ],
+ "Grpc.HealthCheck.Tests": [
"Grpc.HealthCheck.Tests.HealthClientServerTest",
- "Grpc.HealthCheck.Tests.HealthServiceImplTest",
- "Grpc.IntegrationTesting.HistogramTest",
+ "Grpc.HealthCheck.Tests.HealthServiceImplTest"
+ ],
+ "Grpc.IntegrationTesting": [
"Grpc.IntegrationTesting.GeneratedClientTest",
"Grpc.IntegrationTesting.GeneratedServiceBaseTest",
+ "Grpc.IntegrationTesting.HistogramTest",
"Grpc.IntegrationTesting.InteropClientServerTest",
"Grpc.IntegrationTesting.MetadataCredentialsTest",
"Grpc.IntegrationTesting.RunnerClientServerTest",
diff --git a/src/node/ext/server_credentials.cc b/src/node/ext/server_credentials.cc
index 5285d53df4..cff821aafc 100644
--- a/src/node/ext/server_credentials.cc
+++ b/src/node/ext/server_credentials.cc
@@ -145,9 +145,13 @@ NAN_METHOD(ServerCredentials::CreateSsl) {
return Nan::ThrowTypeError(
"createSsl's second argument must be a list of objects");
}
- int force_client_auth = 0;
+
+ grpc_ssl_client_certificate_request_type client_certificate_request;
if (info[2]->IsBoolean()) {
- force_client_auth = (int)Nan::To<bool>(info[2]).FromJust();
+ client_certificate_request =
+ Nan::To<bool>(info[2]).FromJust()
+ ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
} else if (!(info[2]->IsUndefined() || info[2]->IsNull())) {
return Nan::ThrowTypeError(
"createSsl's third argument must be a boolean if provided");
@@ -180,8 +184,9 @@ NAN_METHOD(ServerCredentials::CreateSsl) {
key_cert_pairs[i].private_key = ::node::Buffer::Data(maybe_key);
key_cert_pairs[i].cert_chain = ::node::Buffer::Data(maybe_cert);
}
- grpc_server_credentials *creds = grpc_ssl_server_credentials_create(
- root_certs, key_cert_pairs, key_cert_pair_count, force_client_auth, NULL);
+ grpc_server_credentials *creds = grpc_ssl_server_credentials_create_ex(
+ root_certs, key_cert_pairs, key_cert_pair_count,
+ client_certificate_request, NULL);
delete key_cert_pairs;
if (creds == NULL) {
info.GetReturnValue().SetNull();
diff --git a/src/node/performance/worker.js b/src/node/performance/worker.js
index 98577bdbc9..7ef9b84fe7 100644
--- a/src/node/performance/worker.js
+++ b/src/node/performance/worker.js
@@ -33,6 +33,7 @@
'use strict';
+var console = require('console');
var worker_service_impl = require('./worker_service_impl');
var grpc = require('../../../');
@@ -48,6 +49,7 @@ function runServer(port) {
var address = '0.0.0.0:' + port;
server.bind(address, server_creds);
server.start();
+ console.log('running QPS worker on %s', address);
return server;
}
diff --git a/src/node/performance/worker_service_impl.js b/src/node/performance/worker_service_impl.js
index 17458e4b93..4b5cb8f9c2 100644
--- a/src/node/performance/worker_service_impl.js
+++ b/src/node/performance/worker_service_impl.js
@@ -34,6 +34,7 @@
'use strict';
var os = require('os');
+var console = require('console');
var BenchmarkClient = require('./benchmark_client');
var BenchmarkServer = require('./benchmark_server');
@@ -49,6 +50,7 @@ exports.runClient = function runClient(call) {
switch (request.argtype) {
case 'setup':
var setup = request.setup;
+ console.log('ClientConfig %j', setup);
client = new BenchmarkClient(setup.server_targets,
setup.client_channels,
setup.histogram_params,
@@ -118,6 +120,7 @@ exports.runServer = function runServer(call) {
var stats;
switch (request.argtype) {
case 'setup':
+ console.log('ServerConfig %j', request.setup);
server = new BenchmarkServer('[::]', request.setup.port,
request.setup.security_params);
server.start();
diff --git a/src/node/stress/stress_client.js b/src/node/stress/stress_client.js
index 8332652e2a..6054d3a253 100644
--- a/src/node/stress/stress_client.js
+++ b/src/node/stress/stress_client.js
@@ -102,7 +102,7 @@ function main() {
var argv = parseArgs(process.argv, {
string: ['server_addresses', 'test_cases', 'metrics_port'],
default: {'server_addresses': 'localhost:8080',
- 'test_duration-secs': -1,
+ 'test_duration_secs': -1,
'num_channels_per_server': 1,
'num_stubs_per_channel': 1,
'metrics_port': '8081'}
@@ -118,8 +118,8 @@ function main() {
}));
start(server_addresses, test_cases, argv.num_channels_per_server,
argv.num_stubs_per_channel, argv.metrics_port);
- if (argv['test_duration-secs'] > -1) {
- setTimeout(stop, argv['test_duration-secs'] * 1000);
+ if (argv.test_duration_secs > -1) {
+ setTimeout(stop, argv.test_duration_secs * 1000);
}
}
diff --git a/src/node/tools/bin/protoc.js b/src/node/tools/bin/protoc.js
new file mode 100755
index 0000000000..0c6d7ce017
--- /dev/null
+++ b/src/node/tools/bin/protoc.js
@@ -0,0 +1,54 @@
+#!/usr/bin/env node
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/**
+ * This file is required because package.json cannot reference a file that
+ * is not distributed with the package, and we use node-pre-gyp to distribute
+ * the protoc binary
+ */
+
+'use strict';
+
+var path = require('path');
+var execFile = require('child_process').execFile;
+
+var protoc = path.resolve(__dirname, 'protoc');
+
+execFile(protoc, process.argv.slice(2), function(error, stdout, stderr) {
+ if (error) {
+ throw error;
+ }
+ console.log(stdout);
+ console.log(stderr);
+});
diff --git a/src/cpp/common/create_auth_context.h b/src/node/tools/index.js
index 387407bfec..2de3918cd3 100644
--- a/src/cpp/common/create_auth_context.h
+++ b/src/node/tools/index.js
@@ -30,13 +30,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
-#include <memory>
-#include <grpc++/security/auth_context.h>
-#include <grpc/grpc.h>
+'use strict';
-namespace grpc {
-
-std::shared_ptr<const AuthContext> CreateAuthContext(grpc_call* call);
+/**
+ * package.json requires this file to be present. In the future, this can
+ * export useful information about the included tools.
+ */
-} // namespace grpc
+module.exports = {};
diff --git a/src/node/tools/package.json b/src/node/tools/package.json
new file mode 100644
index 0000000000..4b3499f2f9
--- /dev/null
+++ b/src/node/tools/package.json
@@ -0,0 +1,38 @@
+{
+ "name": "grpc-tools",
+ "version": "0.14.0-dev",
+ "author": "Google Inc.",
+ "description": "Tools for developing with gRPC on Node.js",
+ "homepage": "http://www.grpc.io/",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/grpc/grpc.git"
+ },
+ "bugs": "https://github.com/grpc/grpc/issues",
+ "contributors": [
+ {
+ "name": "Michael Lumish",
+ "email": "mlumish@google.com"
+ }
+ ],
+ "bin": {
+ "grpc-tools-protoc": "./bin/protoc.js"
+ },
+ "scripts": {
+ "install": "./node_modules/.bin/node-pre-gyp install"
+ },
+ "bundledDependencies": ["node-pre-gyp"],
+ "binary": {
+ "module_name": "grpc_tools",
+ "host": "https://storage.googleapis.com/",
+ "remote_path": "grpc-precompiled-binaries/node/{name}/v{version}",
+ "package_name": "{platform}-{arch}.tar.gz",
+ "module_path": "bin"
+ },
+ "files": [
+ "index.js",
+ "bin/protoc.js",
+ "LICENSE"
+ ],
+ "main": "index.js"
+}
diff --git a/src/php/ext/grpc/byte_buffer.c b/src/php/ext/grpc/byte_buffer.c
index 8be0a20607..7a726de5db 100644
--- a/src/php/ext/grpc/byte_buffer.c
+++ b/src/php/ext/grpc/byte_buffer.c
@@ -72,6 +72,7 @@ void byte_buffer_to_string(grpc_byte_buffer *buffer, char **out_string,
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
memcpy(string + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next));
offset += GPR_SLICE_LENGTH(next);
+ gpr_slice_unref(next);
}
*out_string = string;
*out_length = length;
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c
index 024ab70571..a0f3d160c6 100644
--- a/src/php/ext/grpc/call.c
+++ b/src/php/ext/grpc/call.c
@@ -492,6 +492,14 @@ cleanup:
if (status_details != NULL) {
gpr_free(status_details);
}
+ for (int i = 0; i < op_num; i++) {
+ if (ops[i].op == GRPC_OP_SEND_MESSAGE) {
+ grpc_byte_buffer_destroy(ops[i].data.send_message);
+ }
+ if (ops[i].op == GRPC_OP_RECV_MESSAGE) {
+ grpc_byte_buffer_destroy(message);
+ }
+ }
RETURN_DESTROY_ZVAL(result);
}
diff --git a/src/php/ext/grpc/server_credentials.c b/src/php/ext/grpc/server_credentials.c
index 79188246bc..f3951b31fe 100644
--- a/src/php/ext/grpc/server_credentials.c
+++ b/src/php/ext/grpc/server_credentials.c
@@ -115,10 +115,11 @@ PHP_METHOD(ServerCredentials, createSsl) {
"createSsl expects 3 strings", 1 TSRMLS_CC);
return;
}
- /* TODO: add a force_client_auth field in ServerCredentials and pass it as
- * the last parameter. */
- grpc_server_credentials *creds = grpc_ssl_server_credentials_create(
- pem_root_certs, &pem_key_cert_pair, 1, 0, NULL);
+ /* TODO: add a client_certificate_request field in ServerCredentials and pass
+ * it as the last parameter. */
+ grpc_server_credentials *creds = grpc_ssl_server_credentials_create_ex(
+ pem_root_certs, &pem_key_cert_pair, 1,
+ GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, NULL);
zval *creds_object = grpc_php_wrap_server_credentials(creds);
RETURN_DESTROY_ZVAL(creds_object);
}
diff --git a/src/php/tests/bootstrap.php b/src/php/tests/bootstrap.php
index b61f2c40a5..8b3d4347e2 100644
--- a/src/php/tests/bootstrap.php
+++ b/src/php/tests/bootstrap.php
@@ -17,5 +17,5 @@
*/
error_reporting(E_ALL | E_STRICT);
-require dirname(__DIR__) . '/vendor/autoload.php';
+require dirname(__DIR__).'/vendor/autoload.php';
date_default_timezone_set('UTC');
diff --git a/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php b/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php
index 6bb1955ccb..6b70b8ac10 100644
--- a/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php
+++ b/src/php/tests/generated_code/GeneratedCodeWithCallbackTest.php
@@ -46,7 +46,8 @@ class GeneratedCodeWithCallbackTest extends AbstractGeneratedCodeTest
$a_copy['foo'] = ['bar'];
return $a_copy;
- }]);
+ },
+ ]);
}
public function tearDown()
diff --git a/src/php/tests/generated_code/math_client.php b/src/php/tests/generated_code/math_client.php
index b8652ceb08..6ee92bc465 100644
--- a/src/php/tests/generated_code/math_client.php
+++ b/src/php/tests/generated_code/math_client.php
@@ -38,13 +38,13 @@ include 'tests/generated_code/math.php';
function p($line)
{
- print("$line<br/>\n");
+ echo "$line<br/>\n";
}
$host = 'localhost:50051';
p("Connecting to host: $host");
$client = new math\MathClient($host, [
- 'credentials' => Grpc\ChannelCredentials::createInsecure()
+ 'credentials' => Grpc\ChannelCredentials::createInsecure(),
]);
p('Client class: '.get_class($client));
p('');
diff --git a/src/php/tests/unit_tests/CallCredentials3Test.php b/src/php/tests/unit_tests/CallCredentials3Test.php
index 6d98815d16..8f5e109bf5 100644
--- a/src/php/tests/unit_tests/CallCredentials3Test.php
+++ b/src/php/tests/unit_tests/CallCredentials3Test.php
@@ -132,5 +132,4 @@ class CallCredentials3Test extends PHPUnit_Framework_TestCase
unset($call);
unset($server_call);
}
-
}
diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php
index 1170a440fa..fa026f0935 100755
--- a/src/php/tests/unit_tests/CallTest.php
+++ b/src/php/tests/unit_tests/CallTest.php
@@ -94,7 +94,7 @@ class CallTest extends PHPUnit_Framework_TestCase
public function testCancel()
{
- $this->assertNull($this->call->cancel());
+ $this->assertNull($this->call->cancel());
}
/**
@@ -118,5 +118,4 @@ class CallTest extends PHPUnit_Framework_TestCase
];
$result = $this->call->startBatch($batch);
}
-
}
diff --git a/src/php/tests/unit_tests/ChannelCredentialsTest.php b/src/php/tests/unit_tests/ChannelCredentialsTest.php
index 1a42d69428..56c1d8f006 100644
--- a/src/php/tests/unit_tests/ChannelCredentialsTest.php
+++ b/src/php/tests/unit_tests/ChannelCredentialsTest.php
@@ -70,4 +70,4 @@ class ChanellCredentialsTest extends PHPUnit_Framework_TestCase
$channel_credentials = Grpc\ChannelCredentials::createInsecure();
$this->assertNull($channel_credentials);
}
-} \ No newline at end of file
+}
diff --git a/src/php/tests/unit_tests/ChannelTest.php b/src/php/tests/unit_tests/ChannelTest.php
index b6eac3109a..a1f9053c39 100644
--- a/src/php/tests/unit_tests/ChannelTest.php
+++ b/src/php/tests/unit_tests/ChannelTest.php
@@ -78,5 +78,4 @@ class ChannelTest extends PHPUnit_Framework_TestCase
]
);
}
-
-} \ No newline at end of file
+}
diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php
index 3fa92c950b..2b09f9d112 100755
--- a/src/php/tests/unit_tests/EndToEndTest.php
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -261,7 +261,8 @@ class EndToEndTest extends PHPUnit_Framework_TestCase
Grpc\OP_SEND_INITIAL_METADATA => [],
Grpc\OP_SEND_CLOSE_FROM_CLIENT => true,
Grpc\OP_SEND_MESSAGE => ['message' => 'abc',
- 'flags' => 'invalid'],
+ 'flags' => 'invalid',
+ ],
]);
}
@@ -574,7 +575,7 @@ class EndToEndTest extends PHPUnit_Framework_TestCase
public function testGetConnectivityStateInvalidParam()
{
$this->assertTrue($this->channel->getConnectivityState(
- new Grpc\Timeval));
+ new Grpc\Timeval()));
}
/**
@@ -591,12 +592,11 @@ class EndToEndTest extends PHPUnit_Framework_TestCase
*/
public function testChannelConstructorInvalidParam()
{
- $this->channel = new Grpc\Channel('localhost:'.$this->port, NULL);
+ $this->channel = new Grpc\Channel('localhost:'.$this->port, null);
}
public function testClose()
{
$this->assertNull($this->channel->close());
}
-
}
diff --git a/src/php/tests/unit_tests/ServerTest.php b/src/php/tests/unit_tests/ServerTest.php
index d18f9abe9b..76aaa06970 100644
--- a/src/php/tests/unit_tests/ServerTest.php
+++ b/src/php/tests/unit_tests/ServerTest.php
@@ -67,5 +67,4 @@ class ServerTest extends PHPUnit_Framework_TestCase
$this->server = new Grpc\Server([]);
$this->port = $this->server->addSecureHttp2Port(['0.0.0.0:0']);
}
-
-} \ No newline at end of file
+}
diff --git a/src/php/tests/unit_tests/TimevalTest.php b/src/php/tests/unit_tests/TimevalTest.php
index 43abba126a..a3dbce079f 100755
--- a/src/php/tests/unit_tests/TimevalTest.php
+++ b/src/php/tests/unit_tests/TimevalTest.php
@@ -94,13 +94,13 @@ class TimevalTest extends PHPUnit_Framework_TestCase
public function testSimilar()
{
- $a = Grpc\Timeval::now();
- $delta = new Grpc\Timeval(1000);
- $b = $a->add($delta);
- $thresh = new Grpc\Timeval(1100);
- $this->assertTrue(Grpc\Timeval::similar($a, $b, $thresh));
- $thresh = new Grpc\Timeval(900);
- $this->assertFalse(Grpc\Timeval::similar($a, $b, $thresh));
+ $a = Grpc\Timeval::now();
+ $delta = new Grpc\Timeval(1000);
+ $b = $a->add($delta);
+ $thresh = new Grpc\Timeval(1100);
+ $this->assertTrue(Grpc\Timeval::similar($a, $b, $thresh));
+ $thresh = new Grpc\Timeval(900);
+ $this->assertFalse(Grpc\Timeval::similar($a, $b, $thresh));
}
public function testSleepUntil()
@@ -155,5 +155,4 @@ class TimevalTest extends PHPUnit_Framework_TestCase
{
$a = Grpc\Timeval::similar(1000, 1100, 1200);
}
-
}
diff --git a/src/proto/gen_build_yaml.py b/src/proto/gen_build_yaml.py
index 8e66939699..2a8d9fab93 100755
--- a/src/proto/gen_build_yaml.py
+++ b/src/proto/gen_build_yaml.py
@@ -36,7 +36,7 @@ import os
import re
import sys
-def update_deps(key, proto_filename, deps, is_trans, visited):
+def update_deps(key, proto_filename, deps, deps_external, is_trans, visited):
if not proto_filename in visited:
visited.append(proto_filename)
with open(proto_filename) as inp:
@@ -44,10 +44,17 @@ def update_deps(key, proto_filename, deps, is_trans, visited):
imp = re.search(r'import "([^"]*)"', line)
if not imp: continue
imp_proto = imp.group(1)
+ # This indicates an external dependency, which we should handle
+ # differently and not traverse recursively
+ if imp_proto.startswith('google/'):
+ if key not in deps_external:
+ deps_external[key] = []
+ deps_external[key].append(imp_proto[:-6])
+ continue
if key not in deps: deps[key] = []
deps[key].append(imp_proto[:-6])
if is_trans:
- update_deps(key, imp_proto, deps, is_trans, visited)
+ update_deps(key, imp_proto, deps, deps_external, is_trans, visited)
def main():
proto_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
@@ -55,17 +62,23 @@ def main():
deps = {}
deps_trans = {}
+ deps_external = {}
+ deps_external_trans = {}
for root, dirs, files in os.walk('src/proto'):
for f in files:
if f[-6:] != '.proto': continue
look_at = os.path.join(root, f)
deps_for = look_at[:-6]
- update_deps(deps_for, look_at, deps, False, []) # First level deps
- update_deps(deps_for, look_at, deps_trans, True, []) # Transitive deps
+ # First level deps
+ update_deps(deps_for, look_at, deps, deps_external, False, [])
+ # Transitive deps
+ update_deps(deps_for, look_at, deps_trans, deps_external_trans, True, [])
json = {
'proto_deps': deps,
- 'proto_transitive_deps': deps_trans
+ 'proto_transitive_deps': deps_trans,
+ 'proto_external_deps': deps_external,
+ 'proto_transitive_external_deps': deps_external_trans
}
print yaml.dump(json)
diff --git a/src/proto/grpc/binary_log/v1alpha/log.proto b/src/proto/grpc/binary_log/v1alpha/log.proto
new file mode 100644
index 0000000000..83166cd410
--- /dev/null
+++ b/src/proto/grpc/binary_log/v1alpha/log.proto
@@ -0,0 +1,108 @@
+// Copyright 2016, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+syntax = "proto3";
+
+import "google/protobuf/timestamp.proto"
+
+package grpc.binary_log.v1alpha;
+
+enum Direction {
+ SERVER_SEND;
+ SERVER_RECV;
+ CLIENT_SEND;
+ CLIENT_RECV;
+}
+
+message KeyValuePair {
+ string key;
+ string value;
+}
+
+// Any sort of metadata that may be sent in either direction during a call
+message Metadata {
+ // Cryptographically unique identifier, generated on the client and sent
+ // to the server.
+ uint64 rpc_id = 1;
+ // Timestamp of logging the metadata
+ google.protobuf.Timestamp timestamp = 2;
+ Direction direction = 3;
+ // The actual metadata that is being sent
+ repeated KeyValuePair metadata = 4;
+
+ // Initial metadata sent by the client to initiate a request
+ message ClientInitialMetadata {
+ // The full method name that is being called
+ string method_name = 1;
+ // The call's deadline
+ google.protobuf.Timestamp deadline = 2;
+ // The address of the connected peer
+ string peer = 3;
+ }
+
+ // Arbitrary key/value pairs specified by the user that are not sent over
+ // the network but are nonetheless useful to log
+ message UserData {
+ }
+
+ // Initial metadata response sent by the server after accepting the request
+ message ServerInitialMetadata {
+ }
+
+ // Status sent by the server when closing the call on the server side
+ message ServerStatus {
+ // The status code
+ uint32 code = 1;
+ // The status details
+ string details = 2;
+ }
+
+ oneof kind {
+ ClientInitialMetadata client_initial_metadata = 5;
+ UserData user_data = 6;
+ ServerInitialMetadata server_initial_metadata = 7;
+ ServerStatus server_status = 8;
+ }
+}
+
+// A message that is sent during a call
+message Message {
+ // Cryptographically unique identifier, generated on the client and sent
+ // to the server.
+ uint64 rpc_id = 1;
+ // The sequence number of the message. Messages sent by the client and by the
+ // server should have independently incrementing sequence numbers.
+ uint32 sequence_number = 2;
+ Direction direction = 3;
+ // The length of the complete message.
+ uint32 length = 4;
+ // The contents of the message. May be a prefix instead of the complete
+ // message.
+ bytes data = 5;
+}
diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto
index 11e752a74b..28769ef653 100644
--- a/src/proto/grpc/testing/control.proto
+++ b/src/proto/grpc/testing/control.proto
@@ -57,18 +57,6 @@ message PoissonParams {
double offered_load = 1;
}
-message UniformParams {
- double interarrival_lo = 1;
- double interarrival_hi = 2;
-}
-
-message DeterministicParams { double offered_load = 1; }
-
-message ParetoParams {
- double interarrival_base = 1;
- double alpha = 2;
-}
-
// Once an RPC finishes, immediately start a new one.
// No configuration parameters needed.
message ClosedLoopParams {}
@@ -77,9 +65,6 @@ message LoadParams {
oneof load {
ClosedLoopParams closed_loop = 1;
PoissonParams poisson = 2;
- UniformParams uniform = 3;
- DeterministicParams determ = 4;
- ParetoParams pareto = 5;
};
}
@@ -169,3 +154,69 @@ message CoreResponse {
message Void {
}
+
+// A single performance scenario: input to qps_json_driver
+message Scenario {
+ // Human readable name for this scenario
+ string name = 1;
+ // Client configuration
+ ClientConfig client_config = 2;
+ // Number of clients to start for the test
+ int32 num_clients = 3;
+ // Server configuration
+ ServerConfig server_config = 4;
+ // Number of servers to start for the test
+ int32 num_servers = 5;
+ // Warmup period, in seconds
+ int32 warmup_seconds = 6;
+ // Benchmark time, in seconds
+ int32 benchmark_seconds = 7;
+ // Number of workers to spawn locally (usually zero)
+ int32 spawn_local_worker_count = 8;
+}
+
+// A set of scenarios to be run with qps_json_driver
+message Scenarios {
+ repeated Scenario scenarios = 1;
+}
+
+// Basic summary that can be computed from ClientStats and ServerStats
+// once the scenario has finished.
+message ScenarioResultSummary
+{
+ // Total number of operations per second over all clients.
+ double qps = 1;
+ // QPS per one server core.
+ double qps_per_server_core = 2;
+ // server load based on system_time (0.85 => 85%)
+ double server_system_time = 3;
+ // server load based on user_time (0.85 => 85%)
+ double server_user_time = 4;
+ // client load based on system_time (0.85 => 85%)
+ double client_system_time = 5;
+ // client load based on user_time (0.85 => 85%)
+ double client_user_time = 6;
+
+ // X% latency percentiles (in nanoseconds)
+ double latency_50 = 7;
+ double latency_90 = 8;
+ double latency_95 = 9;
+ double latency_99 = 10;
+ double latency_999 = 11;
+}
+
+// Results of a single benchmark scenario.
+message ScenarioResult {
+ // Inputs used to run the scenario.
+ Scenario scenario = 1;
+ // Histograms from all clients merged into one histogram.
+ HistogramData latencies = 2;
+ // Client stats for each client
+ repeated ClientStats client_stats = 3;
+ // Server stats for each server
+ repeated ServerStats server_stats = 4;
+ // Number of cores available to each server
+ repeated int32 server_cores = 5;
+ // An after-the-fact computed summary
+ ScenarioResultSummary summary = 6;
+}
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
index 842635f56b..94d13b5999 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/credentials.pyx.pxi
@@ -302,6 +302,8 @@ def server_credentials_ssl(pem_root_certs, pem_key_cert_pairs,
(<SslPemKeyCertPair>pem_key_cert_pairs[i]).c_pair)
credentials.c_credentials = grpc_ssl_server_credentials_create(
c_pem_root_certs, credentials.c_ssl_pem_key_cert_pairs,
- credentials.c_ssl_pem_key_cert_pairs_count, force_client_auth, NULL)
+ credentials.c_ssl_pem_key_cert_pairs_count,
+ GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY if force_client_auth else GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ NULL)
return credentials
diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
index 7696f8c7f7..3d158a7707 100644
--- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
+++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
@@ -105,6 +105,13 @@ cdef extern from "grpc/_cython/loader.h":
GRPC_SSL_ROOTS_OVERRIDE_FAILED_PERMANENTLY
GRPC_SSL_ROOTS_OVERRIDE_FAILED
+ ctypedef enum grpc_ssl_client_certificate_request_type:
+ GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE,
+ GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_BUT_DONT_VERIFY
+ GRPC_SSL_REQUEST_CLIENT_CERTIFICATE_AND_VERIFY
+ GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_BUT_DONT_VERIFY
+ GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+
struct grpc_byte_buffer_reader:
# We don't care about the internals
pass
diff --git a/src/python/grpcio/grpc/_cython/imports.generated.c b/src/python/grpcio/grpc/_cython/imports.generated.c
index 8bd6ae6372..9ab0696702 100644
--- a/src/python/grpcio/grpc/_cython/imports.generated.c
+++ b/src/python/grpcio/grpc/_cython/imports.generated.c
@@ -152,6 +152,7 @@ grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_crea
grpc_secure_channel_create_type grpc_secure_channel_create_import;
grpc_server_credentials_release_type grpc_server_credentials_release_import;
grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import;
+grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import;
grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
grpc_call_set_credentials_type grpc_call_set_credentials_import;
grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import;
@@ -174,6 +175,8 @@ grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
gpr_log_type gpr_log_import;
gpr_log_message_type gpr_log_message_import;
+gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
+gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
gpr_set_log_function_type gpr_set_log_function_import;
gpr_slice_ref_type gpr_slice_ref_import;
gpr_slice_unref_type gpr_slice_unref_import;
@@ -418,6 +421,7 @@ void pygrpc_load_imports(HMODULE library) {
grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create");
grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release");
grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create");
+ grpc_ssl_server_credentials_create_ex_import = (grpc_ssl_server_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_ex");
grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port");
grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials");
grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor");
@@ -440,6 +444,8 @@ void pygrpc_load_imports(HMODULE library) {
grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader");
gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log");
gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message");
+ gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity");
+ gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init");
gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function");
gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref");
gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref");
diff --git a/src/python/grpcio/grpc/_cython/imports.generated.h b/src/python/grpcio/grpc/_cython/imports.generated.h
index 272e85b485..e50051ddc7 100644
--- a/src/python/grpcio/grpc/_cython/imports.generated.h
+++ b/src/python/grpcio/grpc/_cython/imports.generated.h
@@ -406,6 +406,9 @@ extern grpc_server_credentials_release_type grpc_server_credentials_release_impo
typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved);
extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import;
#define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import
+typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_ex_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void *reserved);
+extern grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import;
+#define grpc_ssl_server_credentials_create_ex grpc_ssl_server_credentials_create_ex_import
typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server *server, const char *addr, grpc_server_credentials *creds);
extern grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
#define grpc_server_add_secure_http2_port grpc_server_add_secure_http2_port_import
@@ -472,6 +475,12 @@ extern gpr_log_type gpr_log_import;
typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message);
extern gpr_log_message_type gpr_log_message_import;
#define gpr_log_message gpr_log_message_import
+typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print);
+extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
+#define gpr_set_log_verbosity gpr_set_log_verbosity_import
+typedef void(*gpr_log_verbosity_init_type)();
+extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
+#define gpr_log_verbosity_init gpr_log_verbosity_init_import
typedef void(*gpr_set_log_function_type)(gpr_log_func func);
extern gpr_set_log_function_type gpr_set_log_function_import;
#define gpr_set_log_function gpr_set_log_function_import
diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py
index 2ed0b1e520..c5a0a398b4 100644
--- a/src/python/grpcio/grpc_core_dependencies.py
+++ b/src/python/grpcio/grpc_core_dependencies.py
@@ -74,63 +74,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/support/tmpfile_posix.c',
'src/core/lib/support/tmpfile_win32.c',
'src/core/lib/support/wrap_memcpy.c',
- 'src/core/ext/census/context.c',
- 'src/core/ext/census/grpc_context.c',
- 'src/core/ext/census/grpc_filter.c',
- 'src/core/ext/census/grpc_plugin.c',
- 'src/core/ext/census/initialize.c',
- 'src/core/ext/census/mlog.c',
- 'src/core/ext/census/operation.c',
- 'src/core/ext/census/placeholders.c',
- 'src/core/ext/census/tracing.c',
- 'src/core/ext/client_config/channel_connectivity.c',
- 'src/core/ext/client_config/client_channel.c',
- 'src/core/ext/client_config/client_channel_factory.c',
- 'src/core/ext/client_config/client_config.c',
- 'src/core/ext/client_config/connector.c',
- 'src/core/ext/client_config/default_initial_connect_string.c',
- 'src/core/ext/client_config/initial_connect_string.c',
- 'src/core/ext/client_config/lb_policy.c',
- 'src/core/ext/client_config/lb_policy_factory.c',
- 'src/core/ext/client_config/lb_policy_registry.c',
- 'src/core/ext/client_config/resolver.c',
- 'src/core/ext/client_config/resolver_factory.c',
- 'src/core/ext/client_config/resolver_registry.c',
- 'src/core/ext/client_config/subchannel.c',
- 'src/core/ext/client_config/subchannel_call_holder.c',
- 'src/core/ext/client_config/subchannel_index.c',
- 'src/core/ext/client_config/uri_parser.c',
- 'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
- 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c',
- 'src/core/ext/lb_policy/pick_first/pick_first.c',
- 'src/core/ext/lb_policy/round_robin/round_robin.c',
- 'src/core/ext/resolver/dns/native/dns_resolver.c',
- 'src/core/ext/resolver/sockaddr/sockaddr_resolver.c',
- 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
- 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
- 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c',
- 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
- 'src/core/ext/transport/chttp2/transport/alpn.c',
- 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
- 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
- 'src/core/ext/transport/chttp2/transport/frame_data.c',
- 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
- 'src/core/ext/transport/chttp2/transport/frame_ping.c',
- 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
- 'src/core/ext/transport/chttp2/transport/frame_settings.c',
- 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
- 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
- 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
- 'src/core/ext/transport/chttp2/transport/hpack_table.c',
- 'src/core/ext/transport/chttp2/transport/huffsyms.c',
- 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
- 'src/core/ext/transport/chttp2/transport/parsing.c',
- 'src/core/ext/transport/chttp2/transport/status_conversion.c',
- 'src/core/ext/transport/chttp2/transport/stream_lists.c',
- 'src/core/ext/transport/chttp2/transport/stream_map.c',
- 'src/core/ext/transport/chttp2/transport/timeout_encoding.c',
- 'src/core/ext/transport/chttp2/transport/varint.c',
- 'src/core/ext/transport/chttp2/transport/writing.c',
+ 'src/core/lib/surface/init.c',
'src/core/lib/channel/channel_args.c',
'src/core/lib/channel/channel_stack.c',
'src/core/lib/channel/channel_stack_builder.c',
@@ -143,7 +87,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/debug/trace.c',
'src/core/lib/http/format_request.c',
'src/core/lib/http/httpcli.c',
- 'src/core/lib/http/httpcli_security_connector.c',
'src/core/lib/http/parser.c',
'src/core/lib/iomgr/closure.c',
'src/core/lib/iomgr/endpoint.c',
@@ -188,20 +131,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/json/json_reader.c',
'src/core/lib/json/json_string.c',
'src/core/lib/json/json_writer.c',
- 'src/core/lib/security/b64.c',
- 'src/core/lib/security/client_auth_filter.c',
- 'src/core/lib/security/credentials.c',
- 'src/core/lib/security/credentials_metadata.c',
- 'src/core/lib/security/credentials_posix.c',
- 'src/core/lib/security/credentials_win32.c',
- 'src/core/lib/security/google_default_credentials.c',
- 'src/core/lib/security/handshake.c',
- 'src/core/lib/security/json_token.c',
- 'src/core/lib/security/jwt_verifier.c',
- 'src/core/lib/security/secure_endpoint.c',
- 'src/core/lib/security/security_connector.c',
- 'src/core/lib/security/security_context.c',
- 'src/core/lib/security/server_auth_filter.c',
'src/core/lib/surface/alarm.c',
'src/core/lib/surface/api_trace.c',
'src/core/lib/surface/byte_buffer.c',
@@ -215,8 +144,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/surface/channel_stack_type.c',
'src/core/lib/surface/completion_queue.c',
'src/core/lib/surface/event_string.c',
- 'src/core/lib/surface/init.c',
- 'src/core/lib/surface/init_secure.c',
'src/core/lib/surface/lame_client.c',
'src/core/lib/surface/metadata_array.c',
'src/core/lib/surface/server.c',
@@ -229,13 +156,89 @@ CORE_SOURCE_FILES = [
'src/core/lib/transport/static_metadata.c',
'src/core/lib/transport/transport.c',
'src/core/lib/transport/transport_op_string.c',
+ 'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
+ 'src/core/ext/transport/chttp2/transport/bin_encoder.c',
+ 'src/core/ext/transport/chttp2/transport/chttp2_plugin.c',
+ 'src/core/ext/transport/chttp2/transport/chttp2_transport.c',
+ 'src/core/ext/transport/chttp2/transport/frame_data.c',
+ 'src/core/ext/transport/chttp2/transport/frame_goaway.c',
+ 'src/core/ext/transport/chttp2/transport/frame_ping.c',
+ 'src/core/ext/transport/chttp2/transport/frame_rst_stream.c',
+ 'src/core/ext/transport/chttp2/transport/frame_settings.c',
+ 'src/core/ext/transport/chttp2/transport/frame_window_update.c',
+ 'src/core/ext/transport/chttp2/transport/hpack_encoder.c',
+ 'src/core/ext/transport/chttp2/transport/hpack_parser.c',
+ 'src/core/ext/transport/chttp2/transport/hpack_table.c',
+ 'src/core/ext/transport/chttp2/transport/huffsyms.c',
+ 'src/core/ext/transport/chttp2/transport/incoming_metadata.c',
+ 'src/core/ext/transport/chttp2/transport/parsing.c',
+ 'src/core/ext/transport/chttp2/transport/status_conversion.c',
+ 'src/core/ext/transport/chttp2/transport/stream_lists.c',
+ 'src/core/ext/transport/chttp2/transport/stream_map.c',
+ 'src/core/ext/transport/chttp2/transport/timeout_encoding.c',
+ 'src/core/ext/transport/chttp2/transport/varint.c',
+ 'src/core/ext/transport/chttp2/transport/writing.c',
+ 'src/core/ext/transport/chttp2/alpn/alpn.c',
+ 'src/core/lib/http/httpcli_security_connector.c',
+ 'src/core/lib/security/b64.c',
+ 'src/core/lib/security/client_auth_filter.c',
+ 'src/core/lib/security/credentials.c',
+ 'src/core/lib/security/credentials_metadata.c',
+ 'src/core/lib/security/credentials_posix.c',
+ 'src/core/lib/security/credentials_win32.c',
+ 'src/core/lib/security/google_default_credentials.c',
+ 'src/core/lib/security/handshake.c',
+ 'src/core/lib/security/json_token.c',
+ 'src/core/lib/security/jwt_verifier.c',
+ 'src/core/lib/security/secure_endpoint.c',
+ 'src/core/lib/security/security_connector.c',
+ 'src/core/lib/security/security_context.c',
+ 'src/core/lib/security/server_auth_filter.c',
+ 'src/core/lib/surface/init_secure.c',
'src/core/lib/tsi/fake_transport_security.c',
'src/core/lib/tsi/ssl_transport_security.c',
'src/core/lib/tsi/transport_security.c',
- 'src/core/plugin_registry/grpc_plugin_registry.c',
+ 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
+ 'src/core/ext/client_config/channel_connectivity.c',
+ 'src/core/ext/client_config/client_channel.c',
+ 'src/core/ext/client_config/client_channel_factory.c',
+ 'src/core/ext/client_config/client_config.c',
+ 'src/core/ext/client_config/client_config_plugin.c',
+ 'src/core/ext/client_config/connector.c',
+ 'src/core/ext/client_config/default_initial_connect_string.c',
+ 'src/core/ext/client_config/initial_connect_string.c',
+ 'src/core/ext/client_config/lb_policy.c',
+ 'src/core/ext/client_config/lb_policy_factory.c',
+ 'src/core/ext/client_config/lb_policy_registry.c',
+ 'src/core/ext/client_config/parse_address.c',
+ 'src/core/ext/client_config/resolver.c',
+ 'src/core/ext/client_config/resolver_factory.c',
+ 'src/core/ext/client_config/resolver_registry.c',
+ 'src/core/ext/client_config/subchannel.c',
+ 'src/core/ext/client_config/subchannel_call_holder.c',
+ 'src/core/ext/client_config/subchannel_index.c',
+ 'src/core/ext/client_config/uri_parser.c',
+ 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c',
+ 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
+ 'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
+ 'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.c',
'third_party/nanopb/pb_common.c',
'third_party/nanopb/pb_decode.c',
'third_party/nanopb/pb_encode.c',
+ 'src/core/ext/lb_policy/pick_first/pick_first.c',
+ 'src/core/ext/lb_policy/round_robin/round_robin.c',
+ 'src/core/ext/resolver/dns/native/dns_resolver.c',
+ 'src/core/ext/resolver/sockaddr/sockaddr_resolver.c',
+ 'src/core/ext/census/context.c',
+ 'src/core/ext/census/grpc_context.c',
+ 'src/core/ext/census/grpc_filter.c',
+ 'src/core/ext/census/grpc_plugin.c',
+ 'src/core/ext/census/initialize.c',
+ 'src/core/ext/census/mlog.c',
+ 'src/core/ext/census/operation.c',
+ 'src/core/ext/census/placeholders.c',
+ 'src/core/ext/census/tracing.c',
+ 'src/core/plugin_registry/grpc_plugin_registry.c',
'src/boringssl/err_data.c',
'third_party/boringssl/crypto/aes/aes.c',
'third_party/boringssl/crypto/aes/mode_wrappers.c',
@@ -308,6 +311,7 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/bn/shift.c',
'third_party/boringssl/crypto/bn/sqrt.c',
'third_party/boringssl/crypto/buf/buf.c',
+ 'third_party/boringssl/crypto/bytestring/asn1_compat.c',
'third_party/boringssl/crypto/bytestring/ber.c',
'third_party/boringssl/crypto/bytestring/cbb.c',
'third_party/boringssl/crypto/bytestring/cbs.c',
@@ -331,6 +335,7 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/crypto/cpu-intel.c',
'third_party/boringssl/crypto/crypto.c',
'third_party/boringssl/crypto/curve25519/curve25519.c',
+ 'third_party/boringssl/crypto/curve25519/x25519-x86_64.c',
'third_party/boringssl/crypto/des/des.c',
'third_party/boringssl/crypto/dh/check.c',
'third_party/boringssl/crypto/dh/dh.c',
@@ -522,6 +527,7 @@ CORE_SOURCE_FILES = [
'third_party/boringssl/ssl/ssl_buffer.c',
'third_party/boringssl/ssl/ssl_cert.c',
'third_party/boringssl/ssl/ssl_cipher.c',
+ 'third_party/boringssl/ssl/ssl_ecdh.c',
'third_party/boringssl/ssl/ssl_file.c',
'third_party/boringssl/ssl/ssl_lib.c',
'third_party/boringssl/ssl/ssl_rsa.c',
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
index 56db4ec686..e2068d752a 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c
@@ -152,6 +152,7 @@ grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_crea
grpc_secure_channel_create_type grpc_secure_channel_create_import;
grpc_server_credentials_release_type grpc_server_credentials_release_import;
grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import;
+grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import;
grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
grpc_call_set_credentials_type grpc_call_set_credentials_import;
grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import;
@@ -174,6 +175,8 @@ grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import;
grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import;
gpr_log_type gpr_log_import;
gpr_log_message_type gpr_log_message_import;
+gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
+gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
gpr_set_log_function_type gpr_set_log_function_import;
gpr_slice_ref_type gpr_slice_ref_import;
gpr_slice_unref_type gpr_slice_unref_import;
@@ -414,6 +417,7 @@ void grpc_rb_load_imports(HMODULE library) {
grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create");
grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release");
grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create");
+ grpc_ssl_server_credentials_create_ex_import = (grpc_ssl_server_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_server_credentials_create_ex");
grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port");
grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials");
grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor");
@@ -436,6 +440,8 @@ void grpc_rb_load_imports(HMODULE library) {
grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader");
gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log");
gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message");
+ gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity");
+ gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init");
gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function");
gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref");
gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref");
diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
index c526f434c6..c8d21333ba 100644
--- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h
+++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h
@@ -406,6 +406,9 @@ extern grpc_server_credentials_release_type grpc_server_credentials_release_impo
typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved);
extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import;
#define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import
+typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_ex_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, void *reserved);
+extern grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex_import;
+#define grpc_ssl_server_credentials_create_ex grpc_ssl_server_credentials_create_ex_import
typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server *server, const char *addr, grpc_server_credentials *creds);
extern grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import;
#define grpc_server_add_secure_http2_port grpc_server_add_secure_http2_port_import
@@ -472,6 +475,12 @@ extern gpr_log_type gpr_log_import;
typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message);
extern gpr_log_message_type gpr_log_message_import;
#define gpr_log_message gpr_log_message_import
+typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print);
+extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import;
+#define gpr_set_log_verbosity gpr_set_log_verbosity_import
+typedef void(*gpr_log_verbosity_init_type)();
+extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import;
+#define gpr_log_verbosity_init gpr_log_verbosity_init_import
typedef void(*gpr_set_log_function_type)(gpr_log_func func);
extern gpr_set_log_function_type gpr_set_log_function_import;
#define gpr_set_log_function gpr_set_log_function_import
diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c
index 33b8372850..b2d7280a30 100644
--- a/src/ruby/ext/grpc/rb_server_credentials.c
+++ b/src/ruby/ext/grpc/rb_server_credentials.c
@@ -90,9 +90,12 @@ static void grpc_rb_server_credentials_mark(void *p) {
static const rb_data_type_t grpc_rb_server_credentials_data_type = {
"grpc_server_credentials",
- {grpc_rb_server_credentials_mark, grpc_rb_server_credentials_free,
- GRPC_RB_MEMSIZE_UNAVAILABLE, {NULL, NULL}},
- NULL, NULL,
+ {grpc_rb_server_credentials_mark,
+ grpc_rb_server_credentials_free,
+ GRPC_RB_MEMSIZE_UNAVAILABLE,
+ {NULL, NULL}},
+ NULL,
+ NULL,
#ifdef RUBY_TYPED_FREE_IMMEDIATELY
RUBY_TYPED_FREE_IMMEDIATELY
#endif
@@ -219,7 +222,9 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
}
}
- auth_client = TYPE(force_client_auth) == T_TRUE;
+ auth_client = TYPE(force_client_auth) == T_TRUE
+ ? GRPC_SSL_REQUEST_AND_REQUIRE_CLIENT_CERTIFICATE_AND_VERIFY
+ : GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE;
key_cert_pairs = ALLOC_N(grpc_ssl_pem_key_cert_pair, num_key_certs);
for (i = 0; i < num_key_certs; i++) {
key_cert = rb_ary_entry(pem_key_certs, i);
@@ -233,13 +238,12 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
&grpc_rb_server_credentials_data_type, wrapper);
if (pem_root_certs == Qnil) {
- creds = grpc_ssl_server_credentials_create(NULL, key_cert_pairs,
- num_key_certs,
- auth_client, NULL);
+ creds = grpc_ssl_server_credentials_create_ex(
+ NULL, key_cert_pairs, num_key_certs, auth_client, NULL);
} else {
- creds = grpc_ssl_server_credentials_create(RSTRING_PTR(pem_root_certs),
- key_cert_pairs, num_key_certs,
- auth_client, NULL);
+ creds = grpc_ssl_server_credentials_create_ex(RSTRING_PTR(pem_root_certs),
+ key_cert_pairs, num_key_certs,
+ auth_client, NULL);
}
xfree(key_cert_pairs);
if (creds == NULL) {
diff --git a/src/ruby/lib/grpc/generic/client_stub.rb b/src/ruby/lib/grpc/generic/client_stub.rb
index 98e83a8396..a6bb92d72c 100644
--- a/src/ruby/lib/grpc/generic/client_stub.rb
+++ b/src/ruby/lib/grpc/generic/client_stub.rb
@@ -85,7 +85,8 @@ module GRPC
# when present, this is the default timeout used for calls
#
# @param host [String] the host the stub connects to
- # @param q [Core::CompletionQueue] used to wait for events
+ # @param q [Core::CompletionQueue] used to wait for events - now deprecated
+ # since each new active call gets its own separately
# @param creds [Core::ChannelCredentials|Symbol] the channel credentials, or
# :this_channel_is_insecure
# @param channel_override [Core::Channel] a pre-created channel
@@ -97,7 +98,6 @@ module GRPC
propagate_mask: nil,
**kw)
fail(TypeError, '!CompletionQueue') unless q.is_a?(Core::CompletionQueue)
- @queue = q
@ch = ClientStub.setup_channel(channel_override, host, creds, **kw)
alt_host = kw[Core::Channel::SSL_TARGET]
@host = alt_host.nil? ? host : alt_host
@@ -458,14 +458,17 @@ module GRPC
if deadline.nil?
deadline = from_relative_time(timeout.nil? ? @timeout : timeout)
end
- call = @ch.create_call(@queue,
+ # Provide each new client call with its own completion queue
+ call_queue = Core::CompletionQueue.new
+ call = @ch.create_call(call_queue,
parent, # parent call
@propagate_mask, # propagation options
method,
nil, # host use nil,
deadline)
call.set_credentials! credentials unless credentials.nil?
- ActiveCall.new(call, @queue, marshal, unmarshal, deadline, started: false)
+ ActiveCall.new(call, call_queue, marshal, unmarshal, deadline,
+ started: false)
end
end
end
diff --git a/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb b/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb
new file mode 100644
index 0000000000..9f6e7e0e42
--- /dev/null
+++ b/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb
@@ -0,0 +1,28 @@
+# Generated by the protocol buffer compiler. DO NOT EDIT!
+# Source: src/proto/grpc/testing/duplicate/echo_duplicate.proto for package 'grpc.testing.duplicate'
+
+require 'grpc'
+require 'src/proto/grpc/testing/duplicate/echo_duplicate'
+
+module Grpc
+ module Testing
+ module Duplicate
+ module EchoTestService
+
+ # TODO: add proto service documentation here
+ class Service
+
+ include GRPC::GenericService
+
+ self.marshal_class_method = :encode
+ self.unmarshal_class_method = :decode
+ self.service_name = 'grpc.testing.duplicate.EchoTestService'
+
+ rpc :Echo, Grpc::Testing::EchoRequest, Grpc::Testing::EchoResponse
+ end
+
+ Stub = Service.rpc_stub_class
+ end
+ end
+ end
+end
diff --git a/src/ruby/qps/server.rb b/src/ruby/qps/server.rb
index 26f46a3140..f05fbbdaaf 100644
--- a/src/ruby/qps/server.rb
+++ b/src/ruby/qps/server.rb
@@ -88,4 +88,7 @@ class BenchmarkServer
def get_port
@port
end
+ def stop
+ @server.stop
+ end
end
diff --git a/src/ruby/qps/src/proto/grpc/testing/control.rb b/src/ruby/qps/src/proto/grpc/testing/control.rb
index d007123f26..b81e22659d 100644
--- a/src/ruby/qps/src/proto/grpc/testing/control.rb
+++ b/src/ruby/qps/src/proto/grpc/testing/control.rb
@@ -9,26 +9,12 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "grpc.testing.PoissonParams" do
optional :offered_load, :double, 1
end
- add_message "grpc.testing.UniformParams" do
- optional :interarrival_lo, :double, 1
- optional :interarrival_hi, :double, 2
- end
- add_message "grpc.testing.DeterministicParams" do
- optional :offered_load, :double, 1
- end
- add_message "grpc.testing.ParetoParams" do
- optional :interarrival_base, :double, 1
- optional :alpha, :double, 2
- end
add_message "grpc.testing.ClosedLoopParams" do
end
add_message "grpc.testing.LoadParams" do
oneof :load do
optional :closed_loop, :message, 1, "grpc.testing.ClosedLoopParams"
optional :poisson, :message, 2, "grpc.testing.PoissonParams"
- optional :uniform, :message, 3, "grpc.testing.UniformParams"
- optional :determ, :message, 4, "grpc.testing.DeterministicParams"
- optional :pareto, :message, 5, "grpc.testing.ParetoParams"
end
end
add_message "grpc.testing.SecurityParams" do
@@ -88,6 +74,40 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
end
add_message "grpc.testing.Void" do
end
+ add_message "grpc.testing.Scenario" do
+ optional :name, :string, 1
+ optional :client_config, :message, 2, "grpc.testing.ClientConfig"
+ optional :num_clients, :int32, 3
+ optional :server_config, :message, 4, "grpc.testing.ServerConfig"
+ optional :num_servers, :int32, 5
+ optional :warmup_seconds, :int32, 6
+ optional :benchmark_seconds, :int32, 7
+ optional :spawn_local_worker_count, :int32, 8
+ end
+ add_message "grpc.testing.Scenarios" do
+ repeated :scenarios, :message, 1, "grpc.testing.Scenario"
+ end
+ add_message "grpc.testing.ScenarioResultSummary" do
+ optional :qps, :double, 1
+ optional :qps_per_server_core, :double, 2
+ optional :server_system_time, :double, 3
+ optional :server_user_time, :double, 4
+ optional :client_system_time, :double, 5
+ optional :client_user_time, :double, 6
+ optional :latency_50, :double, 7
+ optional :latency_90, :double, 8
+ optional :latency_95, :double, 9
+ optional :latency_99, :double, 10
+ optional :latency_999, :double, 11
+ end
+ add_message "grpc.testing.ScenarioResult" do
+ optional :scenario, :message, 1, "grpc.testing.Scenario"
+ optional :latencies, :message, 2, "grpc.testing.HistogramData"
+ repeated :client_stats, :message, 3, "grpc.testing.ClientStats"
+ repeated :server_stats, :message, 4, "grpc.testing.ServerStats"
+ repeated :server_cores, :int32, 5
+ optional :summary, :message, 6, "grpc.testing.ScenarioResultSummary"
+ end
add_enum "grpc.testing.ClientType" do
value :SYNC_CLIENT, 0
value :ASYNC_CLIENT, 1
@@ -106,9 +126,6 @@ end
module Grpc
module Testing
PoissonParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.PoissonParams").msgclass
- UniformParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.UniformParams").msgclass
- DeterministicParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.DeterministicParams").msgclass
- ParetoParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ParetoParams").msgclass
ClosedLoopParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ClosedLoopParams").msgclass
LoadParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.LoadParams").msgclass
SecurityParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.SecurityParams").msgclass
@@ -122,6 +139,10 @@ module Grpc
CoreRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.CoreRequest").msgclass
CoreResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.CoreResponse").msgclass
Void = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Void").msgclass
+ Scenario = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Scenario").msgclass
+ Scenarios = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.Scenarios").msgclass
+ ScenarioResultSummary = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ScenarioResultSummary").msgclass
+ ScenarioResult = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ScenarioResult").msgclass
ClientType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ClientType").enummodule
ServerType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ServerType").enummodule
RpcType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.RpcType").enummodule
diff --git a/src/ruby/qps/src/proto/grpc/testing/messages.rb b/src/ruby/qps/src/proto/grpc/testing/messages.rb
index b9c32dbef5..2bdfe0eade 100644
--- a/src/ruby/qps/src/proto/grpc/testing/messages.rb
+++ b/src/ruby/qps/src/proto/grpc/testing/messages.rb
@@ -46,6 +46,9 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "grpc.testing.StreamingOutputCallResponse" do
optional :payload, :message, 1, "grpc.testing.Payload"
end
+ add_message "grpc.testing.ReconnectParams" do
+ optional :max_reconnect_backoff_ms, :int32, 1
+ end
add_message "grpc.testing.ReconnectInfo" do
optional :passed, :bool, 1
repeated :backoff_ms, :int32, 2
@@ -73,6 +76,7 @@ module Grpc
ResponseParameters = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ResponseParameters").msgclass
StreamingOutputCallRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingOutputCallRequest").msgclass
StreamingOutputCallResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.StreamingOutputCallResponse").msgclass
+ ReconnectParams = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ReconnectParams").msgclass
ReconnectInfo = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ReconnectInfo").msgclass
PayloadType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.PayloadType").enummodule
CompressionType = Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.CompressionType").enummodule
diff --git a/src/ruby/qps/worker.rb b/src/ruby/qps/worker.rb
index 7c29204cc2..665fb86352 100755
--- a/src/ruby/qps/worker.rb
+++ b/src/ruby/qps/worker.rb
@@ -55,12 +55,12 @@ class WorkerServiceImpl < Grpc::Testing::WorkerService::Service
Thread.new {
bms = ''
gtss = Grpc::Testing::ServerStatus
- reqs.each do |req|
+ reqs.each do |req|
case req.argtype.to_s
when 'setup'
bms = BenchmarkServer.new(req.setup, @server_port)
q.push(gtss.new(stats: bms.mark(false), port: bms.get_port))
- when 'mark'
+ when 'mark'
q.push(gtss.new(stats: bms.mark(req.mark.reset), cores: cpu_cores))
end
end
diff --git a/src/ruby/spec/pb/duplicate/codegen_spec.rb b/src/ruby/spec/pb/duplicate/codegen_spec.rb
new file mode 100644
index 0000000000..54c136c510
--- /dev/null
+++ b/src/ruby/spec/pb/duplicate/codegen_spec.rb
@@ -0,0 +1,71 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+require 'open3'
+require 'tmpdir'
+
+def can_run_codegen_check
+ system('which grpc_ruby_plugin') && system('which protoc')
+end
+
+describe 'Ping protobuf code generation' do
+ if !can_run_codegen_check
+ skip 'protoc || grpc_ruby_plugin missing, cannot verify ping code-gen'
+ else
+ it 'should have the same content as created by code generation' do
+ root_dir = File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..')
+
+ # Get the current content
+ service_path = File.join(root_dir, 'src', 'ruby', 'pb', 'grpc',
+ 'testing', 'duplicate',
+ 'echo_duplicate_services.rb')
+ want = nil
+ File.open(service_path) { |f| want = f.read }
+
+ # Regenerate it
+ plugin, = Open3.capture2('which', 'grpc_ruby_plugin')
+ plugin = plugin.strip
+ got = nil
+ Dir.mktmpdir do |tmp_dir|
+ gen_out = File.join(tmp_dir, 'src', 'proto', 'grpc', 'testing',
+ 'duplicate', 'echo_duplicate_services.rb')
+ pid = spawn(
+ 'protoc',
+ '-I.',
+ 'src/proto/grpc/testing/duplicate/echo_duplicate.proto',
+ "--grpc_out=#{tmp_dir}",
+ "--plugin=protoc-gen-grpc=#{plugin}",
+ chdir: root_dir)
+ Process.wait(pid)
+ File.open(gen_out) { |f| got = f.read }
+ end
+ expect(got).to eq(want)
+ end
+ end
+end