Merge github.com:grpc/grpc into sometimes-its-good-just-to-check-in-with-each-other

pull/2477/head
Craig Tiller 10 years ago
commit 47f18378b5
  1. 8
      BUILD
  2. 126
      Makefile
  3. 2
      README.md
  4. 36
      build.json
  5. 75
      doc/interop-test-descriptions.md
  6. 8
      include/grpc++/fixed_size_thread_pool.h
  7. 2
      include/grpc++/thread_pool_interface.h
  8. 50
      src/compiler/csharp_generator.cc
  9. 2
      src/core/client_config/uri_parser.c
  10. 1
      src/core/httpcli/httpcli.c
  11. 29
      src/core/security/secure_transport_setup.c
  12. 2
      src/core/security/secure_transport_setup.h
  13. 47
      src/core/security/server_secure_chttp2.c
  14. 1
      src/core/surface/secure_channel_create.c
  15. 4
      src/cpp/server/create_default_thread_pool.cc
  16. 15
      src/cpp/server/fixed_size_thread_pool.cc
  17. 2
      src/cpp/server/server_builder.cc
  18. 8
      src/csharp/Grpc.Auth/OAuth2InterceptorFactory.cs
  19. 10
      src/csharp/Grpc.Core.Tests/Internal/MetadataArraySafeHandleTest.cs
  20. 2
      src/csharp/Grpc.Core/Calls.cs
  21. 41
      src/csharp/Grpc.Core/ClientBase.cs
  22. 3
      src/csharp/Grpc.Core/Grpc.Core.csproj
  23. 8
      src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs
  24. 169
      src/csharp/Grpc.Core/Metadata.cs
  25. 64
      src/csharp/Grpc.Core/Stub/StubConfiguration.cs
  26. 1
      src/csharp/Grpc.Core/Version.cs
  27. 14
      src/csharp/Grpc.Examples.MathClient/MathClient.cs
  28. 10
      src/csharp/Grpc.Examples.Tests/MathClientServerTests.cs
  29. 26
      src/csharp/Grpc.Examples/MathExamples.cs
  30. 58
      src/csharp/Grpc.Examples/MathGrpc.cs
  31. 2
      src/csharp/Grpc.HealthCheck.Tests/HealthClientServerTest.cs
  32. 34
      src/csharp/Grpc.HealthCheck/HealthGrpc.cs
  33. 9
      src/csharp/Grpc.IntegrationTesting/InteropClient.cs
  34. 2
      src/csharp/Grpc.IntegrationTesting/InteropClientServerTest.cs
  35. 82
      src/csharp/Grpc.IntegrationTesting/TestGrpc.cs
  36. 7
      src/csharp/generate_proto_csharp.sh
  37. 8
      src/objective-c/tests/GRPCClientTests.m
  38. 15
      src/objective-c/tests/InteropTests.m
  39. 2
      src/php/bin/determine_extension_dir.sh
  40. 56
      templates/Makefile.template
  41. 1
      test/core/client_config/uri_parser_test.c
  42. 3
      test/cpp/end2end/client_crash_test.cc
  43. 4
      test/cpp/end2end/end2end_test.cc
  44. 4
      test/cpp/end2end/mock_test.cc
  45. 3
      test/cpp/end2end/server_crash_test.cc
  46. 4
      test/cpp/end2end/thread_stress_test.cc
  47. 2
      test/cpp/qps/server_async.cc
  48. 4
      test/cpp/qps/server_sync.cc
  49. 10
      test/cpp/server/fixed_size_thread_pool_test.cc
  50. 4
      test/cpp/util/cli_call_test.cc
  51. 1
      tools/doxygen/Doxyfile.c++
  52. 4
      tools/doxygen/Doxyfile.c++.internal
  53. 2
      tools/jenkins/docker_run_jenkins.sh
  54. 13
      tools/jenkins/run_jenkins.sh
  55. 46
      tools/run_tests/sources_and_headers.json
  56. 18
      tools/run_tests/tests.json
  57. 6
      vsprojects/grpc++/grpc++.vcxproj
  58. 12
      vsprojects/grpc++/grpc++.vcxproj.filters
  59. 6
      vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj
  60. 12
      vsprojects/grpc++_unsecure/grpc++_unsecure.vcxproj.filters

@ -639,7 +639,6 @@ cc_library(
"src/cpp/server/secure_server_credentials.h", "src/cpp/server/secure_server_credentials.h",
"src/cpp/client/channel.h", "src/cpp/client/channel.h",
"src/cpp/common/create_auth_context.h", "src/cpp/common/create_auth_context.h",
"src/cpp/server/thread_pool.h",
"src/cpp/client/secure_channel_arguments.cc", "src/cpp/client/secure_channel_arguments.cc",
"src/cpp/client/secure_credentials.cc", "src/cpp/client/secure_credentials.cc",
"src/cpp/common/secure_auth_context.cc", "src/cpp/common/secure_auth_context.cc",
@ -659,12 +658,12 @@ cc_library(
"src/cpp/proto/proto_utils.cc", "src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc", "src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/fixed_size_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc", "src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc", "src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc", "src/cpp/server/server_builder.cc",
"src/cpp/server/server_context.cc", "src/cpp/server/server_context.cc",
"src/cpp/server/server_credentials.cc", "src/cpp/server/server_credentials.cc",
"src/cpp/server/thread_pool.cc",
"src/cpp/util/byte_buffer.cc", "src/cpp/util/byte_buffer.cc",
"src/cpp/util/slice.cc", "src/cpp/util/slice.cc",
"src/cpp/util/status.cc", "src/cpp/util/status.cc",
@ -683,6 +682,7 @@ cc_library(
"include/grpc++/config_protobuf.h", "include/grpc++/config_protobuf.h",
"include/grpc++/create_channel.h", "include/grpc++/create_channel.h",
"include/grpc++/credentials.h", "include/grpc++/credentials.h",
"include/grpc++/fixed_size_thread_pool.h",
"include/grpc++/generic_stub.h", "include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h", "include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/client_unary_call.h",
@ -727,7 +727,6 @@ cc_library(
srcs = [ srcs = [
"src/cpp/client/channel.h", "src/cpp/client/channel.h",
"src/cpp/common/create_auth_context.h", "src/cpp/common/create_auth_context.h",
"src/cpp/server/thread_pool.h",
"src/cpp/common/insecure_create_auth_context.cc", "src/cpp/common/insecure_create_auth_context.cc",
"src/cpp/client/channel.cc", "src/cpp/client/channel.cc",
"src/cpp/client/channel_arguments.cc", "src/cpp/client/channel_arguments.cc",
@ -743,12 +742,12 @@ cc_library(
"src/cpp/proto/proto_utils.cc", "src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc", "src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/fixed_size_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc", "src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc", "src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc", "src/cpp/server/server_builder.cc",
"src/cpp/server/server_context.cc", "src/cpp/server/server_context.cc",
"src/cpp/server/server_credentials.cc", "src/cpp/server/server_credentials.cc",
"src/cpp/server/thread_pool.cc",
"src/cpp/util/byte_buffer.cc", "src/cpp/util/byte_buffer.cc",
"src/cpp/util/slice.cc", "src/cpp/util/slice.cc",
"src/cpp/util/status.cc", "src/cpp/util/status.cc",
@ -767,6 +766,7 @@ cc_library(
"include/grpc++/config_protobuf.h", "include/grpc++/config_protobuf.h",
"include/grpc++/create_channel.h", "include/grpc++/create_channel.h",
"include/grpc++/credentials.h", "include/grpc++/credentials.h",
"include/grpc++/fixed_size_thread_pool.h",
"include/grpc++/generic_stub.h", "include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h", "include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/client_unary_call.h",

File diff suppressed because one or more lines are too long

@ -40,8 +40,8 @@ Libraries in different languages are in different state of development. We are s
* NodeJS Library: [src/node] (src/node) : Early adopter ready - Alpha. * NodeJS Library: [src/node] (src/node) : Early adopter ready - Alpha.
* Python Library: [src/python] (src/python) : Early adopter ready - Alpha. * Python Library: [src/python] (src/python) : Early adopter ready - Alpha.
* C# Library: [src/csharp] (src/csharp) : Early adopter ready - Alpha. * C# Library: [src/csharp] (src/csharp) : Early adopter ready - Alpha.
* Objective-C Library: [src/objective-c] (src/objective-c): Early adopter ready - Alpha.
* PHP Library: [src/php] (src/php) : Pre-Alpha. * PHP Library: [src/php] (src/php) : Pre-Alpha.
* Objective-C Library: [src/objective-c] (src/objective-c): Pre-Alpha.
#Overview #Overview

@ -40,6 +40,7 @@
"include/grpc++/config_protobuf.h", "include/grpc++/config_protobuf.h",
"include/grpc++/create_channel.h", "include/grpc++/create_channel.h",
"include/grpc++/credentials.h", "include/grpc++/credentials.h",
"include/grpc++/fixed_size_thread_pool.h",
"include/grpc++/generic_stub.h", "include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h", "include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/client_unary_call.h",
@ -69,8 +70,7 @@
], ],
"headers": [ "headers": [
"src/cpp/client/channel.h", "src/cpp/client/channel.h",
"src/cpp/common/create_auth_context.h", "src/cpp/common/create_auth_context.h"
"src/cpp/server/thread_pool.h"
], ],
"src": [ "src": [
"src/cpp/client/channel.cc", "src/cpp/client/channel.cc",
@ -87,12 +87,12 @@
"src/cpp/proto/proto_utils.cc", "src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc", "src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/fixed_size_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc", "src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc", "src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc", "src/cpp/server/server_builder.cc",
"src/cpp/server/server_context.cc", "src/cpp/server/server_context.cc",
"src/cpp/server/server_credentials.cc", "src/cpp/server/server_credentials.cc",
"src/cpp/server/thread_pool.cc",
"src/cpp/util/byte_buffer.cc", "src/cpp/util/byte_buffer.cc",
"src/cpp/util/slice.cc", "src/cpp/util/slice.cc",
"src/cpp/util/status.cc", "src/cpp/util/status.cc",
@ -2056,6 +2056,21 @@
"gpr" "gpr"
] ]
}, },
{
"name": "fixed_size_thread_pool_test",
"build": "test",
"language": "c++",
"src": [
"test/cpp/server/fixed_size_thread_pool_test.cc"
],
"deps": [
"grpc_test_util",
"grpc++",
"grpc",
"gpr_test_util",
"gpr"
]
},
{ {
"name": "generic_end2end_test", "name": "generic_end2end_test",
"build": "test", "build": "test",
@ -2462,21 +2477,6 @@
"gpr" "gpr"
] ]
}, },
{
"name": "thread_pool_test",
"build": "test",
"language": "c++",
"src": [
"test/cpp/server/thread_pool_test.cc"
],
"deps": [
"grpc_test_util",
"grpc++",
"grpc",
"gpr_test_util",
"gpr"
]
},
{ {
"name": "thread_stress_test", "name": "thread_stress_test",
"build": "test", "build": "test",

@ -396,14 +396,23 @@ Asserts:
Similar to the other auth tests, this test is only for cloud-to-prod path. Similar to the other auth tests, this test is only for cloud-to-prod path.
This test verifies unary calls succeed in sending messages using an OAuth2 token that is obtained OOB. For the purpose of the test, the OAuth2 token is actually obtained from the service account credentials via the language-specific authorization library. This test verifies unary calls succeed in sending messages using an OAuth2 token
that is obtained out of band. For the purpose of the test, the OAuth2 token is
actually obtained from the service account credentials via the
language-specific authorization library.
The difference between this test and the other auth tests is that rather than configuring the test client with ServiceAccountCredentials directly, the test first uses the authorization library to obtain an authorization token. The difference between this test and the other auth tests is that rather than
configuring the test client with ServiceAccountCredentials directly, the test
first uses the authorization library to obtain an authorization token.
The test The test
- uses the flag `--service_account_key_file` with the path to a json key file - uses the flag `--service_account_key_file` with the path to a json key file
downloaded from https://console.developers.google.com. Alternately, if using a usable auth implementation, it may specify the file location in the environment variable GOOGLE_APPLICATION_CREDENTIALS downloaded from https://console.developers.google.com. Alternately, if using a
- uses the flag `--oauth_scope` for the oauth scope. For testing against grpc-test.sandbox.google.com, "https://www.googleapis.com/auth/xapi.zoo" should be passed as the `--oauth_scope`. usable auth implementation, it may specify the file location in the environment
variable GOOGLE_APPLICATION_CREDENTIALS
- uses the flag `--oauth_scope` for the oauth scope. For testing against
grpc-test.sandbox.google.com, "https://www.googleapis.com/auth/xapi.zoo" should
be passed as the `--oauth_scope`.
Server features: Server features:
* [UnaryCall][] * [UnaryCall][]
@ -412,16 +421,56 @@ Server features:
* [Echo OAuth Scope][] * [Echo OAuth Scope][]
Procedure: Procedure:
1. Client use the auth library to obtain an authorization token 1. Client uses the auth library to obtain an authorization token
2. Client calls UnaryCall, attaching the authorization token obtained in step1, with the following message 2. Client configures the channel to use AccessTokenCredentials with the access token obtained in step 1.
3. Client calls UnaryCall with the following message
``` ```
{ {
response_type: COMPRESSABLE fill_username: true
response_size: 314159 fill_oauth_scope: true
payload:{
body: 271828 bytes of zeros
} }
```
Asserts:
* call was successful
* received SimpleResponse.username is in the json key file used by the auth
library to obtain the authorization token
* received SimpleResponse.oauth_scope is in `--oauth_scope`
### per_rpc_creds
Similar to the other auth tests, this test is only for cloud-to-prod path.
This test verifies unary calls succeed in sending messages using an OAuth2 token
that is obtained out of band. For the purpose of the test, the OAuth2 token is
actually obtained from the service account credentials via the
language-specific authorization library.
The test
- uses the flag `--service_account_key_file` with the path to a json key file
downloaded from https://console.developers.google.com. Alternately, if using a
usable auth implementation, it may specify the file location in the environment
variable GOOGLE_APPLICATION_CREDENTIALS
- uses the flag `--oauth_scope` for the oauth scope. For testing against
grpc-test.sandbox.google.com, "https://www.googleapis.com/auth/xapi.zoo" should
be passed as the `--oauth_scope`.
Server features:
* [UnaryCall][]
* [Compressable Payload][]
* [Echo Authenticated Username][]
* [Echo OAuth Scope][]
Procedure:
1. Client uses the auth library to obtain an authorization token
2. Client configures the channel with just SSL credentials.
3. Client calls UnaryCall, setting per-call credentials to
AccessTokenCredentials with the access token obtained in step 1. The request is
the following message
```
{
fill_username: true fill_username: true
fill_oauth_scope: true fill_oauth_scope: true
} }
@ -429,11 +478,9 @@ Procedure:
Asserts: Asserts:
* call was successful * call was successful
* received SimpleResponse.username is in the json key file used by the auth library to obtain the authorization token * received SimpleResponse.username is in the json key file used by the auth
library to obtain the authorization token
* received SimpleResponse.oauth_scope is in `--oauth_scope` * received SimpleResponse.oauth_scope is in `--oauth_scope`
* response payload body is 314159 bytes in size
* clients are free to assert that the response payload body contents are zero
and comparing the entire response message against a golden response
### Metadata (TODO: fix name) ### Metadata (TODO: fix name)

@ -45,10 +45,10 @@
namespace grpc { namespace grpc {
class ThreadPool GRPC_FINAL : public ThreadPoolInterface { class FixedSizeThreadPool GRPC_FINAL : public ThreadPoolInterface {
public: public:
explicit ThreadPool(int num_threads); explicit FixedSizeThreadPool(int num_threads);
~ThreadPool(); ~FixedSizeThreadPool();
void ScheduleCallback(const std::function<void()>& callback) GRPC_OVERRIDE; void ScheduleCallback(const std::function<void()>& callback) GRPC_OVERRIDE;
@ -62,8 +62,6 @@ class ThreadPool GRPC_FINAL : public ThreadPoolInterface {
void ThreadFunc(); void ThreadFunc();
}; };
ThreadPoolInterface* CreateDefaultThreadPool();
} // namespace grpc } // namespace grpc
#endif // GRPC_INTERNAL_CPP_SERVER_THREAD_POOL_H #endif // GRPC_INTERNAL_CPP_SERVER_THREAD_POOL_H

@ -47,6 +47,8 @@ class ThreadPoolInterface {
virtual void ScheduleCallback(const std::function<void()>& callback) = 0; virtual void ScheduleCallback(const std::function<void()>& callback) = 0;
}; };
ThreadPoolInterface* CreateDefaultThreadPool();
} // namespace grpc } // namespace grpc
#endif // GRPCXX_THREAD_POOL_INTERFACE_H #endif // GRPCXX_THREAD_POOL_INTERFACE_H

@ -257,7 +257,7 @@ void GenerateStaticMethodField(Printer* out, const MethodDescriptor *method) {
} }
void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) { void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
out->Print("// client-side stub interface\n"); out->Print("// client interface\n");
out->Print("public interface $name$\n", "name", out->Print("public interface $name$\n", "name",
GetClientInterfaceName(service)); GetClientInterfaceName(service));
out->Print("{\n"); out->Print("{\n");
@ -269,7 +269,7 @@ void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
if (method_type == METHODTYPE_NO_STREAMING) { if (method_type == METHODTYPE_NO_STREAMING) {
// unary calls have an extra synchronous stub method // unary calls have an extra synchronous stub method
out->Print( out->Print(
"$response$ $methodname$($request$ request, CancellationToken token = default(CancellationToken));\n", "$response$ $methodname$($request$ request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));\n",
"methodname", method->name(), "request", "methodname", method->name(), "request",
GetClassName(method->input_type()), "response", GetClassName(method->input_type()), "response",
GetClassName(method->output_type())); GetClassName(method->output_type()));
@ -280,7 +280,7 @@ void GenerateClientInterface(Printer* out, const ServiceDescriptor *service) {
method_name += "Async"; // prevent name clash with synchronous method. method_name += "Async"; // prevent name clash with synchronous method.
} }
out->Print( out->Print(
"$returntype$ $methodname$($request_maybe$CancellationToken token = default(CancellationToken));\n", "$returntype$ $methodname$($request_maybe$Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));\n",
"methodname", method_name, "request_maybe", "methodname", method_name, "request_maybe",
GetMethodRequestParamMaybe(method), "returntype", GetMethodRequestParamMaybe(method), "returntype",
GetMethodReturnTypeClient(method)); GetMethodReturnTypeClient(method));
@ -312,7 +312,7 @@ void GenerateServerInterface(Printer* out, const ServiceDescriptor *service) {
void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
out->Print("// client stub\n"); out->Print("// client stub\n");
out->Print( out->Print(
"public class $name$ : AbstractStub<$name$, StubConfiguration>, $interface$\n", "public class $name$ : ClientBase, $interface$\n",
"name", GetClientClassName(service), "interface", "name", GetClientClassName(service), "interface",
GetClientInterfaceName(service)); GetClientInterfaceName(service));
out->Print("{\n"); out->Print("{\n");
@ -320,12 +320,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
// constructors // constructors
out->Print( out->Print(
"public $name$(Channel channel) : this(channel, StubConfiguration.Default)\n", "public $name$(Channel channel) : base(channel)\n",
"name", GetClientClassName(service));
out->Print("{\n");
out->Print("}\n");
out->Print(
"public $name$(Channel channel, StubConfiguration config) : base(channel, config)\n",
"name", GetClientClassName(service)); "name", GetClientClassName(service));
out->Print("{\n"); out->Print("{\n");
out->Print("}\n"); out->Print("}\n");
@ -337,16 +332,16 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
if (method_type == METHODTYPE_NO_STREAMING) { if (method_type == METHODTYPE_NO_STREAMING) {
// unary calls have an extra synchronous stub method // unary calls have an extra synchronous stub method
out->Print( out->Print(
"public $response$ $methodname$($request$ request, CancellationToken token = default(CancellationToken))\n", "public $response$ $methodname$($request$ request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))\n",
"methodname", method->name(), "request", "methodname", method->name(), "request",
GetClassName(method->input_type()), "response", GetClassName(method->input_type()), "response",
GetClassName(method->output_type())); GetClassName(method->output_type()));
out->Print("{\n"); out->Print("{\n");
out->Indent(); out->Indent();
out->Print("var call = CreateCall($servicenamefield$, $methodfield$);\n", out->Print("var call = CreateCall($servicenamefield$, $methodfield$, headers);\n",
"servicenamefield", GetServiceNameFieldName(), "methodfield", "servicenamefield", GetServiceNameFieldName(), "methodfield",
GetMethodFieldName(method)); GetMethodFieldName(method));
out->Print("return Calls.BlockingUnaryCall(call, request, token);\n"); out->Print("return Calls.BlockingUnaryCall(call, request, cancellationToken);\n");
out->Outdent(); out->Outdent();
out->Print("}\n"); out->Print("}\n");
} }
@ -356,28 +351,28 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) {
method_name += "Async"; // prevent name clash with synchronous method. method_name += "Async"; // prevent name clash with synchronous method.
} }
out->Print( out->Print(
"public $returntype$ $methodname$($request_maybe$CancellationToken token = default(CancellationToken))\n", "public $returntype$ $methodname$($request_maybe$Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))\n",
"methodname", method_name, "request_maybe", "methodname", method_name, "request_maybe",
GetMethodRequestParamMaybe(method), "returntype", GetMethodRequestParamMaybe(method), "returntype",
GetMethodReturnTypeClient(method)); GetMethodReturnTypeClient(method));
out->Print("{\n"); out->Print("{\n");
out->Indent(); out->Indent();
out->Print("var call = CreateCall($servicenamefield$, $methodfield$);\n", out->Print("var call = CreateCall($servicenamefield$, $methodfield$, headers);\n",
"servicenamefield", GetServiceNameFieldName(), "methodfield", "servicenamefield", GetServiceNameFieldName(), "methodfield",
GetMethodFieldName(method)); GetMethodFieldName(method));
switch (GetMethodType(method)) { switch (GetMethodType(method)) {
case METHODTYPE_NO_STREAMING: case METHODTYPE_NO_STREAMING:
out->Print("return Calls.AsyncUnaryCall(call, request, token);\n"); out->Print("return Calls.AsyncUnaryCall(call, request, cancellationToken);\n");
break; break;
case METHODTYPE_CLIENT_STREAMING: case METHODTYPE_CLIENT_STREAMING:
out->Print("return Calls.AsyncClientStreamingCall(call, token);\n"); out->Print("return Calls.AsyncClientStreamingCall(call, cancellationToken);\n");
break; break;
case METHODTYPE_SERVER_STREAMING: case METHODTYPE_SERVER_STREAMING:
out->Print( out->Print(
"return Calls.AsyncServerStreamingCall(call, request, token);\n"); "return Calls.AsyncServerStreamingCall(call, request, cancellationToken);\n");
break; break;
case METHODTYPE_BIDI_STREAMING: case METHODTYPE_BIDI_STREAMING:
out->Print("return Calls.AsyncDuplexStreamingCall(call, token);\n"); out->Print("return Calls.AsyncDuplexStreamingCall(call, cancellationToken);\n");
break; break;
default: default:
GOOGLE_LOG(FATAL)<< "Can't get here."; GOOGLE_LOG(FATAL)<< "Can't get here.";
@ -423,9 +418,9 @@ void GenerateBindServiceMethod(Printer* out, const ServiceDescriptor *service) {
} }
void GenerateNewStubMethods(Printer* out, const ServiceDescriptor *service) { void GenerateNewStubMethods(Printer* out, const ServiceDescriptor *service) {
out->Print("// creates a new client stub\n"); out->Print("// creates a new client\n");
out->Print("public static $interface$ NewStub(Channel channel)\n", out->Print("public static $classname$ NewClient(Channel channel)\n",
"interface", GetClientInterfaceName(service)); "classname", GetClientClassName(service));
out->Print("{\n"); out->Print("{\n");
out->Indent(); out->Indent();
out->Print("return new $classname$(channel);\n", "classname", out->Print("return new $classname$(channel);\n", "classname",
@ -433,17 +428,6 @@ void GenerateNewStubMethods(Printer* out, const ServiceDescriptor *service) {
out->Outdent(); out->Outdent();
out->Print("}\n"); out->Print("}\n");
out->Print("\n"); out->Print("\n");
out->Print("// creates a new client stub\n");
out->Print(
"public static $interface$ NewStub(Channel channel, StubConfiguration config)\n",
"interface", GetClientInterfaceName(service));
out->Print("{\n");
out->Indent();
out->Print("return new $classname$(channel, config);\n", "classname",
GetClientClassName(service));
out->Outdent();
out->Print("}\n");
} }
void GenerateService(Printer* out, const ServiceDescriptor *service) { void GenerateService(Printer* out, const ServiceDescriptor *service) {

@ -98,7 +98,7 @@ grpc_uri *grpc_uri_parse(const char *uri_text, int suppress_errors) {
if (uri_text[scheme_end + 1] == '/' && uri_text[scheme_end + 2] == '/') { if (uri_text[scheme_end + 1] == '/' && uri_text[scheme_end + 2] == '/') {
authority_begin = scheme_end + 3; authority_begin = scheme_end + 3;
for (i = authority_begin; uri_text[i] != 0; i++) { for (i = authority_begin; uri_text[i] != 0 && authority_end == -1; i++) {
if (uri_text[i] == '/') { if (uri_text[i] == '/') {
authority_end = i; authority_end = i;
} }

@ -165,6 +165,7 @@ static void start_write(internal_request *req) {
static void on_secure_transport_setup_done(void *rp, static void on_secure_transport_setup_done(void *rp,
grpc_security_status status, grpc_security_status status,
grpc_endpoint *wrapped_endpoint,
grpc_endpoint *secure_endpoint) { grpc_endpoint *secure_endpoint) {
internal_request *req = rp; internal_request *req = rp;
if (status != GRPC_SECURITY_OK) { if (status != GRPC_SECURITY_OK) {

@ -47,7 +47,8 @@ typedef struct {
tsi_handshaker *handshaker; tsi_handshaker *handshaker;
unsigned char *handshake_buffer; unsigned char *handshake_buffer;
size_t handshake_buffer_size; size_t handshake_buffer_size;
grpc_endpoint *endpoint; grpc_endpoint *wrapped_endpoint;
grpc_endpoint *secure_endpoint;
gpr_slice_buffer left_overs; gpr_slice_buffer left_overs;
grpc_secure_transport_setup_done_cb cb; grpc_secure_transport_setup_done_cb cb;
void *user_data; void *user_data;
@ -63,13 +64,16 @@ static void on_handshake_data_sent_to_peer(void *setup,
static void secure_transport_setup_done(grpc_secure_transport_setup *s, static void secure_transport_setup_done(grpc_secure_transport_setup *s,
int is_success) { int is_success) {
if (is_success) { if (is_success) {
s->cb(s->user_data, GRPC_SECURITY_OK, s->endpoint); s->cb(s->user_data, GRPC_SECURITY_OK, s->wrapped_endpoint,
s->secure_endpoint);
} else { } else {
if (s->endpoint != NULL) { if (s->secure_endpoint != NULL) {
grpc_endpoint_shutdown(s->endpoint); grpc_endpoint_shutdown(s->secure_endpoint);
grpc_endpoint_destroy(s->endpoint); grpc_endpoint_destroy(s->secure_endpoint);
} else {
grpc_endpoint_destroy(s->wrapped_endpoint);
} }
s->cb(s->user_data, GRPC_SECURITY_ERROR, NULL); s->cb(s->user_data, GRPC_SECURITY_ERROR, s->wrapped_endpoint, NULL);
} }
if (s->handshaker != NULL) tsi_handshaker_destroy(s->handshaker); if (s->handshaker != NULL) tsi_handshaker_destroy(s->handshaker);
if (s->handshake_buffer != NULL) gpr_free(s->handshake_buffer); if (s->handshake_buffer != NULL) gpr_free(s->handshake_buffer);
@ -95,8 +99,9 @@ static void on_peer_checked(void *user_data, grpc_security_status status) {
secure_transport_setup_done(s, 0); secure_transport_setup_done(s, 0);
return; return;
} }
s->endpoint = grpc_secure_endpoint_create( s->secure_endpoint =
protector, s->endpoint, s->left_overs.slices, s->left_overs.count); grpc_secure_endpoint_create(protector, s->wrapped_endpoint,
s->left_overs.slices, s->left_overs.count);
secure_transport_setup_done(s, 1); secure_transport_setup_done(s, 1);
return; return;
} }
@ -152,7 +157,7 @@ static void send_handshake_bytes_to_peer(grpc_secure_transport_setup *s) {
gpr_slice_from_copied_buffer((const char *)s->handshake_buffer, offset); gpr_slice_from_copied_buffer((const char *)s->handshake_buffer, offset);
/* TODO(klempner,jboeuf): This should probably use the client setup /* TODO(klempner,jboeuf): This should probably use the client setup
deadline */ deadline */
write_status = grpc_endpoint_write(s->endpoint, &to_send, 1, write_status = grpc_endpoint_write(s->wrapped_endpoint, &to_send, 1,
on_handshake_data_sent_to_peer, s); on_handshake_data_sent_to_peer, s);
if (write_status == GRPC_ENDPOINT_WRITE_ERROR) { if (write_status == GRPC_ENDPOINT_WRITE_ERROR) {
gpr_log(GPR_ERROR, "Could not send handshake data to peer."); gpr_log(GPR_ERROR, "Could not send handshake data to peer.");
@ -198,7 +203,7 @@ static void on_handshake_data_received_from_peer(
if (result == TSI_INCOMPLETE_DATA) { if (result == TSI_INCOMPLETE_DATA) {
/* TODO(klempner,jboeuf): This should probably use the client setup /* TODO(klempner,jboeuf): This should probably use the client setup
deadline */ deadline */
grpc_endpoint_notify_on_read(s->endpoint, grpc_endpoint_notify_on_read(s->wrapped_endpoint,
on_handshake_data_received_from_peer, setup); on_handshake_data_received_from_peer, setup);
cleanup_slices(slices, nslices); cleanup_slices(slices, nslices);
return; return;
@ -256,7 +261,7 @@ static void on_handshake_data_sent_to_peer(void *setup,
if (tsi_handshaker_is_in_progress(s->handshaker)) { if (tsi_handshaker_is_in_progress(s->handshaker)) {
/* TODO(klempner,jboeuf): This should probably use the client setup /* TODO(klempner,jboeuf): This should probably use the client setup
deadline */ deadline */
grpc_endpoint_notify_on_read(s->endpoint, grpc_endpoint_notify_on_read(s->wrapped_endpoint,
on_handshake_data_received_from_peer, setup); on_handshake_data_received_from_peer, setup);
} else { } else {
check_peer(s); check_peer(s);
@ -280,7 +285,7 @@ void grpc_setup_secure_transport(grpc_security_connector *connector,
GRPC_SECURITY_CONNECTOR_REF(connector, "secure_transport_setup"); GRPC_SECURITY_CONNECTOR_REF(connector, "secure_transport_setup");
s->handshake_buffer_size = GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE; s->handshake_buffer_size = GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE;
s->handshake_buffer = gpr_malloc(s->handshake_buffer_size); s->handshake_buffer = gpr_malloc(s->handshake_buffer_size);
s->endpoint = nonsecure_endpoint; s->wrapped_endpoint = nonsecure_endpoint;
s->user_data = user_data; s->user_data = user_data;
s->cb = cb; s->cb = cb;
gpr_slice_buffer_init(&s->left_overs); gpr_slice_buffer_init(&s->left_overs);

@ -42,7 +42,7 @@
/* Ownership of the secure_endpoint is transfered. */ /* Ownership of the secure_endpoint is transfered. */
typedef void (*grpc_secure_transport_setup_done_cb)( typedef void (*grpc_secure_transport_setup_done_cb)(
void *user_data, grpc_security_status status, void *user_data, grpc_security_status status,
grpc_endpoint *secure_endpoint); grpc_endpoint *wrapped_endpoint, grpc_endpoint *secure_endpoint);
/* Calls the callback upon completion. */ /* Calls the callback upon completion. */
void grpc_setup_secure_transport(grpc_security_connector *connector, void grpc_setup_secure_transport(grpc_security_connector *connector,

@ -51,10 +51,16 @@
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include <grpc/support/useful.h> #include <grpc/support/useful.h>
typedef struct tcp_endpoint_list {
grpc_endpoint *tcp_endpoint;
struct tcp_endpoint_list *next;
} tcp_endpoint_list;
typedef struct grpc_server_secure_state { typedef struct grpc_server_secure_state {
grpc_server *server; grpc_server *server;
grpc_tcp_server *tcp; grpc_tcp_server *tcp;
grpc_security_connector *sc; grpc_security_connector *sc;
tcp_endpoint_list *handshaking_tcp_endpoints;
int is_shutdown; int is_shutdown;
gpr_mu mu; gpr_mu mu;
gpr_refcount refcount; gpr_refcount refcount;
@ -88,14 +94,37 @@ static void setup_transport(void *statep, grpc_transport *transport,
grpc_channel_args_destroy(args_copy); grpc_channel_args_destroy(args_copy);
} }
static int remove_tcp_from_list_locked(grpc_server_secure_state *state,
grpc_endpoint *tcp) {
tcp_endpoint_list *node = state->handshaking_tcp_endpoints;
tcp_endpoint_list *tmp = NULL;
if (node && node->tcp_endpoint == tcp) {
state->handshaking_tcp_endpoints = state->handshaking_tcp_endpoints->next;
gpr_free(node);
return 0;
}
while (node) {
if (node->next->tcp_endpoint == tcp) {
tmp = node->next;
node->next = node->next->next;
gpr_free(tmp);
return 0;
}
node = node->next;
}
return -1;
}
static void on_secure_transport_setup_done(void *statep, static void on_secure_transport_setup_done(void *statep,
grpc_security_status status, grpc_security_status status,
grpc_endpoint *wrapped_endpoint,
grpc_endpoint *secure_endpoint) { grpc_endpoint *secure_endpoint) {
grpc_server_secure_state *state = statep; grpc_server_secure_state *state = statep;
grpc_transport *transport; grpc_transport *transport;
grpc_mdctx *mdctx; grpc_mdctx *mdctx;
if (status == GRPC_SECURITY_OK) { if (status == GRPC_SECURITY_OK) {
gpr_mu_lock(&state->mu); gpr_mu_lock(&state->mu);
remove_tcp_from_list_locked(state, wrapped_endpoint);
if (!state->is_shutdown) { if (!state->is_shutdown) {
mdctx = grpc_mdctx_create(); mdctx = grpc_mdctx_create();
transport = grpc_create_chttp2_transport( transport = grpc_create_chttp2_transport(
@ -110,6 +139,9 @@ static void on_secure_transport_setup_done(void *statep,
} }
gpr_mu_unlock(&state->mu); gpr_mu_unlock(&state->mu);
} else { } else {
gpr_mu_lock(&state->mu);
remove_tcp_from_list_locked(state, wrapped_endpoint);
gpr_mu_unlock(&state->mu);
gpr_log(GPR_ERROR, "Secure transport failed with error %d", status); gpr_log(GPR_ERROR, "Secure transport failed with error %d", status);
} }
state_unref(state); state_unref(state);
@ -117,7 +149,14 @@ static void on_secure_transport_setup_done(void *statep,
static void on_accept(void *statep, grpc_endpoint *tcp) { static void on_accept(void *statep, grpc_endpoint *tcp) {
grpc_server_secure_state *state = statep; grpc_server_secure_state *state = statep;
tcp_endpoint_list *node;
state_ref(state); state_ref(state);
node = gpr_malloc(sizeof(tcp_endpoint_list));
node->tcp_endpoint = tcp;
gpr_mu_lock(&state->mu);
node->next = state->handshaking_tcp_endpoints;
state->handshaking_tcp_endpoints = node;
gpr_mu_unlock(&state->mu);
grpc_setup_secure_transport(state->sc, tcp, on_secure_transport_setup_done, grpc_setup_secure_transport(state->sc, tcp, on_secure_transport_setup_done,
state); state);
} }
@ -132,6 +171,13 @@ static void start(grpc_server *server, void *statep, grpc_pollset **pollsets,
static void destroy_done(void *statep) { static void destroy_done(void *statep) {
grpc_server_secure_state *state = statep; grpc_server_secure_state *state = statep;
grpc_server_listener_destroy_done(state->server); grpc_server_listener_destroy_done(state->server);
gpr_mu_lock(&state->mu);
while (state->handshaking_tcp_endpoints != NULL) {
grpc_endpoint_shutdown(state->handshaking_tcp_endpoints->tcp_endpoint);
remove_tcp_from_list_locked(state,
state->handshaking_tcp_endpoints->tcp_endpoint);
}
gpr_mu_unlock(&state->mu);
state_unref(state); state_unref(state);
} }
@ -209,6 +255,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
state->server = server; state->server = server;
state->tcp = tcp; state->tcp = tcp;
state->sc = sc; state->sc = sc;
state->handshaking_tcp_endpoints = NULL;
state->is_shutdown = 0; state->is_shutdown = 0;
gpr_mu_init(&state->mu); gpr_mu_init(&state->mu);
gpr_ref_init(&state->refcount, 1); gpr_ref_init(&state->refcount, 1);

@ -75,6 +75,7 @@ static void connector_unref(grpc_connector *con) {
static void on_secure_transport_setup_done(void *arg, static void on_secure_transport_setup_done(void *arg,
grpc_security_status status, grpc_security_status status,
grpc_endpoint *wrapped_endpoint,
grpc_endpoint *secure_endpoint) { grpc_endpoint *secure_endpoint) {
connector *c = arg; connector *c = arg;
grpc_iomgr_closure *notify; grpc_iomgr_closure *notify;

@ -32,7 +32,7 @@
*/ */
#include <grpc/support/cpu.h> #include <grpc/support/cpu.h>
#include "src/cpp/server/thread_pool.h" #include <grpc++/fixed_size_thread_pool.h>
#ifndef GRPC_CUSTOM_DEFAULT_THREAD_POOL #ifndef GRPC_CUSTOM_DEFAULT_THREAD_POOL
@ -41,7 +41,7 @@ namespace grpc {
ThreadPoolInterface* CreateDefaultThreadPool() { ThreadPoolInterface* CreateDefaultThreadPool() {
int cores = gpr_cpu_num_cores(); int cores = gpr_cpu_num_cores();
if (!cores) cores = 4; if (!cores) cores = 4;
return new ThreadPool(cores); return new FixedSizeThreadPool(cores);
} }
} // namespace grpc } // namespace grpc

@ -33,12 +33,11 @@
#include <grpc++/impl/sync.h> #include <grpc++/impl/sync.h>
#include <grpc++/impl/thd.h> #include <grpc++/impl/thd.h>
#include <grpc++/fixed_size_thread_pool.h>
#include "src/cpp/server/thread_pool.h"
namespace grpc { namespace grpc {
void ThreadPool::ThreadFunc() { void FixedSizeThreadPool::ThreadFunc() {
for (;;) { for (;;) {
// Wait until work is available or we are shutting down. // Wait until work is available or we are shutting down.
grpc::unique_lock<grpc::mutex> lock(mu_); grpc::unique_lock<grpc::mutex> lock(mu_);
@ -58,13 +57,14 @@ void ThreadPool::ThreadFunc() {
} }
} }
ThreadPool::ThreadPool(int num_threads) : shutdown_(false) { FixedSizeThreadPool::FixedSizeThreadPool(int num_threads) : shutdown_(false) {
for (int i = 0; i < num_threads; i++) { for (int i = 0; i < num_threads; i++) {
threads_.push_back(new grpc::thread(&ThreadPool::ThreadFunc, this)); threads_.push_back(
new grpc::thread(&FixedSizeThreadPool::ThreadFunc, this));
} }
} }
ThreadPool::~ThreadPool() { FixedSizeThreadPool::~FixedSizeThreadPool() {
{ {
grpc::lock_guard<grpc::mutex> lock(mu_); grpc::lock_guard<grpc::mutex> lock(mu_);
shutdown_ = true; shutdown_ = true;
@ -76,7 +76,8 @@ ThreadPool::~ThreadPool() {
} }
} }
void ThreadPool::ScheduleCallback(const std::function<void()>& callback) { void FixedSizeThreadPool::ScheduleCallback(
const std::function<void()>& callback) {
grpc::lock_guard<grpc::mutex> lock(mu_); grpc::lock_guard<grpc::mutex> lock(mu_);
callbacks_.push(callback); callbacks_.push(callback);
cv_.notify_one(); cv_.notify_one();

@ -37,7 +37,7 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc++/impl/service_type.h> #include <grpc++/impl/service_type.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include "src/cpp/server/thread_pool.h" #include <grpc++/thread_pool_interface.h>
namespace grpc { namespace grpc {

@ -52,10 +52,10 @@ namespace Grpc.Auth
/// <summary> /// <summary>
/// Creates OAuth2 interceptor. /// Creates OAuth2 interceptor.
/// </summary> /// </summary>
public static HeaderInterceptorDelegate Create(GoogleCredential googleCredential) public static MetadataInterceptorDelegate Create(GoogleCredential googleCredential)
{ {
var interceptor = new OAuth2Interceptor(googleCredential.InternalCredential, SystemClock.Default); var interceptor = new OAuth2Interceptor(googleCredential.InternalCredential, SystemClock.Default);
return new HeaderInterceptorDelegate(interceptor.InterceptHeaders); return new MetadataInterceptorDelegate(interceptor.InterceptHeaders);
} }
/// <summary> /// <summary>
@ -94,10 +94,10 @@ namespace Grpc.Auth
return credential.Token.AccessToken; return credential.Token.AccessToken;
} }
public void InterceptHeaders(Metadata.Builder headerBuilder) public void InterceptHeaders(Metadata metadata)
{ {
var accessToken = GetAccessToken(CancellationToken.None); var accessToken = GetAccessToken(CancellationToken.None);
headerBuilder.Add(new Metadata.MetadataEntry(AuthorizationHeader, Schema + " " + accessToken)); metadata.Add(new Metadata.Entry(AuthorizationHeader, Schema + " " + accessToken));
} }
} }
} }

@ -44,17 +44,17 @@ namespace Grpc.Core.Internal.Tests
[Test] [Test]
public void CreateEmptyAndDestroy() public void CreateEmptyAndDestroy()
{ {
var metadata = Metadata.CreateBuilder().Build(); var nativeMetadata = MetadataArraySafeHandle.Create(new Metadata());
var nativeMetadata = MetadataArraySafeHandle.Create(metadata);
nativeMetadata.Dispose(); nativeMetadata.Dispose();
} }
[Test] [Test]
public void CreateAndDestroy() public void CreateAndDestroy()
{ {
var metadata = Metadata.CreateBuilder() var metadata = new Metadata {
.Add(new Metadata.MetadataEntry("host", "somehost")) new Metadata.Entry("host", "somehost"),
.Add(new Metadata.MetadataEntry("header2", "header value")).Build(); new Metadata.Entry("header2", "header value"),
};
var nativeMetadata = MetadataArraySafeHandle.Create(metadata); var nativeMetadata = MetadataArraySafeHandle.Create(metadata);
nativeMetadata.Dispose(); nativeMetadata.Dispose();
} }

@ -39,7 +39,7 @@ using Grpc.Core.Internal;
namespace Grpc.Core namespace Grpc.Core
{ {
/// <summary> /// <summary>
/// Helper methods for generated client stubs to make RPC calls. /// Helper methods for generated clients to make RPC calls.
/// </summary> /// </summary>
public static class Calls public static class Calls
{ {

@ -32,26 +32,39 @@
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using Grpc.Core.Internal; using Grpc.Core.Internal;
namespace Grpc.Core namespace Grpc.Core
{ {
// TODO: support adding timeout to methods. public delegate void MetadataInterceptorDelegate(Metadata metadata);
/// <summary> /// <summary>
/// Base for client-side stubs. /// Base class for client-side stubs.
/// </summary> /// </summary>
public abstract class AbstractStub<TStub, TConfig> public abstract class ClientBase
where TConfig : StubConfiguration
{ {
readonly Channel channel; readonly Channel channel;
readonly TConfig config;
public AbstractStub(Channel channel, TConfig config) public ClientBase(Channel channel)
{ {
this.channel = channel; this.channel = channel;
this.config = config;
} }
/// <summary>
/// Can be used to register a custom header (initial metadata) interceptor.
/// The delegate each time before a new call on this client is started.
/// </summary>
public MetadataInterceptorDelegate HeaderInterceptor
{
get;
set;
}
/// <summary>
/// Channel associated with this client.
/// </summary>
public Channel Channel public Channel Channel
{ {
get get
@ -63,13 +76,19 @@ namespace Grpc.Core
/// <summary> /// <summary>
/// Creates a new call to given method. /// Creates a new call to given method.
/// </summary> /// </summary>
protected Call<TRequest, TResponse> CreateCall<TRequest, TResponse>(string serviceName, Method<TRequest, TResponse> method) protected Call<TRequest, TResponse> CreateCall<TRequest, TResponse>(string serviceName, Method<TRequest, TResponse> method, Metadata metadata)
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class
{ {
var headerBuilder = Metadata.CreateBuilder(); var interceptor = HeaderInterceptor;
config.HeaderInterceptor(headerBuilder); if (interceptor != null)
return new Call<TRequest, TResponse>(serviceName, method, channel, headerBuilder.Build()); {
metadata = metadata ?? new Metadata();
interceptor(metadata);
metadata.Freeze();
}
metadata = metadata ?? Metadata.Empty;
return new Call<TRequest, TResponse>(serviceName, method, channel, metadata);
} }
} }
} }

@ -88,8 +88,7 @@
<Compile Include="ServerCredentials.cs" /> <Compile Include="ServerCredentials.cs" />
<Compile Include="Metadata.cs" /> <Compile Include="Metadata.cs" />
<Compile Include="Internal\MetadataArraySafeHandle.cs" /> <Compile Include="Internal\MetadataArraySafeHandle.cs" />
<Compile Include="Stub\AbstractStub.cs" /> <Compile Include="ClientBase.cs" />
<Compile Include="Stub\StubConfiguration.cs" />
<Compile Include="Internal\ServerCalls.cs" /> <Compile Include="Internal\ServerCalls.cs" />
<Compile Include="ServerMethods.cs" /> <Compile Include="ServerMethods.cs" />
<Compile Include="Internal\ClientRequestStream.cs" /> <Compile Include="Internal\ClientRequestStream.cs" />

@ -54,11 +54,11 @@ namespace Grpc.Core.Internal
public static MetadataArraySafeHandle Create(Metadata metadata) public static MetadataArraySafeHandle Create(Metadata metadata)
{ {
var entries = metadata.Entries; // TODO(jtattermusch): we might wanna check that the metadata is readonly
var metadataArray = grpcsharp_metadata_array_create(new UIntPtr((ulong)entries.Count)); var metadataArray = grpcsharp_metadata_array_create(new UIntPtr((ulong)metadata.Count));
for (int i = 0; i < entries.Count; i++) for (int i = 0; i < metadata.Count; i++)
{ {
grpcsharp_metadata_array_add(metadataArray, entries[i].Key, entries[i].ValueBytes, new UIntPtr((ulong)entries[i].ValueBytes.Length)); grpcsharp_metadata_array_add(metadataArray, metadata[i].Key, metadata[i].ValueBytes, new UIntPtr((ulong)metadata[i].ValueBytes.Length));
} }
return metadataArray; return metadataArray;
} }

@ -30,96 +30,195 @@
#endregion #endregion
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Collections.Specialized;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text; using System.Text;
using Grpc.Core.Utils;
namespace Grpc.Core namespace Grpc.Core
{ {
/// <summary> /// <summary>
/// gRPC call metadata. /// Provides access to read and write metadata values to be exchanged during a call.
/// </summary> /// </summary>
public class Metadata public sealed class Metadata : IList<Metadata.Entry>
{
/// <summary>
/// An read-only instance of metadata containing no entries.
/// </summary>
public static readonly Metadata Empty = new Metadata().Freeze();
readonly List<Entry> entries;
bool readOnly;
public Metadata()
{
this.entries = new List<Entry>();
}
public Metadata(ICollection<Entry> entries)
{ {
public static readonly Metadata Empty = new Metadata(ImmutableList<MetadataEntry>.Empty); this.entries = new List<Entry>(entries);
}
/// <summary>
/// Makes this object read-only.
/// </summary>
/// <returns>this object</returns>
public Metadata Freeze()
{
this.readOnly = true;
return this;
}
// TODO: add support for access by key
readonly ImmutableList<MetadataEntry> entries; #region IList members
public Metadata(ImmutableList<MetadataEntry> entries) public int IndexOf(Metadata.Entry item)
{ {
this.entries = entries; return entries.IndexOf(item);
} }
public ImmutableList<MetadataEntry> Entries public void Insert(int index, Metadata.Entry item)
{
CheckWriteable();
entries.Insert(index, item);
}
public void RemoveAt(int index)
{
CheckWriteable();
entries.RemoveAt(index);
}
public Metadata.Entry this[int index]
{ {
get get
{ {
return this.entries; return entries[index];
}
set
{
CheckWriteable();
entries[index] = value;
} }
} }
public static Builder CreateBuilder() public void Add(Metadata.Entry item)
{ {
return new Builder(); CheckWriteable();
entries.Add(item);
} }
public struct MetadataEntry public void Clear()
{ {
readonly string key; CheckWriteable();
readonly byte[] valueBytes; entries.Clear();
}
public MetadataEntry(string key, byte[] valueBytes) public bool Contains(Metadata.Entry item)
{ {
this.key = key; return entries.Contains(item);
this.valueBytes = valueBytes;
} }
public MetadataEntry(string key, string value) public void CopyTo(Metadata.Entry[] array, int arrayIndex)
{ {
this.key = key; entries.CopyTo(array, arrayIndex);
this.valueBytes = Encoding.ASCII.GetBytes(value);
} }
public string Key public int Count
{ {
get get { return entries.Count; }
}
public bool IsReadOnly
{ {
return this.key; get { return readOnly; }
} }
public bool Remove(Metadata.Entry item)
{
CheckWriteable();
return entries.Remove(item);
} }
// TODO: using ByteString would guarantee immutability. public IEnumerator<Metadata.Entry> GetEnumerator()
public byte[] ValueBytes
{ {
get return entries.GetEnumerator();
}
IEnumerator System.Collections.IEnumerable.GetEnumerator()
{ {
return this.valueBytes; return entries.GetEnumerator();
} }
private void CheckWriteable()
{
Preconditions.CheckState(!readOnly, "Object is read only");
} }
#endregion
/// <summary>
/// Metadata entry
/// </summary>
public struct Entry
{
private static readonly Encoding Encoding = Encoding.ASCII;
readonly string key;
string value;
byte[] valueBytes;
public Entry(string key, byte[] valueBytes)
{
this.key = Preconditions.CheckNotNull(key);
this.value = null;
this.valueBytes = Preconditions.CheckNotNull(valueBytes);
} }
public class Builder public Entry(string key, string value)
{ {
readonly List<Metadata.MetadataEntry> entries = new List<Metadata.MetadataEntry>(); this.key = Preconditions.CheckNotNull(key);
this.value = Preconditions.CheckNotNull(value);
this.valueBytes = null;
}
public List<MetadataEntry> Entries public string Key
{ {
get get
{ {
return entries; return this.key;
} }
} }
public Builder Add(MetadataEntry entry) public byte[] ValueBytes
{ {
entries.Add(entry); get
return this; {
if (valueBytes == null)
{
valueBytes = Encoding.GetBytes(value);
}
return valueBytes;
}
} }
public Metadata Build() public string Value
{
get
{
if (value == null)
{ {
return new Metadata(entries.ToImmutableList()); value = Encoding.GetString(valueBytes);
}
return value;
}
} }
} }
} }

@ -1,64 +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 Grpc.Core.Internal;
using Grpc.Core.Utils;
namespace Grpc.Core
{
public delegate void HeaderInterceptorDelegate(Metadata.Builder headerBuilder);
public class StubConfiguration
{
/// <summary>
/// The default stub configuration.
/// </summary>
public static readonly StubConfiguration Default = new StubConfiguration((headerBuilder) => { });
readonly HeaderInterceptorDelegate headerInterceptor;
public StubConfiguration(HeaderInterceptorDelegate headerInterceptor)
{
this.headerInterceptor = Preconditions.CheckNotNull(headerInterceptor);
}
public HeaderInterceptorDelegate HeaderInterceptor
{
get
{
return headerInterceptor;
}
}
}
}

@ -3,4 +3,3 @@ using System.Runtime.CompilerServices;
// The current version of gRPC C#. // The current version of gRPC C#.
[assembly: AssemblyVersion("0.6.0.*")] [assembly: AssemblyVersion("0.6.0.*")]

@ -41,18 +41,18 @@ namespace math
{ {
using (Channel channel = new Channel("127.0.0.1", 23456)) using (Channel channel = new Channel("127.0.0.1", 23456))
{ {
Math.IMathClient stub = new Math.MathClient(channel); Math.IMathClient client = new Math.MathClient(channel);
MathExamples.DivExample(stub); MathExamples.DivExample(client);
MathExamples.DivAsyncExample(stub).Wait(); MathExamples.DivAsyncExample(client).Wait();
MathExamples.FibExample(stub).Wait(); MathExamples.FibExample(client).Wait();
MathExamples.SumExample(stub).Wait(); MathExamples.SumExample(client).Wait();
MathExamples.DivManyExample(stub).Wait(); MathExamples.DivManyExample(client).Wait();
MathExamples.DependendRequestsExample(stub).Wait(); MathExamples.DependendRequestsExample(client).Wait();
} }
GrpcEnvironment.Shutdown(); GrpcEnvironment.Shutdown();

@ -49,7 +49,7 @@ namespace math.Tests
string host = "localhost"; string host = "localhost";
Server server; Server server;
Channel channel; Channel channel;
Math.IMathClient client; Math.MathClient client;
[TestFixtureSetUp] [TestFixtureSetUp]
public void Init() public void Init()
@ -59,14 +59,14 @@ namespace math.Tests
int port = server.AddListeningPort(host, Server.PickUnusedPort); int port = server.AddListeningPort(host, Server.PickUnusedPort);
server.Start(); server.Start();
channel = new Channel(host, port); channel = new Channel(host, port);
client = Math.NewClient(channel);
// TODO(jtattermusch): get rid of the custom header here once we have dedicated tests // TODO(jtattermusch): get rid of the custom header here once we have dedicated tests
// for header support. // for header support.
var stubConfig = new StubConfiguration((headerBuilder) => client.HeaderInterceptor = (metadata) =>
{ {
headerBuilder.Add(new Metadata.MetadataEntry("customHeader", "abcdef")); metadata.Add(new Metadata.Entry("customHeader", "abcdef"));
}); };
client = Math.NewStub(channel, stubConfig);
} }
[TestFixtureTearDown] [TestFixtureTearDown]

@ -38,29 +38,29 @@ namespace math
{ {
public static class MathExamples public static class MathExamples
{ {
public static void DivExample(Math.IMathClient stub) public static void DivExample(Math.IMathClient client)
{ {
DivReply result = stub.Div(new DivArgs.Builder { Dividend = 10, Divisor = 3 }.Build()); DivReply result = client.Div(new DivArgs.Builder { Dividend = 10, Divisor = 3 }.Build());
Console.WriteLine("Div Result: " + result); Console.WriteLine("Div Result: " + result);
} }
public static async Task DivAsyncExample(Math.IMathClient stub) public static async Task DivAsyncExample(Math.IMathClient client)
{ {
Task<DivReply> resultTask = stub.DivAsync(new DivArgs.Builder { Dividend = 4, Divisor = 5 }.Build()); Task<DivReply> resultTask = client.DivAsync(new DivArgs.Builder { Dividend = 4, Divisor = 5 }.Build());
DivReply result = await resultTask; DivReply result = await resultTask;
Console.WriteLine("DivAsync Result: " + result); Console.WriteLine("DivAsync Result: " + result);
} }
public static async Task FibExample(Math.IMathClient stub) public static async Task FibExample(Math.IMathClient client)
{ {
using (var call = stub.Fib(new FibArgs.Builder { Limit = 5 }.Build())) using (var call = client.Fib(new FibArgs.Builder { Limit = 5 }.Build()))
{ {
List<Num> result = await call.ResponseStream.ToList(); List<Num> result = await call.ResponseStream.ToList();
Console.WriteLine("Fib Result: " + string.Join("|", result)); Console.WriteLine("Fib Result: " + string.Join("|", result));
} }
} }
public static async Task SumExample(Math.IMathClient stub) public static async Task SumExample(Math.IMathClient client)
{ {
var numbers = new List<Num> var numbers = new List<Num>
{ {
@ -69,14 +69,14 @@ namespace math
new Num.Builder { Num_ = 3 }.Build() new Num.Builder { Num_ = 3 }.Build()
}; };
using (var call = stub.Sum()) using (var call = client.Sum())
{ {
await call.RequestStream.WriteAll(numbers); await call.RequestStream.WriteAll(numbers);
Console.WriteLine("Sum Result: " + await call.Result); Console.WriteLine("Sum Result: " + await call.Result);
} }
} }
public static async Task DivManyExample(Math.IMathClient stub) public static async Task DivManyExample(Math.IMathClient client)
{ {
var divArgsList = new List<DivArgs> var divArgsList = new List<DivArgs>
{ {
@ -84,14 +84,14 @@ namespace math
new DivArgs.Builder { Dividend = 100, Divisor = 21 }.Build(), new DivArgs.Builder { Dividend = 100, Divisor = 21 }.Build(),
new DivArgs.Builder { Dividend = 7, Divisor = 2 }.Build() new DivArgs.Builder { Dividend = 7, Divisor = 2 }.Build()
}; };
using (var call = stub.DivMany()) using (var call = client.DivMany())
{ {
await call.RequestStream.WriteAll(divArgsList); await call.RequestStream.WriteAll(divArgsList);
Console.WriteLine("DivMany Result: " + string.Join("|", await call.ResponseStream.ToList())); Console.WriteLine("DivMany Result: " + string.Join("|", await call.ResponseStream.ToList()));
} }
} }
public static async Task DependendRequestsExample(Math.IMathClient stub) public static async Task DependendRequestsExample(Math.IMathClient client)
{ {
var numbers = new List<Num> var numbers = new List<Num>
{ {
@ -101,13 +101,13 @@ namespace math
}; };
Num sum; Num sum;
using (var sumCall = stub.Sum()) using (var sumCall = client.Sum())
{ {
await sumCall.RequestStream.WriteAll(numbers); await sumCall.RequestStream.WriteAll(numbers);
sum = await sumCall.Result; sum = await sumCall.Result;
} }
DivReply result = await stub.DivAsync(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numbers.Count }.Build()); DivReply result = await client.DivAsync(new DivArgs.Builder { Dividend = sum.Num_, Divisor = numbers.Count }.Build());
Console.WriteLine("Avg Result: " + result); Console.WriteLine("Avg Result: " + result);
} }
} }

@ -41,14 +41,14 @@ namespace math {
__Marshaller_Num, __Marshaller_Num,
__Marshaller_Num); __Marshaller_Num);
// client-side stub interface // client interface
public interface IMathClient public interface IMathClient
{ {
global::math.DivReply Div(global::math.DivArgs request, CancellationToken token = default(CancellationToken)); global::math.DivReply Div(global::math.DivArgs request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
Task<global::math.DivReply> DivAsync(global::math.DivArgs request, CancellationToken token = default(CancellationToken)); Task<global::math.DivReply> DivAsync(global::math.DivArgs request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
AsyncDuplexStreamingCall<global::math.DivArgs, global::math.DivReply> DivMany(CancellationToken token = default(CancellationToken)); AsyncDuplexStreamingCall<global::math.DivArgs, global::math.DivReply> DivMany(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
AsyncServerStreamingCall<global::math.Num> Fib(global::math.FibArgs request, CancellationToken token = default(CancellationToken)); AsyncServerStreamingCall<global::math.Num> Fib(global::math.FibArgs request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
AsyncClientStreamingCall<global::math.Num, global::math.Num> Sum(CancellationToken token = default(CancellationToken)); AsyncClientStreamingCall<global::math.Num, global::math.Num> Sum(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
} }
// server-side interface // server-side interface
@ -61,38 +61,35 @@ namespace math {
} }
// client stub // client stub
public class MathClient : AbstractStub<MathClient, StubConfiguration>, IMathClient public class MathClient : ClientBase, IMathClient
{ {
public MathClient(Channel channel) : this(channel, StubConfiguration.Default) public MathClient(Channel channel) : base(channel)
{ {
} }
public MathClient(Channel channel, StubConfiguration config) : base(channel, config) public global::math.DivReply Div(global::math.DivArgs request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_Div, headers);
return Calls.BlockingUnaryCall(call, request, cancellationToken);
} }
public global::math.DivReply Div(global::math.DivArgs request, CancellationToken token = default(CancellationToken)) public Task<global::math.DivReply> DivAsync(global::math.DivArgs request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_Div); var call = CreateCall(__ServiceName, __Method_Div, headers);
return Calls.BlockingUnaryCall(call, request, token); return Calls.AsyncUnaryCall(call, request, cancellationToken);
} }
public Task<global::math.DivReply> DivAsync(global::math.DivArgs request, CancellationToken token = default(CancellationToken)) public AsyncDuplexStreamingCall<global::math.DivArgs, global::math.DivReply> DivMany(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_Div); var call = CreateCall(__ServiceName, __Method_DivMany, headers);
return Calls.AsyncUnaryCall(call, request, token); return Calls.AsyncDuplexStreamingCall(call, cancellationToken);
} }
public AsyncDuplexStreamingCall<global::math.DivArgs, global::math.DivReply> DivMany(CancellationToken token = default(CancellationToken)) public AsyncServerStreamingCall<global::math.Num> Fib(global::math.FibArgs request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_DivMany); var call = CreateCall(__ServiceName, __Method_Fib, headers);
return Calls.AsyncDuplexStreamingCall(call, token); return Calls.AsyncServerStreamingCall(call, request, cancellationToken);
} }
public AsyncServerStreamingCall<global::math.Num> Fib(global::math.FibArgs request, CancellationToken token = default(CancellationToken)) public AsyncClientStreamingCall<global::math.Num, global::math.Num> Sum(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_Fib); var call = CreateCall(__ServiceName, __Method_Sum, headers);
return Calls.AsyncServerStreamingCall(call, request, token); return Calls.AsyncClientStreamingCall(call, cancellationToken);
}
public AsyncClientStreamingCall<global::math.Num, global::math.Num> Sum(CancellationToken token = default(CancellationToken))
{
var call = CreateCall(__ServiceName, __Method_Sum);
return Calls.AsyncClientStreamingCall(call, token);
} }
} }
@ -106,17 +103,12 @@ namespace math {
.AddMethod(__Method_Sum, serviceImpl.Sum).Build(); .AddMethod(__Method_Sum, serviceImpl.Sum).Build();
} }
// creates a new client stub // creates a new client
public static IMathClient NewStub(Channel channel) public static MathClient NewClient(Channel channel)
{ {
return new MathClient(channel); return new MathClient(channel);
} }
// creates a new client stub
public static IMathClient NewStub(Channel channel, StubConfiguration config)
{
return new MathClient(channel, config);
}
} }
} }
#endregion #endregion

@ -63,7 +63,7 @@ namespace Grpc.HealthCheck.Tests
server.Start(); server.Start();
channel = new Channel(Host, port); channel = new Channel(Host, port);
client = Grpc.Health.V1Alpha.Health.NewStub(channel); client = Grpc.Health.V1Alpha.Health.NewClient(channel);
} }
[TestFixtureTearDown] [TestFixtureTearDown]

@ -21,11 +21,11 @@ namespace Grpc.Health.V1Alpha {
__Marshaller_HealthCheckRequest, __Marshaller_HealthCheckRequest,
__Marshaller_HealthCheckResponse); __Marshaller_HealthCheckResponse);
// client-side stub interface // client interface
public interface IHealthClient public interface IHealthClient
{ {
global::Grpc.Health.V1Alpha.HealthCheckResponse Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, CancellationToken token = default(CancellationToken)); global::Grpc.Health.V1Alpha.HealthCheckResponse Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
Task<global::Grpc.Health.V1Alpha.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1Alpha.HealthCheckRequest request, CancellationToken token = default(CancellationToken)); Task<global::Grpc.Health.V1Alpha.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1Alpha.HealthCheckRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
} }
// server-side interface // server-side interface
@ -35,23 +35,20 @@ namespace Grpc.Health.V1Alpha {
} }
// client stub // client stub
public class HealthClient : AbstractStub<HealthClient, StubConfiguration>, IHealthClient public class HealthClient : ClientBase, IHealthClient
{ {
public HealthClient(Channel channel) : this(channel, StubConfiguration.Default) public HealthClient(Channel channel) : base(channel)
{ {
} }
public HealthClient(Channel channel, StubConfiguration config) : base(channel, config) public global::Grpc.Health.V1Alpha.HealthCheckResponse Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_Check, headers);
return Calls.BlockingUnaryCall(call, request, cancellationToken);
} }
public global::Grpc.Health.V1Alpha.HealthCheckResponse Check(global::Grpc.Health.V1Alpha.HealthCheckRequest request, CancellationToken token = default(CancellationToken)) public Task<global::Grpc.Health.V1Alpha.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1Alpha.HealthCheckRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_Check); var call = CreateCall(__ServiceName, __Method_Check, headers);
return Calls.BlockingUnaryCall(call, request, token); return Calls.AsyncUnaryCall(call, request, cancellationToken);
}
public Task<global::Grpc.Health.V1Alpha.HealthCheckResponse> CheckAsync(global::Grpc.Health.V1Alpha.HealthCheckRequest request, CancellationToken token = default(CancellationToken))
{
var call = CreateCall(__ServiceName, __Method_Check);
return Calls.AsyncUnaryCall(call, request, token);
} }
} }
@ -62,17 +59,12 @@ namespace Grpc.Health.V1Alpha {
.AddMethod(__Method_Check, serviceImpl.Check).Build(); .AddMethod(__Method_Check, serviceImpl.Check).Build();
} }
// creates a new client stub // creates a new client
public static IHealthClient NewStub(Channel channel) public static HealthClient NewClient(Channel channel)
{ {
return new HealthClient(channel); return new HealthClient(channel);
} }
// creates a new client stub
public static IHealthClient NewStub(Channel channel, StubConfiguration config)
{
return new HealthClient(channel, config);
}
} }
} }
#endregion #endregion

@ -119,7 +119,7 @@ namespace Grpc.IntegrationTesting
using (Channel channel = new Channel(options.serverHost, options.serverPort.Value, credentials, channelOptions)) using (Channel channel = new Channel(options.serverHost, options.serverPort.Value, credentials, channelOptions))
{ {
var stubConfig = StubConfiguration.Default; TestService.TestServiceClient client = new TestService.TestServiceClient(channel);
if (options.testCase == "service_account_creds" || options.testCase == "compute_engine_creds") if (options.testCase == "service_account_creds" || options.testCase == "compute_engine_creds")
{ {
var credential = GoogleCredential.GetApplicationDefault(); var credential = GoogleCredential.GetApplicationDefault();
@ -127,10 +127,9 @@ namespace Grpc.IntegrationTesting
{ {
credential = credential.CreateScoped(new[] { AuthScope }); credential = credential.CreateScoped(new[] { AuthScope });
} }
stubConfig = new StubConfiguration(OAuth2InterceptorFactory.Create(credential)); client.HeaderInterceptor = OAuth2InterceptorFactory.Create(credential);
} }
TestService.ITestServiceClient client = new TestService.TestServiceClient(channel, stubConfig);
RunTestCase(options.testCase, client); RunTestCase(options.testCase, client);
} }
GrpcEnvironment.Shutdown(); GrpcEnvironment.Shutdown();
@ -363,7 +362,7 @@ namespace Grpc.IntegrationTesting
Console.WriteLine("running cancel_after_begin"); Console.WriteLine("running cancel_after_begin");
var cts = new CancellationTokenSource(); var cts = new CancellationTokenSource();
using (var call = client.StreamingInputCall(cts.Token)) using (var call = client.StreamingInputCall(cancellationToken: cts.Token))
{ {
// TODO(jtattermusch): we need this to ensure call has been initiated once we cancel it. // TODO(jtattermusch): we need this to ensure call has been initiated once we cancel it.
await Task.Delay(1000); await Task.Delay(1000);
@ -390,7 +389,7 @@ namespace Grpc.IntegrationTesting
Console.WriteLine("running cancel_after_first_response"); Console.WriteLine("running cancel_after_first_response");
var cts = new CancellationTokenSource(); var cts = new CancellationTokenSource();
using (var call = client.FullDuplexCall(cts.Token)) using (var call = client.FullDuplexCall(cancellationToken: cts.Token))
{ {
await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder() await call.RequestStream.WriteAsync(StreamingOutputCallRequest.CreateBuilder()
.SetResponseType(PayloadType.COMPRESSABLE) .SetResponseType(PayloadType.COMPRESSABLE)

@ -65,7 +65,7 @@ namespace Grpc.IntegrationTesting
new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride) new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride)
}; };
channel = new Channel(host, port, TestCredentials.CreateTestClientCredentials(true), options); channel = new Channel(host, port, TestCredentials.CreateTestClientCredentials(true), options);
client = TestService.NewStub(channel); client = TestService.NewClient(channel);
} }
[TestFixtureTearDown] [TestFixtureTearDown]

@ -56,17 +56,17 @@ namespace grpc.testing {
__Marshaller_StreamingOutputCallRequest, __Marshaller_StreamingOutputCallRequest,
__Marshaller_StreamingOutputCallResponse); __Marshaller_StreamingOutputCallResponse);
// client-side stub interface // client interface
public interface ITestServiceClient public interface ITestServiceClient
{ {
global::grpc.testing.Empty EmptyCall(global::grpc.testing.Empty request, CancellationToken token = default(CancellationToken)); global::grpc.testing.Empty EmptyCall(global::grpc.testing.Empty request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
Task<global::grpc.testing.Empty> EmptyCallAsync(global::grpc.testing.Empty request, CancellationToken token = default(CancellationToken)); Task<global::grpc.testing.Empty> EmptyCallAsync(global::grpc.testing.Empty request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
global::grpc.testing.SimpleResponse UnaryCall(global::grpc.testing.SimpleRequest request, CancellationToken token = default(CancellationToken)); global::grpc.testing.SimpleResponse UnaryCall(global::grpc.testing.SimpleRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
Task<global::grpc.testing.SimpleResponse> UnaryCallAsync(global::grpc.testing.SimpleRequest request, CancellationToken token = default(CancellationToken)); Task<global::grpc.testing.SimpleResponse> UnaryCallAsync(global::grpc.testing.SimpleRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
AsyncServerStreamingCall<global::grpc.testing.StreamingOutputCallResponse> StreamingOutputCall(global::grpc.testing.StreamingOutputCallRequest request, CancellationToken token = default(CancellationToken)); AsyncServerStreamingCall<global::grpc.testing.StreamingOutputCallResponse> StreamingOutputCall(global::grpc.testing.StreamingOutputCallRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
AsyncClientStreamingCall<global::grpc.testing.StreamingInputCallRequest, global::grpc.testing.StreamingInputCallResponse> StreamingInputCall(CancellationToken token = default(CancellationToken)); AsyncClientStreamingCall<global::grpc.testing.StreamingInputCallRequest, global::grpc.testing.StreamingInputCallResponse> StreamingInputCall(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
AsyncDuplexStreamingCall<global::grpc.testing.StreamingOutputCallRequest, global::grpc.testing.StreamingOutputCallResponse> FullDuplexCall(CancellationToken token = default(CancellationToken)); AsyncDuplexStreamingCall<global::grpc.testing.StreamingOutputCallRequest, global::grpc.testing.StreamingOutputCallResponse> FullDuplexCall(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
AsyncDuplexStreamingCall<global::grpc.testing.StreamingOutputCallRequest, global::grpc.testing.StreamingOutputCallResponse> HalfDuplexCall(CancellationToken token = default(CancellationToken)); AsyncDuplexStreamingCall<global::grpc.testing.StreamingOutputCallRequest, global::grpc.testing.StreamingOutputCallResponse> HalfDuplexCall(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken));
} }
// server-side interface // server-side interface
@ -81,53 +81,50 @@ namespace grpc.testing {
} }
// client stub // client stub
public class TestServiceClient : AbstractStub<TestServiceClient, StubConfiguration>, ITestServiceClient public class TestServiceClient : ClientBase, ITestServiceClient
{ {
public TestServiceClient(Channel channel) : this(channel, StubConfiguration.Default) public TestServiceClient(Channel channel) : base(channel)
{ {
} }
public TestServiceClient(Channel channel, StubConfiguration config) : base(channel, config) public global::grpc.testing.Empty EmptyCall(global::grpc.testing.Empty request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_EmptyCall, headers);
return Calls.BlockingUnaryCall(call, request, cancellationToken);
} }
public global::grpc.testing.Empty EmptyCall(global::grpc.testing.Empty request, CancellationToken token = default(CancellationToken)) public Task<global::grpc.testing.Empty> EmptyCallAsync(global::grpc.testing.Empty request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_EmptyCall); var call = CreateCall(__ServiceName, __Method_EmptyCall, headers);
return Calls.BlockingUnaryCall(call, request, token); return Calls.AsyncUnaryCall(call, request, cancellationToken);
} }
public Task<global::grpc.testing.Empty> EmptyCallAsync(global::grpc.testing.Empty request, CancellationToken token = default(CancellationToken)) public global::grpc.testing.SimpleResponse UnaryCall(global::grpc.testing.SimpleRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_EmptyCall); var call = CreateCall(__ServiceName, __Method_UnaryCall, headers);
return Calls.AsyncUnaryCall(call, request, token); return Calls.BlockingUnaryCall(call, request, cancellationToken);
} }
public global::grpc.testing.SimpleResponse UnaryCall(global::grpc.testing.SimpleRequest request, CancellationToken token = default(CancellationToken)) public Task<global::grpc.testing.SimpleResponse> UnaryCallAsync(global::grpc.testing.SimpleRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_UnaryCall); var call = CreateCall(__ServiceName, __Method_UnaryCall, headers);
return Calls.BlockingUnaryCall(call, request, token); return Calls.AsyncUnaryCall(call, request, cancellationToken);
} }
public Task<global::grpc.testing.SimpleResponse> UnaryCallAsync(global::grpc.testing.SimpleRequest request, CancellationToken token = default(CancellationToken)) public AsyncServerStreamingCall<global::grpc.testing.StreamingOutputCallResponse> StreamingOutputCall(global::grpc.testing.StreamingOutputCallRequest request, Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_UnaryCall); var call = CreateCall(__ServiceName, __Method_StreamingOutputCall, headers);
return Calls.AsyncUnaryCall(call, request, token); return Calls.AsyncServerStreamingCall(call, request, cancellationToken);
} }
public AsyncServerStreamingCall<global::grpc.testing.StreamingOutputCallResponse> StreamingOutputCall(global::grpc.testing.StreamingOutputCallRequest request, CancellationToken token = default(CancellationToken)) public AsyncClientStreamingCall<global::grpc.testing.StreamingInputCallRequest, global::grpc.testing.StreamingInputCallResponse> StreamingInputCall(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_StreamingOutputCall); var call = CreateCall(__ServiceName, __Method_StreamingInputCall, headers);
return Calls.AsyncServerStreamingCall(call, request, token); return Calls.AsyncClientStreamingCall(call, cancellationToken);
} }
public AsyncClientStreamingCall<global::grpc.testing.StreamingInputCallRequest, global::grpc.testing.StreamingInputCallResponse> StreamingInputCall(CancellationToken token = default(CancellationToken)) public AsyncDuplexStreamingCall<global::grpc.testing.StreamingOutputCallRequest, global::grpc.testing.StreamingOutputCallResponse> FullDuplexCall(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_StreamingInputCall); var call = CreateCall(__ServiceName, __Method_FullDuplexCall, headers);
return Calls.AsyncClientStreamingCall(call, token); return Calls.AsyncDuplexStreamingCall(call, cancellationToken);
} }
public AsyncDuplexStreamingCall<global::grpc.testing.StreamingOutputCallRequest, global::grpc.testing.StreamingOutputCallResponse> FullDuplexCall(CancellationToken token = default(CancellationToken)) public AsyncDuplexStreamingCall<global::grpc.testing.StreamingOutputCallRequest, global::grpc.testing.StreamingOutputCallResponse> HalfDuplexCall(Metadata headers = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
var call = CreateCall(__ServiceName, __Method_FullDuplexCall); var call = CreateCall(__ServiceName, __Method_HalfDuplexCall, headers);
return Calls.AsyncDuplexStreamingCall(call, token); return Calls.AsyncDuplexStreamingCall(call, cancellationToken);
}
public AsyncDuplexStreamingCall<global::grpc.testing.StreamingOutputCallRequest, global::grpc.testing.StreamingOutputCallResponse> HalfDuplexCall(CancellationToken token = default(CancellationToken))
{
var call = CreateCall(__ServiceName, __Method_HalfDuplexCall);
return Calls.AsyncDuplexStreamingCall(call, token);
} }
} }
@ -143,17 +140,12 @@ namespace grpc.testing {
.AddMethod(__Method_HalfDuplexCall, serviceImpl.HalfDuplexCall).Build(); .AddMethod(__Method_HalfDuplexCall, serviceImpl.HalfDuplexCall).Build();
} }
// creates a new client stub // creates a new client
public static ITestServiceClient NewStub(Channel channel) public static TestServiceClient NewClient(Channel channel)
{ {
return new TestServiceClient(channel); return new TestServiceClient(channel);
} }
// creates a new client stub
public static ITestServiceClient NewStub(Channel channel, StubConfiguration config)
{
return new TestServiceClient(channel, config);
}
} }
} }
#endregion #endregion

@ -32,16 +32,17 @@
set +e set +e
cd $(dirname $0) cd $(dirname $0)
PROTOC=../../bins/opt/protobuf/protoc
PLUGIN=protoc-gen-grpc=../../bins/opt/grpc_csharp_plugin PLUGIN=protoc-gen-grpc=../../bins/opt/grpc_csharp_plugin
EXAMPLES_DIR=Grpc.Examples EXAMPLES_DIR=Grpc.Examples
INTEROP_DIR=Grpc.IntegrationTesting INTEROP_DIR=Grpc.IntegrationTesting
HEALTHCHECK_DIR=Grpc.HealthCheck HEALTHCHECK_DIR=Grpc.HealthCheck
protoc --plugin=$PLUGIN --grpc_out=$EXAMPLES_DIR \ $PROTOC --plugin=$PLUGIN --grpc_out=$EXAMPLES_DIR \
-I $EXAMPLES_DIR/proto $EXAMPLES_DIR/proto/math.proto -I $EXAMPLES_DIR/proto $EXAMPLES_DIR/proto/math.proto
protoc --plugin=$PLUGIN --grpc_out=$INTEROP_DIR \ $PROTOC --plugin=$PLUGIN --grpc_out=$INTEROP_DIR \
-I $INTEROP_DIR/proto $INTEROP_DIR/proto/test.proto -I $INTEROP_DIR/proto $INTEROP_DIR/proto/test.proto
protoc --plugin=$PLUGIN --grpc_out=$HEALTHCHECK_DIR \ $PROTOC --plugin=$PLUGIN --grpc_out=$HEALTHCHECK_DIR \
-I $HEALTHCHECK_DIR/proto $HEALTHCHECK_DIR/proto/health.proto -I $HEALTHCHECK_DIR/proto $HEALTHCHECK_DIR/proto/health.proto

@ -87,7 +87,7 @@ static ProtoMethod *kUnaryCallMethod;
[call startWithWriteable:responsesWriteable]; [call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:2. handler:nil]; [self waitForExpectationsWithTimeout:4 handler:nil];
} }
- (void)testEmptyRPC { - (void)testEmptyRPC {
@ -109,7 +109,7 @@ static ProtoMethod *kUnaryCallMethod;
[call startWithWriteable:responsesWriteable]; [call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:2. handler:nil]; [self waitForExpectationsWithTimeout:4 handler:nil];
} }
- (void)testSimpleProtoRPC { - (void)testSimpleProtoRPC {
@ -141,7 +141,7 @@ static ProtoMethod *kUnaryCallMethod;
[call startWithWriteable:responsesWriteable]; [call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:2. handler:nil]; [self waitForExpectationsWithTimeout:4 handler:nil];
} }
- (void)testMetadata { - (void)testMetadata {
@ -173,7 +173,7 @@ static ProtoMethod *kUnaryCallMethod;
[call startWithWriteable:responsesWriteable]; [call startWithWriteable:responsesWriteable];
[self waitForExpectationsWithTimeout:2. handler:nil]; [self waitForExpectationsWithTimeout:4 handler:nil];
} }
@end @end

@ -103,7 +103,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:2 handler:nil]; [self waitForExpectationsWithTimeout:4 handler:nil];
} }
- (void)testLargeUnaryRPC { - (void)testLargeUnaryRPC {
@ -125,7 +125,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:4 handler:nil]; [self waitForExpectationsWithTimeout:8 handler:nil];
} }
- (void)testClientStreamingRPC { - (void)testClientStreamingRPC {
@ -157,7 +157,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:4 handler:nil]; [self waitForExpectationsWithTimeout:8 handler:nil];
} }
- (void)testServerStreamingRPC { - (void)testServerStreamingRPC {
@ -193,7 +193,7 @@
} }
}]; }];
[self waitForExpectationsWithTimeout:4 handler:nil]; [self waitForExpectationsWithTimeout:8 handler:nil];
} }
- (void)testPingPongRPC { - (void)testPingPongRPC {
@ -236,7 +236,7 @@
[expectation fulfill]; [expectation fulfill];
} }
}]; }];
[self waitForExpectationsWithTimeout:2 handler:nil]; [self waitForExpectationsWithTimeout:4 handler:nil];
} }
- (void)testEmptyStreamRPC { - (void)testEmptyStreamRPC {
@ -282,7 +282,8 @@
[requestsBuffer writeValue:request]; [requestsBuffer writeValue:request];
__block ProtoRPC *call = [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer __block ProtoRPC *call =
[_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer
eventHandler:^(BOOL done, eventHandler:^(BOOL done,
RMTStreamingOutputCallResponse *response, RMTStreamingOutputCallResponse *response,
NSError *error) { NSError *error) {
@ -299,7 +300,7 @@
} }
}]; }];
[call start]; [call start];
[self waitForExpectationsWithTimeout:4 handler:nil]; [self waitForExpectationsWithTimeout:8 handler:nil];
} }
@end @end

@ -46,4 +46,6 @@ elif [ ! -e $default_extension_dir/grpc.so ]; then
ln -s $f $module_dir/$(basename $f) &> /dev/null || true ln -s $f $module_dir/$(basename $f) &> /dev/null || true
done done
extension_dir="-d extension_dir=${module_dir} -d extension=grpc.so" extension_dir="-d extension_dir=${module_dir} -d extension=grpc.so"
else
extension_dir="-d extension=grpc.so"
fi fi

@ -353,20 +353,20 @@ CACHE_MK =
HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false) HAS_PKG_CONFIG ?= $(shell command -v $(PKG_CONFIG) >/dev/null 2>&1 && echo true || echo false)
ifeq ($(HAS_PKG_CONFIG), true) ifeq ($(HAS_PKG_CONFIG), true)
CACHE_MK += HAS_PKG_CONFIG = true\n CACHE_MK += HAS_PKG_CONFIG = true,
endif endif
PC_TEMPLATE = prefix=$(prefix)\n\ PC_TEMPLATE = prefix=$(prefix),\
exec_prefix=${'\$${prefix}'}\n\ exec_prefix=${'\$${prefix}'},\
includedir=${'\$${prefix}'}/include\n\ includedir=${'\$${prefix}'}/include,\
libdir=${'\$${exec_prefix}'}/lib\n\ libdir=${'\$${exec_prefix}'}/lib,\
\n\ ,\
Name: $(PC_NAME)\n\ Name: $(PC_NAME),\
Description: $(PC_DESCRIPTION)\n\ Description: $(PC_DESCRIPTION),\
Version: $(VERSION)\n\ Version: $(VERSION),\
Cflags: -I${'\$${includedir}'} $(PC_CFLAGS)\n\ Cflags: -I${'\$${includedir}'} $(PC_CFLAGS),\
Requires.private: $(PC_REQUIRES_PRIVATE)\n\ Requires.private: $(PC_REQUIRES_PRIVATE),\
Libs: -L${'\$${libdir}'} $(PC_LIB)\n\ Libs: -L${'\$${libdir}'} $(PC_LIB),\
Libs.private: $(PC_LIBS_PRIVATE) Libs.private: $(PC_LIBS_PRIVATE)
# gpr .pc file # gpr .pc file
@ -442,7 +442,7 @@ HAS_SYSTEM_PERFTOOLS ?= $(shell $(PERFTOOLS_CHECK_CMD) 2> /dev/null && echo true
ifeq ($(HAS_SYSTEM_PERFTOOLS),true) ifeq ($(HAS_SYSTEM_PERFTOOLS),true)
DEFINES += GRPC_HAVE_PERFTOOLS DEFINES += GRPC_HAVE_PERFTOOLS
LIBS += profiler LIBS += profiler
CACHE_MK += HAS_SYSTEM_PERFTOOLS = true\n CACHE_MK += HAS_SYSTEM_PERFTOOLS = true,
endif endif
endif endif
@ -451,20 +451,20 @@ ifndef REQUIRE_CUSTOM_LIBRARIES_$(CONFIG)
HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_OPENSSL_ALPN ?= $(shell $(OPENSSL_ALPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true) ifeq ($(HAS_SYSTEM_OPENSSL_ALPN),true)
HAS_SYSTEM_OPENSSL_NPN = true HAS_SYSTEM_OPENSSL_NPN = true
CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true\n CACHE_MK += HAS_SYSTEM_OPENSSL_ALPN = true,
else else
HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_OPENSSL_NPN ?= $(shell $(OPENSSL_NPN_CHECK_CMD) 2> /dev/null && echo true || echo false)
endif endif
ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true) ifeq ($(HAS_SYSTEM_OPENSSL_NPN),true)
CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true\n CACHE_MK += HAS_SYSTEM_OPENSSL_NPN = true,
endif endif
HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_SYSTEM_ZLIB ?= $(shell $(ZLIB_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_SYSTEM_ZLIB),true) ifeq ($(HAS_SYSTEM_ZLIB),true)
CACHE_MK += HAS_SYSTEM_ZLIB = true\n CACHE_MK += HAS_SYSTEM_ZLIB = true,
endif endif
HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY) HAS_SYSTEM_PROTOBUF ?= $(HAS_SYSTEM_PROTOBUF_VERIFY)
ifeq ($(HAS_SYSTEM_PROTOBUF),true) ifeq ($(HAS_SYSTEM_PROTOBUF),true)
CACHE_MK += HAS_SYSTEM_PROTOBUF = true\n CACHE_MK += HAS_SYSTEM_PROTOBUF = true,
endif endif
else else
# override system libraries if the config requires a custom compiled library # override system libraries if the config requires a custom compiled library
@ -476,10 +476,10 @@ endif
HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false) HAS_PROTOC ?= $(shell $(PROTOC_CHECK_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_PROTOC),true) ifeq ($(HAS_PROTOC),true)
CACHE_MK += HAS_PROTOC = true\n CACHE_MK += HAS_PROTOC = true,
HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false) HAS_VALID_PROTOC ?= $(shell $(PROTOC_CHECK_VERSION_CMD) 2> /dev/null && echo true || echo false)
ifeq ($(HAS_VALID_PROTOC),true) ifeq ($(HAS_VALID_PROTOC),true)
CACHE_MK += HAS_VALID_PROTOC = true\n CACHE_MK += HAS_VALID_PROTOC = true,
endif endif
else else
HAS_VALID_PROTOC = false HAS_VALID_PROTOC = false
@ -500,7 +500,7 @@ endif
endif endif
ifeq ($(HAS_SYSTEMTAP),true) ifeq ($(HAS_SYSTEMTAP),true)
CACHE_MK += HAS_SYSTEMTAP = true\n CACHE_MK += HAS_SYSTEMTAP = true,
endif endif
# Note that for testing purposes, one can do: # Note that for testing purposes, one can do:
@ -1108,32 +1108,32 @@ endif
cache.mk:: cache.mk::
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) echo -e "$(CACHE_MK)" >$@ $(Q) echo "$(CACHE_MK)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/gpr.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GPR_PC_FILE)" >$@ $(Q) echo "$(GPR_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPC_PC_FILE)" >$@ $(Q) echo "$(GRPC_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc_unsecure.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPC_UNSECURE_PC_FILE)" >$@ $(Q) echo "$(GRPC_UNSECURE_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPCXX_PC_FILE)" >$@ $(Q) echo "$(GRPCXX_PC_FILE)" | tr , '\n' >$@
$(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc:
$(E) "[MAKE] Generating $@" $(E) "[MAKE] Generating $@"
$(Q) mkdir -p $(@D) $(Q) mkdir -p $(@D)
$(Q) echo -e "$(GRPCXX_UNSECURE_PC_FILE)" >$@ $(Q) echo "$(GRPCXX_UNSECURE_PC_FILE)" | tr , '\n' >$@
% for p in protos: % for p in protos:
ifeq ($(NO_PROTOC),true) ifeq ($(NO_PROTOC),true)

@ -60,6 +60,7 @@ int main(int argc, char **argv) {
test_succeeds("http://www.google.com:90", "http", "www.google.com:90", ""); test_succeeds("http://www.google.com:90", "http", "www.google.com:90", "");
test_succeeds("a192.4-df:foo.coom", "a192.4-df", "", "foo.coom"); test_succeeds("a192.4-df:foo.coom", "a192.4-df", "", "foo.coom");
test_succeeds("a+b:foo.coom", "a+b", "", "foo.coom"); test_succeeds("a+b:foo.coom", "a+b", "", "foo.coom");
test_succeeds("zookeeper://127.0.0.1:2181/foo/bar", "zookeeper", "127.0.0.1:2181", "/foo/bar");
test_fails("xyz"); test_fails("xyz");
test_fails("http://www.google.com?why-are-you-using-queries"); test_fails("http://www.google.com?why-are-you-using-queries");
test_fails("dns:foo.com#fragments-arent-supported-here"); test_fails("dns:foo.com#fragments-arent-supported-here");

@ -31,13 +31,10 @@
* *
*/ */
#include <thread>
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo_duplicate.grpc.pb.h"
#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h"
#include "src/cpp/server/thread_pool.h"
#include <grpc++/channel_arguments.h> #include <grpc++/channel_arguments.h>
#include <grpc++/channel_interface.h> #include <grpc++/channel_interface.h>
#include <grpc++/client_context.h> #include <grpc++/client_context.h>

@ -35,7 +35,6 @@
#include <thread> #include <thread>
#include "src/core/security/credentials.h" #include "src/core/security/credentials.h"
#include "src/cpp/server/thread_pool.h"
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo_duplicate.grpc.pb.h"
@ -46,6 +45,7 @@
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/fixed_size_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
@ -260,7 +260,7 @@ class End2endTest : public ::testing::Test {
TestServiceImpl service_; TestServiceImpl service_;
TestServiceImpl special_service_; TestServiceImpl special_service_;
TestServiceImplDupPkg dup_pkg_service_; TestServiceImplDupPkg dup_pkg_service_;
ThreadPool thread_pool_; FixedSizeThreadPool thread_pool_;
}; };
static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub, static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub,

@ -37,12 +37,12 @@
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo_duplicate.grpc.pb.h"
#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h"
#include "src/cpp/server/thread_pool.h"
#include <grpc++/channel_arguments.h> #include <grpc++/channel_arguments.h>
#include <grpc++/channel_interface.h> #include <grpc++/channel_interface.h>
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/fixed_size_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
@ -260,7 +260,7 @@ class MockTest : public ::testing::Test {
std::unique_ptr<Server> server_; std::unique_ptr<Server> server_;
std::ostringstream server_address_; std::ostringstream server_address_;
TestServiceImpl service_; TestServiceImpl service_;
ThreadPool thread_pool_; FixedSizeThreadPool thread_pool_;
}; };
// Do one real rpc and one mocked one // Do one real rpc and one mocked one

@ -31,13 +31,10 @@
* *
*/ */
#include <thread>
#include "test/core/util/port.h" #include "test/core/util/port.h"
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo_duplicate.grpc.pb.h"
#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h"
#include "src/cpp/server/thread_pool.h"
#include <grpc++/channel_arguments.h> #include <grpc++/channel_arguments.h>
#include <grpc++/channel_interface.h> #include <grpc++/channel_interface.h>
#include <grpc++/client_context.h> #include <grpc++/client_context.h>

@ -38,12 +38,12 @@
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/echo_duplicate.grpc.pb.h" #include "test/cpp/util/echo_duplicate.grpc.pb.h"
#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h"
#include "src/cpp/server/thread_pool.h"
#include <grpc++/channel_arguments.h> #include <grpc++/channel_arguments.h>
#include <grpc++/channel_interface.h> #include <grpc++/channel_interface.h>
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/fixed_size_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
@ -206,7 +206,7 @@ class End2endTest : public ::testing::Test {
const int kMaxMessageSize_; const int kMaxMessageSize_;
TestServiceImpl service_; TestServiceImpl service_;
TestServiceImplDupPkg dup_pkg_service_; TestServiceImplDupPkg dup_pkg_service_;
ThreadPool thread_pool_; FixedSizeThreadPool thread_pool_;
}; };
static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub, static void SendRpc(grpc::cpp::test::util::TestService::Stub* stub,

@ -45,6 +45,7 @@
#include <grpc/support/host_port.h> #include <grpc/support/host_port.h>
#include <grpc++/async_unary_call.h> #include <grpc++/async_unary_call.h>
#include <grpc++/config.h> #include <grpc++/config.h>
#include <grpc++/fixed_size_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
@ -52,7 +53,6 @@
#include <grpc++/status.h> #include <grpc++/status.h>
#include <grpc++/stream.h> #include <grpc++/stream.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "src/cpp/server/thread_pool.h"
#include "test/cpp/qps/qpstest.grpc.pb.h" #include "test/cpp/qps/qpstest.grpc.pb.h"
#include "test/cpp/qps/server.h" #include "test/cpp/qps/server.h"

@ -40,13 +40,13 @@
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/host_port.h> #include <grpc/support/host_port.h>
#include <grpc++/config.h> #include <grpc++/config.h>
#include <grpc++/fixed_size_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
#include <grpc++/server_credentials.h> #include <grpc++/server_credentials.h>
#include <grpc++/status.h> #include <grpc++/status.h>
#include <grpc++/stream.h> #include <grpc++/stream.h>
#include "src/cpp/server/thread_pool.h"
#include "test/cpp/qps/qpstest.grpc.pb.h" #include "test/cpp/qps/qpstest.grpc.pb.h"
#include "test/cpp/qps/server.h" #include "test/cpp/qps/server.h"
#include "test/cpp/qps/timer.h" #include "test/cpp/qps/timer.h"
@ -111,7 +111,7 @@ class SynchronousServer GRPC_FINAL : public grpc::testing::Server {
} }
TestServiceImpl service_; TestServiceImpl service_;
ThreadPool thread_pool_; FixedSizeThreadPool thread_pool_;
std::unique_ptr<grpc::Server> impl_; std::unique_ptr<grpc::Server> impl_;
}; };

@ -35,17 +35,17 @@
#include <functional> #include <functional>
#include <mutex> #include <mutex>
#include "src/cpp/server/thread_pool.h" #include <grpc++/fixed_size_thread_pool.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace grpc { namespace grpc {
class ThreadPoolTest : public ::testing::Test { class FixedSizeThreadPoolTest : public ::testing::Test {
public: public:
ThreadPoolTest() : thread_pool_(4) {} FixedSizeThreadPoolTest() : thread_pool_(4) {}
protected: protected:
ThreadPool thread_pool_; FixedSizeThreadPool thread_pool_;
}; };
void Callback(std::mutex* mu, std::condition_variable* cv, bool* done) { void Callback(std::mutex* mu, std::condition_variable* cv, bool* done) {
@ -54,7 +54,7 @@ void Callback(std::mutex* mu, std::condition_variable* cv, bool* done) {
cv->notify_all(); cv->notify_all();
} }
TEST_F(ThreadPoolTest, ScheduleCallback) { TEST_F(FixedSizeThreadPoolTest, ScheduleCallback) {
std::mutex mu; std::mutex mu;
std::condition_variable cv; std::condition_variable cv;
bool done = false; bool done = false;

@ -34,12 +34,12 @@
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#include "test/cpp/util/cli_call.h" #include "test/cpp/util/cli_call.h"
#include "test/cpp/util/echo.grpc.pb.h" #include "test/cpp/util/echo.grpc.pb.h"
#include "src/cpp/server/thread_pool.h"
#include <grpc++/channel_arguments.h> #include <grpc++/channel_arguments.h>
#include <grpc++/channel_interface.h> #include <grpc++/channel_interface.h>
#include <grpc++/client_context.h> #include <grpc++/client_context.h>
#include <grpc++/create_channel.h> #include <grpc++/create_channel.h>
#include <grpc++/credentials.h> #include <grpc++/credentials.h>
#include <grpc++/fixed_size_thread_pool.h>
#include <grpc++/server.h> #include <grpc++/server.h>
#include <grpc++/server_builder.h> #include <grpc++/server_builder.h>
#include <grpc++/server_context.h> #include <grpc++/server_context.h>
@ -102,7 +102,7 @@ class CliCallTest : public ::testing::Test {
std::unique_ptr<Server> server_; std::unique_ptr<Server> server_;
std::ostringstream server_address_; std::ostringstream server_address_;
TestServiceImpl service_; TestServiceImpl service_;
ThreadPool thread_pool_; FixedSizeThreadPool thread_pool_;
}; };
// Send a rpc with a normal stub and then a CliCall. Verify they match. // Send a rpc with a normal stub and then a CliCall. Verify they match.

@ -772,6 +772,7 @@ include/grpc++/config.h \
include/grpc++/config_protobuf.h \ include/grpc++/config_protobuf.h \
include/grpc++/create_channel.h \ include/grpc++/create_channel.h \
include/grpc++/credentials.h \ include/grpc++/credentials.h \
include/grpc++/fixed_size_thread_pool.h \
include/grpc++/generic_stub.h \ include/grpc++/generic_stub.h \
include/grpc++/impl/call.h \ include/grpc++/impl/call.h \
include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/client_unary_call.h \

@ -772,6 +772,7 @@ include/grpc++/config.h \
include/grpc++/config_protobuf.h \ include/grpc++/config_protobuf.h \
include/grpc++/create_channel.h \ include/grpc++/create_channel.h \
include/grpc++/credentials.h \ include/grpc++/credentials.h \
include/grpc++/fixed_size_thread_pool.h \
include/grpc++/generic_stub.h \ include/grpc++/generic_stub.h \
include/grpc++/impl/call.h \ include/grpc++/impl/call.h \
include/grpc++/impl/client_unary_call.h \ include/grpc++/impl/client_unary_call.h \
@ -803,7 +804,6 @@ src/cpp/common/secure_auth_context.h \
src/cpp/server/secure_server_credentials.h \ src/cpp/server/secure_server_credentials.h \
src/cpp/client/channel.h \ src/cpp/client/channel.h \
src/cpp/common/create_auth_context.h \ src/cpp/common/create_auth_context.h \
src/cpp/server/thread_pool.h \
src/cpp/client/secure_channel_arguments.cc \ src/cpp/client/secure_channel_arguments.cc \
src/cpp/client/secure_credentials.cc \ src/cpp/client/secure_credentials.cc \
src/cpp/common/secure_auth_context.cc \ src/cpp/common/secure_auth_context.cc \
@ -823,12 +823,12 @@ src/cpp/common/rpc_method.cc \
src/cpp/proto/proto_utils.cc \ src/cpp/proto/proto_utils.cc \
src/cpp/server/async_generic_service.cc \ src/cpp/server/async_generic_service.cc \
src/cpp/server/create_default_thread_pool.cc \ src/cpp/server/create_default_thread_pool.cc \
src/cpp/server/fixed_size_thread_pool.cc \
src/cpp/server/insecure_server_credentials.cc \ src/cpp/server/insecure_server_credentials.cc \
src/cpp/server/server.cc \ src/cpp/server/server.cc \
src/cpp/server/server_builder.cc \ src/cpp/server/server_builder.cc \
src/cpp/server/server_context.cc \ src/cpp/server/server_context.cc \
src/cpp/server/server_credentials.cc \ src/cpp/server/server_credentials.cc \
src/cpp/server/thread_pool.cc \
src/cpp/util/byte_buffer.cc \ src/cpp/util/byte_buffer.cc \
src/cpp/util/slice.cc \ src/cpp/util/slice.cc \
src/cpp/util/status.cc \ src/cpp/util/status.cc \

@ -42,4 +42,4 @@ cd /var/local/git/grpc
nvm use 0.12 nvm use 0.12
rvm use ruby-2.1 rvm use ruby-2.1
tools/run_tests/prepare_travis.sh tools/run_tests/prepare_travis.sh
tools/run_tests/run_tests.py -t -c $config -l $language -x report.xml $arch tools/run_tests/run_tests.py -t -c $config -l $language -x report.xml

@ -31,12 +31,24 @@
# This script is invoked by Jenkins and triggers a test run based on # This script is invoked by Jenkins and triggers a test run based on
# env variable settings. # env variable settings.
# #
# Setting up rvm environment BEFORE we set -ex.
[[ -s /etc/profile.d/rvm.sh ]] && . /etc/profile.d/rvm.sh
# To prevent cygwin bash complaining about empty lines ending with \r # To prevent cygwin bash complaining about empty lines ending with \r
# we set the igncr option. The option doesn't exist on Linux, so we fallback # we set the igncr option. The option doesn't exist on Linux, so we fallback
# to just 'set -ex' there. # to just 'set -ex' there.
# NOTE: No empty lines should appear in this file before igncr is set! # NOTE: No empty lines should appear in this file before igncr is set!
set -ex -o igncr || set -ex set -ex -o igncr || set -ex
# Grabbing the machine's architecture
arch=`uname -m`
case $platform in
i386)
arch="i386"
platform="linux"
;;
esac
if [ "$platform" == "linux" ] if [ "$platform" == "linux" ]
then then
echo "building $language on Linux" echo "building $language on Linux"
@ -61,6 +73,7 @@ then
docker run \ docker run \
-e "config=$config" \ -e "config=$config" \
-e "language=$language" \ -e "language=$language" \
-e "arch=$arch" \
-i \ -i \
-v "$git_root:/var/local/jenkins/grpc" \ -v "$git_root:/var/local/jenkins/grpc" \
--cidfile=docker.cid \ --cidfile=docker.cid \

@ -1198,6 +1198,21 @@
"test/cpp/end2end/end2end_test.cc" "test/cpp/end2end/end2end_test.cc"
] ]
}, },
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc++",
"grpc_test_util"
],
"headers": [],
"language": "c++",
"name": "fixed_size_thread_pool_test",
"src": [
"test/cpp/server/fixed_size_thread_pool_test.cc"
]
},
{ {
"deps": [ "deps": [
"gpr", "gpr",
@ -1589,21 +1604,6 @@
"test/cpp/qps/sync_unary_ping_pong_test.cc" "test/cpp/qps/sync_unary_ping_pong_test.cc"
] ]
}, },
{
"deps": [
"gpr",
"gpr_test_util",
"grpc",
"grpc++",
"grpc_test_util"
],
"headers": [],
"language": "c++",
"name": "thread_pool_test",
"src": [
"test/cpp/server/thread_pool_test.cc"
]
},
{ {
"deps": [ "deps": [
"gpr", "gpr",
@ -10375,6 +10375,7 @@
"include/grpc++/config_protobuf.h", "include/grpc++/config_protobuf.h",
"include/grpc++/create_channel.h", "include/grpc++/create_channel.h",
"include/grpc++/credentials.h", "include/grpc++/credentials.h",
"include/grpc++/fixed_size_thread_pool.h",
"include/grpc++/generic_stub.h", "include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h", "include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/client_unary_call.h",
@ -10405,8 +10406,7 @@
"src/cpp/client/secure_credentials.h", "src/cpp/client/secure_credentials.h",
"src/cpp/common/create_auth_context.h", "src/cpp/common/create_auth_context.h",
"src/cpp/common/secure_auth_context.h", "src/cpp/common/secure_auth_context.h",
"src/cpp/server/secure_server_credentials.h", "src/cpp/server/secure_server_credentials.h"
"src/cpp/server/thread_pool.h"
], ],
"language": "c++", "language": "c++",
"name": "grpc++", "name": "grpc++",
@ -10423,6 +10423,7 @@
"include/grpc++/config_protobuf.h", "include/grpc++/config_protobuf.h",
"include/grpc++/create_channel.h", "include/grpc++/create_channel.h",
"include/grpc++/credentials.h", "include/grpc++/credentials.h",
"include/grpc++/fixed_size_thread_pool.h",
"include/grpc++/generic_stub.h", "include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h", "include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/client_unary_call.h",
@ -10471,6 +10472,7 @@
"src/cpp/proto/proto_utils.cc", "src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc", "src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/fixed_size_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc", "src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/secure_server_credentials.cc", "src/cpp/server/secure_server_credentials.cc",
"src/cpp/server/secure_server_credentials.h", "src/cpp/server/secure_server_credentials.h",
@ -10478,8 +10480,6 @@
"src/cpp/server/server_builder.cc", "src/cpp/server/server_builder.cc",
"src/cpp/server/server_context.cc", "src/cpp/server/server_context.cc",
"src/cpp/server/server_credentials.cc", "src/cpp/server/server_credentials.cc",
"src/cpp/server/thread_pool.cc",
"src/cpp/server/thread_pool.h",
"src/cpp/util/byte_buffer.cc", "src/cpp/util/byte_buffer.cc",
"src/cpp/util/slice.cc", "src/cpp/util/slice.cc",
"src/cpp/util/status.cc", "src/cpp/util/status.cc",
@ -10546,6 +10546,7 @@
"include/grpc++/config_protobuf.h", "include/grpc++/config_protobuf.h",
"include/grpc++/create_channel.h", "include/grpc++/create_channel.h",
"include/grpc++/credentials.h", "include/grpc++/credentials.h",
"include/grpc++/fixed_size_thread_pool.h",
"include/grpc++/generic_stub.h", "include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h", "include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/client_unary_call.h",
@ -10573,8 +10574,7 @@
"include/grpc++/thread_pool_interface.h", "include/grpc++/thread_pool_interface.h",
"include/grpc++/time.h", "include/grpc++/time.h",
"src/cpp/client/channel.h", "src/cpp/client/channel.h",
"src/cpp/common/create_auth_context.h", "src/cpp/common/create_auth_context.h"
"src/cpp/server/thread_pool.h"
], ],
"language": "c++", "language": "c++",
"name": "grpc++_unsecure", "name": "grpc++_unsecure",
@ -10591,6 +10591,7 @@
"include/grpc++/config_protobuf.h", "include/grpc++/config_protobuf.h",
"include/grpc++/create_channel.h", "include/grpc++/create_channel.h",
"include/grpc++/credentials.h", "include/grpc++/credentials.h",
"include/grpc++/fixed_size_thread_pool.h",
"include/grpc++/generic_stub.h", "include/grpc++/generic_stub.h",
"include/grpc++/impl/call.h", "include/grpc++/impl/call.h",
"include/grpc++/impl/client_unary_call.h", "include/grpc++/impl/client_unary_call.h",
@ -10634,13 +10635,12 @@
"src/cpp/proto/proto_utils.cc", "src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc", "src/cpp/server/async_generic_service.cc",
"src/cpp/server/create_default_thread_pool.cc", "src/cpp/server/create_default_thread_pool.cc",
"src/cpp/server/fixed_size_thread_pool.cc",
"src/cpp/server/insecure_server_credentials.cc", "src/cpp/server/insecure_server_credentials.cc",
"src/cpp/server/server.cc", "src/cpp/server/server.cc",
"src/cpp/server/server_builder.cc", "src/cpp/server/server_builder.cc",
"src/cpp/server/server_context.cc", "src/cpp/server/server_context.cc",
"src/cpp/server/server_credentials.cc", "src/cpp/server/server_credentials.cc",
"src/cpp/server/thread_pool.cc",
"src/cpp/server/thread_pool.h",
"src/cpp/util/byte_buffer.cc", "src/cpp/util/byte_buffer.cc",
"src/cpp/util/slice.cc", "src/cpp/util/slice.cc",
"src/cpp/util/status.cc", "src/cpp/util/status.cc",

@ -684,6 +684,15 @@
"posix" "posix"
] ]
}, },
{
"flaky": false,
"language": "c++",
"name": "fixed_size_thread_pool_test",
"platforms": [
"windows",
"posix"
]
},
{ {
"flaky": false, "flaky": false,
"language": "c++", "language": "c++",
@ -774,15 +783,6 @@
"posix" "posix"
] ]
}, },
{
"flaky": false,
"language": "c++",
"name": "thread_pool_test",
"platforms": [
"windows",
"posix"
]
},
{ {
"flaky": false, "flaky": false,
"language": "c++", "language": "c++",

@ -158,6 +158,7 @@
<ClInclude Include="..\..\include\grpc++\config_protobuf.h" /> <ClInclude Include="..\..\include\grpc++\config_protobuf.h" />
<ClInclude Include="..\..\include\grpc++\create_channel.h" /> <ClInclude Include="..\..\include\grpc++\create_channel.h" />
<ClInclude Include="..\..\include\grpc++\credentials.h" /> <ClInclude Include="..\..\include\grpc++\credentials.h" />
<ClInclude Include="..\..\include\grpc++\fixed_size_thread_pool.h" />
<ClInclude Include="..\..\include\grpc++\generic_stub.h" /> <ClInclude Include="..\..\include\grpc++\generic_stub.h" />
<ClInclude Include="..\..\include\grpc++\impl\call.h" /> <ClInclude Include="..\..\include\grpc++\impl\call.h" />
<ClInclude Include="..\..\include\grpc++\impl\client_unary_call.h" /> <ClInclude Include="..\..\include\grpc++\impl\client_unary_call.h" />
@ -191,7 +192,6 @@
<ClInclude Include="..\..\src\cpp\server\secure_server_credentials.h" /> <ClInclude Include="..\..\src\cpp\server\secure_server_credentials.h" />
<ClInclude Include="..\..\src\cpp\client\channel.h" /> <ClInclude Include="..\..\src\cpp\client\channel.h" />
<ClInclude Include="..\..\src\cpp\common\create_auth_context.h" /> <ClInclude Include="..\..\src\cpp\common\create_auth_context.h" />
<ClInclude Include="..\..\src\cpp\server\thread_pool.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\cpp\client\secure_channel_arguments.cc"> <ClCompile Include="..\..\src\cpp\client\secure_channel_arguments.cc">
@ -232,6 +232,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\create_default_thread_pool.cc"> <ClCompile Include="..\..\src\cpp\server\create_default_thread_pool.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\fixed_size_thread_pool.cc">
</ClCompile>
<ClCompile Include="..\..\src\cpp\server\insecure_server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\insecure_server_credentials.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\server.cc"> <ClCompile Include="..\..\src\cpp\server\server.cc">
@ -242,8 +244,6 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\server_credentials.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\thread_pool.cc">
</ClCompile>
<ClCompile Include="..\..\src\cpp\util\byte_buffer.cc"> <ClCompile Include="..\..\src\cpp\util\byte_buffer.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\util\slice.cc"> <ClCompile Include="..\..\src\cpp\util\slice.cc">

@ -58,6 +58,9 @@
<ClCompile Include="..\..\src\cpp\server\create_default_thread_pool.cc"> <ClCompile Include="..\..\src\cpp\server\create_default_thread_pool.cc">
<Filter>src\cpp\server</Filter> <Filter>src\cpp\server</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\fixed_size_thread_pool.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cpp\server\insecure_server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\insecure_server_credentials.cc">
<Filter>src\cpp\server</Filter> <Filter>src\cpp\server</Filter>
</ClCompile> </ClCompile>
@ -73,9 +76,6 @@
<ClCompile Include="..\..\src\cpp\server\server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\server_credentials.cc">
<Filter>src\cpp\server</Filter> <Filter>src\cpp\server</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\thread_pool.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cpp\util\byte_buffer.cc"> <ClCompile Include="..\..\src\cpp\util\byte_buffer.cc">
<Filter>src\cpp\util</Filter> <Filter>src\cpp\util</Filter>
</ClCompile> </ClCompile>
@ -126,6 +126,9 @@
<ClInclude Include="..\..\include\grpc++\credentials.h"> <ClInclude Include="..\..\include\grpc++\credentials.h">
<Filter>include\grpc++</Filter> <Filter>include\grpc++</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\include\grpc++\fixed_size_thread_pool.h">
<Filter>include\grpc++</Filter>
</ClInclude>
<ClInclude Include="..\..\include\grpc++\generic_stub.h"> <ClInclude Include="..\..\include\grpc++\generic_stub.h">
<Filter>include\grpc++</Filter> <Filter>include\grpc++</Filter>
</ClInclude> </ClInclude>
@ -221,9 +224,6 @@
<ClInclude Include="..\..\src\cpp\common\create_auth_context.h"> <ClInclude Include="..\..\src\cpp\common\create_auth_context.h">
<Filter>src\cpp\common</Filter> <Filter>src\cpp\common</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\cpp\server\thread_pool.h">
<Filter>src\cpp\server</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

@ -158,6 +158,7 @@
<ClInclude Include="..\..\include\grpc++\config_protobuf.h" /> <ClInclude Include="..\..\include\grpc++\config_protobuf.h" />
<ClInclude Include="..\..\include\grpc++\create_channel.h" /> <ClInclude Include="..\..\include\grpc++\create_channel.h" />
<ClInclude Include="..\..\include\grpc++\credentials.h" /> <ClInclude Include="..\..\include\grpc++\credentials.h" />
<ClInclude Include="..\..\include\grpc++\fixed_size_thread_pool.h" />
<ClInclude Include="..\..\include\grpc++\generic_stub.h" /> <ClInclude Include="..\..\include\grpc++\generic_stub.h" />
<ClInclude Include="..\..\include\grpc++\impl\call.h" /> <ClInclude Include="..\..\include\grpc++\impl\call.h" />
<ClInclude Include="..\..\include\grpc++\impl\client_unary_call.h" /> <ClInclude Include="..\..\include\grpc++\impl\client_unary_call.h" />
@ -188,7 +189,6 @@
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\src\cpp\client\channel.h" /> <ClInclude Include="..\..\src\cpp\client\channel.h" />
<ClInclude Include="..\..\src\cpp\common\create_auth_context.h" /> <ClInclude Include="..\..\src\cpp\common\create_auth_context.h" />
<ClInclude Include="..\..\src\cpp\server\thread_pool.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\src\cpp\common\insecure_create_auth_context.cc"> <ClCompile Include="..\..\src\cpp\common\insecure_create_auth_context.cc">
@ -221,6 +221,8 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\create_default_thread_pool.cc"> <ClCompile Include="..\..\src\cpp\server\create_default_thread_pool.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\fixed_size_thread_pool.cc">
</ClCompile>
<ClCompile Include="..\..\src\cpp\server\insecure_server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\insecure_server_credentials.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\server.cc"> <ClCompile Include="..\..\src\cpp\server\server.cc">
@ -231,8 +233,6 @@
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\server_credentials.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\thread_pool.cc">
</ClCompile>
<ClCompile Include="..\..\src\cpp\util\byte_buffer.cc"> <ClCompile Include="..\..\src\cpp\util\byte_buffer.cc">
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\util\slice.cc"> <ClCompile Include="..\..\src\cpp\util\slice.cc">

@ -46,6 +46,9 @@
<ClCompile Include="..\..\src\cpp\server\create_default_thread_pool.cc"> <ClCompile Include="..\..\src\cpp\server\create_default_thread_pool.cc">
<Filter>src\cpp\server</Filter> <Filter>src\cpp\server</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\fixed_size_thread_pool.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cpp\server\insecure_server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\insecure_server_credentials.cc">
<Filter>src\cpp\server</Filter> <Filter>src\cpp\server</Filter>
</ClCompile> </ClCompile>
@ -61,9 +64,6 @@
<ClCompile Include="..\..\src\cpp\server\server_credentials.cc"> <ClCompile Include="..\..\src\cpp\server\server_credentials.cc">
<Filter>src\cpp\server</Filter> <Filter>src\cpp\server</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\src\cpp\server\thread_pool.cc">
<Filter>src\cpp\server</Filter>
</ClCompile>
<ClCompile Include="..\..\src\cpp\util\byte_buffer.cc"> <ClCompile Include="..\..\src\cpp\util\byte_buffer.cc">
<Filter>src\cpp\util</Filter> <Filter>src\cpp\util</Filter>
</ClCompile> </ClCompile>
@ -114,6 +114,9 @@
<ClInclude Include="..\..\include\grpc++\credentials.h"> <ClInclude Include="..\..\include\grpc++\credentials.h">
<Filter>include\grpc++</Filter> <Filter>include\grpc++</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\include\grpc++\fixed_size_thread_pool.h">
<Filter>include\grpc++</Filter>
</ClInclude>
<ClInclude Include="..\..\include\grpc++\generic_stub.h"> <ClInclude Include="..\..\include\grpc++\generic_stub.h">
<Filter>include\grpc++</Filter> <Filter>include\grpc++</Filter>
</ClInclude> </ClInclude>
@ -200,9 +203,6 @@
<ClInclude Include="..\..\src\cpp\common\create_auth_context.h"> <ClInclude Include="..\..\src\cpp\common\create_auth_context.h">
<Filter>src\cpp\common</Filter> <Filter>src\cpp\common</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\src\cpp\server\thread_pool.h">
<Filter>src\cpp\server</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

Loading…
Cancel
Save