Merge branch 'master' of https://github.com/grpc/grpc into serialization-refactor

pull/10743/head
ncteisen 8 years ago
commit fde16afefa
  1. 3
      .gitmodules
  2. 105
      BUILD
  3. 389
      CMakeLists.txt
  4. 21
      INSTALL.md
  5. 205
      Makefile
  6. 1
      PYTHON-MANIFEST.in
  7. 9
      README.md
  8. 2
      Rakefile
  9. 11
      WORKSPACE
  10. 4
      bazel/BUILD
  11. 6
      bazel/cc_grpc_library.bzl
  12. 31
      bazel/generate_cc.bzl
  13. 19
      bazel/grpc_build_system.bzl
  14. 43
      binding.gyp
  15. 95
      build.yaml
  16. 5
      config.m4
  17. 1
      doc/g_stands_for.md
  18. 6
      doc/interop-test-descriptions.md
  19. 21
      doc/service_config.md
  20. 22
      examples/BUILD
  21. 42
      examples/cpp/helloworld/BUILD
  22. 34
      examples/csharp/helloworld-from-cli/Greeter.sln
  23. 19
      examples/csharp/helloworld-from-cli/Greeter/Greeter.csproj
  24. 37
      examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs
  25. 73
      examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs
  26. 31
      examples/csharp/helloworld-from-cli/Greeter/project.json
  27. 17
      examples/csharp/helloworld-from-cli/GreeterClient/GreeterClient.csproj
  28. 35
      examples/csharp/helloworld-from-cli/GreeterClient/project.json
  29. 17
      examples/csharp/helloworld-from-cli/GreeterServer/GreeterServer.csproj
  30. 35
      examples/csharp/helloworld-from-cli/GreeterServer/project.json
  31. 17
      examples/csharp/helloworld-from-cli/README.md
  32. 42
      examples/csharp/helloworld-from-cli/generate_protos.bat
  33. 5
      examples/csharp/helloworld-from-cli/global.json
  34. 27
      examples/csharp/helloworld/Greeter/Greeter.csproj
  35. 37
      examples/csharp/helloworld/Greeter/Helloworld.cs
  36. 73
      examples/csharp/helloworld/Greeter/HelloworldGrpc.cs
  37. 10
      examples/csharp/helloworld/Greeter/packages.config
  38. 27
      examples/csharp/helloworld/GreeterClient/GreeterClient.csproj
  39. 8
      examples/csharp/helloworld/GreeterClient/packages.config
  40. 27
      examples/csharp/helloworld/GreeterServer/GreeterServer.csproj
  41. 8
      examples/csharp/helloworld/GreeterServer/packages.config
  42. 2
      examples/csharp/helloworld/generate_protos.bat
  43. 46
      examples/csharp/route_guide/RouteGuide/RouteGuide.cs
  44. 29
      examples/csharp/route_guide/RouteGuide/RouteGuide.csproj
  45. 248
      examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs
  46. 8
      examples/csharp/route_guide/RouteGuide/packages.config
  47. 27
      examples/csharp/route_guide/RouteGuideClient/RouteGuideClient.csproj
  48. 8
      examples/csharp/route_guide/RouteGuideClient/packages.config
  49. 29
      examples/csharp/route_guide/RouteGuideServer/RouteGuideServer.csproj
  50. 10
      examples/csharp/route_guide/RouteGuideServer/packages.config
  51. 2
      examples/csharp/route_guide/generate_protos.bat
  52. 19
      gRPC-Core.podspec
  53. 5
      grpc.def
  54. 12
      grpc.gemspec
  55. 37
      include/grpc++/impl/codegen/call.h
  56. 4
      include/grpc++/impl/codegen/client_unary_call.h
  57. 36
      include/grpc++/impl/codegen/completion_queue.h
  58. 9
      include/grpc++/impl/codegen/core_codegen.h
  59. 6
      include/grpc++/impl/codegen/core_codegen_interface.h
  60. 2
      include/grpc++/impl/codegen/proto_utils.h
  61. 12
      include/grpc++/impl/codegen/sync_stream.h
  62. 217
      include/grpc++/impl/codegen/thrift_serializer.h
  63. 163
      include/grpc++/test/mock_stream.h
  64. 58
      include/grpc/grpc.h
  65. 2
      include/grpc/grpc_security.h
  66. 7
      include/grpc/impl/codegen/compression_types.h
  67. 1
      include/grpc/impl/codegen/gpr_types.h
  68. 55
      include/grpc/impl/codegen/grpc_types.h
  69. 8
      include/grpc/impl/codegen/port_platform.h
  70. 3
      include/grpc/impl/codegen/slice.h
  71. 22
      include/grpc/slice.h
  72. 4
      include/grpc/slice_buffer.h
  73. 3
      package.json
  74. 12
      package.xml
  75. 25
      setup.py
  76. 182
      src/compiler/cpp_generator.cc
  77. 34
      src/compiler/cpp_generator.h
  78. 21
      src/compiler/cpp_plugin.cc
  79. 1
      src/compiler/objective_c_plugin.cc
  80. 12
      src/compiler/python_generator.cc
  81. 159
      src/core/ext/filters/client_channel/client_channel.c
  82. 3
      src/core/ext/filters/client_channel/lb_policy.c
  83. 11
      src/core/ext/filters/client_channel/lb_policy.h
  84. 153
      src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
  85. 42
      src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h
  86. 398
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
  87. 133
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c
  88. 65
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
  89. 52
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
  90. 6
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
  91. 3
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c
  92. 3
      src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c
  93. 17
      src/core/ext/filters/client_channel/subchannel.c
  94. 1
      src/core/ext/filters/client_channel/subchannel.h
  95. 2
      src/core/ext/filters/http/client/http_client_filter.c
  96. 24
      src/core/ext/filters/http/message_compress/message_compress_filter.c
  97. 13
      src/core/ext/filters/message_size/message_size_filter.c
  98. 2
      src/core/ext/transport/chttp2/server/chttp2_server.c
  99. 4
      src/core/ext/transport/chttp2/transport/bin_decoder.c
  100. 6
      src/core/ext/transport/chttp2/transport/bin_encoder.c
  101. Some files were not shown because too many files have changed in this diff Show More

3
.gitmodules vendored

@ -14,9 +14,6 @@
[submodule "third_party/boringssl"] [submodule "third_party/boringssl"]
path = third_party/boringssl path = third_party/boringssl
url = https://github.com/google/boringssl.git url = https://github.com/google/boringssl.git
[submodule "third_party/thrift"]
path = third_party/thrift
url = https://github.com/apache/thrift.git
[submodule "third_party/benchmark"] [submodule "third_party/benchmark"]
path = third_party/benchmark path = third_party/benchmark
url = https://github.com/google/benchmark url = https://github.com/google/benchmark

105
BUILD

@ -35,10 +35,11 @@ exports_files(["LICENSE"])
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_proto_plugin") load("//bazel:grpc_build_system.bzl", "grpc_cc_library",
"grpc_proto_plugin", "grpc_cc_libraries")
# This should be updated along with build.yaml # This should be updated along with build.yaml
g_stands_for = "gentle" g_stands_for = "gregarious"
core_version = "3.0.0-dev" core_version = "3.0.0-dev"
@ -53,33 +54,46 @@ grpc_cc_library(
], ],
) )
grpc_cc_library( grpc_cc_libraries(
name = "grpc", name_list = ["grpc", "grpc_unsecure",],
srcs = [ srcs = [
"src/core/lib/surface/init.c", "src/core/lib/surface/init.c",
"src/core/plugin_registry/grpc_plugin_registry.c", ],
additional_src_list = [
[
"src/core/plugin_registry/grpc_plugin_registry.c",
],
[
"src/core/lib/surface/init_unsecure.c",
"src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
],
], ],
language = "c", language = "c",
standalone = True, standalone = True,
deps = [ deps = [
"census", "census",
"grpc_base", "grpc_base",
"grpc_lb_policy_grpclb_secure",
"grpc_lb_policy_pick_first", "grpc_lb_policy_pick_first",
"grpc_lb_policy_round_robin", "grpc_lb_policy_round_robin",
"grpc_load_reporting", "grpc_load_reporting",
"grpc_max_age_filter", "grpc_max_age_filter",
"grpc_resolver_dns_ares",
"grpc_resolver_dns_native", "grpc_resolver_dns_native",
"grpc_resolver_sockaddr", "grpc_resolver_sockaddr",
"grpc_secure",
"grpc_transport_chttp2_client_insecure", "grpc_transport_chttp2_client_insecure",
"grpc_transport_chttp2_client_secure",
"grpc_transport_chttp2_server_insecure", "grpc_transport_chttp2_server_insecure",
"grpc_transport_chttp2_server_secure",
"grpc_message_size_filter", "grpc_message_size_filter",
"grpc_deadline_filter", "grpc_deadline_filter",
], ],
additional_dep_list = [
[
"grpc_secure",
"grpc_resolver_dns_ares",
"grpc_lb_policy_grpclb_secure",
"grpc_transport_chttp2_client_secure",
"grpc_transport_chttp2_server_secure",
],
[],
],
) )
grpc_cc_library( grpc_cc_library(
@ -97,32 +111,6 @@ grpc_cc_library(
], ],
) )
grpc_cc_library(
name = "grpc_unsecure",
srcs = [
"src/core/lib/surface/init.c",
"src/core/lib/surface/init_unsecure.c",
"src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
],
language = "c",
standalone = True,
deps = [
"census",
"grpc_base",
"grpc_lb_policy_grpclb",
"grpc_lb_policy_pick_first",
"grpc_lb_policy_round_robin",
"grpc_load_reporting",
"grpc_max_age_filter",
"grpc_resolver_dns_native",
"grpc_resolver_sockaddr",
"grpc_transport_chttp2_client_insecure",
"grpc_transport_chttp2_server_insecure",
"grpc_message_size_filter",
"grpc_deadline_filter",
],
)
grpc_cc_library( grpc_cc_library(
name = "grpc++", name = "grpc++",
srcs = [ srcs = [
@ -163,7 +151,7 @@ grpc_cc_library(
standalone = True, standalone = True,
deps = [ deps = [
"gpr", "gpr",
"grpc++_base", "grpc++_base_unsecure",
"grpc++_codegen_base", "grpc++_codegen_base",
"grpc++_codegen_base_src", "grpc++_codegen_base_src",
"grpc_unsecure", "grpc_unsecure",
@ -388,6 +376,10 @@ grpc_cc_library(
"src/core/lib/support/backoff.h", "src/core/lib/support/backoff.h",
"src/core/lib/support/block_annotate.h", "src/core/lib/support/block_annotate.h",
"src/core/lib/support/env.h", "src/core/lib/support/env.h",
"src/core/lib/support/memory.h",
"src/core/lib/support/atomic.h",
"src/core/lib/support/atomic_with_atm.h",
"src/core/lib/support/atomic_with_std.h",
"src/core/lib/support/mpscq.h", "src/core/lib/support/mpscq.h",
"src/core/lib/support/murmur_hash.h", "src/core/lib/support/murmur_hash.h",
"src/core/lib/support/spinlock.h", "src/core/lib/support/spinlock.h",
@ -555,7 +547,7 @@ grpc_cc_library(
"src/core/lib/surface/completion_queue.c", "src/core/lib/surface/completion_queue.c",
"src/core/lib/surface/completion_queue_factory.c", "src/core/lib/surface/completion_queue_factory.c",
"src/core/lib/surface/event_string.c", "src/core/lib/surface/event_string.c",
"src/core/lib/surface/lame_client.c", "src/core/lib/surface/lame_client.cc",
"src/core/lib/surface/metadata_array.c", "src/core/lib/surface/metadata_array.c",
"src/core/lib/surface/server.c", "src/core/lib/surface/server.c",
"src/core/lib/surface/validate_metadata.c", "src/core/lib/surface/validate_metadata.c",
@ -837,14 +829,18 @@ grpc_cc_library(
grpc_cc_library( grpc_cc_library(
name = "grpc_lb_policy_grpclb", name = "grpc_lb_policy_grpclb",
srcs = [ srcs = [
"src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c", "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c", "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c", "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
], ],
hdrs = [ hdrs = [
"src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
], ],
@ -861,14 +857,18 @@ grpc_cc_library(
grpc_cc_library( grpc_cc_library(
name = "grpc_lb_policy_grpclb_secure", name = "grpc_lb_policy_grpclb_secure",
srcs = [ srcs = [
"src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c", "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c", "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c", "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c", "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
], ],
hdrs = [ hdrs = [
"src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h",
"src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h", "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
], ],
@ -1214,12 +1214,14 @@ grpc_cc_library(
"src/core/tsi/fake_transport_security.c", "src/core/tsi/fake_transport_security.c",
"src/core/tsi/ssl_transport_security.c", "src/core/tsi/ssl_transport_security.c",
"src/core/tsi/transport_security.c", "src/core/tsi/transport_security.c",
"src/core/tsi/transport_security_adapter.c",
], ],
hdrs = [ hdrs = [
"src/core/tsi/fake_transport_security.h", "src/core/tsi/fake_transport_security.h",
"src/core/tsi/ssl_transport_security.h", "src/core/tsi/ssl_transport_security.h",
"src/core/tsi/ssl_types.h", "src/core/tsi/ssl_types.h",
"src/core/tsi/transport_security.h", "src/core/tsi/transport_security.h",
"src/core/tsi/transport_security_adapter.h",
"src/core/tsi/transport_security_interface.h", "src/core/tsi/transport_security_interface.h",
], ],
external_deps = [ external_deps = [
@ -1231,8 +1233,12 @@ grpc_cc_library(
], ],
) )
grpc_cc_library( grpc_cc_libraries(
name = "grpc++_base", name_list = ["grpc++_base", "grpc++_base_unsecure"],
additional_dep_list = [
["grpc", ],
["grpc_unsecure", ],
],
srcs = [ srcs = [
"src/cpp/client/channel_cc.cc", "src/cpp/client/channel_cc.cc",
"src/cpp/client/client_context.cc", "src/cpp/client/client_context.cc",
@ -1267,7 +1273,7 @@ grpc_cc_library(
"src/cpp/util/status.cc", "src/cpp/util/status.cc",
"src/cpp/util/string_ref.cc", "src/cpp/util/string_ref.cc",
"src/cpp/util/time_cc.cc", "src/cpp/util/time_cc.cc",
], ],
hdrs = [ hdrs = [
"src/cpp/client/create_channel_internal.h", "src/cpp/client/create_channel_internal.h",
"src/cpp/common/channel_filter.h", "src/cpp/common/channel_filter.h",
@ -1276,7 +1282,7 @@ grpc_cc_library(
"src/cpp/server/health/health.pb.h", "src/cpp/server/health/health.pb.h",
"src/cpp/server/thread_pool_interface.h", "src/cpp/server/thread_pool_interface.h",
"src/cpp/thread_manager/thread_manager.h", "src/cpp/thread_manager/thread_manager.h",
], ],
language = "c++", language = "c++",
public_hdrs = [ public_hdrs = [
"include/grpc++/alarm.h", "include/grpc++/alarm.h",
@ -1326,9 +1332,8 @@ grpc_cc_library(
"include/grpc++/support/stub_options.h", "include/grpc++/support/stub_options.h",
"include/grpc++/support/sync_stream.h", "include/grpc++/support/sync_stream.h",
"include/grpc++/support/time.h", "include/grpc++/support/time.h",
], ],
deps = [ deps = [
"grpc",
"grpc++_codegen_base", "grpc++_codegen_base",
], ],
) )
@ -1406,18 +1411,6 @@ grpc_cc_library(
], ],
) )
grpc_cc_library(
name = "thrift_util",
language = "c++",
public_hdrs = [
"include/grpc++/impl/codegen/thrift_serializer.h",
"include/grpc++/impl/codegen/thrift_utils.h",
],
deps = [
"grpc++_codegen_base",
],
)
grpc_cc_library( grpc_cc_library(
name = "grpc++_reflection", name = "grpc++_reflection",
srcs = [ srcs = [

File diff suppressed because it is too large Load Diff

@ -28,16 +28,29 @@ If you plan to build from source and run tests, install the following as well:
$ [sudo] apt-get install clang libc++-dev $ [sudo] apt-get install clang libc++-dev
``` ```
## Mac OSX ## macOS
For a Mac system, git is not available by default. You will first need to On a Mac, you will first need to
install Xcode from the Mac AppStore and then run the following command from a install Xcode or
terminal: [Command Line Tools for Xcode](https://developer.apple.com/download/more/)
and then run the following command from a terminal:
```sh ```sh
$ [sudo] xcode-select --install $ [sudo] xcode-select --install
``` ```
To build gRPC from source, you may also need to install the following
packages, which you can get from [Homebrew](https://brew.sh):
```sh
$ brew install autoconf automake libtool shtool
```
If you plan to build from source and run tests, install the following as well:
```sh
$ brew install gflags
```
## Protoc ## Protoc
By default gRPC uses [protocol buffers](https://github.com/google/protobuf), By default gRPC uses [protocol buffers](https://github.com/google/protobuf),

@ -92,6 +92,7 @@ CC_opt = $(DEFAULT_CC)
CXX_opt = $(DEFAULT_CXX) CXX_opt = $(DEFAULT_CXX)
LD_opt = $(DEFAULT_CC) LD_opt = $(DEFAULT_CC)
LDXX_opt = $(DEFAULT_CXX) LDXX_opt = $(DEFAULT_CXX)
CXXFLAGS_opt = -fno-exceptions
CPPFLAGS_opt = -O2 CPPFLAGS_opt = -O2
DEFINES_opt = NDEBUG DEFINES_opt = NDEBUG
@ -99,7 +100,7 @@ VALID_CONFIG_asan-trace-cmp = 1
REQUIRE_CUSTOM_LIBRARIES_asan-trace-cmp = 1 REQUIRE_CUSTOM_LIBRARIES_asan-trace-cmp = 1
CC_asan-trace-cmp = clang CC_asan-trace-cmp = clang
CXX_asan-trace-cmp = clang++ CXX_asan-trace-cmp = clang++
LD_asan-trace-cmp = clang LD_asan-trace-cmp = clang++
LDXX_asan-trace-cmp = clang++ LDXX_asan-trace-cmp = clang++
CPPFLAGS_asan-trace-cmp = -O0 -fsanitize-coverage=edge -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CPPFLAGS_asan-trace-cmp = -O0 -fsanitize-coverage=edge -fsanitize-coverage=trace-cmp -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_asan-trace-cmp = -fsanitize=address LDFLAGS_asan-trace-cmp = -fsanitize=address
@ -109,6 +110,7 @@ CC_dbg = $(DEFAULT_CC)
CXX_dbg = $(DEFAULT_CXX) CXX_dbg = $(DEFAULT_CXX)
LD_dbg = $(DEFAULT_CC) LD_dbg = $(DEFAULT_CC)
LDXX_dbg = $(DEFAULT_CXX) LDXX_dbg = $(DEFAULT_CXX)
CXXFLAGS_dbg = -fno-exceptions
CPPFLAGS_dbg = -O0 CPPFLAGS_dbg = -O0
DEFINES_dbg = _DEBUG DEBUG DEFINES_dbg = _DEBUG DEBUG
@ -116,7 +118,7 @@ VALID_CONFIG_asan = 1
REQUIRE_CUSTOM_LIBRARIES_asan = 1 REQUIRE_CUSTOM_LIBRARIES_asan = 1
CC_asan = clang CC_asan = clang
CXX_asan = clang++ CXX_asan = clang++
LD_asan = clang LD_asan = clang++
LDXX_asan = clang++ LDXX_asan = clang++
CPPFLAGS_asan = -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CPPFLAGS_asan = -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_asan = -fsanitize=address LDFLAGS_asan = -fsanitize=address
@ -125,7 +127,7 @@ VALID_CONFIG_msan = 1
REQUIRE_CUSTOM_LIBRARIES_msan = 1 REQUIRE_CUSTOM_LIBRARIES_msan = 1
CC_msan = clang CC_msan = clang
CXX_msan = clang++ CXX_msan = clang++
LD_msan = clang LD_msan = clang++
LDXX_msan = clang++ LDXX_msan = clang++
CPPFLAGS_msan = -O0 -fsanitize-coverage=edge -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS CPPFLAGS_msan = -O0 -fsanitize-coverage=edge -fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) LDFLAGS_msan = -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
@ -152,7 +154,7 @@ VALID_CONFIG_asan-noleaks = 1
REQUIRE_CUSTOM_LIBRARIES_asan-noleaks = 1 REQUIRE_CUSTOM_LIBRARIES_asan-noleaks = 1
CC_asan-noleaks = clang CC_asan-noleaks = clang
CXX_asan-noleaks = clang++ CXX_asan-noleaks = clang++
LD_asan-noleaks = clang LD_asan-noleaks = clang++
LDXX_asan-noleaks = clang++ LDXX_asan-noleaks = clang++
CPPFLAGS_asan-noleaks = -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CPPFLAGS_asan-noleaks = -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_asan-noleaks = -fsanitize=address LDFLAGS_asan-noleaks = -fsanitize=address
@ -170,17 +172,17 @@ VALID_CONFIG_ubsan = 1
REQUIRE_CUSTOM_LIBRARIES_ubsan = 1 REQUIRE_CUSTOM_LIBRARIES_ubsan = 1
CC_ubsan = clang CC_ubsan = clang
CXX_ubsan = clang++ CXX_ubsan = clang++
LD_ubsan = clang LD_ubsan = clang++
LDXX_ubsan = clang++ LDXX_ubsan = clang++
CPPFLAGS_ubsan = -O0 -fsanitize-coverage=edge -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs CPPFLAGS_ubsan = -O0 -fsanitize-coverage=edge -fsanitize=undefined -fno-omit-frame-pointer -Wno-unused-command-line-argument -Wvarargs
LDFLAGS_ubsan = -fsanitize=undefined,unsigned-integer-overflow LDFLAGS_ubsan = -fsanitize=undefined,unsigned-integer-overflow
DEFINES_ubsan = NDEBUG DEFINES_ubsan = NDEBUG GRPC_UBSAN
VALID_CONFIG_tsan = 1 VALID_CONFIG_tsan = 1
REQUIRE_CUSTOM_LIBRARIES_tsan = 1 REQUIRE_CUSTOM_LIBRARIES_tsan = 1
CC_tsan = clang CC_tsan = clang
CXX_tsan = clang++ CXX_tsan = clang++
LD_tsan = clang LD_tsan = clang++
LDXX_tsan = clang++ LDXX_tsan = clang++
CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_tsan = -fsanitize=thread LDFLAGS_tsan = -fsanitize=thread
@ -418,7 +420,7 @@ AROPTS = $(GRPC_CROSS_AROPTS) # e.g., rc --target=elf32-little
USE_BUILT_PROTOC = false USE_BUILT_PROTOC = false
endif endif
GTEST_LIB = -Ithird_party/googletest/googletest/include -Ithird_party/googletest/googletest third_party/googletest/googletest/src/gtest-all.cc GTEST_LIB = -Ithird_party/googletest/googletest/include -Ithird_party/googletest/googletest third_party/googletest/googletest/src/gtest-all.cc -Ithird_party/googletest/googlemock/include -Ithird_party/googletest/googlemock third_party/googletest/googlemock/src/gmock-all.cc
GTEST_LIB += -lgflags GTEST_LIB += -lgflags
ifeq ($(V),1) ifeq ($(V),1)
E = @: E = @:
@ -793,7 +795,7 @@ PROTOBUF_PKG_CONFIG = false
PC_REQUIRES_GRPCXX = PC_REQUIRES_GRPCXX =
PC_LIBS_GRPCXX = PC_LIBS_GRPCXX =
CPPFLAGS := -Ithird_party/googletest/googletest/include $(CPPFLAGS) CPPFLAGS := -Ithird_party/googletest/googletest/include -Ithird_party/googletest/googlemock/include $(CPPFLAGS)
PROTOC_PLUGINS_ALL = $(BINDIR)/$(CONFIG)/grpc_cpp_plugin $(BINDIR)/$(CONFIG)/grpc_csharp_plugin $(BINDIR)/$(CONFIG)/grpc_node_plugin $(BINDIR)/$(CONFIG)/grpc_objective_c_plugin $(BINDIR)/$(CONFIG)/grpc_php_plugin $(BINDIR)/$(CONFIG)/grpc_python_plugin $(BINDIR)/$(CONFIG)/grpc_ruby_plugin PROTOC_PLUGINS_ALL = $(BINDIR)/$(CONFIG)/grpc_cpp_plugin $(BINDIR)/$(CONFIG)/grpc_csharp_plugin $(BINDIR)/$(CONFIG)/grpc_node_plugin $(BINDIR)/$(CONFIG)/grpc_objective_c_plugin $(BINDIR)/$(CONFIG)/grpc_php_plugin $(BINDIR)/$(CONFIG)/grpc_python_plugin $(BINDIR)/$(CONFIG)/grpc_ruby_plugin
PROTOC_PLUGINS_DIR = $(BINDIR)/$(CONFIG) PROTOC_PLUGINS_DIR = $(BINDIR)/$(CONFIG)
@ -1082,6 +1084,7 @@ server_chttp2_test: $(BINDIR)/$(CONFIG)/server_chttp2_test
server_fuzzer: $(BINDIR)/$(CONFIG)/server_fuzzer server_fuzzer: $(BINDIR)/$(CONFIG)/server_fuzzer
server_test: $(BINDIR)/$(CONFIG)/server_test server_test: $(BINDIR)/$(CONFIG)/server_test
slice_buffer_test: $(BINDIR)/$(CONFIG)/slice_buffer_test slice_buffer_test: $(BINDIR)/$(CONFIG)/slice_buffer_test
slice_hash_table_test: $(BINDIR)/$(CONFIG)/slice_hash_table_test
slice_string_helpers_test: $(BINDIR)/$(CONFIG)/slice_string_helpers_test slice_string_helpers_test: $(BINDIR)/$(CONFIG)/slice_string_helpers_test
slice_test: $(BINDIR)/$(CONFIG)/slice_test slice_test: $(BINDIR)/$(CONFIG)/slice_test
sockaddr_resolver_test: $(BINDIR)/$(CONFIG)/sockaddr_resolver_test sockaddr_resolver_test: $(BINDIR)/$(CONFIG)/sockaddr_resolver_test
@ -1151,6 +1154,7 @@ grpc_python_plugin: $(BINDIR)/$(CONFIG)/grpc_python_plugin
grpc_ruby_plugin: $(BINDIR)/$(CONFIG)/grpc_ruby_plugin grpc_ruby_plugin: $(BINDIR)/$(CONFIG)/grpc_ruby_plugin
grpc_tool_test: $(BINDIR)/$(CONFIG)/grpc_tool_test grpc_tool_test: $(BINDIR)/$(CONFIG)/grpc_tool_test
grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test
grpclb_end2end_test: $(BINDIR)/$(CONFIG)/grpclb_end2end_test
grpclb_test: $(BINDIR)/$(CONFIG)/grpclb_test grpclb_test: $(BINDIR)/$(CONFIG)/grpclb_test
health_service_end2end_test: $(BINDIR)/$(CONFIG)/health_service_end2end_test health_service_end2end_test: $(BINDIR)/$(CONFIG)/health_service_end2end_test
http2_client: $(BINDIR)/$(CONFIG)/http2_client http2_client: $(BINDIR)/$(CONFIG)/http2_client
@ -1159,6 +1163,7 @@ interop_client: $(BINDIR)/$(CONFIG)/interop_client
interop_server: $(BINDIR)/$(CONFIG)/interop_server interop_server: $(BINDIR)/$(CONFIG)/interop_server
interop_test: $(BINDIR)/$(CONFIG)/interop_test interop_test: $(BINDIR)/$(CONFIG)/interop_test
json_run_localhost: $(BINDIR)/$(CONFIG)/json_run_localhost json_run_localhost: $(BINDIR)/$(CONFIG)/json_run_localhost
memory_test: $(BINDIR)/$(CONFIG)/memory_test
metrics_client: $(BINDIR)/$(CONFIG)/metrics_client metrics_client: $(BINDIR)/$(CONFIG)/metrics_client
mock_test: $(BINDIR)/$(CONFIG)/mock_test mock_test: $(BINDIR)/$(CONFIG)/mock_test
noop-benchmark: $(BINDIR)/$(CONFIG)/noop-benchmark noop-benchmark: $(BINDIR)/$(CONFIG)/noop-benchmark
@ -1452,6 +1457,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/server_chttp2_test \ $(BINDIR)/$(CONFIG)/server_chttp2_test \
$(BINDIR)/$(CONFIG)/server_test \ $(BINDIR)/$(CONFIG)/server_test \
$(BINDIR)/$(CONFIG)/slice_buffer_test \ $(BINDIR)/$(CONFIG)/slice_buffer_test \
$(BINDIR)/$(CONFIG)/slice_hash_table_test \
$(BINDIR)/$(CONFIG)/slice_string_helpers_test \ $(BINDIR)/$(CONFIG)/slice_string_helpers_test \
$(BINDIR)/$(CONFIG)/slice_test \ $(BINDIR)/$(CONFIG)/slice_test \
$(BINDIR)/$(CONFIG)/sockaddr_resolver_test \ $(BINDIR)/$(CONFIG)/sockaddr_resolver_test \
@ -1573,6 +1579,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/grpc_cli \ $(BINDIR)/$(CONFIG)/grpc_cli \
$(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpc_tool_test \
$(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \
$(BINDIR)/$(CONFIG)/grpclb_end2end_test \
$(BINDIR)/$(CONFIG)/grpclb_test \ $(BINDIR)/$(CONFIG)/grpclb_test \
$(BINDIR)/$(CONFIG)/health_service_end2end_test \ $(BINDIR)/$(CONFIG)/health_service_end2end_test \
$(BINDIR)/$(CONFIG)/http2_client \ $(BINDIR)/$(CONFIG)/http2_client \
@ -1581,6 +1588,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/interop_server \ $(BINDIR)/$(CONFIG)/interop_server \
$(BINDIR)/$(CONFIG)/interop_test \ $(BINDIR)/$(CONFIG)/interop_test \
$(BINDIR)/$(CONFIG)/json_run_localhost \ $(BINDIR)/$(CONFIG)/json_run_localhost \
$(BINDIR)/$(CONFIG)/memory_test \
$(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/metrics_client \
$(BINDIR)/$(CONFIG)/mock_test \ $(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/noop-benchmark \ $(BINDIR)/$(CONFIG)/noop-benchmark \
@ -1693,6 +1701,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/grpc_cli \ $(BINDIR)/$(CONFIG)/grpc_cli \
$(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpc_tool_test \
$(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \
$(BINDIR)/$(CONFIG)/grpclb_end2end_test \
$(BINDIR)/$(CONFIG)/grpclb_test \ $(BINDIR)/$(CONFIG)/grpclb_test \
$(BINDIR)/$(CONFIG)/health_service_end2end_test \ $(BINDIR)/$(CONFIG)/health_service_end2end_test \
$(BINDIR)/$(CONFIG)/http2_client \ $(BINDIR)/$(CONFIG)/http2_client \
@ -1701,6 +1710,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/interop_server \ $(BINDIR)/$(CONFIG)/interop_server \
$(BINDIR)/$(CONFIG)/interop_test \ $(BINDIR)/$(CONFIG)/interop_test \
$(BINDIR)/$(CONFIG)/json_run_localhost \ $(BINDIR)/$(CONFIG)/json_run_localhost \
$(BINDIR)/$(CONFIG)/memory_test \
$(BINDIR)/$(CONFIG)/metrics_client \ $(BINDIR)/$(CONFIG)/metrics_client \
$(BINDIR)/$(CONFIG)/mock_test \ $(BINDIR)/$(CONFIG)/mock_test \
$(BINDIR)/$(CONFIG)/noop-benchmark \ $(BINDIR)/$(CONFIG)/noop-benchmark \
@ -1924,6 +1934,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/server_test || ( echo test server_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/server_test || ( echo test server_test failed ; exit 1 )
$(E) "[RUN] Testing slice_buffer_test" $(E) "[RUN] Testing slice_buffer_test"
$(Q) $(BINDIR)/$(CONFIG)/slice_buffer_test || ( echo test slice_buffer_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/slice_buffer_test || ( echo test slice_buffer_test failed ; exit 1 )
$(E) "[RUN] Testing slice_hash_table_test"
$(Q) $(BINDIR)/$(CONFIG)/slice_hash_table_test || ( echo test slice_hash_table_test failed ; exit 1 )
$(E) "[RUN] Testing slice_string_helpers_test" $(E) "[RUN] Testing slice_string_helpers_test"
$(Q) $(BINDIR)/$(CONFIG)/slice_string_helpers_test || ( echo test slice_string_helpers_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/slice_string_helpers_test || ( echo test slice_string_helpers_test failed ; exit 1 )
$(E) "[RUN] Testing slice_test" $(E) "[RUN] Testing slice_test"
@ -2072,12 +2084,16 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/grpc_tool_test || ( echo test grpc_tool_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpc_tool_test || ( echo test grpc_tool_test failed ; exit 1 )
$(E) "[RUN] Testing grpclb_api_test" $(E) "[RUN] Testing grpclb_api_test"
$(Q) $(BINDIR)/$(CONFIG)/grpclb_api_test || ( echo test grpclb_api_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpclb_api_test || ( echo test grpclb_api_test failed ; exit 1 )
$(E) "[RUN] Testing grpclb_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/grpclb_end2end_test || ( echo test grpclb_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing grpclb_test" $(E) "[RUN] Testing grpclb_test"
$(Q) $(BINDIR)/$(CONFIG)/grpclb_test || ( echo test grpclb_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpclb_test || ( echo test grpclb_test failed ; exit 1 )
$(E) "[RUN] Testing health_service_end2end_test" $(E) "[RUN] Testing health_service_end2end_test"
$(Q) $(BINDIR)/$(CONFIG)/health_service_end2end_test || ( echo test health_service_end2end_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/health_service_end2end_test || ( echo test health_service_end2end_test failed ; exit 1 )
$(E) "[RUN] Testing interop_test" $(E) "[RUN] Testing interop_test"
$(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/interop_test || ( echo test interop_test failed ; exit 1 )
$(E) "[RUN] Testing memory_test"
$(Q) $(BINDIR)/$(CONFIG)/memory_test || ( echo test memory_test failed ; exit 1 )
$(E) "[RUN] Testing mock_test" $(E) "[RUN] Testing mock_test"
$(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/mock_test || ( echo test mock_test failed ; exit 1 )
$(E) "[RUN] Testing noop-benchmark" $(E) "[RUN] Testing noop-benchmark"
@ -2234,6 +2250,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/health/v1/health.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/health/v1/health.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/health/v1/health.pb.cc: src/proto/grpc/health/v1/health.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/health/v1/health.pb.cc: src/proto/grpc/health/v1/health.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2249,6 +2266,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc: src/proto/grpc/lb/v1/load_balancer.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc: src/proto/grpc/lb/v1/load_balancer.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2264,6 +2282,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc: src/proto/grpc/reflection/v1alpha/reflection.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc: src/proto/grpc/reflection/v1alpha/reflection.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2279,6 +2298,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/status/status.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/status/status.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/status/status.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/status/status.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/status/status.pb.cc: src/proto/grpc/status/status.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/status/status.pb.cc: src/proto/grpc/status/status.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2294,6 +2314,8 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/compiler_test.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/compiler_test.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/compiler_test.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/compiler_test.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/compiler_test.pb.cc: src/proto/grpc/testing/compiler_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/compiler_test.pb.cc: src/proto/grpc/testing/compiler_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2302,13 +2324,14 @@ $(GENDIR)/src/proto/grpc/testing/compiler_test.pb.cc: src/proto/grpc/testing/com
$(GENDIR)/src/proto/grpc/testing/compiler_test.grpc.pb.cc: src/proto/grpc/testing/compiler_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/compiler_test.grpc.pb.cc: src/proto/grpc/testing/compiler_test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=generate_mock_code=true:$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $<
endif endif
ifeq ($(NO_PROTOC),true) ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/control.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/control.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/control.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/control.pb.cc: src/proto/grpc/testing/control.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc: src/proto/grpc/testing/control.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2324,6 +2347,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc: src/proto/grpc/testing/duplicate/echo_duplicate.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/duplicate/echo_duplicate.pb.cc: src/proto/grpc/testing/duplicate/echo_duplicate.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2339,6 +2363,8 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/echo.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/echo.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/echo.pb.cc: src/proto/grpc/testing/echo.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.pb.cc: src/proto/grpc/testing/echo.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2347,13 +2373,14 @@ $(GENDIR)/src/proto/grpc/testing/echo.pb.cc: src/proto/grpc/testing/echo.proto $
$(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc: src/proto/grpc/testing/echo.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc $(GENDIR)/src/proto/grpc/testing/echo.grpc.pb.cc: src/proto/grpc/testing/echo.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc
$(E) "[GRPC] Generating gRPC's protobuf service CC file from $<" $(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $< $(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=generate_mock_code=true:$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin$(EXECUTABLE_SUFFIX) $<
endif endif
ifeq ($(NO_PROTOC),true) ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/echo_messages.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc: src/proto/grpc/testing/echo_messages.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/echo_messages.pb.cc: src/proto/grpc/testing/echo_messages.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2369,6 +2396,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/empty.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/empty.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/empty.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/empty.pb.cc: src/proto/grpc/testing/empty.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/empty.pb.cc: src/proto/grpc/testing/empty.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2384,6 +2412,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/messages.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/messages.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/messages.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/messages.pb.cc: src/proto/grpc/testing/messages.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/messages.pb.cc: src/proto/grpc/testing/messages.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2399,6 +2428,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/metrics.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/metrics.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/metrics.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/metrics.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/metrics.pb.cc: src/proto/grpc/testing/metrics.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/metrics.pb.cc: src/proto/grpc/testing/metrics.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2414,6 +2444,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/payloads.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/payloads.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/payloads.pb.cc: src/proto/grpc/testing/payloads.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/payloads.pb.cc: src/proto/grpc/testing/payloads.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2429,6 +2460,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/services.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/services.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/services.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/services.pb.cc: src/proto/grpc/testing/services.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc $(GENDIR)/src/proto/grpc/testing/services.pb.cc: src/proto/grpc/testing/services.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/control.pb.cc $(GENDIR)/src/proto/grpc/testing/stats.pb.cc
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2444,6 +2476,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/stats.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/stats.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/stats.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/stats.pb.cc: src/proto/grpc/testing/stats.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/stats.pb.cc: src/proto/grpc/testing/stats.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2459,6 +2492,7 @@ ifeq ($(NO_PROTOC),true)
$(GENDIR)/src/proto/grpc/testing/test.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/test.pb.cc: protoc_dep_error
$(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc: protoc_dep_error $(GENDIR)/src/proto/grpc/testing/test.grpc.pb.cc: protoc_dep_error
else else
$(GENDIR)/src/proto/grpc/testing/test.pb.cc: src/proto/grpc/testing/test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc $(GENDIR)/src/proto/grpc/testing/test.pb.cc: src/proto/grpc/testing/test.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS) $(GENDIR)/src/proto/grpc/testing/empty.pb.cc $(GENDIR)/src/proto/grpc/testing/messages.pb.cc
$(E) "[PROTOC] Generating protobuf CC file from $<" $(E) "[PROTOC] Generating protobuf CC file from $<"
$(Q) mkdir -p `dirname $@` $(Q) mkdir -p `dirname $@`
@ -2969,7 +3003,7 @@ LIBGRPC_SRC = \
src/core/lib/surface/completion_queue.c \ src/core/lib/surface/completion_queue.c \
src/core/lib/surface/completion_queue_factory.c \ src/core/lib/surface/completion_queue_factory.c \
src/core/lib/surface/event_string.c \ src/core/lib/surface/event_string.c \
src/core/lib/surface/lame_client.c \ src/core/lib/surface/lame_client.cc \
src/core/lib/surface/metadata_array.c \ src/core/lib/surface/metadata_array.c \
src/core/lib/surface/server.c \ src/core/lib/surface/server.c \
src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/validate_metadata.c \
@ -3041,6 +3075,7 @@ LIBGRPC_SRC = \
src/core/tsi/fake_transport_security.c \ src/core/tsi/fake_transport_security.c \
src/core/tsi/ssl_transport_security.c \ src/core/tsi/ssl_transport_security.c \
src/core/tsi/transport_security.c \ src/core/tsi/transport_security.c \
src/core/tsi/transport_security_adapter.c \
src/core/ext/transport/chttp2/server/chttp2_server.c \ src/core/ext/transport/chttp2/server/chttp2_server.c \
src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \ src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \
src/core/ext/filters/client_channel/channel_connectivity.c \ src/core/ext/filters/client_channel/channel_connectivity.c \
@ -3069,8 +3104,10 @@ LIBGRPC_SRC = \
src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
src/core/ext/transport/chttp2/client/insecure/channel_create.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \ third_party/nanopb/pb_common.c \
@ -3292,7 +3329,7 @@ LIBGRPC_CRONET_SRC = \
src/core/lib/surface/completion_queue.c \ src/core/lib/surface/completion_queue.c \
src/core/lib/surface/completion_queue_factory.c \ src/core/lib/surface/completion_queue_factory.c \
src/core/lib/surface/event_string.c \ src/core/lib/surface/event_string.c \
src/core/lib/surface/lame_client.c \ src/core/lib/surface/lame_client.cc \
src/core/lib/surface/metadata_array.c \ src/core/lib/surface/metadata_array.c \
src/core/lib/surface/server.c \ src/core/lib/surface/server.c \
src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/validate_metadata.c \
@ -3388,6 +3425,7 @@ LIBGRPC_CRONET_SRC = \
src/core/tsi/fake_transport_security.c \ src/core/tsi/fake_transport_security.c \
src/core/tsi/ssl_transport_security.c \ src/core/tsi/ssl_transport_security.c \
src/core/tsi/transport_security.c \ src/core/tsi/transport_security.c \
src/core/tsi/transport_security_adapter.c \
src/core/ext/transport/chttp2/client/chttp2_connector.c \ src/core/ext/transport/chttp2/client/chttp2_connector.c \
src/core/ext/filters/load_reporting/load_reporting.c \ src/core/ext/filters/load_reporting/load_reporting.c \
src/core/ext/filters/load_reporting/load_reporting_filter.c \ src/core/ext/filters/load_reporting/load_reporting_filter.c \
@ -3601,7 +3639,7 @@ LIBGRPC_TEST_UTIL_SRC = \
src/core/lib/surface/completion_queue.c \ src/core/lib/surface/completion_queue.c \
src/core/lib/surface/completion_queue_factory.c \ src/core/lib/surface/completion_queue_factory.c \
src/core/lib/surface/event_string.c \ src/core/lib/surface/event_string.c \
src/core/lib/surface/lame_client.c \ src/core/lib/surface/lame_client.cc \
src/core/lib/surface/metadata_array.c \ src/core/lib/surface/metadata_array.c \
src/core/lib/surface/server.c \ src/core/lib/surface/server.c \
src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/validate_metadata.c \
@ -3829,7 +3867,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/surface/completion_queue.c \ src/core/lib/surface/completion_queue.c \
src/core/lib/surface/completion_queue_factory.c \ src/core/lib/surface/completion_queue_factory.c \
src/core/lib/surface/event_string.c \ src/core/lib/surface/event_string.c \
src/core/lib/surface/lame_client.c \ src/core/lib/surface/lame_client.cc \
src/core/lib/surface/metadata_array.c \ src/core/lib/surface/metadata_array.c \
src/core/lib/surface/server.c \ src/core/lib/surface/server.c \
src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/validate_metadata.c \
@ -3907,8 +3945,10 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c \
src/core/ext/filters/load_reporting/load_reporting.c \ src/core/ext/filters/load_reporting/load_reporting.c \
src/core/ext/filters/load_reporting/load_reporting_filter.c \ src/core/ext/filters/load_reporting/load_reporting_filter.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \ third_party/nanopb/pb_common.c \
@ -4225,7 +4265,7 @@ LIBGRPC++_SRC = \
src/core/lib/surface/completion_queue.c \ src/core/lib/surface/completion_queue.c \
src/core/lib/surface/completion_queue_factory.c \ src/core/lib/surface/completion_queue_factory.c \
src/core/lib/surface/event_string.c \ src/core/lib/surface/event_string.c \
src/core/lib/surface/lame_client.c \ src/core/lib/surface/lame_client.cc \
src/core/lib/surface/metadata_array.c \ src/core/lib/surface/metadata_array.c \
src/core/lib/surface/server.c \ src/core/lib/surface/server.c \
src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/validate_metadata.c \
@ -4558,7 +4598,7 @@ LIBGRPC++_CRONET_SRC = \
src/core/lib/surface/completion_queue.c \ src/core/lib/surface/completion_queue.c \
src/core/lib/surface/completion_queue_factory.c \ src/core/lib/surface/completion_queue_factory.c \
src/core/lib/surface/event_string.c \ src/core/lib/surface/event_string.c \
src/core/lib/surface/lame_client.c \ src/core/lib/surface/lame_client.cc \
src/core/lib/surface/metadata_array.c \ src/core/lib/surface/metadata_array.c \
src/core/lib/surface/server.c \ src/core/lib/surface/server.c \
src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/validate_metadata.c \
@ -5126,8 +5166,6 @@ PUBLIC_HEADERS_CXX += \
include/grpc/impl/codegen/sync_windows.h \ include/grpc/impl/codegen/sync_windows.h \
include/grpc++/impl/codegen/proto_utils.h \ include/grpc++/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/config_protobuf.h \ include/grpc++/impl/codegen/config_protobuf.h \
include/grpc++/impl/codegen/thrift_serializer.h \
include/grpc++/impl/codegen/thrift_utils.h \
LIBGRPC++_TEST_UTIL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_TEST_UTIL_SRC)))) LIBGRPC++_TEST_UTIL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_TEST_UTIL_SRC))))
@ -5319,7 +5357,7 @@ LIBGRPC++_UNSECURE_SRC = \
src/core/lib/surface/completion_queue.c \ src/core/lib/surface/completion_queue.c \
src/core/lib/surface/completion_queue_factory.c \ src/core/lib/surface/completion_queue_factory.c \
src/core/lib/surface/event_string.c \ src/core/lib/surface/event_string.c \
src/core/lib/surface/lame_client.c \ src/core/lib/surface/lame_client.cc \
src/core/lib/surface/metadata_array.c \ src/core/lib/surface/metadata_array.c \
src/core/lib/surface/server.c \ src/core/lib/surface/server.c \
src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/validate_metadata.c \
@ -8241,8 +8279,8 @@ PUBLIC_HEADERS_C += \
LIBARES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBARES_SRC)))) LIBARES_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBARES_SRC))))
$(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DHAVE_CONFIG_H $(LIBARES_OBJS): CPPFLAGS += -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
$(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion -Wno-invalid-source-encoding $(LIBARES_OBJS): CFLAGS += -Wno-sign-conversion $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
$(LIBDIR)/$(CONFIG)/libares.a: $(ZLIB_DEP) $(LIBARES_OBJS) $(LIBDIR)/$(CONFIG)/libares.a: $(ZLIB_DEP) $(LIBARES_OBJS)
$(E) "[AR] Creating $@" $(E) "[AR] Creating $@"
@ -12354,6 +12392,38 @@ endif
endif endif
SLICE_HASH_TABLE_TEST_SRC = \
test/core/slice/slice_hash_table_test.c \
SLICE_HASH_TABLE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(SLICE_HASH_TABLE_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/slice_hash_table_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/slice_hash_table_test: $(SLICE_HASH_TABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(SLICE_HASH_TABLE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/slice_hash_table_test
endif
$(OBJDIR)/$(CONFIG)/test/core/slice/slice_hash_table_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_slice_hash_table_test: $(SLICE_HASH_TABLE_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(SLICE_HASH_TABLE_TEST_OBJS:.o=.dep)
endif
endif
SLICE_STRING_HELPERS_TEST_SRC = \ SLICE_STRING_HELPERS_TEST_SRC = \
test/core/slice/slice_string_helpers_test.c \ test/core/slice/slice_string_helpers_test.c \
@ -15031,6 +15101,53 @@ endif
$(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_api_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_api_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
GRPCLB_END2END_TEST_SRC = \
$(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc \
test/cpp/end2end/grpclb_end2end_test.cc \
GRPCLB_END2END_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPCLB_END2END_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/grpclb_end2end_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
$(BINDIR)/$(CONFIG)/grpclb_end2end_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/grpclb_end2end_test: $(PROTOBUF_DEP) $(GRPCLB_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(GRPCLB_END2END_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpclb_end2end_test
endif
endif
$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v1/load_balancer.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/grpclb_end2end_test.o: $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_grpclb_end2end_test: $(GRPCLB_END2END_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(GRPCLB_END2END_TEST_OBJS:.o=.dep)
endif
endif
$(OBJDIR)/$(CONFIG)/test/cpp/end2end/grpclb_end2end_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
GRPCLB_TEST_SRC = \ GRPCLB_TEST_SRC = \
$(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc \
test/cpp/grpclb/grpclb_test.cc \ test/cpp/grpclb/grpclb_test.cc \
@ -15343,6 +15460,49 @@ endif
endif endif
MEMORY_TEST_SRC = \
test/core/support/memory_test.cc \
MEMORY_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MEMORY_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/memory_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
$(BINDIR)/$(CONFIG)/memory_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/memory_test: $(PROTOBUF_DEP) $(MEMORY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(MEMORY_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/memory_test
endif
endif
$(OBJDIR)/$(CONFIG)/test/core/support/memory_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_memory_test: $(MEMORY_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(MEMORY_TEST_OBJS:.o=.dep)
endif
endif
METRICS_CLIENT_SRC = \ METRICS_CLIENT_SRC = \
$(GENDIR)/src/proto/grpc/testing/metrics.pb.cc $(GENDIR)/src/proto/grpc/testing/metrics.grpc.pb.cc \ $(GENDIR)/src/proto/grpc/testing/metrics.pb.cc $(GENDIR)/src/proto/grpc/testing/metrics.grpc.pb.cc \
test/cpp/interop/metrics_client.cc \ test/cpp/interop/metrics_client.cc \
@ -19486,6 +19646,7 @@ src/core/plugin_registry/grpc_plugin_registry.c: $(OPENSSL_DEP)
src/core/tsi/fake_transport_security.c: $(OPENSSL_DEP) src/core/tsi/fake_transport_security.c: $(OPENSSL_DEP)
src/core/tsi/ssl_transport_security.c: $(OPENSSL_DEP) src/core/tsi/ssl_transport_security.c: $(OPENSSL_DEP)
src/core/tsi/transport_security.c: $(OPENSSL_DEP) src/core/tsi/transport_security.c: $(OPENSSL_DEP)
src/core/tsi/transport_security_adapter.c: $(OPENSSL_DEP)
src/cpp/client/cronet_credentials.cc: $(OPENSSL_DEP) src/cpp/client/cronet_credentials.cc: $(OPENSSL_DEP)
src/cpp/client/secure_credentials.cc: $(OPENSSL_DEP) src/cpp/client/secure_credentials.cc: $(OPENSSL_DEP)
src/cpp/common/auth_property_iterator.cc: $(OPENSSL_DEP) src/cpp/common/auth_property_iterator.cc: $(OPENSSL_DEP)

@ -17,3 +17,4 @@ include src/python/grpcio/support.py
include src/python/grpcio/README.rst include src/python/grpcio/README.rst
include requirements.txt include requirements.txt
include etc/roots.pem include etc/roots.pem
include Makefile

@ -21,7 +21,7 @@ See [Performance dashboard](http://performance-dot-grpc-testing.appspot.com/expl
# Repository Structure & Status # Repository Structure & Status
This repository contains source code for gRPC libraries for multiple languages written on top of shared C core library [src/core] (src/core). This repository contains source code for gRPC libraries for multiple languages written on top of shared C core library [src/core](src/core).
Libraries in different languages may be in different states of development. We are seeking contributions for all of these libraries. Libraries in different languages may be in different states of development. We are seeking contributions for all of these libraries.
@ -36,10 +36,9 @@ Libraries in different languages may be in different states of development. We a
| C# | [src/csharp](src/csharp) | 1.0 | | C# | [src/csharp](src/csharp) | 1.0 |
| Objective-C | [src/objective-c](src/objective-c) | 1.0 | | Objective-C | [src/objective-c](src/objective-c) | 1.0 |
<small> Java source code is in the [grpc-java](http://github.com/grpc/grpc-java)
Java source code is in the [grpc-java](http://github.com/grpc/grpc-java) repository. repository. Go source code is in the
Go source code is in the [grpc-go](http://github.com/grpc/grpc-go) repository. [grpc-go](http://github.com/grpc/grpc-go) repository.
</small>
See [MANIFEST.md](MANIFEST.md) for a listing of top-level items in the See [MANIFEST.md](MANIFEST.md) for a listing of top-level items in the
repository. repository.

@ -80,7 +80,7 @@ task 'dlls' do
grpc_config = ENV['GRPC_CONFIG'] || 'opt' grpc_config = ENV['GRPC_CONFIG'] || 'opt'
verbose = ENV['V'] || '0' verbose = ENV['V'] || '0'
env = 'CPPFLAGS="-D_WIN32_WINNT=0x600 -DUNICODE -D_UNICODE -Wno-unused-variable -Wno-unused-result" ' env = 'CPPFLAGS="-D_WIN32_WINNT=0x600 -DUNICODE -D_UNICODE -Wno-unused-variable -Wno-unused-result -DCARES_STATICLIB" '
env += 'LDFLAGS=-static ' env += 'LDFLAGS=-static '
env += 'SYSTEM=MINGW32 ' env += 'SYSTEM=MINGW32 '
env += 'EMBED_ZLIB=true ' env += 'EMBED_ZLIB=true '

@ -15,17 +15,17 @@ bind(
bind( bind(
name = "protobuf", name = "protobuf",
actual = "@submodule_protobuf//:protobuf", actual = "@com_google_protobuf//:protobuf",
) )
bind( bind(
name = "protobuf_clib", name = "protobuf_clib",
actual = "@submodule_protobuf//:protoc_lib", actual = "@com_google_protobuf//:protoc_lib",
) )
bind( bind(
name = "protocol_compiler", name = "protocol_compiler",
actual = "@submodule_protobuf//:protoc", actual = "@com_google_protobuf//:protoc",
) )
bind( bind(
@ -48,9 +48,8 @@ bind(
actual = "@com_github_gflags_gflags//:gflags", actual = "@com_github_gflags_gflags//:gflags",
) )
new_local_repository( local_repository(
name = "submodule_boringssl", name = "submodule_boringssl",
build_file = "third_party/boringssl-with-bazel/BUILD",
path = "third_party/boringssl-with-bazel", path = "third_party/boringssl-with-bazel",
) )
@ -61,7 +60,7 @@ new_local_repository(
) )
new_local_repository( new_local_repository(
name = "submodule_protobuf", name = "com_google_protobuf",
build_file = "third_party/protobuf/BUILD", build_file = "third_party/protobuf/BUILD",
path = "third_party/protobuf", path = "third_party/protobuf",
) )

@ -35,12 +35,12 @@ load(":cc_grpc_library.bzl", "cc_grpc_library")
proto_library( proto_library(
name = "well_known_protos_list", name = "well_known_protos_list",
srcs = ["@submodule_protobuf//:well_known_protos"], srcs = ["@com_google_protobuf//:well_known_protos"],
) )
cc_grpc_library( cc_grpc_library(
name = "well_known_protos", name = "well_known_protos",
srcs = "well_known_protos_list", srcs = "well_known_protos_list",
deps = [],
proto_only = True, proto_only = True,
deps = [],
) )

@ -2,7 +2,7 @@
load("//:bazel/generate_cc.bzl", "generate_cc") load("//:bazel/generate_cc.bzl", "generate_cc")
def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, use_external = False, **kwargs): def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, generate_mock, use_external = False, **kwargs):
"""Generates C++ grpc classes from a .proto file. """Generates C++ grpc classes from a .proto file.
Assumes the generated classes will be used in cc_api_version = 2. Assumes the generated classes will be used in cc_api_version = 2.
@ -14,9 +14,10 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, use_externa
the compiled code of any message that the services depend on. the compiled code of any message that the services depend on.
well_known_protos: The target from protobuf library that exports well well_known_protos: The target from protobuf library that exports well
known protos. Currently it will only work if the value is known protos. Currently it will only work if the value is
"@submodule_protobuf//:well_known_protos" "@com_google_protobuf//:well_known_protos"
use_external: When True the grpc deps are prefixed with //external. This use_external: When True the grpc deps are prefixed with //external. This
allows grpc to be used as a dependency in other bazel projects. allows grpc to be used as a dependency in other bazel projects.
generate_mock: When true GMOCk code for client stub is generated.
**kwargs: rest of arguments, e.g., compatible_with and visibility. **kwargs: rest of arguments, e.g., compatible_with and visibility.
""" """
if len(srcs) > 1: if len(srcs) > 1:
@ -54,6 +55,7 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, use_externa
srcs = [proto_target], srcs = [proto_target],
plugin = plugin, plugin = plugin,
well_known_protos = well_known_protos, well_known_protos = well_known_protos,
generate_mock = generate_mock,
**kwargs **kwargs
) )

@ -9,21 +9,26 @@ def generate_cc_impl(ctx):
protos = [f for src in ctx.attr.srcs for f in src.proto.direct_sources] protos = [f for src in ctx.attr.srcs for f in src.proto.direct_sources]
includes = [f for src in ctx.attr.srcs for f in src.proto.transitive_imports] includes = [f for src in ctx.attr.srcs for f in src.proto.transitive_imports]
outs = [] outs = []
# label_len is length of the path from WORKSPACE root to the location of this build file
label_len = len(ctx.label.package) + 1
if ctx.executable.plugin: if ctx.executable.plugin:
outs += [proto.basename[:-len(".proto")] + ".grpc.pb.h" for proto in protos] outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.h" for proto in protos]
outs += [proto.basename[:-len(".proto")] + ".grpc.pb.cc" for proto in protos] outs += [proto.path[label_len:-len(".proto")] + ".grpc.pb.cc" for proto in protos]
if ctx.attr.generate_mock:
outs += [proto.path[label_len:-len(".proto")] + "_mock.grpc.pb.h" for proto in protos]
else: else:
outs += [proto.basename[:-len(".proto")] + ".pb.h" for proto in protos] outs += [proto.path[label_len:-len(".proto")] + ".pb.h" for proto in protos]
outs += [proto.basename[:-len(".proto")] + ".pb.cc" for proto in protos] outs += [proto.path[label_len:-len(".proto")] + ".pb.cc" for proto in protos]
out_files = [ctx.new_file(out) for out in outs] out_files = [ctx.new_file(out) for out in outs]
# The following should be replaced with ctx.configuration.buildout dir_out = str(ctx.genfiles_dir.path)
# whenever this is added to Skylark.
dir_out = out_files[0].dirname[:-len(protos[0].dirname)]
arguments = [] arguments = []
if ctx.executable.plugin: if ctx.executable.plugin:
arguments += ["--plugin=protoc-gen-PLUGIN=" + ctx.executable.plugin.path] arguments += ["--plugin=protoc-gen-PLUGIN=" + ctx.executable.plugin.path]
arguments += ["--PLUGIN_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] flags = list(ctx.attr.flags)
if ctx.attr.generate_mock:
flags.append("generate_mock_code=true")
arguments += ["--PLUGIN_out=" + ",".join(flags) + ":" + dir_out]
additional_input = [ctx.executable.plugin] additional_input = [ctx.executable.plugin]
else: else:
arguments += ["--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out] arguments += ["--cpp_out=" + ",".join(ctx.attr.flags) + ":" + dir_out]
@ -35,10 +40,10 @@ def generate_cc_impl(ctx):
well_known_proto_files = [] well_known_proto_files = []
if ctx.attr.well_known_protos: if ctx.attr.well_known_protos:
f = ctx.attr.well_known_protos.files.to_list()[0].dirname f = ctx.attr.well_known_protos.files.to_list()[0].dirname
if f != "external/submodule_protobuf/src/google/protobuf": if f != "external/com_google_protobuf/src/google/protobuf":
print("Error: Only @submodule_protobuf//:well_known_protos is supported") print("Error: Only @com_google_protobuf//:well_known_protos is supported")
else: else:
# f points to "external/submodule_protobuf/src/google/protobuf" # f points to "external/com_google_protobuf/src/google/protobuf"
# add -I argument to protoc so it knows where to look for the proto files. # add -I argument to protoc so it knows where to look for the proto files.
arguments += ["-I{0}".format(f + "/../..")] arguments += ["-I{0}".format(f + "/../..")]
well_known_proto_files = [f for f in ctx.attr.well_known_protos.files] well_known_proto_files = [f for f in ctx.attr.well_known_protos.files]
@ -71,6 +76,10 @@ generate_cc = rule(
"well_known_protos" : attr.label( "well_known_protos" : attr.label(
mandatory = False, mandatory = False,
), ),
"generate_mock" : attr.bool(
default = False,
mandatory = False,
),
"_protoc": attr.label( "_protoc": attr.label(
default = Label("//external:protocol_compiler"), default = Label("//external:protocol_compiler"),
executable = True, executable = True,

@ -49,6 +49,22 @@ def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps
] ]
) )
def grpc_cc_libraries(name_list, additional_src_list = [], additional_dep_list = [], srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language="C++"):
names = len(name_list)
asl = additional_src_list + [[]]*(names - len(additional_src_list))
adl = additional_dep_list + [[]]*(names - len(additional_dep_list))
for i in range(names):
grpc_cc_library(
name = name_list[i],
srcs = srcs + asl[i],
hdrs = hdrs,
public_hdrs = public_hdrs,
deps = deps + adl[i],
external_deps = external_deps,
standalone = standalone,
language = language
)
def grpc_proto_plugin(name, srcs = [], deps = []): def grpc_proto_plugin(name, srcs = [], deps = []):
native.cc_binary( native.cc_binary(
name = name, name = name,
@ -59,7 +75,7 @@ def grpc_proto_plugin(name, srcs = [], deps = []):
load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library") load("//:bazel/cc_grpc_library.bzl", "cc_grpc_library")
def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = None, def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = None,
has_services = True, use_external = False): has_services = True, use_external = False, generate_mock = False):
cc_grpc_library( cc_grpc_library(
name = name, name = name,
srcs = srcs, srcs = srcs,
@ -67,5 +83,6 @@ def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = None,
well_known_protos = well_known_protos, well_known_protos = well_known_protos,
proto_only = not has_services, proto_only = not has_services,
use_external = use_external, use_external = use_external,
generate_mock = generate_mock,
) )

@ -39,15 +39,16 @@
{ {
'variables': { 'variables': {
'runtime%': 'node', 'runtime%': 'node',
# UV integration in C core is enabled by default. It can be disabled
# by setting this argument to anything else.
'grpc_uv%': 'true',
# Some Node installations use the system installation of OpenSSL, and on # Some Node installations use the system installation of OpenSSL, and on
# some systems, the system OpenSSL still does not have ALPN support. This # some systems, the system OpenSSL still does not have ALPN support. This
# will let users recompile gRPC to work without ALPN. # will let users recompile gRPC to work without ALPN.
'grpc_alpn%': 'true', 'grpc_alpn%': 'true',
# Indicates that the library should be built with gcov. # Indicates that the library should be built with gcov.
'grpc_gcov%': 'false' 'grpc_gcov%': 'false',
# Indicates that the library should be built with compatibility for musl
# libc, so that it can run on Alpine Linux. This is only necessary if not
# building on Alpine Linux
'grpc_alpine%': 'false'
}, },
'target_defaults': { 'target_defaults': {
'configurations': { 'configurations': {
@ -86,17 +87,11 @@
'include' 'include'
], ],
'defines': [ 'defines': [
'GPR_BACKWARDS_COMPATIBILITY_MODE' 'GPR_BACKWARDS_COMPATIBILITY_MODE',
'GRPC_ARES=0',
'GRPC_UV'
], ],
'conditions': [ 'conditions': [
['grpc_uv=="true"', {
'defines': [
'GRPC_ARES=0',
# Disabling this while bugs are ironed out. Uncomment this to
# re-enable libuv integration in C core.
'GRPC_UV'
]
}],
['grpc_gcov=="true"', { ['grpc_gcov=="true"', {
'cflags': [ 'cflags': [
'-O0', '-O0',
@ -115,6 +110,11 @@
'-rdynamic', '-rdynamic',
], ],
}], }],
['grpc_alpine=="true"', {
'defines': [
'GPR_MUSL_LIBC_COMPAT'
]
}],
['OS!="win" and runtime=="electron"', { ['OS!="win" and runtime=="electron"', {
"defines": [ "defines": [
'OPENSSL_NO_THREADS' 'OPENSSL_NO_THREADS'
@ -535,6 +535,10 @@
} }
] ]
}, },
]
}],
['OS == "win"', {
'targets': [
# Only want to compile zlib under Windows # Only want to compile zlib under Windows
{ {
'cflags': [ 'cflags': [
@ -569,7 +573,6 @@
}] }]
], ],
'targets': [ 'targets': [
{ {
'cflags': [ 'cflags': [
'-std=c99', '-std=c99',
@ -648,7 +651,6 @@
'type': 'static_library', 'type': 'static_library',
'dependencies': [ 'dependencies': [
'gpr', 'gpr',
'node_modules/cares/deps/cares/cares.gyp:cares',
], ],
'sources': [ 'sources': [
'src/core/lib/surface/init.c', 'src/core/lib/surface/init.c',
@ -754,7 +756,7 @@
'src/core/lib/surface/completion_queue.c', 'src/core/lib/surface/completion_queue.c',
'src/core/lib/surface/completion_queue_factory.c', 'src/core/lib/surface/completion_queue_factory.c',
'src/core/lib/surface/event_string.c', 'src/core/lib/surface/event_string.c',
'src/core/lib/surface/lame_client.c', 'src/core/lib/surface/lame_client.cc',
'src/core/lib/surface/metadata_array.c', 'src/core/lib/surface/metadata_array.c',
'src/core/lib/surface/server.c', 'src/core/lib/surface/server.c',
'src/core/lib/surface/validate_metadata.c', 'src/core/lib/surface/validate_metadata.c',
@ -826,6 +828,7 @@
'src/core/tsi/fake_transport_security.c', 'src/core/tsi/fake_transport_security.c',
'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/ssl_transport_security.c',
'src/core/tsi/transport_security.c', 'src/core/tsi/transport_security.c',
'src/core/tsi/transport_security_adapter.c',
'src/core/ext/transport/chttp2/server/chttp2_server.c', 'src/core/ext/transport/chttp2/server/chttp2_server.c',
'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c', 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
'src/core/ext/filters/client_channel/channel_connectivity.c', 'src/core/ext/filters/client_channel/channel_connectivity.c',
@ -854,8 +857,10 @@
'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_common.c',
@ -939,20 +944,16 @@
"src/node/ext/call_credentials.cc", "src/node/ext/call_credentials.cc",
"src/node/ext/channel.cc", "src/node/ext/channel.cc",
"src/node/ext/channel_credentials.cc", "src/node/ext/channel_credentials.cc",
"src/node/ext/completion_queue_threadpool.cc", "src/node/ext/completion_queue.cc",
"src/node/ext/completion_queue_uv.cc",
"src/node/ext/node_grpc.cc", "src/node/ext/node_grpc.cc",
"src/node/ext/server.cc", "src/node/ext/server.cc",
"src/node/ext/server_credentials.cc", "src/node/ext/server_credentials.cc",
"src/node/ext/server_generic.cc",
"src/node/ext/server_uv.cc",
"src/node/ext/slice.cc", "src/node/ext/slice.cc",
"src/node/ext/timeval.cc", "src/node/ext/timeval.cc",
], ],
"dependencies": [ "dependencies": [
"grpc", "grpc",
"gpr", "gpr",
"node_modules/cares/deps/cares/cares.gyp:cares",
] ]
}, },
{ {

@ -13,7 +13,7 @@ settings:
'#09': Per-language overrides are possible with (eg) ruby_version tag here '#09': Per-language overrides are possible with (eg) ruby_version tag here
'#10': See the expand_version.py for all the quirks here '#10': See the expand_version.py for all the quirks here
core_version: 4.0.0-dev core_version: 4.0.0-dev
g_stands_for: gentle g_stands_for: gregarious
version: 1.4.0-dev version: 1.4.0-dev
filegroups: filegroups:
- name: census - name: census
@ -86,9 +86,13 @@ filegroups:
headers: headers:
- src/core/lib/profiling/timers.h - src/core/lib/profiling/timers.h
- src/core/lib/support/arena.h - src/core/lib/support/arena.h
- src/core/lib/support/atomic.h
- src/core/lib/support/atomic_with_atm.h
- src/core/lib/support/atomic_with_std.h
- src/core/lib/support/backoff.h - src/core/lib/support/backoff.h
- src/core/lib/support/block_annotate.h - src/core/lib/support/block_annotate.h
- src/core/lib/support/env.h - src/core/lib/support/env.h
- src/core/lib/support/memory.h
- src/core/lib/support/mpscq.h - src/core/lib/support/mpscq.h
- src/core/lib/support/murmur_hash.h - src/core/lib/support/murmur_hash.h
- src/core/lib/support/spinlock.h - src/core/lib/support/spinlock.h
@ -382,7 +386,7 @@ filegroups:
- src/core/lib/surface/completion_queue.c - src/core/lib/surface/completion_queue.c
- src/core/lib/surface/completion_queue_factory.c - src/core/lib/surface/completion_queue_factory.c
- src/core/lib/surface/event_string.c - src/core/lib/surface/event_string.c
- src/core/lib/surface/lame_client.c - src/core/lib/surface/lame_client.cc
- src/core/lib/surface/metadata_array.c - src/core/lib/surface/metadata_array.c
- src/core/lib/surface/server.c - src/core/lib/surface/server.c
- src/core/lib/surface/validate_metadata.c - src/core/lib/surface/validate_metadata.c
@ -484,13 +488,17 @@ filegroups:
- grpc_base - grpc_base
- name: grpc_lb_policy_grpclb - name: grpc_lb_policy_grpclb
headers: headers:
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
src: src:
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
plugin: grpc_lb_policy_grpclb plugin: grpc_lb_policy_grpclb
@ -500,13 +508,17 @@ filegroups:
- nanopb - nanopb
- name: grpc_lb_policy_grpclb_secure - name: grpc_lb_policy_grpclb_secure
headers: headers:
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
- src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
src: src:
- src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c - src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c
- src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c - src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
plugin: grpc_lb_policy_grpclb plugin: grpc_lb_policy_grpclb
@ -809,11 +821,13 @@ filegroups:
- src/core/tsi/ssl_transport_security.h - src/core/tsi/ssl_transport_security.h
- src/core/tsi/ssl_types.h - src/core/tsi/ssl_types.h
- src/core/tsi/transport_security.h - src/core/tsi/transport_security.h
- src/core/tsi/transport_security_adapter.h
- src/core/tsi/transport_security_interface.h - src/core/tsi/transport_security_interface.h
src: src:
- src/core/tsi/fake_transport_security.c - src/core/tsi/fake_transport_security.c
- src/core/tsi/ssl_transport_security.c - src/core/tsi/ssl_transport_security.c
- src/core/tsi/transport_security.c - src/core/tsi/transport_security.c
- src/core/tsi/transport_security_adapter.c
deps: deps:
- gpr - gpr
secure: true secure: true
@ -969,16 +983,10 @@ filegroups:
- name: grpc++_test - name: grpc++_test
language: c++ language: c++
public_headers: public_headers:
- include/grpc++/test/mock_stream.h
- include/grpc++/test/server_context_test_spouse.h - include/grpc++/test/server_context_test_spouse.h
deps: deps:
- grpc++ - grpc++
- name: thrift_util
language: c++
public_headers:
- include/grpc++/impl/codegen/thrift_serializer.h
- include/grpc++/impl/codegen/thrift_utils.h
uses:
- grpc++_codegen_base
libs: libs:
- name: gpr - name: gpr
build: all build: all
@ -1276,7 +1284,6 @@ libs:
- grpc++_codegen_base_src - grpc++_codegen_base_src
- grpc++_codegen_proto - grpc++_codegen_proto
- grpc++_config_proto - grpc++_config_proto
- thrift_util
- name: grpc++_unsecure - name: grpc++_unsecure
build: all build: all
language: c++ language: c++
@ -2810,6 +2817,16 @@ targets:
- grpc - grpc
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: slice_hash_table_test
build: test
language: c
src:
- test/core/slice/slice_hash_table_test.c
deps:
- grpc_test_util
- grpc
- gpr_test_util
- gpr
- name: slice_string_helpers_test - name: slice_string_helpers_test
build: test build: test
language: c language: c
@ -3681,7 +3698,7 @@ targets:
- grpc - grpc
- gpr - gpr
args: args:
- --generated_file_path=gens/src/proto/grpc/testing/compiler_test.grpc.pb.h - --generated_file_path=gens/src/proto/grpc/testing/
- name: grpc_cli - name: grpc_cli
build: test build: test
run: false run: false
@ -3795,6 +3812,20 @@ targets:
- grpc_test_util - grpc_test_util
- grpc++ - grpc++
- grpc - grpc
- name: grpclb_end2end_test
gtest: true
build: test
language: c++
src:
- src/proto/grpc/lb/v1/load_balancer.proto
- test/cpp/end2end/grpclb_end2end_test.cc
deps:
- grpc++_test_util
- grpc_test_util
- grpc++
- grpc
- gpr_test_util
- gpr
- name: grpclb_test - name: grpclb_test
gtest: false gtest: false
build: test build: test
@ -3924,6 +3955,20 @@ targets:
- mac - mac
- linux - linux
- posix - posix
- name: memory_test
gtest: true
build: test
language: c++
src:
- test/core/support/memory_test.cc
deps:
- grpc_test_util
- grpc++
- grpc
- gpr_test_util
- gpr
uses:
- grpc++_test
- name: metrics_client - name: metrics_client
build: test build: test
run: false run: false
@ -3942,6 +3987,8 @@ targets:
gtest: true gtest: true
build: test build: test
language: c++ language: c++
headers:
- include/grpc++/test/mock_stream.h
src: src:
- test/cpp/end2end/mock_test.cc - test/cpp/end2end/mock_test.cc
deps: deps:
@ -4351,7 +4398,7 @@ configs:
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer
-Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++ CXX: clang++
LD: clang LD: clang++
LDFLAGS: -fsanitize=address LDFLAGS: -fsanitize=address
LDXX: clang++ LDXX: clang++
compile_the_world: true compile_the_world: true
@ -4363,7 +4410,7 @@ configs:
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=address -fno-omit-frame-pointer
-Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++ CXX: clang++
LD: clang LD: clang++
LDFLAGS: -fsanitize=address LDFLAGS: -fsanitize=address
LDXX: clang++ LDXX: clang++
compile_the_world: true compile_the_world: true
@ -4374,7 +4421,7 @@ configs:
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize-coverage=trace-cmp -fsanitize=address CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize-coverage=trace-cmp -fsanitize=address
-fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++ CXX: clang++
LD: clang LD: clang++
LDFLAGS: -fsanitize=address LDFLAGS: -fsanitize=address
LDXX: clang++ LDXX: clang++
compile_the_world: true compile_the_world: true
@ -4393,6 +4440,7 @@ configs:
DEFINES: NDEBUG DEFINES: NDEBUG
dbg: dbg:
CPPFLAGS: -O0 CPPFLAGS: -O0
CXXFLAGS: -fno-exceptions
DEFINES: _DEBUG DEBUG DEFINES: _DEBUG DEBUG
gcov: gcov:
CC: gcc CC: gcc
@ -4422,7 +4470,7 @@ configs:
-Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++ CXX: clang++
DEFINES: NDEBUG DEFINES: NDEBUG
LD: clang LD: clang++
LDFLAGS: -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1 LDFLAGS: -fsanitize=memory -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_USE_OWN_TR1_TUPLE=1
-fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
LDXX: clang++ LDXX: clang++
@ -4433,6 +4481,7 @@ configs:
LDFLAGS: -rdynamic LDFLAGS: -rdynamic
opt: opt:
CPPFLAGS: -O2 CPPFLAGS: -O2
CXXFLAGS: -fno-exceptions
DEFINES: NDEBUG DEFINES: NDEBUG
stapprof: stapprof:
CPPFLAGS: -O2 -DGRPC_STAP_PROFILER CPPFLAGS: -O2 -DGRPC_STAP_PROFILER
@ -4443,7 +4492,7 @@ configs:
-DGPR_NO_DIRECT_SYSCALLS -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++ CXX: clang++
DEFINES: GRPC_TSAN DEFINES: GRPC_TSAN
LD: clang LD: clang++
LDFLAGS: -fsanitize=thread LDFLAGS: -fsanitize=thread
LDXX: clang++ LDXX: clang++
compile_the_world: true compile_the_world: true
@ -4454,8 +4503,8 @@ configs:
CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=undefined -fno-omit-frame-pointer CPPFLAGS: -O0 -fsanitize-coverage=edge -fsanitize=undefined -fno-omit-frame-pointer
-Wno-unused-command-line-argument -Wvarargs -Wno-unused-command-line-argument -Wvarargs
CXX: clang++ CXX: clang++
DEFINES: NDEBUG DEFINES: NDEBUG GRPC_UBSAN
LD: clang LD: clang++
LDFLAGS: -fsanitize=undefined,unsigned-integer-overflow LDFLAGS: -fsanitize=undefined,unsigned-integer-overflow
LDXX: clang++ LDXX: clang++
compile_the_world: true compile_the_world: true
@ -4463,10 +4512,11 @@ configs:
UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1:suppressions=tools/ubsan_suppressions.txt UBSAN_OPTIONS: halt_on_error=1:print_stacktrace=1:suppressions=tools/ubsan_suppressions.txt
defaults: defaults:
ares: ares:
CFLAGS: -Wno-sign-conversion -Wno-invalid-source-encoding CFLAGS: -Wno-sign-conversion $(if $(subst MINGW32,,$(SYSTEM)),-Wno-invalid-source-encoding,)
CPPFLAGS: -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux) CPPFLAGS: -Ithird_party/cares -Ithird_party/cares/cares $(if $(subst Linux,,$(SYSTEM)),,-Ithird_party/cares/config_linux)
$(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden $(if $(subst Darwin,,$(SYSTEM)),,-Ithird_party/cares/config_darwin) -fvisibility=hidden
-D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DHAVE_CONFIG_H -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX $(if $(subst
MINGW32,,$(SYSTEM)),-DHAVE_CONFIG_H,)
benchmark: benchmark:
CPPFLAGS: -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX CPPFLAGS: -Ithird_party/benchmark/include -DHAVE_POSIX_REGEX
boringssl: boringssl:
@ -4512,13 +4562,10 @@ node_modules:
- src/node/ext/call_credentials.cc - src/node/ext/call_credentials.cc
- src/node/ext/channel.cc - src/node/ext/channel.cc
- src/node/ext/channel_credentials.cc - src/node/ext/channel_credentials.cc
- src/node/ext/completion_queue_threadpool.cc - src/node/ext/completion_queue.cc
- src/node/ext/completion_queue_uv.cc
- src/node/ext/node_grpc.cc - src/node/ext/node_grpc.cc
- src/node/ext/server.cc - src/node/ext/server.cc
- src/node/ext/server_credentials.cc - src/node/ext/server_credentials.cc
- src/node/ext/server_generic.cc
- src/node/ext/server_uv.cc
- src/node/ext/slice.cc - src/node/ext/slice.cc
- src/node/ext/timeval.cc - src/node/ext/timeval.cc
openssl_fallback: openssl_fallback:

@ -190,7 +190,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/surface/completion_queue.c \ src/core/lib/surface/completion_queue.c \
src/core/lib/surface/completion_queue_factory.c \ src/core/lib/surface/completion_queue_factory.c \
src/core/lib/surface/event_string.c \ src/core/lib/surface/event_string.c \
src/core/lib/surface/lame_client.c \ src/core/lib/surface/lame_client.cc \
src/core/lib/surface/metadata_array.c \ src/core/lib/surface/metadata_array.c \
src/core/lib/surface/server.c \ src/core/lib/surface/server.c \
src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/validate_metadata.c \
@ -262,6 +262,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/tsi/fake_transport_security.c \ src/core/tsi/fake_transport_security.c \
src/core/tsi/ssl_transport_security.c \ src/core/tsi/ssl_transport_security.c \
src/core/tsi/transport_security.c \ src/core/tsi/transport_security.c \
src/core/tsi/transport_security_adapter.c \
src/core/ext/transport/chttp2/server/chttp2_server.c \ src/core/ext/transport/chttp2/server/chttp2_server.c \
src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \ src/core/ext/transport/chttp2/client/secure/secure_channel_create.c \
src/core/ext/filters/client_channel/channel_connectivity.c \ src/core/ext/filters/client_channel/channel_connectivity.c \
@ -290,8 +291,10 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
src/core/ext/transport/chttp2/client/insecure/channel_create.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c \
src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
third_party/nanopb/pb_common.c \ third_party/nanopb/pb_common.c \

@ -8,3 +8,4 @@ future), and the corresponding version numbers that used them:
- 1.1 'g' stands for 'good' - 1.1 'g' stands for 'good'
- 1.2 'g' stands for 'green' - 1.2 'g' stands for 'green'
- 1.3 'g' stands for 'gentle' - 1.3 'g' stands for 'gentle'
- 1.4 'g' stands for 'gregarious'

@ -81,9 +81,8 @@ Procedure:
Client marks the request as cacheable by setting the cacheable flag in the Client marks the request as cacheable by setting the cacheable flag in the
request context. Longer term this should be driven by the method option request context. Longer term this should be driven by the method option
specified in the proto file itself. specified in the proto file itself.
2. Client calls CacheableUnaryCall with `SimpleRequest` request again 2. Client calls CacheableUnaryCall again immediately with the same request and
immediately with the same payload as the previous request. Cacheable flag is configuration as the previous call.
also set for this request's context.
Client asserts: Client asserts:
* Both calls were successful * Both calls were successful
@ -986,6 +985,7 @@ for the `SimpleRequest.response_type`. If the server does not support the
`response_type`, then it should fail the RPC with `INVALID_ARGUMENT`. `response_type`, then it should fail the RPC with `INVALID_ARGUMENT`.
### CacheableUnaryCall ### CacheableUnaryCall
[CacheableUnaryCall]: #cacheableunarycall
Server gets the default SimpleRequest proto as the request. The content of the Server gets the default SimpleRequest proto as the request. The content of the
request is ignored. It returns the SimpleResponse proto with the payload set request is ignored. It returns the SimpleResponse proto with the payload set

@ -13,12 +13,21 @@ The service config is a JSON string of the following form:
``` ```
{ {
// Load balancing policy name. // Load balancing policy name.
// Supported values are 'round_robin' and 'grpclb'. // Currently, the only selectable client-side policy provided with gRPC
// Optional; if unset, the default behavior is pick the first available // is 'round_robin', but third parties may add their own policies.
// backend. // This field is optional; if unset, the default behavior is to pick
// Note that if the resolver returns only balancer addresses and no // the first available backend.
// backend addresses, gRPC will always use the 'grpclb' policy, // If the policy name is set via the client API, that value overrides
// regardless of what this field is set to. // the value specified here.
//
// Note that if the resolver returns at least one balancer address (as
// opposed to backend addresses), gRPC will use grpclb (see
// https://github.com/grpc/grpc/blob/master/doc/load-balancing.md),
// regardless of what LB policy is requested either here or via the
// client API. However, if the resolver returns at least one backend
// address in addition to the balancer address(es), the client may fall
// back to the requested policy if it is unable to reach any of the
// grpclb load balancers.
'loadBalancingPolicy': string, 'loadBalancingPolicy': string,
// Per-method configuration. Optional. // Per-method configuration. Optional.

@ -33,20 +33,34 @@ load("//bazel:grpc_build_system.bzl", "grpc_proto_library")
grpc_proto_library( grpc_proto_library(
name = "auth_sample", name = "auth_sample",
srcs = ["auth_sample.proto"], srcs = ["protos/auth_sample.proto"],
) )
grpc_proto_library( grpc_proto_library(
name = "hellostreamingworld", name = "hellostreamingworld",
srcs = ["hellostreamingworld.proto"], srcs = ["protos/hellostreamingworld.proto"],
) )
grpc_proto_library( grpc_proto_library(
name = "helloworld", name = "helloworld",
srcs = ["helloworld.proto"], srcs = ["protos/helloworld.proto"],
) )
grpc_proto_library( grpc_proto_library(
name = "route_guide", name = "route_guide",
srcs = ["route_guide.proto"], srcs = ["protos/route_guide.proto"],
)
cc_binary(
name = "greeter_client",
srcs = ["cpp/helloworld/greeter_client.cc"],
deps = ["helloworld"],
defines = ["BAZEL_BUILD"],
)
cc_binary(
name = "greeter_server",
srcs = ["cpp/helloworld/greeter_server.cc"],
deps = ["helloworld"],
defines = ["BAZEL_BUILD"],
) )

@ -1,42 +0,0 @@
# Copyright 2017, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cc_binary(
name = "greeter_client",
srcs = ["greeter_client.cc"],
deps = ["//examples/protos:helloworld"],
defines = ["BAZEL_BUILD"],
)
cc_binary(
name = "greeter_server",
srcs = ["greeter_server.cc"],
deps = ["//examples/protos:helloworld"],
defines = ["BAZEL_BUILD"],
)

@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greeter", "Greeter\Greeter.csproj", "{13B6DFC8-F5F6-4CC2-99DF-57A7CF042033}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreeterClient", "GreeterClient\GreeterClient.csproj", "{B754FB02-D501-4308-8B89-33AB7119C80D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreeterServer", "GreeterServer\GreeterServer.csproj", "{DDBFF994-E076-43AD-B18D-049DFC1B670C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{13B6DFC8-F5F6-4CC2-99DF-57A7CF042033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13B6DFC8-F5F6-4CC2-99DF-57A7CF042033}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13B6DFC8-F5F6-4CC2-99DF-57A7CF042033}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13B6DFC8-F5F6-4CC2-99DF-57A7CF042033}.Release|Any CPU.Build.0 = Release|Any CPU
{B754FB02-D501-4308-8B89-33AB7119C80D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B754FB02-D501-4308-8B89-33AB7119C80D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B754FB02-D501-4308-8B89-33AB7119C80D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B754FB02-D501-4308-8B89-33AB7119C80D}.Release|Any CPU.Build.0 = Release|Any CPU
{DDBFF994-E076-43AD-B18D-049DFC1B670C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DDBFF994-E076-43AD-B18D-049DFC1B670C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DDBFF994-E076-43AD-B18D-049DFC1B670C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DDBFF994-E076-43AD-B18D-049DFC1B670C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>Greeter</AssemblyTitle>
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>Greeter</AssemblyName>
<PackageId>Greeter</PackageId>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.2.0" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.2.0" />
<PackageReference Include="Grpc" Version="1.2.2" />
<PackageReference Include="Grpc.Tools" Version="1.2.2" />
</ItemGroup>
</Project>

@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic;
namespace Helloworld { namespace Helloworld {
/// <summary>Holder for reflection information generated from helloworld.proto</summary> /// <summary>Holder for reflection information generated from helloworld.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class HelloworldReflection { public static partial class HelloworldReflection {
#region Descriptor #region Descriptor
@ -41,31 +40,36 @@ namespace Helloworld {
} }
#region Messages #region Messages
/// <summary> /// <summary>
/// The request message containing the user's name. /// The request message containing the user's name.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class HelloRequest : pb::IMessage<HelloRequest> { public sealed partial class HelloRequest : pb::IMessage<HelloRequest> {
private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest()); private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest());
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } } public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; } get { return Descriptor; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloRequest() { public HelloRequest() {
OnConstruction(); OnConstruction();
} }
partial void OnConstruction(); partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloRequest(HelloRequest other) : this() { public HelloRequest(HelloRequest other) : this() {
name_ = other.name_; name_ = other.name_;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloRequest Clone() { public HelloRequest Clone() {
return new HelloRequest(this); return new HelloRequest(this);
} }
@ -73,6 +77,7 @@ namespace Helloworld {
/// <summary>Field number for the "name" field.</summary> /// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name { public string Name {
get { return name_; } get { return name_; }
set { set {
@ -80,10 +85,12 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as HelloRequest); return Equals(other as HelloRequest);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(HelloRequest other) { public bool Equals(HelloRequest other) {
if (ReferenceEquals(other, null)) { if (ReferenceEquals(other, null)) {
return false; return false;
@ -95,16 +102,19 @@ namespace Helloworld {
return true; return true;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Name.Length != 0) hash ^= Name.GetHashCode();
return hash; return hash;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) { if (Name.Length != 0) {
output.WriteRawTag(10); output.WriteRawTag(10);
@ -112,6 +122,7 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
if (Name.Length != 0) { if (Name.Length != 0) {
@ -120,6 +131,7 @@ namespace Helloworld {
return size; return size;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(HelloRequest other) { public void MergeFrom(HelloRequest other) {
if (other == null) { if (other == null) {
return; return;
@ -129,6 +141,7 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) { public void MergeFrom(pb::CodedInputStream input) {
uint tag; uint tag;
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
@ -147,31 +160,36 @@ namespace Helloworld {
} }
/// <summary> /// <summary>
/// The response message containing the greetings /// The response message containing the greetings
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class HelloReply : pb::IMessage<HelloReply> { public sealed partial class HelloReply : pb::IMessage<HelloReply> {
private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply()); private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply());
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<HelloReply> Parser { get { return _parser; } } public static pb::MessageParser<HelloReply> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; } get { return Descriptor; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloReply() { public HelloReply() {
OnConstruction(); OnConstruction();
} }
partial void OnConstruction(); partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloReply(HelloReply other) : this() { public HelloReply(HelloReply other) : this() {
message_ = other.message_; message_ = other.message_;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloReply Clone() { public HelloReply Clone() {
return new HelloReply(this); return new HelloReply(this);
} }
@ -179,6 +197,7 @@ namespace Helloworld {
/// <summary>Field number for the "message" field.</summary> /// <summary>Field number for the "message" field.</summary>
public const int MessageFieldNumber = 1; public const int MessageFieldNumber = 1;
private string message_ = ""; private string message_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Message { public string Message {
get { return message_; } get { return message_; }
set { set {
@ -186,10 +205,12 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as HelloReply); return Equals(other as HelloReply);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(HelloReply other) { public bool Equals(HelloReply other) {
if (ReferenceEquals(other, null)) { if (ReferenceEquals(other, null)) {
return false; return false;
@ -201,16 +222,19 @@ namespace Helloworld {
return true; return true;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (Message.Length != 0) hash ^= Message.GetHashCode(); if (Message.Length != 0) hash ^= Message.GetHashCode();
return hash; return hash;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
if (Message.Length != 0) { if (Message.Length != 0) {
output.WriteRawTag(10); output.WriteRawTag(10);
@ -218,6 +242,7 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
if (Message.Length != 0) { if (Message.Length != 0) {
@ -226,6 +251,7 @@ namespace Helloworld {
return size; return size;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(HelloReply other) { public void MergeFrom(HelloReply other) {
if (other == null) { if (other == null) {
return; return;
@ -235,6 +261,7 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) { public void MergeFrom(pb::CodedInputStream input) {
uint tag; uint tag;
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {

@ -35,21 +35,21 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Grpc.Core; using grpc = global::Grpc.Core;
namespace Helloworld { namespace Helloworld {
/// <summary> /// <summary>
/// The greeting service definition. /// The greeting service definition.
/// </summary> /// </summary>
public static class Greeter public static partial class Greeter
{ {
static readonly string __ServiceName = "helloworld.Greeter"; static readonly string __ServiceName = "helloworld.Greeter";
static readonly Marshaller<global::Helloworld.HelloRequest> __Marshaller_HelloRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloRequest.Parser.ParseFrom); static readonly grpc::Marshaller<global::Helloworld.HelloRequest> __Marshaller_HelloRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloRequest.Parser.ParseFrom);
static readonly Marshaller<global::Helloworld.HelloReply> __Marshaller_HelloReply = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloReply.Parser.ParseFrom); static readonly grpc::Marshaller<global::Helloworld.HelloReply> __Marshaller_HelloReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloReply.Parser.ParseFrom);
static readonly Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>( static readonly grpc::Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new grpc::Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>(
MethodType.Unary, grpc::MethodType.Unary,
__ServiceName, __ServiceName,
"SayHello", "SayHello",
__Marshaller_HelloRequest, __Marshaller_HelloRequest,
@ -62,29 +62,32 @@ namespace Helloworld {
} }
/// <summary>Base class for server-side implementations of Greeter</summary> /// <summary>Base class for server-side implementations of Greeter</summary>
public abstract class GreeterBase public abstract partial class GreeterBase
{ {
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual global::System.Threading.Tasks.Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, ServerCallContext context) /// <param name="request">The request received from the client.</param>
/// <param name="context">The context of the server-side call handler being invoked.</param>
/// <returns>The response to send back to the client (wrapped by a task).</returns>
public virtual global::System.Threading.Tasks.Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, grpc::ServerCallContext context)
{ {
throw new RpcException(new Status(StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
} }
} }
/// <summary>Client for Greeter</summary> /// <summary>Client for Greeter</summary>
public class GreeterClient : ClientBase<GreeterClient> public partial class GreeterClient : grpc::ClientBase<GreeterClient>
{ {
/// <summary>Creates a new client for Greeter</summary> /// <summary>Creates a new client for Greeter</summary>
/// <param name="channel">The channel to use to make remote calls.</param> /// <param name="channel">The channel to use to make remote calls.</param>
public GreeterClient(Channel channel) : base(channel) public GreeterClient(grpc::Channel channel) : base(channel)
{ {
} }
/// <summary>Creates a new client for Greeter that uses a custom <c>CallInvoker</c>.</summary> /// <summary>Creates a new client for Greeter that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param> /// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public GreeterClient(CallInvoker callInvoker) : base(callInvoker) public GreeterClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{ {
} }
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary> /// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
@ -98,33 +101,50 @@ namespace Helloworld {
} }
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The response received from the server.</returns>
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return SayHello(request, new CallOptions(headers, deadline, cancellationToken)); return SayHello(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, CallOptions options) /// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The response received from the server.</returns>
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, grpc::CallOptions options)
{ {
return CallInvoker.BlockingUnaryCall(__Method_SayHello, null, options, request); return CallInvoker.BlockingUnaryCall(__Method_SayHello, null, options, request);
} }
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return SayHelloAsync(request, new CallOptions(headers, deadline, cancellationToken)); return SayHelloAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, CallOptions options) /// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, grpc::CallOptions options)
{ {
return CallInvoker.AsyncUnaryCall(__Method_SayHello, null, options, request); return CallInvoker.AsyncUnaryCall(__Method_SayHello, null, options, request);
} }
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override GreeterClient NewInstance(ClientBaseConfiguration configuration) protected override GreeterClient NewInstance(ClientBaseConfiguration configuration)
{ {
return new GreeterClient(configuration); return new GreeterClient(configuration);
@ -132,9 +152,10 @@ namespace Helloworld {
} }
/// <summary>Creates service definition that can be registered with a server</summary> /// <summary>Creates service definition that can be registered with a server</summary>
public static ServerServiceDefinition BindService(GreeterBase serviceImpl) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(GreeterBase serviceImpl)
{ {
return ServerServiceDefinition.CreateBuilder() return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_SayHello, serviceImpl.SayHello).Build(); .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build();
} }

@ -1,31 +0,0 @@
{
"title": "Greeter",
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
},
"dependencies": {
"Google.Protobuf": "3.0.0",
"Grpc": "1.0.1",
},
"frameworks": {
"net45": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.IO": ""
},
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": "dnxcore50"
}
}
}

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>GreeterClient</AssemblyTitle>
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>GreeterClient</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>GreeterClient</PackageId>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Greeter\Greeter.csproj" />
</ItemGroup>
</Project>

@ -1,35 +0,0 @@
{
"title": "GreeterClient",
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": "true"
},
"dependencies": {
"Google.Protobuf": "3.0.0",
"Grpc": "1.0.1",
"Greeter": {
"target": "project"
}
},
"frameworks": {
"net45": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.IO": ""
},
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": "dnxcore50"
}
}
}

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyTitle>GreeterServer</AssemblyTitle>
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
<DebugType>portable</DebugType>
<AssemblyName>GreeterServer</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>GreeterServer</PackageId>
<RuntimeFrameworkVersion Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">1.0.4</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Greeter\Greeter.csproj" />
</ItemGroup>
</Project>

@ -1,35 +0,0 @@
{
"title": "GreeterServer",
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": "true"
},
"dependencies": {
"Google.Protobuf": "3.0.0",
"Grpc": "1.0.1",
"Greeter": {
"target": "project"
}
},
"frameworks": {
"net45": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.IO": ""
},
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.1"
}
},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": "dnxcore50"
}
}
}

@ -12,26 +12,19 @@ Example projects in this directory depend on the [Grpc](https://www.nuget.org/pa
and [Google.Protobuf](https://www.nuget.org/packages/Google.Protobuf/) NuGet packages and [Google.Protobuf](https://www.nuget.org/packages/Google.Protobuf/) NuGet packages
which have been already added to the project for you. which have been already added to the project for you.
The examples in this directory target .NET 4.5 framework, as .NET Core support is
currently experimental.
PREREQUISITES PREREQUISITES
------------- -------------
- The DotNetCore SDK cli. - The [.NET Core SDK](https://www.microsoft.com/net/core).
- The .NET 4.5 framework.
Both are available to download at https://www.microsoft.com/net/download
BUILD BUILD
------- -------
From the `examples/csharp/helloworld-from-cli` directory: From the `examples/csharp/helloworld-from-cli` directory:
- `dotnet restore` - `dotnet restore Greeter.sln`
- `dotnet build **/project.json` (this will automatically download NuGet dependencies) - `dotnet build Greeter.sln`
Try it! Try it!
------- -------
@ -40,14 +33,14 @@ Try it!
``` ```
> cd GreeterServer > cd GreeterServer
> dotnet run > dotnet run -f netcoreapp1.0
``` ```
- Run the client - Run the client
``` ```
> cd GreeterClient > cd GreeterClient
> dotnet run > dotnet run -f netcoreapp1.0
``` ```
Tutorial Tutorial

@ -0,0 +1,42 @@
@rem Copyright 2016, Google Inc.
@rem All rights reserved.
@rem
@rem Redistribution and use in source and binary forms, with or without
@rem modification, are permitted provided that the following conditions are
@rem met:
@rem
@rem * Redistributions of source code must retain the above copyright
@rem notice, this list of conditions and the following disclaimer.
@rem * Redistributions in binary form must reproduce the above
@rem copyright notice, this list of conditions and the following disclaimer
@rem in the documentation and/or other materials provided with the
@rem distribution.
@rem * Neither the name of Google Inc. nor the names of its
@rem contributors may be used to endorse or promote products derived from
@rem this software without specific prior written permission.
@rem
@rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
@rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
@rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
@rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
@rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
@rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
@rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@rem Generate the C# code for .proto files
setlocal
@rem enter this directory
cd /d %~dp0
set PROTOC=%UserProfile%\.nuget\packages\Google.Protobuf.Tools\3.2.0\tools\windows_x64\protoc.exe
set PLUGIN=%UserProfile%\.nuget\packages\Grpc.Tools\1.2.2\tools\windows_x64\grpc_csharp_plugin.exe
%PROTOC% -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=%PLUGIN%
endlocal

@ -1,5 +0,0 @@
{
"sdk": {
"version": "1.0.0-preview2-003131"
}
}

@ -10,7 +10,8 @@
<RootNamespace>Greeter</RootNamespace> <RootNamespace>Greeter</RootNamespace>
<AssemblyName>Greeter</AssemblyName> <AssemblyName>Greeter</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>2669b4f2</NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -31,18 +32,18 @@
<ConsolePause>false</ConsolePause> <ConsolePause>false</ConsolePause>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
<HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Grpc.Core, Version=1.0.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL"> <Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
<HintPath>..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath>
<HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -61,11 +62,11 @@
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" /> <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets'))" /> <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
</Target> </Target>
</Project> </Project>

@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic;
namespace Helloworld { namespace Helloworld {
/// <summary>Holder for reflection information generated from helloworld.proto</summary> /// <summary>Holder for reflection information generated from helloworld.proto</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class HelloworldReflection { public static partial class HelloworldReflection {
#region Descriptor #region Descriptor
@ -41,31 +40,36 @@ namespace Helloworld {
} }
#region Messages #region Messages
/// <summary> /// <summary>
/// The request message containing the user's name. /// The request message containing the user's name.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class HelloRequest : pb::IMessage<HelloRequest> { public sealed partial class HelloRequest : pb::IMessage<HelloRequest> {
private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest()); private static readonly pb::MessageParser<HelloRequest> _parser = new pb::MessageParser<HelloRequest>(() => new HelloRequest());
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } } public static pb::MessageParser<HelloRequest> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; } get { return Descriptor; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloRequest() { public HelloRequest() {
OnConstruction(); OnConstruction();
} }
partial void OnConstruction(); partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloRequest(HelloRequest other) : this() { public HelloRequest(HelloRequest other) : this() {
name_ = other.name_; name_ = other.name_;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloRequest Clone() { public HelloRequest Clone() {
return new HelloRequest(this); return new HelloRequest(this);
} }
@ -73,6 +77,7 @@ namespace Helloworld {
/// <summary>Field number for the "name" field.</summary> /// <summary>Field number for the "name" field.</summary>
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name { public string Name {
get { return name_; } get { return name_; }
set { set {
@ -80,10 +85,12 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as HelloRequest); return Equals(other as HelloRequest);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(HelloRequest other) { public bool Equals(HelloRequest other) {
if (ReferenceEquals(other, null)) { if (ReferenceEquals(other, null)) {
return false; return false;
@ -95,16 +102,19 @@ namespace Helloworld {
return true; return true;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (Name.Length != 0) hash ^= Name.GetHashCode(); if (Name.Length != 0) hash ^= Name.GetHashCode();
return hash; return hash;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
if (Name.Length != 0) { if (Name.Length != 0) {
output.WriteRawTag(10); output.WriteRawTag(10);
@ -112,6 +122,7 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
if (Name.Length != 0) { if (Name.Length != 0) {
@ -120,6 +131,7 @@ namespace Helloworld {
return size; return size;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(HelloRequest other) { public void MergeFrom(HelloRequest other) {
if (other == null) { if (other == null) {
return; return;
@ -129,6 +141,7 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) { public void MergeFrom(pb::CodedInputStream input) {
uint tag; uint tag;
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {
@ -147,31 +160,36 @@ namespace Helloworld {
} }
/// <summary> /// <summary>
/// The response message containing the greetings /// The response message containing the greetings
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class HelloReply : pb::IMessage<HelloReply> { public sealed partial class HelloReply : pb::IMessage<HelloReply> {
private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply()); private static readonly pb::MessageParser<HelloReply> _parser = new pb::MessageParser<HelloReply>(() => new HelloReply());
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<HelloReply> Parser { get { return _parser; } } public static pb::MessageParser<HelloReply> Parser { get { return _parser; } }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pbr::MessageDescriptor Descriptor { public static pbr::MessageDescriptor Descriptor {
get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
pbr::MessageDescriptor pb::IMessage.Descriptor { pbr::MessageDescriptor pb::IMessage.Descriptor {
get { return Descriptor; } get { return Descriptor; }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloReply() { public HelloReply() {
OnConstruction(); OnConstruction();
} }
partial void OnConstruction(); partial void OnConstruction();
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloReply(HelloReply other) : this() { public HelloReply(HelloReply other) : this() {
message_ = other.message_; message_ = other.message_;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public HelloReply Clone() { public HelloReply Clone() {
return new HelloReply(this); return new HelloReply(this);
} }
@ -179,6 +197,7 @@ namespace Helloworld {
/// <summary>Field number for the "message" field.</summary> /// <summary>Field number for the "message" field.</summary>
public const int MessageFieldNumber = 1; public const int MessageFieldNumber = 1;
private string message_ = ""; private string message_ = "";
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Message { public string Message {
get { return message_; } get { return message_; }
set { set {
@ -186,10 +205,12 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override bool Equals(object other) { public override bool Equals(object other) {
return Equals(other as HelloReply); return Equals(other as HelloReply);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public bool Equals(HelloReply other) { public bool Equals(HelloReply other) {
if (ReferenceEquals(other, null)) { if (ReferenceEquals(other, null)) {
return false; return false;
@ -201,16 +222,19 @@ namespace Helloworld {
return true; return true;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override int GetHashCode() { public override int GetHashCode() {
int hash = 1; int hash = 1;
if (Message.Length != 0) hash ^= Message.GetHashCode(); if (Message.Length != 0) hash ^= Message.GetHashCode();
return hash; return hash;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public override string ToString() { public override string ToString() {
return pb::JsonFormatter.ToDiagnosticString(this); return pb::JsonFormatter.ToDiagnosticString(this);
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void WriteTo(pb::CodedOutputStream output) { public void WriteTo(pb::CodedOutputStream output) {
if (Message.Length != 0) { if (Message.Length != 0) {
output.WriteRawTag(10); output.WriteRawTag(10);
@ -218,6 +242,7 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int CalculateSize() { public int CalculateSize() {
int size = 0; int size = 0;
if (Message.Length != 0) { if (Message.Length != 0) {
@ -226,6 +251,7 @@ namespace Helloworld {
return size; return size;
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(HelloReply other) { public void MergeFrom(HelloReply other) {
if (other == null) { if (other == null) {
return; return;
@ -235,6 +261,7 @@ namespace Helloworld {
} }
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public void MergeFrom(pb::CodedInputStream input) { public void MergeFrom(pb::CodedInputStream input) {
uint tag; uint tag;
while ((tag = input.ReadTag()) != 0) { while ((tag = input.ReadTag()) != 0) {

@ -35,21 +35,21 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Grpc.Core; using grpc = global::Grpc.Core;
namespace Helloworld { namespace Helloworld {
/// <summary> /// <summary>
/// The greeting service definition. /// The greeting service definition.
/// </summary> /// </summary>
public static class Greeter public static partial class Greeter
{ {
static readonly string __ServiceName = "helloworld.Greeter"; static readonly string __ServiceName = "helloworld.Greeter";
static readonly Marshaller<global::Helloworld.HelloRequest> __Marshaller_HelloRequest = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloRequest.Parser.ParseFrom); static readonly grpc::Marshaller<global::Helloworld.HelloRequest> __Marshaller_HelloRequest = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloRequest.Parser.ParseFrom);
static readonly Marshaller<global::Helloworld.HelloReply> __Marshaller_HelloReply = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloReply.Parser.ParseFrom); static readonly grpc::Marshaller<global::Helloworld.HelloReply> __Marshaller_HelloReply = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Helloworld.HelloReply.Parser.ParseFrom);
static readonly Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>( static readonly grpc::Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply> __Method_SayHello = new grpc::Method<global::Helloworld.HelloRequest, global::Helloworld.HelloReply>(
MethodType.Unary, grpc::MethodType.Unary,
__ServiceName, __ServiceName,
"SayHello", "SayHello",
__Marshaller_HelloRequest, __Marshaller_HelloRequest,
@ -62,29 +62,32 @@ namespace Helloworld {
} }
/// <summary>Base class for server-side implementations of Greeter</summary> /// <summary>Base class for server-side implementations of Greeter</summary>
public abstract class GreeterBase public abstract partial class GreeterBase
{ {
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual global::System.Threading.Tasks.Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, ServerCallContext context) /// <param name="request">The request received from the client.</param>
/// <param name="context">The context of the server-side call handler being invoked.</param>
/// <returns>The response to send back to the client (wrapped by a task).</returns>
public virtual global::System.Threading.Tasks.Task<global::Helloworld.HelloReply> SayHello(global::Helloworld.HelloRequest request, grpc::ServerCallContext context)
{ {
throw new RpcException(new Status(StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
} }
} }
/// <summary>Client for Greeter</summary> /// <summary>Client for Greeter</summary>
public class GreeterClient : ClientBase<GreeterClient> public partial class GreeterClient : grpc::ClientBase<GreeterClient>
{ {
/// <summary>Creates a new client for Greeter</summary> /// <summary>Creates a new client for Greeter</summary>
/// <param name="channel">The channel to use to make remote calls.</param> /// <param name="channel">The channel to use to make remote calls.</param>
public GreeterClient(Channel channel) : base(channel) public GreeterClient(grpc::Channel channel) : base(channel)
{ {
} }
/// <summary>Creates a new client for Greeter that uses a custom <c>CallInvoker</c>.</summary> /// <summary>Creates a new client for Greeter that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param> /// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public GreeterClient(CallInvoker callInvoker) : base(callInvoker) public GreeterClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{ {
} }
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary> /// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
@ -98,33 +101,50 @@ namespace Helloworld {
} }
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The response received from the server.</returns>
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return SayHello(request, new CallOptions(headers, deadline, cancellationToken)); return SayHello(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, CallOptions options) /// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The response received from the server.</returns>
public virtual global::Helloworld.HelloReply SayHello(global::Helloworld.HelloRequest request, grpc::CallOptions options)
{ {
return CallInvoker.BlockingUnaryCall(__Method_SayHello, null, options, request); return CallInvoker.BlockingUnaryCall(__Method_SayHello, null, options, request);
} }
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return SayHelloAsync(request, new CallOptions(headers, deadline, cancellationToken)); return SayHelloAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// Sends a greeting /// Sends a greeting
/// </summary> /// </summary>
public virtual AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, CallOptions options) /// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncUnaryCall<global::Helloworld.HelloReply> SayHelloAsync(global::Helloworld.HelloRequest request, grpc::CallOptions options)
{ {
return CallInvoker.AsyncUnaryCall(__Method_SayHello, null, options, request); return CallInvoker.AsyncUnaryCall(__Method_SayHello, null, options, request);
} }
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override GreeterClient NewInstance(ClientBaseConfiguration configuration) protected override GreeterClient NewInstance(ClientBaseConfiguration configuration)
{ {
return new GreeterClient(configuration); return new GreeterClient(configuration);
@ -132,9 +152,10 @@ namespace Helloworld {
} }
/// <summary>Creates service definition that can be registered with a server</summary> /// <summary>Creates service definition that can be registered with a server</summary>
public static ServerServiceDefinition BindService(GreeterBase serviceImpl) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(GreeterBase serviceImpl)
{ {
return ServerServiceDefinition.CreateBuilder() return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_SayHello, serviceImpl.SayHello).Build(); .AddMethod(__Method_SayHello, serviceImpl.SayHello).Build();
} }

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
<package id="Grpc" version="1.0.1" targetFramework="net45" /> <package id="Grpc" version="1.2.2" targetFramework="net45" />
<package id="Grpc.Core" version="1.0.1" targetFramework="net45" /> <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> <package id="Grpc.Tools" version="1.2.2" targetFramework="net45" />
<package id="Grpc.Tools" version="1.0.1" targetFramework="net45" /> <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> </packages>

@ -10,7 +10,8 @@
<RootNamespace>GreeterClient</RootNamespace> <RootNamespace>GreeterClient</RootNamespace>
<AssemblyName>GreeterClient</AssemblyName> <AssemblyName>GreeterClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>5e942a7d</NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -31,18 +32,18 @@
<Externalconsole>true</Externalconsole> <Externalconsole>true</Externalconsole>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
<HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Grpc.Core, Version=1.0.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL"> <Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
<HintPath>..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath>
<HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -59,11 +60,11 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" /> <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets'))" /> <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
</Target> </Target>
</Project> </Project>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
<package id="Grpc" version="1.0.1" targetFramework="net45" /> <package id="Grpc" version="1.2.2" targetFramework="net45" />
<package id="Grpc.Core" version="1.0.1" targetFramework="net45" /> <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> </packages>

@ -10,7 +10,8 @@
<RootNamespace>GreeterServer</RootNamespace> <RootNamespace>GreeterServer</RootNamespace>
<AssemblyName>GreeterServer</AssemblyName> <AssemblyName>GreeterServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<NuGetPackageImportStamp>9c7b2963</NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -31,18 +32,18 @@
<Externalconsole>true</Externalconsole> <Externalconsole>true</Externalconsole>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
<HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Grpc.Core, Version=1.0.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL"> <Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
<HintPath>..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath>
<HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -59,11 +60,11 @@
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" /> <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets'))" /> <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
</Target> </Target>
</Project> </Project>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
<package id="Grpc" version="1.0.1" targetFramework="net45" /> <package id="Grpc" version="1.2.2" targetFramework="net45" />
<package id="Grpc.Core" version="1.0.1" targetFramework="net45" /> <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> </packages>

@ -34,7 +34,7 @@ setlocal
@rem enter this directory @rem enter this directory
cd /d %~dp0 cd /d %~dp0
set TOOLS_PATH=packages\Grpc.Tools.1.0.1\tools\windows_x86 set TOOLS_PATH=packages\Grpc.Tools.1.2.2\tools\windows_x86
%TOOLS_PATH%\protoc.exe -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe %TOOLS_PATH%\protoc.exe -I../../protos --csharp_out Greeter ../../protos/helloworld.proto --grpc_out Greeter --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe

@ -53,10 +53,10 @@ namespace Routeguide {
} }
#region Messages #region Messages
/// <summary> /// <summary>
/// Points are represented as latitude-longitude pairs in the E7 representation /// Points are represented as latitude-longitude pairs in the E7 representation
/// (degrees multiplied by 10**7 and rounded to the nearest integer). /// (degrees multiplied by 10**7 and rounded to the nearest integer).
/// Latitudes should be in the range +/- 90 degrees and longitude should be in /// Latitudes should be in the range +/- 90 degrees and longitude should be in
/// the range +/- 180 degrees (inclusive). /// the range +/- 180 degrees (inclusive).
/// </summary> /// </summary>
public sealed partial class Point : pb::IMessage<Point> { public sealed partial class Point : pb::IMessage<Point> {
private static readonly pb::MessageParser<Point> _parser = new pb::MessageParser<Point>(() => new Point()); private static readonly pb::MessageParser<Point> _parser = new pb::MessageParser<Point>(() => new Point());
@ -204,8 +204,8 @@ namespace Routeguide {
} }
/// <summary> /// <summary>
/// A latitude-longitude rectangle, represented as two diagonally opposite /// A latitude-longitude rectangle, represented as two diagonally opposite
/// points "lo" and "hi". /// points "lo" and "hi".
/// </summary> /// </summary>
public sealed partial class Rectangle : pb::IMessage<Rectangle> { public sealed partial class Rectangle : pb::IMessage<Rectangle> {
private static readonly pb::MessageParser<Rectangle> _parser = new pb::MessageParser<Rectangle>(() => new Rectangle()); private static readonly pb::MessageParser<Rectangle> _parser = new pb::MessageParser<Rectangle>(() => new Rectangle());
@ -244,7 +244,7 @@ namespace Routeguide {
public const int LoFieldNumber = 1; public const int LoFieldNumber = 1;
private global::Routeguide.Point lo_; private global::Routeguide.Point lo_;
/// <summary> /// <summary>
/// One corner of the rectangle. /// One corner of the rectangle.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Routeguide.Point Lo { public global::Routeguide.Point Lo {
@ -258,7 +258,7 @@ namespace Routeguide {
public const int HiFieldNumber = 2; public const int HiFieldNumber = 2;
private global::Routeguide.Point hi_; private global::Routeguide.Point hi_;
/// <summary> /// <summary>
/// The other corner of the rectangle. /// The other corner of the rectangle.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Routeguide.Point Hi { public global::Routeguide.Point Hi {
@ -371,9 +371,9 @@ namespace Routeguide {
} }
/// <summary> /// <summary>
/// A feature names something at a given point. /// A feature names something at a given point.
/// ///
/// If a feature could not be named, the name is empty. /// If a feature could not be named, the name is empty.
/// </summary> /// </summary>
public sealed partial class Feature : pb::IMessage<Feature> { public sealed partial class Feature : pb::IMessage<Feature> {
private static readonly pb::MessageParser<Feature> _parser = new pb::MessageParser<Feature>(() => new Feature()); private static readonly pb::MessageParser<Feature> _parser = new pb::MessageParser<Feature>(() => new Feature());
@ -412,7 +412,7 @@ namespace Routeguide {
public const int NameFieldNumber = 1; public const int NameFieldNumber = 1;
private string name_ = ""; private string name_ = "";
/// <summary> /// <summary>
/// The name of the feature. /// The name of the feature.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Name { public string Name {
@ -426,7 +426,7 @@ namespace Routeguide {
public const int LocationFieldNumber = 2; public const int LocationFieldNumber = 2;
private global::Routeguide.Point location_; private global::Routeguide.Point location_;
/// <summary> /// <summary>
/// The point where the feature is detected. /// The point where the feature is detected.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Routeguide.Point Location { public global::Routeguide.Point Location {
@ -533,7 +533,7 @@ namespace Routeguide {
} }
/// <summary> /// <summary>
/// A RouteNote is a message sent while at a given point. /// A RouteNote is a message sent while at a given point.
/// </summary> /// </summary>
public sealed partial class RouteNote : pb::IMessage<RouteNote> { public sealed partial class RouteNote : pb::IMessage<RouteNote> {
private static readonly pb::MessageParser<RouteNote> _parser = new pb::MessageParser<RouteNote>(() => new RouteNote()); private static readonly pb::MessageParser<RouteNote> _parser = new pb::MessageParser<RouteNote>(() => new RouteNote());
@ -572,7 +572,7 @@ namespace Routeguide {
public const int LocationFieldNumber = 1; public const int LocationFieldNumber = 1;
private global::Routeguide.Point location_; private global::Routeguide.Point location_;
/// <summary> /// <summary>
/// The location from which the message is sent. /// The location from which the message is sent.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public global::Routeguide.Point Location { public global::Routeguide.Point Location {
@ -586,7 +586,7 @@ namespace Routeguide {
public const int MessageFieldNumber = 2; public const int MessageFieldNumber = 2;
private string message_ = ""; private string message_ = "";
/// <summary> /// <summary>
/// The message to be sent. /// The message to be sent.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string Message { public string Message {
@ -693,11 +693,11 @@ namespace Routeguide {
} }
/// <summary> /// <summary>
/// A RouteSummary is received in response to a RecordRoute rpc. /// A RouteSummary is received in response to a RecordRoute rpc.
/// ///
/// It contains the number of individual points received, the number of /// It contains the number of individual points received, the number of
/// detected features, and the total distance covered as the cumulative sum of /// detected features, and the total distance covered as the cumulative sum of
/// the distance between each point. /// the distance between each point.
/// </summary> /// </summary>
public sealed partial class RouteSummary : pb::IMessage<RouteSummary> { public sealed partial class RouteSummary : pb::IMessage<RouteSummary> {
private static readonly pb::MessageParser<RouteSummary> _parser = new pb::MessageParser<RouteSummary>(() => new RouteSummary()); private static readonly pb::MessageParser<RouteSummary> _parser = new pb::MessageParser<RouteSummary>(() => new RouteSummary());
@ -738,7 +738,7 @@ namespace Routeguide {
public const int PointCountFieldNumber = 1; public const int PointCountFieldNumber = 1;
private int pointCount_; private int pointCount_;
/// <summary> /// <summary>
/// The number of points received. /// The number of points received.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int PointCount { public int PointCount {
@ -752,7 +752,7 @@ namespace Routeguide {
public const int FeatureCountFieldNumber = 2; public const int FeatureCountFieldNumber = 2;
private int featureCount_; private int featureCount_;
/// <summary> /// <summary>
/// The number of known features passed while traversing the route. /// The number of known features passed while traversing the route.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int FeatureCount { public int FeatureCount {
@ -766,7 +766,7 @@ namespace Routeguide {
public const int DistanceFieldNumber = 3; public const int DistanceFieldNumber = 3;
private int distance_; private int distance_;
/// <summary> /// <summary>
/// The distance covered in metres. /// The distance covered in metres.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int Distance { public int Distance {
@ -780,7 +780,7 @@ namespace Routeguide {
public const int ElapsedTimeFieldNumber = 4; public const int ElapsedTimeFieldNumber = 4;
private int elapsedTime_; private int elapsedTime_;
/// <summary> /// <summary>
/// The duration of the traversal in seconds. /// The duration of the traversal in seconds.
/// </summary> /// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public int ElapsedTime { public int ElapsedTime {

@ -11,7 +11,8 @@
<AssemblyName>RouteGuide</AssemblyName> <AssemblyName>RouteGuide</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>de2137f9</NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -31,13 +32,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
<HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Grpc.Core, Version=1.0.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL"> <Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
<HintPath>..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -45,15 +46,15 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
@ -74,12 +75,12 @@
</None> </None>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" /> <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets'))" /> <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

@ -35,45 +35,45 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Grpc.Core; using grpc = global::Grpc.Core;
namespace Routeguide { namespace Routeguide {
/// <summary> /// <summary>
/// Interface exported by the server. /// Interface exported by the server.
/// </summary> /// </summary>
public static class RouteGuide public static partial class RouteGuide
{ {
static readonly string __ServiceName = "routeguide.RouteGuide"; static readonly string __ServiceName = "routeguide.RouteGuide";
static readonly Marshaller<global::Routeguide.Point> __Marshaller_Point = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.Point.Parser.ParseFrom); static readonly grpc::Marshaller<global::Routeguide.Point> __Marshaller_Point = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.Point.Parser.ParseFrom);
static readonly Marshaller<global::Routeguide.Feature> __Marshaller_Feature = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.Feature.Parser.ParseFrom); static readonly grpc::Marshaller<global::Routeguide.Feature> __Marshaller_Feature = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.Feature.Parser.ParseFrom);
static readonly Marshaller<global::Routeguide.Rectangle> __Marshaller_Rectangle = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.Rectangle.Parser.ParseFrom); static readonly grpc::Marshaller<global::Routeguide.Rectangle> __Marshaller_Rectangle = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.Rectangle.Parser.ParseFrom);
static readonly Marshaller<global::Routeguide.RouteSummary> __Marshaller_RouteSummary = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.RouteSummary.Parser.ParseFrom); static readonly grpc::Marshaller<global::Routeguide.RouteSummary> __Marshaller_RouteSummary = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.RouteSummary.Parser.ParseFrom);
static readonly Marshaller<global::Routeguide.RouteNote> __Marshaller_RouteNote = Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.RouteNote.Parser.ParseFrom); static readonly grpc::Marshaller<global::Routeguide.RouteNote> __Marshaller_RouteNote = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Routeguide.RouteNote.Parser.ParseFrom);
static readonly Method<global::Routeguide.Point, global::Routeguide.Feature> __Method_GetFeature = new Method<global::Routeguide.Point, global::Routeguide.Feature>( static readonly grpc::Method<global::Routeguide.Point, global::Routeguide.Feature> __Method_GetFeature = new grpc::Method<global::Routeguide.Point, global::Routeguide.Feature>(
MethodType.Unary, grpc::MethodType.Unary,
__ServiceName, __ServiceName,
"GetFeature", "GetFeature",
__Marshaller_Point, __Marshaller_Point,
__Marshaller_Feature); __Marshaller_Feature);
static readonly Method<global::Routeguide.Rectangle, global::Routeguide.Feature> __Method_ListFeatures = new Method<global::Routeguide.Rectangle, global::Routeguide.Feature>( static readonly grpc::Method<global::Routeguide.Rectangle, global::Routeguide.Feature> __Method_ListFeatures = new grpc::Method<global::Routeguide.Rectangle, global::Routeguide.Feature>(
MethodType.ServerStreaming, grpc::MethodType.ServerStreaming,
__ServiceName, __ServiceName,
"ListFeatures", "ListFeatures",
__Marshaller_Rectangle, __Marshaller_Rectangle,
__Marshaller_Feature); __Marshaller_Feature);
static readonly Method<global::Routeguide.Point, global::Routeguide.RouteSummary> __Method_RecordRoute = new Method<global::Routeguide.Point, global::Routeguide.RouteSummary>( static readonly grpc::Method<global::Routeguide.Point, global::Routeguide.RouteSummary> __Method_RecordRoute = new grpc::Method<global::Routeguide.Point, global::Routeguide.RouteSummary>(
MethodType.ClientStreaming, grpc::MethodType.ClientStreaming,
__ServiceName, __ServiceName,
"RecordRoute", "RecordRoute",
__Marshaller_Point, __Marshaller_Point,
__Marshaller_RouteSummary); __Marshaller_RouteSummary);
static readonly Method<global::Routeguide.RouteNote, global::Routeguide.RouteNote> __Method_RouteChat = new Method<global::Routeguide.RouteNote, global::Routeguide.RouteNote>( static readonly grpc::Method<global::Routeguide.RouteNote, global::Routeguide.RouteNote> __Method_RouteChat = new grpc::Method<global::Routeguide.RouteNote, global::Routeguide.RouteNote>(
MethodType.DuplexStreaming, grpc::MethodType.DuplexStreaming,
__ServiceName, __ServiceName,
"RouteChat", "RouteChat",
__Marshaller_RouteNote, __Marshaller_RouteNote,
@ -86,69 +86,83 @@ namespace Routeguide {
} }
/// <summary>Base class for server-side implementations of RouteGuide</summary> /// <summary>Base class for server-side implementations of RouteGuide</summary>
public abstract class RouteGuideBase public abstract partial class RouteGuideBase
{ {
/// <summary> /// <summary>
/// A simple RPC. /// A simple RPC.
/// ///
/// Obtains the feature at a given position. /// Obtains the feature at a given position.
/// ///
/// A feature with an empty name is returned if there's no feature at the given /// A feature with an empty name is returned if there's no feature at the given
/// position. /// position.
/// </summary> /// </summary>
public virtual global::System.Threading.Tasks.Task<global::Routeguide.Feature> GetFeature(global::Routeguide.Point request, ServerCallContext context) /// <param name="request">The request received from the client.</param>
/// <param name="context">The context of the server-side call handler being invoked.</param>
/// <returns>The response to send back to the client (wrapped by a task).</returns>
public virtual global::System.Threading.Tasks.Task<global::Routeguide.Feature> GetFeature(global::Routeguide.Point request, grpc::ServerCallContext context)
{ {
throw new RpcException(new Status(StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
} }
/// <summary> /// <summary>
/// A server-to-client streaming RPC. /// A server-to-client streaming RPC.
/// ///
/// Obtains the Features available within the given Rectangle. Results are /// Obtains the Features available within the given Rectangle. Results are
/// streamed rather than returned at once (e.g. in a response message with a /// streamed rather than returned at once (e.g. in a response message with a
/// repeated field), as the rectangle may cover a large area and contain a /// repeated field), as the rectangle may cover a large area and contain a
/// huge number of features. /// huge number of features.
/// </summary> /// </summary>
public virtual global::System.Threading.Tasks.Task ListFeatures(global::Routeguide.Rectangle request, IServerStreamWriter<global::Routeguide.Feature> responseStream, ServerCallContext context) /// <param name="request">The request received from the client.</param>
/// <param name="responseStream">Used for sending responses back to the client.</param>
/// <param name="context">The context of the server-side call handler being invoked.</param>
/// <returns>A task indicating completion of the handler.</returns>
public virtual global::System.Threading.Tasks.Task ListFeatures(global::Routeguide.Rectangle request, grpc::IServerStreamWriter<global::Routeguide.Feature> responseStream, grpc::ServerCallContext context)
{ {
throw new RpcException(new Status(StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
} }
/// <summary> /// <summary>
/// A client-to-server streaming RPC. /// A client-to-server streaming RPC.
/// ///
/// Accepts a stream of Points on a route being traversed, returning a /// Accepts a stream of Points on a route being traversed, returning a
/// RouteSummary when traversal is completed. /// RouteSummary when traversal is completed.
/// </summary> /// </summary>
public virtual global::System.Threading.Tasks.Task<global::Routeguide.RouteSummary> RecordRoute(IAsyncStreamReader<global::Routeguide.Point> requestStream, ServerCallContext context) /// <param name="requestStream">Used for reading requests from the client.</param>
/// <param name="context">The context of the server-side call handler being invoked.</param>
/// <returns>The response to send back to the client (wrapped by a task).</returns>
public virtual global::System.Threading.Tasks.Task<global::Routeguide.RouteSummary> RecordRoute(grpc::IAsyncStreamReader<global::Routeguide.Point> requestStream, grpc::ServerCallContext context)
{ {
throw new RpcException(new Status(StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
} }
/// <summary> /// <summary>
/// A Bidirectional streaming RPC. /// A Bidirectional streaming RPC.
/// ///
/// Accepts a stream of RouteNotes sent while a route is being traversed, /// Accepts a stream of RouteNotes sent while a route is being traversed,
/// while receiving other RouteNotes (e.g. from other users). /// while receiving other RouteNotes (e.g. from other users).
/// </summary> /// </summary>
public virtual global::System.Threading.Tasks.Task RouteChat(IAsyncStreamReader<global::Routeguide.RouteNote> requestStream, IServerStreamWriter<global::Routeguide.RouteNote> responseStream, ServerCallContext context) /// <param name="requestStream">Used for reading requests from the client.</param>
/// <param name="responseStream">Used for sending responses back to the client.</param>
/// <param name="context">The context of the server-side call handler being invoked.</param>
/// <returns>A task indicating completion of the handler.</returns>
public virtual global::System.Threading.Tasks.Task RouteChat(grpc::IAsyncStreamReader<global::Routeguide.RouteNote> requestStream, grpc::IServerStreamWriter<global::Routeguide.RouteNote> responseStream, grpc::ServerCallContext context)
{ {
throw new RpcException(new Status(StatusCode.Unimplemented, "")); throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, ""));
} }
} }
/// <summary>Client for RouteGuide</summary> /// <summary>Client for RouteGuide</summary>
public class RouteGuideClient : ClientBase<RouteGuideClient> public partial class RouteGuideClient : grpc::ClientBase<RouteGuideClient>
{ {
/// <summary>Creates a new client for RouteGuide</summary> /// <summary>Creates a new client for RouteGuide</summary>
/// <param name="channel">The channel to use to make remote calls.</param> /// <param name="channel">The channel to use to make remote calls.</param>
public RouteGuideClient(Channel channel) : base(channel) public RouteGuideClient(grpc::Channel channel) : base(channel)
{ {
} }
/// <summary>Creates a new client for RouteGuide that uses a custom <c>CallInvoker</c>.</summary> /// <summary>Creates a new client for RouteGuide that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param> /// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public RouteGuideClient(CallInvoker callInvoker) : base(callInvoker) public RouteGuideClient(grpc::CallInvoker callInvoker) : base(callInvoker)
{ {
} }
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary> /// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
@ -162,117 +176,154 @@ namespace Routeguide {
} }
/// <summary> /// <summary>
/// A simple RPC. /// A simple RPC.
/// ///
/// Obtains the feature at a given position. /// Obtains the feature at a given position.
/// ///
/// A feature with an empty name is returned if there's no feature at the given /// A feature with an empty name is returned if there's no feature at the given
/// position. /// position.
/// </summary> /// </summary>
public virtual global::Routeguide.Feature GetFeature(global::Routeguide.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The response received from the server.</returns>
public virtual global::Routeguide.Feature GetFeature(global::Routeguide.Point request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return GetFeature(request, new CallOptions(headers, deadline, cancellationToken)); return GetFeature(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// A simple RPC. /// A simple RPC.
/// ///
/// Obtains the feature at a given position. /// Obtains the feature at a given position.
/// ///
/// A feature with an empty name is returned if there's no feature at the given /// A feature with an empty name is returned if there's no feature at the given
/// position. /// position.
/// </summary> /// </summary>
public virtual global::Routeguide.Feature GetFeature(global::Routeguide.Point request, CallOptions options) /// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The response received from the server.</returns>
public virtual global::Routeguide.Feature GetFeature(global::Routeguide.Point request, grpc::CallOptions options)
{ {
return CallInvoker.BlockingUnaryCall(__Method_GetFeature, null, options, request); return CallInvoker.BlockingUnaryCall(__Method_GetFeature, null, options, request);
} }
/// <summary> /// <summary>
/// A simple RPC. /// A simple RPC.
/// ///
/// Obtains the feature at a given position. /// Obtains the feature at a given position.
/// ///
/// A feature with an empty name is returned if there's no feature at the given /// A feature with an empty name is returned if there's no feature at the given
/// position. /// position.
/// </summary> /// </summary>
public virtual AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return GetFeatureAsync(request, new CallOptions(headers, deadline, cancellationToken)); return GetFeatureAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// A simple RPC. /// A simple RPC.
/// ///
/// Obtains the feature at a given position. /// Obtains the feature at a given position.
/// ///
/// A feature with an empty name is returned if there's no feature at the given /// A feature with an empty name is returned if there's no feature at the given
/// position. /// position.
/// </summary> /// </summary>
public virtual AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, CallOptions options) /// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncUnaryCall<global::Routeguide.Feature> GetFeatureAsync(global::Routeguide.Point request, grpc::CallOptions options)
{ {
return CallInvoker.AsyncUnaryCall(__Method_GetFeature, null, options, request); return CallInvoker.AsyncUnaryCall(__Method_GetFeature, null, options, request);
} }
/// <summary> /// <summary>
/// A server-to-client streaming RPC. /// A server-to-client streaming RPC.
/// ///
/// Obtains the Features available within the given Rectangle. Results are /// Obtains the Features available within the given Rectangle. Results are
/// streamed rather than returned at once (e.g. in a response message with a /// streamed rather than returned at once (e.g. in a response message with a
/// repeated field), as the rectangle may cover a large area and contain a /// repeated field), as the rectangle may cover a large area and contain a
/// huge number of features. /// huge number of features.
/// </summary> /// </summary>
public virtual AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return ListFeatures(request, new CallOptions(headers, deadline, cancellationToken)); return ListFeatures(request, new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// A server-to-client streaming RPC. /// A server-to-client streaming RPC.
/// ///
/// Obtains the Features available within the given Rectangle. Results are /// Obtains the Features available within the given Rectangle. Results are
/// streamed rather than returned at once (e.g. in a response message with a /// streamed rather than returned at once (e.g. in a response message with a
/// repeated field), as the rectangle may cover a large area and contain a /// repeated field), as the rectangle may cover a large area and contain a
/// huge number of features. /// huge number of features.
/// </summary> /// </summary>
public virtual AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, CallOptions options) /// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncServerStreamingCall<global::Routeguide.Feature> ListFeatures(global::Routeguide.Rectangle request, grpc::CallOptions options)
{ {
return CallInvoker.AsyncServerStreamingCall(__Method_ListFeatures, null, options, request); return CallInvoker.AsyncServerStreamingCall(__Method_ListFeatures, null, options, request);
} }
/// <summary> /// <summary>
/// A client-to-server streaming RPC. /// A client-to-server streaming RPC.
/// ///
/// Accepts a stream of Points on a route being traversed, returning a /// Accepts a stream of Points on a route being traversed, returning a
/// RouteSummary when traversal is completed. /// RouteSummary when traversal is completed.
/// </summary> /// </summary>
public virtual AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return RecordRoute(new CallOptions(headers, deadline, cancellationToken)); return RecordRoute(new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// A client-to-server streaming RPC. /// A client-to-server streaming RPC.
/// ///
/// Accepts a stream of Points on a route being traversed, returning a /// Accepts a stream of Points on a route being traversed, returning a
/// RouteSummary when traversal is completed. /// RouteSummary when traversal is completed.
/// </summary> /// </summary>
public virtual AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(CallOptions options) /// <param name="options">The options for the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncClientStreamingCall<global::Routeguide.Point, global::Routeguide.RouteSummary> RecordRoute(grpc::CallOptions options)
{ {
return CallInvoker.AsyncClientStreamingCall(__Method_RecordRoute, null, options); return CallInvoker.AsyncClientStreamingCall(__Method_RecordRoute, null, options);
} }
/// <summary> /// <summary>
/// A Bidirectional streaming RPC. /// A Bidirectional streaming RPC.
/// ///
/// Accepts a stream of RouteNotes sent while a route is being traversed, /// Accepts a stream of RouteNotes sent while a route is being traversed,
/// while receiving other RouteNotes (e.g. from other users). /// while receiving other RouteNotes (e.g. from other users).
/// </summary> /// </summary>
public virtual AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) /// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken))
{ {
return RouteChat(new CallOptions(headers, deadline, cancellationToken)); return RouteChat(new grpc::CallOptions(headers, deadline, cancellationToken));
} }
/// <summary> /// <summary>
/// A Bidirectional streaming RPC. /// A Bidirectional streaming RPC.
/// ///
/// Accepts a stream of RouteNotes sent while a route is being traversed, /// Accepts a stream of RouteNotes sent while a route is being traversed,
/// while receiving other RouteNotes (e.g. from other users). /// while receiving other RouteNotes (e.g. from other users).
/// </summary> /// </summary>
public virtual AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(CallOptions options) /// <param name="options">The options for the call.</param>
/// <returns>The call object.</returns>
public virtual grpc::AsyncDuplexStreamingCall<global::Routeguide.RouteNote, global::Routeguide.RouteNote> RouteChat(grpc::CallOptions options)
{ {
return CallInvoker.AsyncDuplexStreamingCall(__Method_RouteChat, null, options); return CallInvoker.AsyncDuplexStreamingCall(__Method_RouteChat, null, options);
} }
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected override RouteGuideClient NewInstance(ClientBaseConfiguration configuration) protected override RouteGuideClient NewInstance(ClientBaseConfiguration configuration)
{ {
return new RouteGuideClient(configuration); return new RouteGuideClient(configuration);
@ -280,9 +331,10 @@ namespace Routeguide {
} }
/// <summary>Creates service definition that can be registered with a server</summary> /// <summary>Creates service definition that can be registered with a server</summary>
public static ServerServiceDefinition BindService(RouteGuideBase serviceImpl) /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public static grpc::ServerServiceDefinition BindService(RouteGuideBase serviceImpl)
{ {
return ServerServiceDefinition.CreateBuilder() return grpc::ServerServiceDefinition.CreateBuilder()
.AddMethod(__Method_GetFeature, serviceImpl.GetFeature) .AddMethod(__Method_GetFeature, serviceImpl.GetFeature)
.AddMethod(__Method_ListFeatures, serviceImpl.ListFeatures) .AddMethod(__Method_ListFeatures, serviceImpl.ListFeatures)
.AddMethod(__Method_RecordRoute, serviceImpl.RecordRoute) .AddMethod(__Method_RecordRoute, serviceImpl.RecordRoute)

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
<package id="Grpc" version="1.0.1" targetFramework="net45" /> <package id="Grpc" version="1.2.2" targetFramework="net45" />
<package id="Grpc.Core" version="1.0.1" targetFramework="net45" /> <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> </packages>

@ -11,7 +11,8 @@
<AssemblyName>RouteGuideClient</AssemblyName> <AssemblyName>RouteGuideClient</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>b880049a</NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -33,13 +34,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
<HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Grpc.Core, Version=1.0.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL"> <Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
<HintPath>..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -47,9 +48,9 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath>
<HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
@ -71,12 +72,12 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" /> <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets'))" /> <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
<package id="Grpc" version="1.0.1" targetFramework="net45" /> <package id="Grpc" version="1.2.2" targetFramework="net45" />
<package id="Grpc.Core" version="1.0.1" targetFramework="net45" /> <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> </packages>

@ -11,7 +11,8 @@
<AssemblyName>RouteGuideServer</AssemblyName> <AssemblyName>RouteGuideServer</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>946ecc79</NuGetPackageImportStamp> <NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -33,13 +34,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.Protobuf, Version=3.0.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL"> <Reference Include="Google.Protobuf, Version=3.2.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Google.Protobuf.3.2.0\lib\net45\Google.Protobuf.dll</HintPath>
<HintPath>..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Grpc.Core, Version=1.0.1.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL"> <Reference Include="Grpc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d754f35622e28bad, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\Grpc.Core.1.2.2\lib\net45\Grpc.Core.dll</HintPath>
<HintPath>..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@ -47,15 +48,15 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Interactive.Async, Version=3.0.1000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\packages\System.Interactive.Async.3.1.1\lib\net45\System.Interactive.Async.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Interactive.Async, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\System.Interactive.Async.3.0.0\lib\net45\System.Interactive.Async.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
@ -72,12 +73,12 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" /> <Import Project="..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets" Condition="Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup> <PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.0.1\build\net45\Grpc.Core.targets'))" /> <Error Condition="!Exists('..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Grpc.Core.1.2.2\build\net45\Grpc.Core.targets'))" />
</Target> </Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.Protobuf" version="3.0.0" targetFramework="net45" /> <package id="Google.Protobuf" version="3.2.0" targetFramework="net45" />
<package id="Grpc" version="1.0.1" targetFramework="net45" /> <package id="Grpc" version="1.2.2" targetFramework="net45" />
<package id="Grpc.Core" version="1.0.1" targetFramework="net45" /> <package id="Grpc.Core" version="1.2.2" targetFramework="net45" />
<package id="System.Interactive.Async" version="3.0.0" targetFramework="net45" /> <package id="Grpc.Tools" version="1.2.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" /> <package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="Grpc.Tools" version="1.0.1" targetFramework="net45" /> <package id="System.Interactive.Async" version="3.1.1" targetFramework="net45" />
</packages> </packages>

@ -34,7 +34,7 @@ setlocal
@rem enter this directory @rem enter this directory
cd /d %~dp0 cd /d %~dp0
set TOOLS_PATH=packages\Grpc.Tools.1.0.0\tools\windows_x86 set TOOLS_PATH=packages\Grpc.Tools.1.2.2\tools\windows_x86
%TOOLS_PATH%\protoc.exe -I../../protos --csharp_out RouteGuide ../../protos/route_guide.proto --grpc_out RouteGuide --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe %TOOLS_PATH%\protoc.exe -I../../protos --csharp_out RouteGuide ../../protos/route_guide.proto --grpc_out RouteGuide --plugin=protoc-gen-grpc=%TOOLS_PATH%\grpc_csharp_plugin.exe

@ -197,9 +197,13 @@ Pod::Spec.new do |s|
# To save you from scrolling, this is the last part of the podspec. # To save you from scrolling, this is the last part of the podspec.
ss.source_files = 'src/core/lib/profiling/timers.h', ss.source_files = 'src/core/lib/profiling/timers.h',
'src/core/lib/support/arena.h', 'src/core/lib/support/arena.h',
'src/core/lib/support/atomic.h',
'src/core/lib/support/atomic_with_atm.h',
'src/core/lib/support/atomic_with_std.h',
'src/core/lib/support/backoff.h', 'src/core/lib/support/backoff.h',
'src/core/lib/support/block_annotate.h', 'src/core/lib/support/block_annotate.h',
'src/core/lib/support/env.h', 'src/core/lib/support/env.h',
'src/core/lib/support/memory.h',
'src/core/lib/support/mpscq.h', 'src/core/lib/support/mpscq.h',
'src/core/lib/support/murmur_hash.h', 'src/core/lib/support/murmur_hash.h',
'src/core/lib/support/spinlock.h', 'src/core/lib/support/spinlock.h',
@ -407,6 +411,7 @@ Pod::Spec.new do |s|
'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/ssl_transport_security.h',
'src/core/tsi/ssl_types.h', 'src/core/tsi/ssl_types.h',
'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security.h',
'src/core/tsi/transport_security_adapter.h',
'src/core/tsi/transport_security_interface.h', 'src/core/tsi/transport_security_interface.h',
'src/core/ext/transport/chttp2/server/chttp2_server.h', 'src/core/ext/transport/chttp2/server/chttp2_server.h',
'src/core/ext/filters/client_channel/client_channel.h', 'src/core/ext/filters/client_channel/client_channel.h',
@ -429,8 +434,10 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/uri_parser.h', 'src/core/ext/filters/client_channel/uri_parser.h',
'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
'third_party/nanopb/pb.h', 'third_party/nanopb/pb.h',
@ -562,7 +569,7 @@ Pod::Spec.new do |s|
'src/core/lib/surface/completion_queue.c', 'src/core/lib/surface/completion_queue.c',
'src/core/lib/surface/completion_queue_factory.c', 'src/core/lib/surface/completion_queue_factory.c',
'src/core/lib/surface/event_string.c', 'src/core/lib/surface/event_string.c',
'src/core/lib/surface/lame_client.c', 'src/core/lib/surface/lame_client.cc',
'src/core/lib/surface/metadata_array.c', 'src/core/lib/surface/metadata_array.c',
'src/core/lib/surface/server.c', 'src/core/lib/surface/server.c',
'src/core/lib/surface/validate_metadata.c', 'src/core/lib/surface/validate_metadata.c',
@ -634,6 +641,7 @@ Pod::Spec.new do |s|
'src/core/tsi/fake_transport_security.c', 'src/core/tsi/fake_transport_security.c',
'src/core/tsi/ssl_transport_security.c', 'src/core/tsi/ssl_transport_security.c',
'src/core/tsi/transport_security.c', 'src/core/tsi/transport_security.c',
'src/core/tsi/transport_security_adapter.c',
'src/core/ext/transport/chttp2/server/chttp2_server.c', 'src/core/ext/transport/chttp2/server/chttp2_server.c',
'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c', 'src/core/ext/transport/chttp2/client/secure/secure_channel_create.c',
'src/core/ext/filters/client_channel/channel_connectivity.c', 'src/core/ext/filters/client_channel/channel_connectivity.c',
@ -662,8 +670,10 @@ Pod::Spec.new do |s|
'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c', 'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_common.c',
@ -698,9 +708,13 @@ Pod::Spec.new do |s|
ss.private_header_files = 'src/core/lib/profiling/timers.h', ss.private_header_files = 'src/core/lib/profiling/timers.h',
'src/core/lib/support/arena.h', 'src/core/lib/support/arena.h',
'src/core/lib/support/atomic.h',
'src/core/lib/support/atomic_with_atm.h',
'src/core/lib/support/atomic_with_std.h',
'src/core/lib/support/backoff.h', 'src/core/lib/support/backoff.h',
'src/core/lib/support/block_annotate.h', 'src/core/lib/support/block_annotate.h',
'src/core/lib/support/env.h', 'src/core/lib/support/env.h',
'src/core/lib/support/memory.h',
'src/core/lib/support/mpscq.h', 'src/core/lib/support/mpscq.h',
'src/core/lib/support/murmur_hash.h', 'src/core/lib/support/murmur_hash.h',
'src/core/lib/support/spinlock.h', 'src/core/lib/support/spinlock.h',
@ -862,6 +876,7 @@ Pod::Spec.new do |s|
'src/core/tsi/ssl_transport_security.h', 'src/core/tsi/ssl_transport_security.h',
'src/core/tsi/ssl_types.h', 'src/core/tsi/ssl_types.h',
'src/core/tsi/transport_security.h', 'src/core/tsi/transport_security.h',
'src/core/tsi/transport_security_adapter.h',
'src/core/tsi/transport_security_interface.h', 'src/core/tsi/transport_security_interface.h',
'src/core/ext/transport/chttp2/server/chttp2_server.h', 'src/core/ext/transport/chttp2/server/chttp2_server.h',
'src/core/ext/filters/client_channel/client_channel.h', 'src/core/ext/filters/client_channel/client_channel.h',
@ -884,8 +899,10 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/uri_parser.h', 'src/core/ext/filters/client_channel/uri_parser.h',
'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h',
'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
'third_party/nanopb/pb.h', 'third_party/nanopb/pb.h',

@ -89,7 +89,6 @@ EXPORTS
grpc_server_request_registered_call grpc_server_request_registered_call
grpc_server_create grpc_server_create
grpc_server_register_completion_queue grpc_server_register_completion_queue
grpc_server_register_non_listening_completion_queue
grpc_server_add_insecure_http2_port grpc_server_add_insecure_http2_port
grpc_server_start grpc_server_start
grpc_server_shutdown_and_notify grpc_server_shutdown_and_notify
@ -142,10 +141,12 @@ EXPORTS
grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor
grpc_slice_ref grpc_slice_ref
grpc_slice_unref grpc_slice_unref
grpc_slice_copy
grpc_slice_new grpc_slice_new
grpc_slice_new_with_user_data grpc_slice_new_with_user_data
grpc_slice_new_with_len grpc_slice_new_with_len
grpc_slice_malloc grpc_slice_malloc
grpc_slice_malloc_large
grpc_slice_intern grpc_slice_intern
grpc_slice_from_copied_string grpc_slice_from_copied_string
grpc_slice_from_copied_buffer grpc_slice_from_copied_buffer
@ -154,6 +155,7 @@ EXPORTS
grpc_slice_sub grpc_slice_sub
grpc_slice_sub_no_ref grpc_slice_sub_no_ref
grpc_slice_split_tail grpc_slice_split_tail
grpc_slice_split_tail_maybe_ref
grpc_slice_split_head grpc_slice_split_head
grpc_empty_slice grpc_empty_slice
grpc_slice_default_hash_impl grpc_slice_default_hash_impl
@ -182,6 +184,7 @@ EXPORTS
grpc_slice_buffer_move_into grpc_slice_buffer_move_into
grpc_slice_buffer_trim_end grpc_slice_buffer_trim_end
grpc_slice_buffer_move_first grpc_slice_buffer_move_first
grpc_slice_buffer_move_first_no_ref
grpc_slice_buffer_move_first_into_buffer grpc_slice_buffer_move_first_into_buffer
grpc_slice_buffer_take_first grpc_slice_buffer_take_first
grpc_slice_buffer_undo_take_first grpc_slice_buffer_undo_take_first

@ -82,9 +82,13 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/sync_windows.h ) s.files += %w( include/grpc/impl/codegen/sync_windows.h )
s.files += %w( src/core/lib/profiling/timers.h ) s.files += %w( src/core/lib/profiling/timers.h )
s.files += %w( src/core/lib/support/arena.h ) s.files += %w( src/core/lib/support/arena.h )
s.files += %w( src/core/lib/support/atomic.h )
s.files += %w( src/core/lib/support/atomic_with_atm.h )
s.files += %w( src/core/lib/support/atomic_with_std.h )
s.files += %w( src/core/lib/support/backoff.h ) s.files += %w( src/core/lib/support/backoff.h )
s.files += %w( src/core/lib/support/block_annotate.h ) s.files += %w( src/core/lib/support/block_annotate.h )
s.files += %w( src/core/lib/support/env.h ) s.files += %w( src/core/lib/support/env.h )
s.files += %w( src/core/lib/support/memory.h )
s.files += %w( src/core/lib/support/mpscq.h ) s.files += %w( src/core/lib/support/mpscq.h )
s.files += %w( src/core/lib/support/murmur_hash.h ) s.files += %w( src/core/lib/support/murmur_hash.h )
s.files += %w( src/core/lib/support/spinlock.h ) s.files += %w( src/core/lib/support/spinlock.h )
@ -323,6 +327,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/tsi/ssl_transport_security.h ) s.files += %w( src/core/tsi/ssl_transport_security.h )
s.files += %w( src/core/tsi/ssl_types.h ) s.files += %w( src/core/tsi/ssl_types.h )
s.files += %w( src/core/tsi/transport_security.h ) s.files += %w( src/core/tsi/transport_security.h )
s.files += %w( src/core/tsi/transport_security_adapter.h )
s.files += %w( src/core/tsi/transport_security_interface.h ) s.files += %w( src/core/tsi/transport_security_interface.h )
s.files += %w( src/core/ext/transport/chttp2/server/chttp2_server.h ) s.files += %w( src/core/ext/transport/chttp2/server/chttp2_server.h )
s.files += %w( src/core/ext/filters/client_channel/client_channel.h ) s.files += %w( src/core/ext/filters/client_channel/client_channel.h )
@ -345,8 +350,10 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/uri_parser.h ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.h )
s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/ext/filters/deadline/deadline_filter.h )
s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h )
s.files += %w( third_party/nanopb/pb.h ) s.files += %w( third_party/nanopb/pb.h )
@ -478,7 +485,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/surface/completion_queue.c ) s.files += %w( src/core/lib/surface/completion_queue.c )
s.files += %w( src/core/lib/surface/completion_queue_factory.c ) s.files += %w( src/core/lib/surface/completion_queue_factory.c )
s.files += %w( src/core/lib/surface/event_string.c ) s.files += %w( src/core/lib/surface/event_string.c )
s.files += %w( src/core/lib/surface/lame_client.c ) s.files += %w( src/core/lib/surface/lame_client.cc )
s.files += %w( src/core/lib/surface/metadata_array.c ) s.files += %w( src/core/lib/surface/metadata_array.c )
s.files += %w( src/core/lib/surface/server.c ) s.files += %w( src/core/lib/surface/server.c )
s.files += %w( src/core/lib/surface/validate_metadata.c ) s.files += %w( src/core/lib/surface/validate_metadata.c )
@ -550,6 +557,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/tsi/fake_transport_security.c ) s.files += %w( src/core/tsi/fake_transport_security.c )
s.files += %w( src/core/tsi/ssl_transport_security.c ) s.files += %w( src/core/tsi/ssl_transport_security.c )
s.files += %w( src/core/tsi/transport_security.c ) s.files += %w( src/core/tsi/transport_security.c )
s.files += %w( src/core/tsi/transport_security_adapter.c )
s.files += %w( src/core/ext/transport/chttp2/server/chttp2_server.c ) s.files += %w( src/core/ext/transport/chttp2/server/chttp2_server.c )
s.files += %w( src/core/ext/transport/chttp2/client/secure/secure_channel_create.c ) s.files += %w( src/core/ext/transport/chttp2/client/secure/secure_channel_create.c )
s.files += %w( src/core/ext/filters/client_channel/channel_connectivity.c ) s.files += %w( src/core/ext/filters/client_channel/channel_connectivity.c )
@ -578,8 +586,10 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c ) s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c )
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.c ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.c )
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c ) s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c )
s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c )
s.files += %w( third_party/nanopb/pb_common.c ) s.files += %w( third_party/nanopb/pb_common.c )

@ -364,28 +364,6 @@ class CallOpRecvMessage {
bool allow_not_getting_message_; bool allow_not_getting_message_;
}; };
namespace CallOpGenericRecvMessageHelper {
class DeserializeFunc {
public:
virtual Status Deserialize(grpc_byte_buffer* buf) = 0;
virtual ~DeserializeFunc() {}
};
template <class R>
class DeserializeFuncType final : public DeserializeFunc {
public:
DeserializeFuncType(R* message) : message_(message) {}
Status Deserialize(grpc_byte_buffer* buf) override {
return SerializationTraits<R>::Deserialize(buf, message_);
}
~DeserializeFuncType() override {}
private:
R* message_; // Not a managed pointer because management is external to this
};
} // namespace CallOpGenericRecvMessageHelper
class CallOpGenericRecvMessage { class CallOpGenericRecvMessage {
public: public:
CallOpGenericRecvMessage() CallOpGenericRecvMessage()
@ -393,11 +371,9 @@ class CallOpGenericRecvMessage {
template <class R> template <class R>
void RecvMessage(R* message) { void RecvMessage(R* message) {
// Use an explicit base class pointer to avoid resolution error in the deserialize_ = [message](grpc_byte_buffer* buf) -> Status {
// following unique_ptr::reset for some old implementations. return SerializationTraits<R>::Deserialize(buf, message);
CallOpGenericRecvMessageHelper::DeserializeFunc* func = };
new CallOpGenericRecvMessageHelper::DeserializeFuncType<R>(message);
deserialize_.reset(func);
} }
// Do not change status if no message is received. // Do not change status if no message is received.
@ -420,7 +396,7 @@ class CallOpGenericRecvMessage {
if (recv_buf_) { if (recv_buf_) {
if (*status) { if (*status) {
got_message = true; got_message = true;
*status = deserialize_->Deserialize(recv_buf_).ok(); *status = deserialize_(recv_buf_).ok();
} else { } else {
got_message = false; got_message = false;
g_core_codegen_interface->grpc_byte_buffer_destroy(recv_buf_); g_core_codegen_interface->grpc_byte_buffer_destroy(recv_buf_);
@ -431,11 +407,12 @@ class CallOpGenericRecvMessage {
*status = false; *status = false;
} }
} }
deserialize_.reset(); deserialize_ = DeserializeFunc();
} }
private: private:
std::unique_ptr<CallOpGenericRecvMessageHelper::DeserializeFunc> deserialize_; typedef std::function<Status(grpc_byte_buffer*)> DeserializeFunc;
DeserializeFunc deserialize_;
grpc_byte_buffer* recv_buf_; grpc_byte_buffer* recv_buf_;
bool allow_not_getting_message_; bool allow_not_getting_message_;
}; };

@ -52,7 +52,9 @@ template <class InputMessage, class OutputMessage>
Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method,
ClientContext* context, const InputMessage& request, ClientContext* context, const InputMessage& request,
OutputMessage* result) { OutputMessage* result) {
CompletionQueue cq(true); // Pluckable completion queue CompletionQueue cq(grpc_completion_queue_attributes{
GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
GRPC_CQ_DEFAULT_POLLING}); // Pluckable completion queue
Call call(channel->CreateCall(method, context, &cq)); Call call(channel->CreateCall(method, context, &cq));
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>, CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>,

@ -102,7 +102,9 @@ class CompletionQueue : private GrpcLibraryCodegen {
public: public:
/// Default constructor. Implicitly creates a \a grpc_completion_queue /// Default constructor. Implicitly creates a \a grpc_completion_queue
/// instance. /// instance.
CompletionQueue() : CompletionQueue(false) {} CompletionQueue()
: CompletionQueue(grpc_completion_queue_attributes{
GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING}) {}
/// Wrap \a take, taking ownership of the instance. /// Wrap \a take, taking ownership of the instance.
/// ///
@ -182,6 +184,16 @@ class CompletionQueue : private GrpcLibraryCodegen {
}; };
void CompleteAvalanching(); void CompleteAvalanching();
protected:
/// Private constructor of CompletionQueue only visible to friend classes
CompletionQueue(const grpc_completion_queue_attributes& attributes) {
cq_ = g_core_codegen_interface->grpc_completion_queue_create(
g_core_codegen_interface->grpc_completion_queue_factory_lookup(
&attributes),
&attributes, NULL);
InitialAvalanching(); // reserve this for the future shutdown
}
private: private:
// Friend synchronous wrappers so that they can access Pluck(), which is // Friend synchronous wrappers so that they can access Pluck(), which is
// a semi-private API geared towards the synchronous implementation. // a semi-private API geared towards the synchronous implementation.
@ -215,18 +227,6 @@ class CompletionQueue : private GrpcLibraryCodegen {
const InputMessage& request, const InputMessage& request,
OutputMessage* result); OutputMessage* result);
/// Private constructor of CompletionQueue only visible to friend classes
CompletionQueue(bool is_pluck) {
if (is_pluck) {
cq_ = g_core_codegen_interface->grpc_completion_queue_create_for_pluck(
nullptr);
} else {
cq_ = g_core_codegen_interface->grpc_completion_queue_create_for_next(
nullptr);
}
InitialAvalanching(); // reserve this for the future shutdown
}
NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline); NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline);
/// Wraps \a grpc_completion_queue_pluck. /// Wraps \a grpc_completion_queue_pluck.
@ -289,17 +289,19 @@ class CompletionQueue : private GrpcLibraryCodegen {
/// by servers. Instantiated by \a ServerBuilder. /// by servers. Instantiated by \a ServerBuilder.
class ServerCompletionQueue : public CompletionQueue { class ServerCompletionQueue : public CompletionQueue {
public: public:
bool IsFrequentlyPolled() { return is_frequently_polled_; } bool IsFrequentlyPolled() { return polling_type_ != GRPC_CQ_NON_LISTENING; }
private: private:
bool is_frequently_polled_; grpc_cq_polling_type polling_type_;
friend class ServerBuilder; friend class ServerBuilder;
/// \param is_frequently_polled Informs the GRPC library about whether the /// \param is_frequently_polled Informs the GRPC library about whether the
/// server completion queue would be actively polled (by calling Next() or /// server completion queue would be actively polled (by calling Next() or
/// AsyncNext()). By default all server completion queues are assumed to be /// AsyncNext()). By default all server completion queues are assumed to be
/// frequently polled. /// frequently polled.
ServerCompletionQueue(bool is_frequently_polled = true) ServerCompletionQueue(grpc_cq_polling_type polling_type)
: is_frequently_polled_(is_frequently_polled) {} : CompletionQueue(grpc_completion_queue_attributes{
GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, polling_type}),
polling_type_(polling_type) {}
}; };
} // namespace grpc } // namespace grpc

@ -44,8 +44,15 @@
namespace grpc { namespace grpc {
/// Implementation of the core codegen interface. /// Implementation of the core codegen interface.
class CoreCodegen : public CoreCodegenInterface { class CoreCodegen final : public CoreCodegenInterface {
private: private:
virtual const grpc_completion_queue_factory*
grpc_completion_queue_factory_lookup(
const grpc_completion_queue_attributes* attributes) override;
virtual grpc_completion_queue* grpc_completion_queue_create(
const grpc_completion_queue_factory* factory,
const grpc_completion_queue_attributes* attributes,
void* reserved) override;
grpc_completion_queue* grpc_completion_queue_create_for_next( grpc_completion_queue* grpc_completion_queue_create_for_next(
void* reserved) override; void* reserved) override;
grpc_completion_queue* grpc_completion_queue_create_for_pluck( grpc_completion_queue* grpc_completion_queue_create_for_pluck(

@ -59,6 +59,12 @@ class CoreCodegenInterface {
virtual void assert_fail(const char* failed_assertion, const char* file, virtual void assert_fail(const char* failed_assertion, const char* file,
int line) = 0; int line) = 0;
virtual const grpc_completion_queue_factory*
grpc_completion_queue_factory_lookup(
const grpc_completion_queue_attributes* attributes) = 0;
virtual grpc_completion_queue* grpc_completion_queue_create(
const grpc_completion_queue_factory* factory,
const grpc_completion_queue_attributes* attributes, void* reserved) = 0;
virtual grpc_completion_queue* grpc_completion_queue_create_for_next( virtual grpc_completion_queue* grpc_completion_queue_create_for_next(
void* reserved) = 0; void* reserved) = 0;
virtual grpc_completion_queue* grpc_completion_queue_create_for_pluck( virtual grpc_completion_queue* grpc_completion_queue_create_for_pluck(

@ -52,7 +52,7 @@ namespace internal {
class GrpcBufferWriterPeer; class GrpcBufferWriterPeer;
const int kGrpcBufferWriterMaxBufferLength = 8192; const int kGrpcBufferWriterMaxBufferLength = 1024 * 1024;
class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream { class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream {
public: public:

@ -156,7 +156,9 @@ class ClientReader final : public ClientReaderInterface<R> {
ClientReader(ChannelInterface* channel, const RpcMethod& method, ClientReader(ChannelInterface* channel, const RpcMethod& method,
ClientContext* context, const W& request) ClientContext* context, const W& request)
: context_(context), : context_(context),
cq_(true), // Pluckable cq cq_(grpc_completion_queue_attributes{
GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
call_(channel->CreateCall(method, context, &cq_)) { call_(channel->CreateCall(method, context, &cq_)) {
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
CallOpClientSendClose> CallOpClientSendClose>
@ -230,7 +232,9 @@ class ClientWriter : public ClientWriterInterface<W> {
ClientWriter(ChannelInterface* channel, const RpcMethod& method, ClientWriter(ChannelInterface* channel, const RpcMethod& method,
ClientContext* context, R* response) ClientContext* context, R* response)
: context_(context), : context_(context),
cq_(true), // Pluckable cq cq_(grpc_completion_queue_attributes{
GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
call_(channel->CreateCall(method, context, &cq_)) { call_(channel->CreateCall(method, context, &cq_)) {
finish_ops_.RecvMessage(response); finish_ops_.RecvMessage(response);
finish_ops_.AllowNoMessage(); finish_ops_.AllowNoMessage();
@ -330,7 +334,9 @@ class ClientReaderWriter final : public ClientReaderWriterInterface<W, R> {
ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method,
ClientContext* context) ClientContext* context)
: context_(context), : context_(context),
cq_(true), // Pluckable cq cq_(grpc_completion_queue_attributes{
GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK,
GRPC_CQ_DEFAULT_POLLING}), // Pluckable cq
call_(channel->CreateCall(method, context, &cq_)) { call_(channel->CreateCall(method, context, &cq_)) {
if (!context_->initial_metadata_corked_) { if (!context_->initial_metadata_corked_) {
CallOpSet<CallOpSendInitialMetadata> ops; CallOpSet<CallOpSendInitialMetadata> ops;

@ -1,217 +0,0 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPCXX_IMPL_CODEGEN_THRIFT_SERIALIZER_H
#define GRPCXX_IMPL_CODEGEN_THRIFT_SERIALIZER_H
#include <grpc/impl/codegen/byte_buffer_reader.h>
#include <grpc/impl/codegen/slice.h>
#include <thrift/protocol/TBinaryProtocol.h>
#include <thrift/protocol/TCompactProtocol.h>
#include <thrift/protocol/TProtocolException.h>
#include <thrift/transport/TBufferTransports.h>
#include <thrift/transport/TTransportUtils.h>
#include <boost/make_shared.hpp>
#include <memory>
#include <stdexcept>
#include <string>
namespace apache {
namespace thrift {
namespace util {
using apache::thrift::protocol::TBinaryProtocolT;
using apache::thrift::protocol::TCompactProtocolT;
using apache::thrift::protocol::TMessageType;
using apache::thrift::protocol::TNetworkBigEndian;
using apache::thrift::transport::TMemoryBuffer;
using apache::thrift::transport::TBufferBase;
using apache::thrift::transport::TTransport;
template <typename Dummy, typename Protocol>
class ThriftSerializer {
public:
ThriftSerializer()
: prepared_(false),
last_deserialized_(false),
serialize_version_(false) {}
virtual ~ThriftSerializer() {}
// Serialize the passed type into the internal buffer
// and returns a pointer to internal buffer and its size
template <typename T>
void Serialize(const T& fields, const uint8_t** serialized_buffer,
size_t* serialized_len) {
// prepare or reset buffer
if (!prepared_ || last_deserialized_) {
prepare();
} else {
buffer_->resetBuffer();
}
last_deserialized_ = false;
// if required serialize protocol version
if (serialize_version_) {
protocol_->writeMessageBegin("", TMessageType(0), 0);
}
// serialize fields into buffer
fields.write(protocol_.get());
// write the end of message
if (serialize_version_) {
protocol_->writeMessageEnd();
}
uint8_t* byte_buffer;
uint32_t byte_buffer_size;
buffer_->getBuffer(&byte_buffer, &byte_buffer_size);
*serialized_buffer = byte_buffer;
*serialized_len = byte_buffer_size;
}
// Serialize the passed type into the byte buffer
template <typename T>
void Serialize(const T& fields, grpc_byte_buffer** bp) {
const uint8_t* byte_buffer;
size_t byte_buffer_size;
Serialize(fields, &byte_buffer, &byte_buffer_size);
grpc_slice slice = grpc_slice_from_copied_buffer(
reinterpret_cast<const char*>(byte_buffer), byte_buffer_size);
*bp = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
}
// Deserialize the passed char array into the passed type, returns the number
// of bytes that have been consumed from the passed string.
template <typename T>
uint32_t Deserialize(uint8_t* serialized_buffer, size_t length, T* fields) {
// prepare buffer if necessary
if (!prepared_) {
prepare();
}
last_deserialized_ = true;
// reset buffer transport
buffer_->resetBuffer(serialized_buffer, length);
// read the protocol version if necessary
if (serialize_version_) {
std::string name = "";
TMessageType mt = static_cast<TMessageType>(0);
int32_t seq_id = 0;
protocol_->readMessageBegin(name, mt, seq_id);
}
// deserialize buffer into fields
uint32_t len = fields->read(protocol_.get());
// read the end of message
if (serialize_version_) {
protocol_->readMessageEnd();
}
return len;
}
// Deserialize the passed byte buffer to passed type, returns the number
// of bytes consumed from byte buffer
template <typename T>
uint32_t Deserialize(grpc_byte_buffer* buffer, T* msg) {
grpc_byte_buffer_reader reader;
grpc_byte_buffer_reader_init(&reader, buffer);
grpc_slice slice = grpc_byte_buffer_reader_readall(&reader);
uint32_t len =
Deserialize(GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice), msg);
grpc_slice_unref(slice);
grpc_byte_buffer_reader_destroy(&reader);
return len;
}
// set serialization version flag
void SetSerializeVersion(bool value) { serialize_version_ = value; }
// Set the container size limit to deserialize
// This function should be called after buffer_ is initialized
void SetContainerSizeLimit(int32_t container_limit) {
if (!prepared_) {
prepare();
}
protocol_->setContainerSizeLimit(container_limit);
}
// Set the string size limit to deserialize
// This function should be called after buffer_ is initialized
void SetStringSizeLimit(int32_t string_limit) {
if (!prepared_) {
prepare();
}
protocol_->setStringSizeLimit(string_limit);
}
private:
bool prepared_;
bool last_deserialized_;
boost::shared_ptr<TMemoryBuffer> buffer_;
std::shared_ptr<Protocol> protocol_;
bool serialize_version_;
void prepare() {
buffer_ = boost::make_shared<TMemoryBuffer>();
// create a protocol for the memory buffer transport
protocol_ = std::make_shared<Protocol>(buffer_);
prepared_ = true;
}
}; // ThriftSerializer
typedef ThriftSerializer<void, TBinaryProtocolT<TBufferBase, TNetworkBigEndian>>
ThriftSerializerBinary;
typedef ThriftSerializer<void, TCompactProtocolT<TBufferBase>>
ThriftSerializerCompact;
} // namespace util
} // namespace thrift
} // namespace apache
#endif // GRPCXX_IMPL_CODEGEN_THRIFT_SERIALIZER_H

@ -0,0 +1,163 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPCXX_TEST_MOCK_STREAM_H
#define GRPCXX_TEST_MOCK_STREAM_H
#include <stdint.h>
#include <gmock/gmock.h>
#include <grpc++/impl/codegen/call.h>
#include <grpc++/support/async_stream.h>
#include <grpc++/support/async_unary_call.h>
#include <grpc++/support/sync_stream.h>
namespace grpc {
namespace testing {
template <class R>
class MockClientReader : public ClientReaderInterface<R> {
public:
MockClientReader() = default;
// ClientStreamingInterface
MOCK_METHOD0_T(Finish, Status());
// ReaderInterface
MOCK_METHOD1_T(NextMessageSize, bool(uint32_t*));
MOCK_METHOD1_T(Read, bool(R*));
// ClientReaderInterface
MOCK_METHOD0_T(WaitForInitialMetadata, void());
};
template <class W>
class MockClientWriter : public ClientWriterInterface<W> {
public:
MockClientWriter() = default;
// ClientStreamingInterface
MOCK_METHOD0_T(Finish, Status());
// WriterInterface
MOCK_METHOD2_T(Write, bool(const W&, const WriteOptions));
// ClientWriterInterface
MOCK_METHOD0_T(WritesDone, bool());
};
template <class W, class R>
class MockClientReaderWriter : public ClientReaderWriterInterface<W, R> {
public:
MockClientReaderWriter() = default;
// ClientStreamingInterface
MOCK_METHOD0_T(Finish, Status());
// ReaderInterface
MOCK_METHOD1_T(NextMessageSize, bool(uint32_t*));
MOCK_METHOD1_T(Read, bool(R*));
// WriterInterface
MOCK_METHOD2_T(Write, bool(const W&, const WriteOptions));
// ClientReaderWriterInterface
MOCK_METHOD0_T(WaitForInitialMetadata, void());
MOCK_METHOD0_T(WritesDone, bool());
};
// TODO: We do not support mocking an async RPC for now.
template <class R>
class MockClientAsyncResponseReader
: public ClientAsyncResponseReaderInterface<R> {
public:
MockClientAsyncResponseReader() = default;
MOCK_METHOD1_T(ReadInitialMetadata, void(void*));
MOCK_METHOD3_T(Finish, void(R*, Status*, void*));
};
template <class R>
class MockClientAsyncReader : public ClientAsyncReaderInterface<R> {
public:
MockClientAsyncReader() = default;
// ClientAsyncStreamingInterface
MOCK_METHOD1_T(ReadInitialMetadata, void(void*));
MOCK_METHOD2_T(Finish, void(Status*, void*));
// AsyncReaderInterface
MOCK_METHOD2_T(Read, void(R*, void*));
};
template <class W>
class MockClientAsyncWriter : public ClientAsyncWriterInterface<W> {
public:
MockClientAsyncWriter() = default;
// ClientAsyncStreamingInterface
MOCK_METHOD1_T(ReadInitialMetadata, void(void*));
MOCK_METHOD2_T(Finish, void(Status*, void*));
// AsyncWriterInterface
MOCK_METHOD2_T(Write, void(const W&, void*));
// ClientAsyncWriterInterface
MOCK_METHOD1_T(WritesDone, void(void*));
};
template <class W, class R>
class MockClientAsyncReaderWriter
: public ClientAsyncReaderWriterInterface<W, R> {
public:
MockClientAsyncReaderWriter() = default;
// ClientAsyncStreamingInterface
MOCK_METHOD1_T(ReadInitialMetadata, void(void*));
MOCK_METHOD2_T(Finish, void(Status*, void*));
// AsyncWriterInterface
MOCK_METHOD2_T(Write, void(const W&, void*));
// AsyncReaderInterface
MOCK_METHOD2_T(Read, void(R*, void*));
// ClientAsyncReaderWriterInterface
MOCK_METHOD1_T(WritesDone, void(void*));
};
} // namespace testing
} // namespace grpc
#endif // GRPCXX_TEST_MOCK_STREAM_H

@ -93,55 +93,6 @@ GRPCAPI const char *grpc_version_string(void);
/** Return a string specifying what the 'g' in gRPC stands for */ /** Return a string specifying what the 'g' in gRPC stands for */
GRPCAPI const char *grpc_g_stands_for(void); GRPCAPI const char *grpc_g_stands_for(void);
/** Specifies the type of APIs to use to pop events from the completion queue */
typedef enum {
/** Events are popped out by calling grpc_completion_queue_next() API ONLY */
GRPC_CQ_NEXT = 1,
/** Events are popped out by calling grpc_completion_queue_pluck() API ONLY*/
GRPC_CQ_PLUCK
} grpc_cq_completion_type;
/** Completion queues internally MAY maintain a set of file descriptors in a
structure called 'pollset'. This enum specifies if a completion queue has an
associated pollset and any restrictions on the type of file descriptors that
can be present in the pollset.
I/O progress can only be made when grpc_completion_queue_next() or
grpc_completion_queue_pluck() are called on the completion queue (unless the
grpc_cq_polling_type is GRPC_CQ_NON_POLLING) and hence it is very important
to actively call these APIs */
typedef enum {
/** The completion queue will have an associated pollset and there is no
restriction on the type of file descriptors the pollset may contain */
GRPC_CQ_DEFAULT_POLLING,
/** Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will
not contain any 'listening file descriptors' (i.e file descriptors used to
listen to incoming channels) */
GRPC_CQ_NON_LISTENING,
/** The completion queue will not have an associated pollset. Note that
grpc_completion_queue_next() or grpc_completion_queue_pluck() MUST still
be called to pop events from the completion queue; it is not required to
call them actively to make I/O progress */
GRPC_CQ_NON_POLLING
} grpc_cq_polling_type;
#define GRPC_CQ_CURRENT_VERSION 1
typedef struct grpc_completion_queue_attributes {
/* The version number of this structure. More fields might be added to this
structure in future. */
int version; /* Set to GRPC_CQ_CURRENT_VERSION */
grpc_cq_completion_type cq_completion_type;
grpc_cq_polling_type cq_polling_type;
} grpc_completion_queue_attributes;
/** The completion queue factory structure is opaque to the callers of grpc */
typedef struct grpc_completion_queue_factory grpc_completion_queue_factory;
/** Returns the completion queue factory based on the attributes. MAY return a /** Returns the completion queue factory based on the attributes. MAY return a
NULL if no factory can be found */ NULL if no factory can be found */
GRPCAPI const grpc_completion_queue_factory * GRPCAPI const grpc_completion_queue_factory *
@ -427,15 +378,6 @@ GRPCAPI void grpc_server_register_completion_queue(grpc_server *server,
grpc_completion_queue *cq, grpc_completion_queue *cq,
void *reserved); void *reserved);
/** Register a non-listening completion queue with the server. This API is
similar to grpc_server_register_completion_queue except that the server will
not use this completion_queue to listen to any incoming channels.
Registering a non-listening completion queue will have negative performance
impact and hence this API is not recommended for production use cases. */
GRPCAPI void grpc_server_register_non_listening_completion_queue(
grpc_server *server, grpc_completion_queue *q, void *reserved);
/** Add a HTTP2 over plaintext over tcp listener. /** Add a HTTP2 over plaintext over tcp listener.
Returns bound port number on success, 0 on failure. Returns bound port number on success, 0 on failure.
REQUIRES: server not started */ REQUIRES: server not started */

@ -158,7 +158,7 @@ typedef struct {
} grpc_ssl_pem_key_cert_pair; } grpc_ssl_pem_key_cert_pair;
/* Creates an SSL credentials object. /* Creates an SSL credentials object.
- pem_roots_cert is the NULL-terminated string containing the PEM encoding - pem_root_certs is the NULL-terminated string containing the PEM encoding
of the server root certificates. If this parameter is NULL, the of the server root certificates. If this parameter is NULL, the
implementation will first try to dereference the file pointed by the implementation will first try to dereference the file pointed by the
GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails, GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails,

@ -34,8 +34,7 @@
#ifndef GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H #ifndef GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H
#define GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H #define GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H
#include <stdbool.h> #include <grpc/impl/codegen/port_platform.h>
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -101,7 +100,7 @@ typedef struct grpc_compression_options {
* precedence over \a default_algorithm. * precedence over \a default_algorithm.
* TODO(dgq): currently only available for server channels. */ * TODO(dgq): currently only available for server channels. */
struct { struct {
bool is_set; int is_set;
grpc_compression_level level; grpc_compression_level level;
} default_level; } default_level;
@ -109,7 +108,7 @@ typedef struct grpc_compression_options {
* call specific settings. This option corresponds to the channel argument key * call specific settings. This option corresponds to the channel argument key
* behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM. */ * behind \a GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM. */
struct { struct {
bool is_set; int is_set;
grpc_compression_algorithm algorithm; grpc_compression_algorithm algorithm;
} default_algorithm; } default_algorithm;

@ -37,7 +37,6 @@
#include <grpc/impl/codegen/port_platform.h> #include <grpc/impl/codegen/port_platform.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

@ -34,6 +34,8 @@
#ifndef GRPC_IMPL_CODEGEN_GRPC_TYPES_H #ifndef GRPC_IMPL_CODEGEN_GRPC_TYPES_H
#define GRPC_IMPL_CODEGEN_GRPC_TYPES_H #define GRPC_IMPL_CODEGEN_GRPC_TYPES_H
#include <grpc/impl/codegen/port_platform.h>
#include <grpc/impl/codegen/compression_types.h> #include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/exec_ctx_fwd.h> #include <grpc/impl/codegen/exec_ctx_fwd.h>
#include <grpc/impl/codegen/gpr_types.h> #include <grpc/impl/codegen/gpr_types.h>
@ -41,7 +43,6 @@
#include <grpc/impl/codegen/status.h> #include <grpc/impl/codegen/status.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -292,6 +293,9 @@ each time recvmsg (or equivalent) is called */
"grpc.experimental.tcp_min_read_chunk_size" "grpc.experimental.tcp_min_read_chunk_size"
#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \ #define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \
"grpc.experimental.tcp_max_read_chunk_size" "grpc.experimental.tcp_max_read_chunk_size"
/* Timeout in milliseconds to use for calls to the grpclb load balancer.
If 0 or unset, the balancer calls will have no deadline. */
#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_timeout_ms"
/** \} */ /** \} */
/** Result of a grpc call. If the caller satisfies the prerequisites of a /** Result of a grpc call. If the caller satisfies the prerequisites of a
@ -556,6 +560,55 @@ typedef struct {
typedef struct grpc_resource_quota grpc_resource_quota; typedef struct grpc_resource_quota grpc_resource_quota;
/** Completion queues internally MAY maintain a set of file descriptors in a
structure called 'pollset'. This enum specifies if a completion queue has an
associated pollset and any restrictions on the type of file descriptors that
can be present in the pollset.
I/O progress can only be made when grpc_completion_queue_next() or
grpc_completion_queue_pluck() are called on the completion queue (unless the
grpc_cq_polling_type is GRPC_CQ_NON_POLLING) and hence it is very important
to actively call these APIs */
typedef enum {
/** The completion queue will have an associated pollset and there is no
restriction on the type of file descriptors the pollset may contain */
GRPC_CQ_DEFAULT_POLLING,
/** Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will
not contain any 'listening file descriptors' (i.e file descriptors used to
listen to incoming channels) */
GRPC_CQ_NON_LISTENING,
/** The completion queue will not have an associated pollset. Note that
grpc_completion_queue_next() or grpc_completion_queue_pluck() MUST still
be called to pop events from the completion queue; it is not required to
call them actively to make I/O progress */
GRPC_CQ_NON_POLLING
} grpc_cq_polling_type;
/** Specifies the type of APIs to use to pop events from the completion queue */
typedef enum {
/** Events are popped out by calling grpc_completion_queue_next() API ONLY */
GRPC_CQ_NEXT = 1,
/** Events are popped out by calling grpc_completion_queue_pluck() API ONLY*/
GRPC_CQ_PLUCK
} grpc_cq_completion_type;
#define GRPC_CQ_CURRENT_VERSION 1
typedef struct grpc_completion_queue_attributes {
/* The version number of this structure. More fields might be added to this
structure in future. */
int version; /* Set to GRPC_CQ_CURRENT_VERSION */
grpc_cq_completion_type cq_completion_type;
grpc_cq_polling_type cq_polling_type;
} grpc_completion_queue_attributes;
/** The completion queue factory structure is opaque to the callers of grpc */
typedef struct grpc_completion_queue_factory grpc_completion_queue_factory;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -189,7 +189,7 @@
#ifdef __GLIBC__ #ifdef __GLIBC__
#define GPR_POSIX_CRASH_HANDLER 1 #define GPR_POSIX_CRASH_HANDLER 1
#else /* musl libc */ #else /* musl libc */
#define GRPC_MSG_IOVLEN_TYPE int #define GPR_MUSL_LIBC_COMPAT 1
#endif #endif
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <Availability.h> #include <Availability.h>
@ -290,6 +290,12 @@
#endif #endif
#endif /* GPR_NO_AUTODETECT_PLATFORM */ #endif /* GPR_NO_AUTODETECT_PLATFORM */
#if defined(__has_include)
#if __has_include(<atomic>)
#define GRPC_HAS_CXX11_ATOMIC
#endif /* __has_include(<atomic>) */
#endif /* defined(__has_include) */
#ifndef GPR_PLATFORM_STRING #ifndef GPR_PLATFORM_STRING
#warning "GPR_PLATFORM_STRING not auto-detected" #warning "GPR_PLATFORM_STRING not auto-detected"
#define GPR_PLATFORM_STRING "unknown" #define GPR_PLATFORM_STRING "unknown"

@ -34,8 +34,9 @@
#ifndef GRPC_IMPL_CODEGEN_SLICE_H #ifndef GRPC_IMPL_CODEGEN_SLICE_H
#define GRPC_IMPL_CODEGEN_SLICE_H #define GRPC_IMPL_CODEGEN_SLICE_H
#include <grpc/impl/codegen/port_platform.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <grpc/impl/codegen/exec_ctx_fwd.h> #include <grpc/impl/codegen/exec_ctx_fwd.h>
#include <grpc/impl/codegen/gpr_slice.h> #include <grpc/impl/codegen/gpr_slice.h>

@ -53,6 +53,9 @@ GPRAPI grpc_slice grpc_slice_ref(grpc_slice s);
where dest!=NULL , then (*dest)(start, len). Requires s initialized. */ where dest!=NULL , then (*dest)(start, len). Requires s initialized. */
GPRAPI void grpc_slice_unref(grpc_slice s); GPRAPI void grpc_slice_unref(grpc_slice s);
/* Copy slice - create a new slice that contains the same data as s */
GPRAPI grpc_slice grpc_slice_copy(grpc_slice s);
/* Create a slice pointing at some data. Calls malloc to allocate a refcount /* Create a slice pointing at some data. Calls malloc to allocate a refcount
for the object, and arranges that destroy will be called with the pointer for the object, and arranges that destroy will be called with the pointer
passed in at destruction. */ passed in at destruction. */
@ -75,6 +78,13 @@ GPRAPI grpc_slice grpc_slice_new_with_len(void *p, size_t len,
call. call.
Aborts if malloc() fails. */ Aborts if malloc() fails. */
GPRAPI grpc_slice grpc_slice_malloc(size_t length); GPRAPI grpc_slice grpc_slice_malloc(size_t length);
GPRAPI grpc_slice grpc_slice_malloc_large(size_t length);
#define GRPC_SLICE_MALLOC(len) \
((len) <= GRPC_SLICE_INLINED_SIZE \
? (grpc_slice){.refcount = NULL, \
.data.inlined = {.length = (uint8_t)(len)}} \
: grpc_slice_malloc_large((len)))
/* Intern a slice: /* Intern a slice:
@ -117,6 +127,18 @@ GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end);
Requires s intialized, split <= s.length */ Requires s intialized, split <= s.length */
GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split); GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split);
typedef enum {
GRPC_SLICE_REF_TAIL = 1,
GRPC_SLICE_REF_HEAD = 2,
GRPC_SLICE_REF_BOTH = 1 + 2
} grpc_slice_ref_whom;
/* The same as grpc_slice_split_tail, but with an option to skip altering
* refcounts (grpc_slice_split_tail_maybe_ref(..., true) is equivalent to
* grpc_slice_split_tail(...)) */
GPRAPI grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *s, size_t split,
grpc_slice_ref_whom ref_whom);
/* Splits s into two: modifies s to be s[split:s.length], and returns a new /* Splits s into two: modifies s to be s[split:s.length], and returns a new
slice, sharing a refcount with s, that contains s[0:split]. slice, sharing a refcount with s, that contains s[0:split].
Requires s intialized, split <= s.length */ Requires s intialized, split <= s.length */

@ -77,6 +77,10 @@ GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n,
/* move the first n bytes of src into dst */ /* move the first n bytes of src into dst */
GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n,
grpc_slice_buffer *dst); grpc_slice_buffer *dst);
/* move the first n bytes of src into dst without adding references */
GPRAPI void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer *src,
size_t n,
grpc_slice_buffer *dst);
/* move the first n bytes of src into dst (copying them) */ /* move the first n bytes of src into dst (copying them) */
GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx, GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
grpc_slice_buffer *src, grpc_slice_buffer *src,

@ -34,8 +34,7 @@
"lodash": "^4.15.0", "lodash": "^4.15.0",
"nan": "^2.0.0", "nan": "^2.0.0",
"node-pre-gyp": "^0.6.0", "node-pre-gyp": "^0.6.0",
"protobufjs": "^6.7.0", "protobufjs": "^6.7.0"
"cares": "^1.1.5"
}, },
"devDependencies": { "devDependencies": {
"async": "^2.0.1", "async": "^2.0.1",

@ -91,9 +91,13 @@
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_windows.h" role="src" /> <file baseinstalldir="/" name="include/grpc/impl/codegen/sync_windows.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/arena.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/support/arena.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/atomic.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/atomic_with_atm.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/atomic_with_std.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/backoff.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/support/backoff.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/block_annotate.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/support/block_annotate.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/env.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/support/env.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/memory.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/mpscq.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/support/mpscq.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/murmur_hash.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/support/murmur_hash.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/support/spinlock.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/support/spinlock.h" role="src" />
@ -332,6 +336,7 @@
<file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl_types.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/ssl_types.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security_adapter.h" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security_interface.h" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security_interface.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/chttp2_server.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/chttp2_server.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/client_channel.h" role="src" />
@ -354,8 +359,10 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/uri_parser.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/uri_parser.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb.h" role="src" /> <file baseinstalldir="/" name="third_party/nanopb/pb.h" role="src" />
@ -487,7 +494,7 @@
<file baseinstalldir="/" name="src/core/lib/surface/completion_queue.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/completion_queue.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/completion_queue_factory.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/completion_queue_factory.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/event_string.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/event_string.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/lame_client.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/lame_client.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/metadata_array.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/metadata_array.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/server.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/server.c" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/validate_metadata.c" role="src" /> <file baseinstalldir="/" name="src/core/lib/surface/validate_metadata.c" role="src" />
@ -559,6 +566,7 @@
<file baseinstalldir="/" name="src/core/tsi/fake_transport_security.c" role="src" /> <file baseinstalldir="/" name="src/core/tsi/fake_transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.c" role="src" /> <file baseinstalldir="/" name="src/core/tsi/ssl_transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security.c" role="src" /> <file baseinstalldir="/" name="src/core/tsi/transport_security.c" role="src" />
<file baseinstalldir="/" name="src/core/tsi/transport_security_adapter.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/chttp2_server.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/chttp2_server.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/secure/secure_channel_create.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/secure/secure_channel_create.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/channel_connectivity.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/channel_connectivity.c" role="src" />
@ -587,8 +595,10 @@
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.c" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c" role="src" /> <file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c" role="src" />
<file baseinstalldir="/" name="third_party/nanopb/pb_common.c" role="src" /> <file baseinstalldir="/" name="third_party/nanopb/pb_common.c" role="src" />

@ -104,6 +104,7 @@ EXTRA_ENV_LINK_ARGS = os.environ.get('GRPC_PYTHON_LDFLAGS', None)
if EXTRA_ENV_COMPILE_ARGS is None: if EXTRA_ENV_COMPILE_ARGS is None:
EXTRA_ENV_COMPILE_ARGS = '' EXTRA_ENV_COMPILE_ARGS = ''
if 'win32' in sys.platform and sys.version_info < (3, 5): if 'win32' in sys.platform and sys.version_info < (3, 5):
EXTRA_ENV_COMPILE_ARGS += ' -std=c++11'
# We use define flags here and don't directly add to DEFINE_MACROS below to # We use define flags here and don't directly add to DEFINE_MACROS below to
# ensure that the expert user/builder has a way of turning it off (via the # ensure that the expert user/builder has a way of turning it off (via the
# envvars) without adding yet more GRPC-specific envvars. # envvars) without adding yet more GRPC-specific envvars.
@ -114,7 +115,9 @@ if EXTRA_ENV_COMPILE_ARGS is None:
EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime64 -D_timeb=__timeb64' EXTRA_ENV_COMPILE_ARGS += ' -D_ftime=_ftime64 -D_timeb=__timeb64'
elif 'win32' in sys.platform: elif 'win32' in sys.platform:
EXTRA_ENV_COMPILE_ARGS += ' -D_PYTHON_MSVC' EXTRA_ENV_COMPILE_ARGS += ' -D_PYTHON_MSVC'
elif "linux" in sys.platform or "darwin" in sys.platform: elif "linux" in sys.platform:
EXTRA_ENV_COMPILE_ARGS += ' -std=c++11 -fvisibility=hidden -fno-wrapv'
elif "darwin" in sys.platform:
EXTRA_ENV_COMPILE_ARGS += ' -fvisibility=hidden -fno-wrapv' EXTRA_ENV_COMPILE_ARGS += ' -fvisibility=hidden -fno-wrapv'
if EXTRA_ENV_LINK_ARGS is None: if EXTRA_ENV_LINK_ARGS is None:
@ -141,6 +144,8 @@ CYTHON_EXTENSION_MODULE_NAMES = ('grpc._cython.cygrpc',)
CYTHON_HELPER_C_FILES = () CYTHON_HELPER_C_FILES = ()
CORE_C_FILES = tuple(grpc_core_dependencies.CORE_SOURCE_FILES) CORE_C_FILES = tuple(grpc_core_dependencies.CORE_SOURCE_FILES)
if "win32" in sys.platform and "64bit" in platform.architecture()[0]:
CORE_C_FILES = filter(lambda x: 'third_party/cares' not in x, CORE_C_FILES)
EXTENSION_INCLUDE_DIRECTORIES = ( EXTENSION_INCLUDE_DIRECTORIES = (
(PYTHON_STEM,) + CORE_INCLUDE + BORINGSSL_INCLUDE + ZLIB_INCLUDE + (PYTHON_STEM,) + CORE_INCLUDE + BORINGSSL_INCLUDE + ZLIB_INCLUDE +
@ -160,7 +165,9 @@ DEFINE_MACROS = (
if "win32" in sys.platform: if "win32" in sys.platform:
DEFINE_MACROS += (('WIN32_LEAN_AND_MEAN', 1), ('CARES_STATICLIB', 1),) DEFINE_MACROS += (('WIN32_LEAN_AND_MEAN', 1), ('CARES_STATICLIB', 1),)
if '64bit' in platform.architecture()[0]: if '64bit' in platform.architecture()[0]:
DEFINE_MACROS += (('MS_WIN64', 1),) # TODO(zyc): Re-enble c-ares on x64 windows after fixing the
# ares_library_init compilation issue
DEFINE_MACROS += (('MS_WIN64', 1), ('GRPC_ARES', 0),)
elif sys.version_info >= (3, 5): elif sys.version_info >= (3, 5):
# For some reason, this is needed to get access to inet_pton/inet_ntop # For some reason, this is needed to get access to inet_pton/inet_ntop
# on msvc, but only for 32 bits # on msvc, but only for 32 bits
@ -192,13 +199,25 @@ def cython_extensions_and_necessity():
cython_module_files = [os.path.join(PYTHON_STEM, cython_module_files = [os.path.join(PYTHON_STEM,
name.replace('.', '/') + '.pyx') name.replace('.', '/') + '.pyx')
for name in CYTHON_EXTENSION_MODULE_NAMES] for name in CYTHON_EXTENSION_MODULE_NAMES]
config = os.environ.get('CONFIG', 'opt')
prefix = 'libs/' + config + '/'
if "darwin" in sys.platform:
extra_objects = [prefix + 'libares.a',
prefix + 'libboringssl.a',
prefix + 'libgpr.a',
prefix + 'libgrpc.a']
core_c_files = []
else:
core_c_files = list(CORE_C_FILES)
extra_objects = []
extensions = [ extensions = [
_extension.Extension( _extension.Extension(
name=module_name, name=module_name,
sources=[module_file] + list(CYTHON_HELPER_C_FILES) + list(CORE_C_FILES), sources=[module_file] + list(CYTHON_HELPER_C_FILES) + core_c_files,
include_dirs=list(EXTENSION_INCLUDE_DIRECTORIES), include_dirs=list(EXTENSION_INCLUDE_DIRECTORIES),
libraries=list(EXTENSION_LIBRARIES), libraries=list(EXTENSION_LIBRARIES),
define_macros=list(DEFINE_MACROS), define_macros=list(DEFINE_MACROS),
extra_objects=extra_objects,
extra_compile_args=list(CFLAGS), extra_compile_args=list(CFLAGS),
extra_link_args=list(LDFLAGS), extra_link_args=list(LDFLAGS),
) for (module_name, module_file) in zip(list(CYTHON_EXTENSION_MODULE_NAMES), cython_module_files) ) for (module_name, module_file) in zip(list(CYTHON_EXTENSION_MODULE_NAMES), cython_module_files)

@ -804,6 +804,12 @@ void PrintHeaderService(grpc_generator::Printer *printer,
" public:\n"); " public:\n");
printer->Indent(); printer->Indent();
// Service metadata
printer->Print(*vars,
"static constexpr char const* service_full_name() {\n"
" return \"$Package$$Service$\";\n"
"}\n");
// Client side // Client side
printer->Print( printer->Print(
"class StubInterface {\n" "class StubInterface {\n"
@ -1408,4 +1414,180 @@ grpc::string GetSourceEpilogue(grpc_generator::File *file,
return temp; return temp;
} }
// TODO(mmukhi): Make sure we need parameters or not.
grpc::string GetMockPrologue(grpc_generator::File *file,
const Parameters & /*params*/) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
vars["filename"] = file->filename();
vars["filename_base"] = file->filename_without_ext();
vars["message_header_ext"] = message_header_ext();
vars["service_header_ext"] = service_header_ext();
printer->Print(vars, "// Generated by the gRPC C++ plugin.\n");
printer->Print(vars,
"// If you make any local change, they will be lost.\n");
printer->Print(vars, "// source: $filename$\n\n");
printer->Print(vars, "#include \"$filename_base$$message_header_ext$\"\n");
printer->Print(vars, "#include \"$filename_base$$service_header_ext$\"\n");
printer->Print(vars, file->additional_headers().c_str());
printer->Print(vars, "\n");
}
return output;
}
// TODO(mmukhi): Add client-stream and completion-queue headers.
grpc::string GetMockIncludes(grpc_generator::File *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
static const char *headers_strs[] = {
"grpc++/impl/codegen/async_stream.h",
"grpc++/impl/codegen/sync_stream.h", "gmock/gmock.h",
};
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
PrintIncludes(printer.get(), headers, params);
if (!file->package().empty()) {
std::vector<grpc::string> parts = file->package_parts();
for (auto part = parts.begin(); part != parts.end(); part++) {
vars["part"] = *part;
printer->Print(vars, "namespace $part$ {\n");
}
}
printer->Print(vars, "\n");
}
return output;
}
void PrintMockClientMethods(grpc_generator::Printer *printer,
const grpc_generator::Method *method,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Method"] = method->name();
(*vars)["Request"] = method->input_type_name();
(*vars)["Response"] = method->output_type_name();
if (method->NoStreaming()) {
printer->Print(
*vars,
"MOCK_METHOD3($Method$, ::grpc::Status(::grpc::ClientContext* context, "
"const $Request$& request, $Response$* response));\n");
printer->Print(*vars,
"MOCK_METHOD3(Async$Method$Raw, "
"::grpc::ClientAsyncResponseReaderInterface< $Response$>*"
"(::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq));\n");
} else if (ClientOnlyStreaming(method)) {
printer->Print(
*vars,
"MOCK_METHOD2($Method$Raw, "
"::grpc::ClientWriterInterface< $Request$>*"
"(::grpc::ClientContext* context, $Response$* response));\n");
printer->Print(*vars,
"MOCK_METHOD4(Async$Method$Raw, "
"::grpc::ClientAsyncWriterInterface< $Request$>*"
"(::grpc::ClientContext* context, $Response$* response, "
"::grpc::CompletionQueue* cq, void* tag));\n");
} else if (ServerOnlyStreaming(method)) {
printer->Print(
*vars,
"MOCK_METHOD2($Method$Raw, "
"::grpc::ClientReaderInterface< $Response$>*"
"(::grpc::ClientContext* context, const $Request$& request));\n");
printer->Print(*vars,
"MOCK_METHOD4(Async$Method$Raw, "
"::grpc::ClientAsyncReaderInterface< $Response$>*"
"(::grpc::ClientContext* context, const $Request$& request, "
"::grpc::CompletionQueue* cq, void* tag));\n");
} else if (method->BidiStreaming()) {
printer->Print(
*vars,
"MOCK_METHOD1($Method$Raw, "
"::grpc::ClientReaderWriterInterface< $Request$, $Response$>*"
"(::grpc::ClientContext* context));\n");
printer->Print(
*vars,
"MOCK_METHOD3(Async$Method$Raw, "
"::grpc::ClientAsyncReaderWriterInterface<$Request$, $Response$>*"
"(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, "
"void* tag));\n");
}
}
void PrintMockService(grpc_generator::Printer *printer,
const grpc_generator::Service *service,
std::map<grpc::string, grpc::string> *vars) {
(*vars)["Service"] = service->name();
printer->Print(*vars,
"class Mock$Service$Stub : public $Service$::StubInterface {\n"
" public:\n");
printer->Indent();
for (int i = 0; i < service->method_count(); ++i) {
PrintMockClientMethods(printer, service->method(i).get(), vars);
}
printer->Outdent();
printer->Print("};\n");
}
grpc::string GetMockServices(grpc_generator::File *file,
const Parameters &params) {
grpc::string output;
{
// Scope the output stream so it closes and finalizes output to the string.
auto printer = file->CreatePrinter(&output);
std::map<grpc::string, grpc::string> vars;
// Package string is empty or ends with a dot. It is used to fully qualify
// method names.
vars["Package"] = file->package();
if (!file->package().empty()) {
vars["Package"].append(".");
}
if (!params.services_namespace.empty()) {
vars["services_namespace"] = params.services_namespace;
printer->Print(vars, "\nnamespace $services_namespace$ {\n\n");
}
for (int i = 0; i < file->service_count(); i++) {
PrintMockService(printer.get(), file->service(i).get(), &vars);
printer->Print("\n");
}
if (!params.services_namespace.empty()) {
printer->Print(vars, "} // namespace $services_namespace$\n\n");
}
}
return output;
}
grpc::string GetMockEpilogue(grpc_generator::File *file,
const Parameters & /*params*/) {
grpc::string temp;
if (!file->package().empty()) {
std::vector<grpc::string> parts = file->package_parts();
for (auto part = parts.begin(); part != parts.end(); part++) {
temp.append("} // namespace ");
temp.append(*part);
temp.append("\n");
}
temp.append("\n");
}
return temp;
}
} // namespace grpc_cpp_generator } // namespace grpc_cpp_generator

@ -65,6 +65,8 @@ struct Parameters {
bool use_system_headers; bool use_system_headers;
// Prefix to any grpc include // Prefix to any grpc include
grpc::string grpc_search_path; grpc::string grpc_search_path;
// Generate GMOCK code to facilitate unit testing.
bool generate_mock_code;
}; };
// Return the prologue of the generated header file. // Return the prologue of the generated header file.
@ -99,6 +101,38 @@ grpc::string GetSourceServices(grpc_generator::File *file,
grpc::string GetSourceEpilogue(grpc_generator::File *file, grpc::string GetSourceEpilogue(grpc_generator::File *file,
const Parameters &params); const Parameters &params);
// Return the prologue of the generated mock file.
grpc::string GetMockPrologue(grpc_generator::File *file,
const Parameters &params);
// Return the includes needed for generated mock file.
grpc::string GetMockIncludes(grpc_generator::File *file,
const Parameters &params);
// Return the services for generated mock file.
grpc::string GetMockServices(grpc_generator::File *file,
const Parameters &params);
// Return the epilogue of generated mock file.
grpc::string GetMockEpilogue(grpc_generator::File *file,
const Parameters &params);
// Return the prologue of the generated mock file.
grpc::string GetMockPrologue(grpc_generator::File *file,
const Parameters &params);
// Return the includes needed for generated mock file.
grpc::string GetMockIncludes(grpc_generator::File *file,
const Parameters &params);
// Return the services for generated mock file.
grpc::string GetMockServices(grpc_generator::File *file,
const Parameters &params);
// Return the epilogue of generated mock file.
grpc::string GetMockEpilogue(grpc_generator::File *file,
const Parameters &params);
} // namespace grpc_cpp_generator } // namespace grpc_cpp_generator
#endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H #endif // GRPC_INTERNAL_COMPILER_CPP_GENERATOR_H

@ -62,6 +62,7 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
grpc_cpp_generator::Parameters generator_parameters; grpc_cpp_generator::Parameters generator_parameters;
generator_parameters.use_system_headers = true; generator_parameters.use_system_headers = true;
generator_parameters.generate_mock_code = false;
ProtoBufFile pbfile(file); ProtoBufFile pbfile(file);
@ -85,6 +86,13 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
} }
} else if (param[0] == "grpc_search_path") { } else if (param[0] == "grpc_search_path") {
generator_parameters.grpc_search_path = param[1]; generator_parameters.grpc_search_path = param[1];
} else if (param[0] == "generate_mock_code") {
if (param[1] == "true") {
generator_parameters.generate_mock_code = true;
} else if (param[1] != "false") {
*error = grpc::string("Invalid parameter: ") + *parameter_string;
return false;
}
} else { } else {
*error = grpc::string("Unknown parameter: ") + *parameter_string; *error = grpc::string("Unknown parameter: ") + *parameter_string;
return false; return false;
@ -114,6 +122,19 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
grpc::protobuf::io::CodedOutputStream source_coded_out(source_output.get()); grpc::protobuf::io::CodedOutputStream source_coded_out(source_output.get());
source_coded_out.WriteRaw(source_code.data(), source_code.size()); source_coded_out.WriteRaw(source_code.data(), source_code.size());
if (!generator_parameters.generate_mock_code) {
return true;
}
grpc::string mock_code =
grpc_cpp_generator::GetMockPrologue(&pbfile, generator_parameters) +
grpc_cpp_generator::GetMockIncludes(&pbfile, generator_parameters) +
grpc_cpp_generator::GetMockServices(&pbfile, generator_parameters) +
grpc_cpp_generator::GetMockEpilogue(&pbfile, generator_parameters);
std::unique_ptr<grpc::protobuf::io::ZeroCopyOutputStream> mock_output(
context->Open(file_name + "_mock.grpc.pb.h"));
grpc::protobuf::io::CodedOutputStream mock_coded_out(mock_output.get());
mock_coded_out.WriteRaw(mock_code.data(), mock_code.size());
return true; return true;
} }

@ -68,6 +68,7 @@ class ObjectiveCGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
::grpc::string imports = ::grpc::string("#import \"") + file_name + ::grpc::string imports = ::grpc::string("#import \"") + file_name +
".pbobjc.h\"\n\n" ".pbobjc.h\"\n\n"
"#import <ProtoRPC/ProtoService.h>\n" "#import <ProtoRPC/ProtoService.h>\n"
"#import <ProtoRPC/ProtoRPC.h>\n"
"#import <RxLibrary/GRXWriteable.h>\n" "#import <RxLibrary/GRXWriteable.h>\n"
"#import <RxLibrary/GRXWriter.h>\n"; "#import <RxLibrary/GRXWriter.h>\n";

@ -622,9 +622,17 @@ bool PrivateGenerator::PrintPreamble(grpc_generator::Printer* out) {
for (StringPairSet::iterator it = imports_set.begin(); for (StringPairSet::iterator it = imports_set.begin();
it != imports_set.end(); ++it) { it != imports_set.end(); ++it) {
var["ModuleName"] = std::get<0>(*it); auto module_name = std::get<0>(*it);
var["ModuleAlias"] = std::get<1>(*it); var["ModuleAlias"] = std::get<1>(*it);
out->Print(var, "import $ModuleName$ as $ModuleAlias$\n"); const size_t last_dot_pos = module_name.rfind('.');
if (last_dot_pos == grpc::string::npos) {
var["ImportStatement"] = "import " + module_name;
} else {
var["ImportStatement"] = "from " + module_name.substr(0, last_dot_pos) +
" import " +
module_name.substr(last_dot_pos + 1);
}
out->Print(var, "$ImportStatement$ as $ModuleAlias$\n");
} }
} }
return true; return true;

@ -96,17 +96,10 @@ static void method_parameters_unref(method_parameters *method_params) {
} }
} }
static void *method_parameters_copy(void *value) {
return method_parameters_ref(value);
}
static void method_parameters_free(grpc_exec_ctx *exec_ctx, void *value) { static void method_parameters_free(grpc_exec_ctx *exec_ctx, void *value) {
method_parameters_unref(value); method_parameters_unref(value);
} }
static const grpc_slice_hash_table_vtable method_parameters_vtable = {
method_parameters_free, method_parameters_copy};
static bool parse_wait_for_ready(grpc_json *field, static bool parse_wait_for_ready(grpc_json *field,
wait_for_ready_value *wait_for_ready) { wait_for_ready_value *wait_for_ready) {
if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) { if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) {
@ -407,26 +400,24 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING);
lb_policy_name = channel_arg->value.string; lb_policy_name = channel_arg->value.string;
} }
// Special case: If all of the addresses are balancer addresses, // Special case: If at least one balancer address is present, we use
// assume that we should use the grpclb policy, regardless of what the // the grpclb policy, regardless of what the resolver actually specified.
// resolver actually specified.
channel_arg = channel_arg =
grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES); grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES);
if (channel_arg != NULL && channel_arg->type == GRPC_ARG_POINTER) { if (channel_arg != NULL && channel_arg->type == GRPC_ARG_POINTER) {
grpc_lb_addresses *addresses = channel_arg->value.pointer.p; grpc_lb_addresses *addresses = channel_arg->value.pointer.p;
bool found_backend_address = false; bool found_balancer_address = false;
for (size_t i = 0; i < addresses->num_addresses; ++i) { for (size_t i = 0; i < addresses->num_addresses; ++i) {
if (!addresses->addresses[i].is_balancer) { if (addresses->addresses[i].is_balancer) {
found_backend_address = true; found_balancer_address = true;
break; break;
} }
} }
if (!found_backend_address) { if (found_balancer_address) {
if (lb_policy_name != NULL && strcmp(lb_policy_name, "grpclb") != 0) { if (lb_policy_name != NULL && strcmp(lb_policy_name, "grpclb") != 0) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"resolver requested LB policy %s but provided only balancer " "resolver requested LB policy %s but provided at least one "
"addresses, no backend addresses -- forcing use of grpclb LB " "balancer address -- forcing use of grpclb LB policy",
"policy",
lb_policy_name); lb_policy_name);
} }
lb_policy_name = "grpclb"; lb_policy_name = "grpclb";
@ -472,7 +463,7 @@ static void on_resolver_result_changed_locked(grpc_exec_ctx *exec_ctx,
grpc_uri_destroy(uri); grpc_uri_destroy(uri);
method_params_table = grpc_service_config_create_method_config_table( method_params_table = grpc_service_config_create_method_config_table(
exec_ctx, service_config, method_parameters_create_from_json, exec_ctx, service_config, method_parameters_create_from_json,
&method_parameters_vtable); method_parameters_free);
grpc_service_config_destroy(service_config); grpc_service_config_destroy(service_config);
} }
} }
@ -769,12 +760,6 @@ static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
#define CANCELLED_CALL ((grpc_subchannel_call *)1) #define CANCELLED_CALL ((grpc_subchannel_call *)1)
typedef enum {
/* zero so that it can be default-initialized */
GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING = 0,
GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL
} subchannel_creation_phase;
/** Call data. Holds a pointer to grpc_subchannel_call and the /** Call data. Holds a pointer to grpc_subchannel_call and the
associated machinery to create such a pointer. associated machinery to create such a pointer.
Handles queueing of stream ops until a call object is ready, waiting Handles queueing of stream ops until a call object is ready, waiting
@ -802,8 +787,9 @@ typedef struct client_channel_call_data {
gpr_atm subchannel_call; gpr_atm subchannel_call;
gpr_arena *arena; gpr_arena *arena;
subchannel_creation_phase creation_phase; bool pick_pending;
grpc_connected_subchannel *connected_subchannel; grpc_connected_subchannel *connected_subchannel;
grpc_call_context_element subchannel_call_context[GRPC_CONTEXT_COUNT];
grpc_polling_entity *pollent; grpc_polling_entity *pollent;
grpc_transport_stream_op_batch **waiting_ops; grpc_transport_stream_op_batch **waiting_ops;
@ -923,11 +909,10 @@ static void subchannel_ready_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_call_element *elem = arg; grpc_call_element *elem = arg;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data; channel_data *chand = elem->channel_data;
GPR_ASSERT(calld->creation_phase == GPR_ASSERT(calld->pick_pending);
GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL); calld->pick_pending = false;
grpc_polling_entity_del_from_pollset_set(exec_ctx, calld->pollent, grpc_polling_entity_del_from_pollset_set(exec_ctx, calld->pollent,
chand->interested_parties); chand->interested_parties);
calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING;
if (calld->connected_subchannel == NULL) { if (calld->connected_subchannel == NULL) {
gpr_atm_no_barrier_store(&calld->subchannel_call, 1); gpr_atm_no_barrier_store(&calld->subchannel_call, 1);
fail_locked(exec_ctx, calld, fail_locked(exec_ctx, calld,
@ -953,7 +938,8 @@ static void subchannel_ready_locked(grpc_exec_ctx *exec_ctx, void *arg,
.path = calld->path, .path = calld->path,
.start_time = calld->call_start_time, .start_time = calld->call_start_time,
.deadline = calld->deadline, .deadline = calld->deadline,
.arena = calld->arena}; .arena = calld->arena,
.context = calld->subchannel_call_context};
grpc_error *new_error = grpc_connected_subchannel_create_call( grpc_error *new_error = grpc_connected_subchannel_create_call(
exec_ctx, calld->connected_subchannel, &call_args, &subchannel_call); exec_ctx, calld->connected_subchannel, &call_args, &subchannel_call);
gpr_atm_rel_store(&calld->subchannel_call, gpr_atm_rel_store(&calld->subchannel_call,
@ -982,6 +968,7 @@ typedef struct {
grpc_metadata_batch *initial_metadata; grpc_metadata_batch *initial_metadata;
uint32_t initial_metadata_flags; uint32_t initial_metadata_flags;
grpc_connected_subchannel **connected_subchannel; grpc_connected_subchannel **connected_subchannel;
grpc_call_context_element *subchannel_call_context;
grpc_closure *on_ready; grpc_closure *on_ready;
grpc_call_element *elem; grpc_call_element *elem;
grpc_closure closure; grpc_closure closure;
@ -993,8 +980,8 @@ typedef struct {
static bool pick_subchannel_locked( static bool pick_subchannel_locked(
grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_metadata_batch *initial_metadata, uint32_t initial_metadata_flags, grpc_metadata_batch *initial_metadata, uint32_t initial_metadata_flags,
grpc_connected_subchannel **connected_subchannel, grpc_closure *on_ready, grpc_connected_subchannel **connected_subchannel,
grpc_error *error); grpc_call_context_element *subchannel_call_context, grpc_closure *on_ready);
static void continue_picking_locked(grpc_exec_ctx *exec_ctx, void *arg, static void continue_picking_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
@ -1006,49 +993,49 @@ static void continue_picking_locked(grpc_exec_ctx *exec_ctx, void *arg,
} else { } else {
if (pick_subchannel_locked(exec_ctx, cpa->elem, cpa->initial_metadata, if (pick_subchannel_locked(exec_ctx, cpa->elem, cpa->initial_metadata,
cpa->initial_metadata_flags, cpa->initial_metadata_flags,
cpa->connected_subchannel, cpa->on_ready, cpa->connected_subchannel,
GRPC_ERROR_NONE)) { cpa->subchannel_call_context, cpa->on_ready)) {
grpc_closure_sched(exec_ctx, cpa->on_ready, GRPC_ERROR_NONE); grpc_closure_sched(exec_ctx, cpa->on_ready, GRPC_ERROR_NONE);
} }
} }
gpr_free(cpa); gpr_free(cpa);
} }
static void cancel_pick_locked(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_error *error) {
channel_data *chand = elem->channel_data;
call_data *calld = elem->call_data;
if (chand->lb_policy != NULL) {
grpc_lb_policy_cancel_pick_locked(exec_ctx, chand->lb_policy,
&calld->connected_subchannel,
GRPC_ERROR_REF(error));
}
for (grpc_closure *closure = chand->waiting_for_config_closures.head;
closure != NULL; closure = closure->next_data.next) {
continue_picking_args *cpa = closure->cb_arg;
if (cpa->connected_subchannel == &calld->connected_subchannel) {
cpa->connected_subchannel = NULL;
grpc_closure_sched(exec_ctx, cpa->on_ready,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick cancelled", &error, 1));
}
}
GRPC_ERROR_UNREF(error);
}
static bool pick_subchannel_locked( static bool pick_subchannel_locked(
grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_metadata_batch *initial_metadata, uint32_t initial_metadata_flags, grpc_metadata_batch *initial_metadata, uint32_t initial_metadata_flags,
grpc_connected_subchannel **connected_subchannel, grpc_closure *on_ready, grpc_connected_subchannel **connected_subchannel,
grpc_error *error) { grpc_call_context_element *subchannel_call_context,
grpc_closure *on_ready) {
GPR_TIMER_BEGIN("pick_subchannel", 0); GPR_TIMER_BEGIN("pick_subchannel", 0);
channel_data *chand = elem->channel_data; channel_data *chand = elem->channel_data;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
continue_picking_args *cpa;
grpc_closure *closure;
GPR_ASSERT(connected_subchannel); GPR_ASSERT(connected_subchannel);
if (initial_metadata == NULL) {
if (chand->lb_policy != NULL) {
grpc_lb_policy_cancel_pick_locked(exec_ctx, chand->lb_policy,
connected_subchannel,
GRPC_ERROR_REF(error));
}
for (closure = chand->waiting_for_config_closures.head; closure != NULL;
closure = closure->next_data.next) {
cpa = closure->cb_arg;
if (cpa->connected_subchannel == connected_subchannel) {
cpa->connected_subchannel = NULL;
grpc_closure_sched(exec_ctx, cpa->on_ready,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick cancelled", &error, 1));
}
}
GPR_TIMER_END("pick_subchannel", 0);
GRPC_ERROR_UNREF(error);
return true;
}
GPR_ASSERT(error == GRPC_ERROR_NONE);
if (chand->lb_policy != NULL) { if (chand->lb_policy != NULL) {
apply_final_configuration_locked(exec_ctx, elem); apply_final_configuration_locked(exec_ctx, elem);
grpc_lb_policy *lb_policy = chand->lb_policy; grpc_lb_policy *lb_policy = chand->lb_policy;
@ -1071,8 +1058,7 @@ static bool pick_subchannel_locked(
} }
} }
const grpc_lb_policy_pick_args inputs = { const grpc_lb_policy_pick_args inputs = {
initial_metadata, initial_metadata_flags, &calld->lb_token_mdelem, initial_metadata, initial_metadata_flags, &calld->lb_token_mdelem};
gpr_inf_future(GPR_CLOCK_MONOTONIC)};
// Wrap the user-provided callback in order to hold a strong reference to // Wrap the user-provided callback in order to hold a strong reference to
// the LB policy for the duration of the pick. // the LB policy for the duration of the pick.
@ -1085,8 +1071,8 @@ static bool pick_subchannel_locked(
GRPC_LB_POLICY_REF(lb_policy, "pick_subchannel_wrapping"); GRPC_LB_POLICY_REF(lb_policy, "pick_subchannel_wrapping");
w_on_pick_arg->lb_policy = lb_policy; w_on_pick_arg->lb_policy = lb_policy;
const bool pick_done = grpc_lb_policy_pick_locked( const bool pick_done = grpc_lb_policy_pick_locked(
exec_ctx, lb_policy, &inputs, connected_subchannel, NULL, exec_ctx, lb_policy, &inputs, connected_subchannel,
&w_on_pick_arg->wrapper_closure); subchannel_call_context, NULL, &w_on_pick_arg->wrapper_closure);
if (pick_done) { if (pick_done) {
/* synchronous grpc_lb_policy_pick call. Unref the LB policy. */ /* synchronous grpc_lb_policy_pick call. Unref the LB policy. */
GRPC_LB_POLICY_UNREF(exec_ctx, w_on_pick_arg->lb_policy, GRPC_LB_POLICY_UNREF(exec_ctx, w_on_pick_arg->lb_policy,
@ -1105,10 +1091,11 @@ static bool pick_subchannel_locked(
&chand->on_resolver_result_changed); &chand->on_resolver_result_changed);
} }
if (chand->resolver != NULL) { if (chand->resolver != NULL) {
cpa = gpr_malloc(sizeof(*cpa)); continue_picking_args *cpa = gpr_malloc(sizeof(*cpa));
cpa->initial_metadata = initial_metadata; cpa->initial_metadata = initial_metadata;
cpa->initial_metadata_flags = initial_metadata_flags; cpa->initial_metadata_flags = initial_metadata_flags;
cpa->connected_subchannel = connected_subchannel; cpa->connected_subchannel = connected_subchannel;
cpa->subchannel_call_context = subchannel_call_context;
cpa->on_ready = on_ready; cpa->on_ready = on_ready;
cpa->elem = elem; cpa->elem = elem;
grpc_closure_init(&cpa->closure, continue_picking_locked, cpa, grpc_closure_init(&cpa->closure, continue_picking_locked, cpa,
@ -1160,16 +1147,13 @@ static void start_transport_stream_op_batch_locked_inner(
error to the caller when the first op does get passed down. */ error to the caller when the first op does get passed down. */
calld->cancel_error = calld->cancel_error =
GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error); GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error);
switch (calld->creation_phase) { if (calld->pick_pending) {
case GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING: cancel_pick_locked(
fail_locked(exec_ctx, calld, exec_ctx, elem,
GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error)); GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error));
break; } else {
case GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL: fail_locked(exec_ctx, calld,
pick_subchannel_locked( GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error));
exec_ctx, elem, NULL, 0, &calld->connected_subchannel, NULL,
GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error));
break;
} }
grpc_transport_stream_op_batch_finish_with_failure( grpc_transport_stream_op_batch_finish_with_failure(
exec_ctx, op, exec_ctx, op,
@ -1179,9 +1163,9 @@ static void start_transport_stream_op_batch_locked_inner(
} }
} }
/* if we don't have a subchannel, try to get one */ /* if we don't have a subchannel, try to get one */
if (calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && if (!calld->pick_pending && calld->connected_subchannel == NULL &&
calld->connected_subchannel == NULL && op->send_initial_metadata) { op->send_initial_metadata) {
calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_PICKING_SUBCHANNEL; calld->pick_pending = true;
grpc_closure_init(&calld->next_step, subchannel_ready_locked, elem, grpc_closure_init(&calld->next_step, subchannel_ready_locked, elem,
grpc_combiner_scheduler(chand->combiner, true)); grpc_combiner_scheduler(chand->combiner, true));
GRPC_CALL_STACK_REF(calld->owning_call, "pick_subchannel"); GRPC_CALL_STACK_REF(calld->owning_call, "pick_subchannel");
@ -1192,8 +1176,9 @@ static void start_transport_stream_op_batch_locked_inner(
exec_ctx, elem, exec_ctx, elem,
op->payload->send_initial_metadata.send_initial_metadata, op->payload->send_initial_metadata.send_initial_metadata,
op->payload->send_initial_metadata.send_initial_metadata_flags, op->payload->send_initial_metadata.send_initial_metadata_flags,
&calld->connected_subchannel, &calld->next_step, GRPC_ERROR_NONE)) { &calld->connected_subchannel, calld->subchannel_call_context,
calld->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING; &calld->next_step)) {
calld->pick_pending = false;
GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel"); GRPC_CALL_STACK_UNREF(exec_ctx, calld->owning_call, "pick_subchannel");
} else { } else {
grpc_polling_entity_add_to_pollset_set(exec_ctx, calld->pollent, grpc_polling_entity_add_to_pollset_set(exec_ctx, calld->pollent,
@ -1201,15 +1186,15 @@ static void start_transport_stream_op_batch_locked_inner(
} }
} }
/* if we've got a subchannel, then let's ask it to create a call */ /* if we've got a subchannel, then let's ask it to create a call */
if (calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING && if (!calld->pick_pending && calld->connected_subchannel != NULL) {
calld->connected_subchannel != NULL) {
grpc_subchannel_call *subchannel_call = NULL; grpc_subchannel_call *subchannel_call = NULL;
const grpc_connected_subchannel_call_args call_args = { const grpc_connected_subchannel_call_args call_args = {
.pollent = calld->pollent, .pollent = calld->pollent,
.path = calld->path, .path = calld->path,
.start_time = calld->call_start_time, .start_time = calld->call_start_time,
.deadline = calld->deadline, .deadline = calld->deadline,
.arena = calld->arena}; .arena = calld->arena,
.context = calld->subchannel_call_context};
grpc_error *error = grpc_connected_subchannel_create_call( grpc_error *error = grpc_connected_subchannel_create_call(
exec_ctx, calld->connected_subchannel, &call_args, &subchannel_call); exec_ctx, calld->connected_subchannel, &call_args, &subchannel_call);
gpr_atm_rel_store(&calld->subchannel_call, gpr_atm_rel_store(&calld->subchannel_call,
@ -1358,12 +1343,18 @@ static void cc_destroy_call_elem(grpc_exec_ctx *exec_ctx,
then_schedule_closure = NULL; then_schedule_closure = NULL;
GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, call, "client_channel_destroy_call"); GRPC_SUBCHANNEL_CALL_UNREF(exec_ctx, call, "client_channel_destroy_call");
} }
GPR_ASSERT(calld->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING); GPR_ASSERT(!calld->pick_pending);
GPR_ASSERT(calld->waiting_ops_count == 0); GPR_ASSERT(calld->waiting_ops_count == 0);
if (calld->connected_subchannel != NULL) { if (calld->connected_subchannel != NULL) {
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel, GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, calld->connected_subchannel,
"picked"); "picked");
} }
for (size_t i = 0; i < GRPC_CONTEXT_COUNT; ++i) {
if (calld->subchannel_call_context[i].value != NULL) {
calld->subchannel_call_context[i].destroy(
calld->subchannel_call_context[i].value);
}
}
gpr_free(calld->waiting_ops); gpr_free(calld->waiting_ops);
grpc_closure_sched(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE); grpc_closure_sched(exec_ctx, then_schedule_closure, GRPC_ERROR_NONE);
} }
@ -1459,12 +1450,12 @@ static void watch_connectivity_state_locked(grpc_exec_ctx *exec_ctx, void *arg,
void grpc_client_channel_watch_connectivity_state( void grpc_client_channel_watch_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset, grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset,
grpc_connectivity_state *state, grpc_closure *on_complete) { grpc_connectivity_state *state, grpc_closure *closure) {
channel_data *chand = elem->channel_data; channel_data *chand = elem->channel_data;
external_connectivity_watcher *w = gpr_malloc(sizeof(*w)); external_connectivity_watcher *w = gpr_malloc(sizeof(*w));
w->chand = chand; w->chand = chand;
w->pollset = pollset; w->pollset = pollset;
w->on_complete = on_complete; w->on_complete = closure;
w->state = state; w->state = state;
grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties, pollset); grpc_pollset_set_add_pollset(exec_ctx, chand->interested_parties, pollset);
GRPC_CHANNEL_STACK_REF(w->chand->owning_stack, GRPC_CHANNEL_STACK_REF(w->chand->owning_stack,

@ -119,9 +119,10 @@ void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx,
int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy, int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
const grpc_lb_policy_pick_args *pick_args, const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target, grpc_connected_subchannel **target,
grpc_call_context_element *context,
void **user_data, grpc_closure *on_complete) { void **user_data, grpc_closure *on_complete) {
return policy->vtable->pick_locked(exec_ctx, policy, pick_args, target, return policy->vtable->pick_locked(exec_ctx, policy, pick_args, target,
user_data, on_complete); context, user_data, on_complete);
} }
void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx *exec_ctx, void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx *exec_ctx,

@ -43,9 +43,6 @@
typedef struct grpc_lb_policy grpc_lb_policy; typedef struct grpc_lb_policy grpc_lb_policy;
typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable; typedef struct grpc_lb_policy_vtable grpc_lb_policy_vtable;
typedef void (*grpc_lb_completion)(void *cb_arg, grpc_subchannel *subchannel,
grpc_status_code status, const char *errmsg);
struct grpc_lb_policy { struct grpc_lb_policy {
const grpc_lb_policy_vtable *vtable; const grpc_lb_policy_vtable *vtable;
gpr_atm ref_pair; gpr_atm ref_pair;
@ -65,8 +62,6 @@ typedef struct grpc_lb_policy_pick_args {
uint32_t initial_metadata_flags; uint32_t initial_metadata_flags;
/** Storage for LB token in \a initial_metadata, or NULL if not used */ /** Storage for LB token in \a initial_metadata, or NULL if not used */
grpc_linked_mdelem *lb_token_mdelem_storage; grpc_linked_mdelem *lb_token_mdelem_storage;
/** Deadline for the call to the LB server */
gpr_timespec deadline;
} grpc_lb_policy_pick_args; } grpc_lb_policy_pick_args;
struct grpc_lb_policy_vtable { struct grpc_lb_policy_vtable {
@ -76,7 +71,8 @@ struct grpc_lb_policy_vtable {
/** \see grpc_lb_policy_pick */ /** \see grpc_lb_policy_pick */
int (*pick_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy, int (*pick_locked)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
const grpc_lb_policy_pick_args *pick_args, const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target, void **user_data, grpc_connected_subchannel **target,
grpc_call_context_element *context, void **user_data,
grpc_closure *on_complete); grpc_closure *on_complete);
/** \see grpc_lb_policy_cancel_pick */ /** \see grpc_lb_policy_cancel_pick */
@ -156,6 +152,8 @@ void grpc_lb_policy_init(grpc_lb_policy *policy,
\a target will be set to the selected subchannel, or NULL on failure. \a target will be set to the selected subchannel, or NULL on failure.
Upon success, \a user_data will be set to whatever opaque information Upon success, \a user_data will be set to whatever opaque information
may need to be propagated from the LB policy, or NULL if not needed. may need to be propagated from the LB policy, or NULL if not needed.
\a context will be populated with context to pass to the subchannel
call, if needed.
If the pick succeeds and a result is known immediately, a non-zero If the pick succeeds and a result is known immediately, a non-zero
value will be returned. Otherwise, \a on_complete will be invoked value will be returned. Otherwise, \a on_complete will be invoked
@ -167,6 +165,7 @@ void grpc_lb_policy_init(grpc_lb_policy *policy,
int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy, int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
const grpc_lb_policy_pick_args *pick_args, const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target, grpc_connected_subchannel **target,
grpc_call_context_element *context,
void **user_data, grpc_closure *on_complete); void **user_data, grpc_closure *on_complete);
/** Perform a connected subchannel ping (see \a grpc_connected_subchannel_ping) /** Perform a connected subchannel ping (see \a grpc_connected_subchannel_ping)

@ -0,0 +1,153 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
#include <grpc/support/atm.h>
#include <grpc/support/log.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
#include "src/core/lib/iomgr/error.h"
#include "src/core/lib/profiling/timers.h"
static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_channel_element_args *args) {
return GRPC_ERROR_NONE;
}
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {}
typedef struct {
// Stats object to update.
grpc_grpclb_client_stats *client_stats;
// State for intercepting send_initial_metadata.
grpc_closure on_complete_for_send;
grpc_closure *original_on_complete_for_send;
bool send_initial_metadata_succeeded;
// State for intercepting recv_initial_metadata.
grpc_closure recv_initial_metadata_ready;
grpc_closure *original_recv_initial_metadata_ready;
bool recv_initial_metadata_succeeded;
} call_data;
static void on_complete_for_send(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
call_data *calld = arg;
if (error == GRPC_ERROR_NONE) {
calld->send_initial_metadata_succeeded = true;
}
grpc_closure_run(exec_ctx, calld->original_on_complete_for_send,
GRPC_ERROR_REF(error));
}
static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
call_data *calld = arg;
if (error == GRPC_ERROR_NONE) {
calld->recv_initial_metadata_succeeded = true;
}
grpc_closure_run(exec_ctx, calld->original_recv_initial_metadata_ready,
GRPC_ERROR_REF(error));
}
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
const grpc_call_element_args *args) {
call_data *calld = elem->call_data;
// Get stats object from context and take a ref.
GPR_ASSERT(args->context != NULL);
GPR_ASSERT(args->context[GRPC_GRPCLB_CLIENT_STATS].value != NULL);
calld->client_stats = grpc_grpclb_client_stats_ref(
args->context[GRPC_GRPCLB_CLIENT_STATS].value);
// Record call started.
grpc_grpclb_client_stats_add_call_started(calld->client_stats);
return GRPC_ERROR_NONE;
}
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info,
grpc_closure *ignored) {
call_data *calld = elem->call_data;
// Record call finished, optionally setting client_failed_to_send and
// received.
grpc_grpclb_client_stats_add_call_finished(
false /* drop_for_rate_limiting */, false /* drop_for_load_balancing */,
!calld->send_initial_metadata_succeeded /* client_failed_to_send */,
calld->recv_initial_metadata_succeeded /* known_received */,
calld->client_stats);
// All done, so unref the stats object.
grpc_grpclb_client_stats_unref(calld->client_stats);
}
static void start_transport_stream_op_batch(
grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_transport_stream_op_batch *batch) {
call_data *calld = elem->call_data;
GPR_TIMER_BEGIN("clr_start_transport_stream_op_batch", 0);
// Intercept send_initial_metadata.
if (batch->send_initial_metadata) {
calld->original_on_complete_for_send = batch->on_complete;
grpc_closure_init(&calld->on_complete_for_send, on_complete_for_send, calld,
grpc_schedule_on_exec_ctx);
batch->on_complete = &calld->on_complete_for_send;
}
// Intercept recv_initial_metadata.
if (batch->recv_initial_metadata) {
calld->original_recv_initial_metadata_ready =
batch->payload->recv_initial_metadata.recv_initial_metadata_ready;
grpc_closure_init(&calld->recv_initial_metadata_ready,
recv_initial_metadata_ready, calld,
grpc_schedule_on_exec_ctx);
batch->payload->recv_initial_metadata.recv_initial_metadata_ready =
&calld->recv_initial_metadata_ready;
}
// Chain to next filter.
grpc_call_next_op(exec_ctx, elem, batch);
GPR_TIMER_END("clr_start_transport_stream_op_batch", 0);
}
const grpc_channel_filter grpc_client_load_reporting_filter = {
start_transport_stream_op_batch,
grpc_channel_next_op,
sizeof(call_data),
init_call_elem,
grpc_call_stack_ignore_set_pollset_or_pollset_set,
destroy_call_elem,
0, // sizeof(channel_data)
init_channel_elem,
destroy_channel_elem,
grpc_call_next_get_peer,
grpc_channel_next_get_info,
"client_load_reporting"};

@ -0,0 +1,42 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_CLIENT_LOAD_REPORTING_FILTER_H
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_CLIENT_LOAD_REPORTING_FILTER_H
#include "src/core/lib/channel/channel_stack.h"
extern const grpc_channel_filter grpc_client_load_reporting_filter;
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_CLIENT_LOAD_REPORTING_FILTER_H \
*/

@ -95,8 +95,7 @@
headers. Therefore, sockaddr.h must always be included first */ headers. Therefore, sockaddr.h must always be included first */
#include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr.h"
#include <errno.h> #include <limits.h>
#include <string.h> #include <string.h>
#include <grpc/byte_buffer_reader.h> #include <grpc/byte_buffer_reader.h>
@ -108,13 +107,16 @@
#include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/client_channel/client_channel_factory.h" #include "src/core/ext/filters/client_channel/client_channel_factory.h"
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h"
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h" #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h"
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h" #include "src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h"
#include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/ext/filters/client_channel/lb_policy_factory.h"
#include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/ext/filters/client_channel/parse_address.h" #include "src/core/ext/filters/client_channel/parse_address.h"
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr.h"
#include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/sockaddr_utils.h"
@ -126,6 +128,7 @@
#include "src/core/lib/support/string.h" #include "src/core/lib/support/string.h"
#include "src/core/lib/surface/call.h" #include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/static_metadata.h"
#define GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS 20 #define GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS 20
@ -147,6 +150,10 @@ static grpc_error *initial_metadata_add_lb_token(
lb_token_mdelem_storage, lb_token); lb_token_mdelem_storage, lb_token);
} }
static void destroy_client_stats(void *arg) {
grpc_grpclb_client_stats_unref(arg);
}
typedef struct wrapped_rr_closure_arg { typedef struct wrapped_rr_closure_arg {
/* the closure instance using this struct as argument */ /* the closure instance using this struct as argument */
grpc_closure wrapper_closure; grpc_closure wrapper_closure;
@ -163,6 +170,13 @@ typedef struct wrapped_rr_closure_arg {
* initial metadata */ * initial metadata */
grpc_connected_subchannel **target; grpc_connected_subchannel **target;
/* the context to be populated for the subchannel call */
grpc_call_context_element *context;
/* Stats for client-side load reporting. Note that this holds a
* reference, which must be either passed on via context or unreffed. */
grpc_grpclb_client_stats *client_stats;
/* the LB token associated with the pick */ /* the LB token associated with the pick */
grpc_mdelem lb_token; grpc_mdelem lb_token;
@ -202,6 +216,12 @@ static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg,
(void *)*wc_arg->target, (void *)wc_arg->rr_policy); (void *)*wc_arg->target, (void *)wc_arg->rr_policy);
abort(); abort();
} }
// Pass on client stats via context. Passes ownership of the reference.
GPR_ASSERT(wc_arg->client_stats != NULL);
wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].value = wc_arg->client_stats;
wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].destroy = destroy_client_stats;
} else {
grpc_grpclb_client_stats_unref(wc_arg->client_stats);
} }
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Unreffing RR %p", (void *)wc_arg->rr_policy); gpr_log(GPR_INFO, "Unreffing RR %p", (void *)wc_arg->rr_policy);
@ -237,6 +257,7 @@ typedef struct pending_pick {
static void add_pending_pick(pending_pick **root, static void add_pending_pick(pending_pick **root,
const grpc_lb_policy_pick_args *pick_args, const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target, grpc_connected_subchannel **target,
grpc_call_context_element *context,
grpc_closure *on_complete) { grpc_closure *on_complete) {
pending_pick *pp = gpr_zalloc(sizeof(*pp)); pending_pick *pp = gpr_zalloc(sizeof(*pp));
pp->next = *root; pp->next = *root;
@ -244,6 +265,7 @@ static void add_pending_pick(pending_pick **root,
pp->target = target; pp->target = target;
pp->wrapped_on_complete_arg.wrapped_closure = on_complete; pp->wrapped_on_complete_arg.wrapped_closure = on_complete;
pp->wrapped_on_complete_arg.target = target; pp->wrapped_on_complete_arg.target = target;
pp->wrapped_on_complete_arg.context = context;
pp->wrapped_on_complete_arg.initial_metadata = pick_args->initial_metadata; pp->wrapped_on_complete_arg.initial_metadata = pick_args->initial_metadata;
pp->wrapped_on_complete_arg.lb_token_mdelem_storage = pp->wrapped_on_complete_arg.lb_token_mdelem_storage =
pick_args->lb_token_mdelem_storage; pick_args->lb_token_mdelem_storage;
@ -287,8 +309,8 @@ typedef struct glb_lb_policy {
grpc_client_channel_factory *cc_factory; grpc_client_channel_factory *cc_factory;
grpc_channel_args *args; grpc_channel_args *args;
/** deadline for the LB's call */ /** timeout in milliseconds for the LB call. 0 means no deadline. */
gpr_timespec deadline; int lb_call_timeout_ms;
/** for communicating with the LB server */ /** for communicating with the LB server */
grpc_channel *lb_channel; grpc_channel *lb_channel;
@ -316,6 +338,10 @@ typedef struct glb_lb_policy {
/************************************************************/ /************************************************************/
/* client data associated with the LB server communication */ /* client data associated with the LB server communication */
/************************************************************/ /************************************************************/
/* Finished sending initial request. */
grpc_closure lb_on_sent_initial_request;
/* Status from the LB server has been received. This signals the end of the LB /* Status from the LB server has been received. This signals the end of the LB
* call. */ * call. */
grpc_closure lb_on_server_status_received; grpc_closure lb_on_server_status_received;
@ -348,6 +374,23 @@ typedef struct glb_lb_policy {
/** LB call retry timer */ /** LB call retry timer */
grpc_timer lb_call_retry_timer; grpc_timer lb_call_retry_timer;
bool initial_request_sent;
bool seen_initial_response;
/* Stats for client-side load reporting. Should be unreffed and
* recreated whenever lb_call is replaced. */
grpc_grpclb_client_stats *client_stats;
/* Interval and timer for next client load report. */
gpr_timespec client_stats_report_interval;
grpc_timer client_load_report_timer;
bool client_load_report_timer_pending;
bool last_client_load_report_counters_were_zero;
/* Closure used for either the load report timer or the callback for
* completion of sending the load report. */
grpc_closure client_load_report_closure;
/* Client load report message payload. */
grpc_byte_buffer *client_load_report_payload;
} glb_lb_policy; } glb_lb_policy;
/* Keeps track and reacts to changes in connectivity of the RR instance */ /* Keeps track and reacts to changes in connectivity of the RR instance */
@ -552,8 +595,8 @@ static bool pick_from_internal_rr_locked(
grpc_connected_subchannel **target, wrapped_rr_closure_arg *wc_arg) { grpc_connected_subchannel **target, wrapped_rr_closure_arg *wc_arg) {
GPR_ASSERT(rr_policy != NULL); GPR_ASSERT(rr_policy != NULL);
const bool pick_done = grpc_lb_policy_pick_locked( const bool pick_done = grpc_lb_policy_pick_locked(
exec_ctx, rr_policy, pick_args, target, (void **)&wc_arg->lb_token, exec_ctx, rr_policy, pick_args, target, wc_arg->context,
&wc_arg->wrapper_closure); (void **)&wc_arg->lb_token, &wc_arg->wrapper_closure);
if (pick_done) { if (pick_done) {
/* synchronous grpc_lb_policy_pick call. Unref the RR policy. */ /* synchronous grpc_lb_policy_pick call. Unref the RR policy. */
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
@ -567,7 +610,12 @@ static bool pick_from_internal_rr_locked(
pick_args->lb_token_mdelem_storage, pick_args->lb_token_mdelem_storage,
GRPC_MDELEM_REF(wc_arg->lb_token)); GRPC_MDELEM_REF(wc_arg->lb_token));
gpr_free(wc_arg); // Pass on client stats via context. Passes ownership of the reference.
GPR_ASSERT(wc_arg->client_stats != NULL);
wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].value = wc_arg->client_stats;
wc_arg->context[GRPC_GRPCLB_CLIENT_STATS].destroy = destroy_client_stats;
gpr_free(wc_arg->free_when_done);
} }
/* else, the pending pick will be registered and taken care of by the /* else, the pending pick will be registered and taken care of by the
* pending pick list inside the RR policy (glb_policy->rr_policy). * pending pick list inside the RR policy (glb_policy->rr_policy).
@ -690,6 +738,8 @@ static void rr_handover_locked(grpc_exec_ctx *exec_ctx,
glb_policy->pending_picks = pp->next; glb_policy->pending_picks = pp->next;
GRPC_LB_POLICY_REF(glb_policy->rr_policy, "rr_handover_pending_pick"); GRPC_LB_POLICY_REF(glb_policy->rr_policy, "rr_handover_pending_pick");
pp->wrapped_on_complete_arg.rr_policy = glb_policy->rr_policy; pp->wrapped_on_complete_arg.rr_policy = glb_policy->rr_policy;
pp->wrapped_on_complete_arg.client_stats =
grpc_grpclb_client_stats_ref(glb_policy->client_stats);
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Pending pick about to PICK from 0x%" PRIxPTR "", gpr_log(GPR_INFO, "Pending pick about to PICK from 0x%" PRIxPTR "",
(intptr_t)glb_policy->rr_policy); (intptr_t)glb_policy->rr_policy);
@ -750,18 +800,11 @@ static void destroy_balancer_name(grpc_exec_ctx *exec_ctx,
gpr_free(balancer_name); gpr_free(balancer_name);
} }
static void *copy_balancer_name(void *balancer_name) {
return gpr_strdup(balancer_name);
}
static grpc_slice_hash_table_entry targets_info_entry_create( static grpc_slice_hash_table_entry targets_info_entry_create(
const char *address, const char *balancer_name) { const char *address, const char *balancer_name) {
static const grpc_slice_hash_table_vtable vtable = {destroy_balancer_name,
copy_balancer_name};
grpc_slice_hash_table_entry entry; grpc_slice_hash_table_entry entry;
entry.key = grpc_slice_from_copied_string(address); entry.key = grpc_slice_from_copied_string(address);
entry.value = (void *)balancer_name; entry.value = gpr_strdup(balancer_name);
entry.vtable = &vtable;
return entry; return entry;
} }
@ -825,11 +868,8 @@ static char *get_lb_uri_target_addresses(grpc_exec_ctx *exec_ctx,
uri_path); uri_path);
gpr_free(uri_path); gpr_free(uri_path);
*targets_info = *targets_info = grpc_slice_hash_table_create(
grpc_slice_hash_table_create(num_grpclb_addrs, targets_info_entries); num_grpclb_addrs, targets_info_entries, destroy_balancer_name);
for (size_t i = 0; i < num_grpclb_addrs; i++) {
grpc_slice_unref_internal(exec_ctx, targets_info_entries[i].key);
}
gpr_free(targets_info_entries); gpr_free(targets_info_entries);
return target_uri_str; return target_uri_str;
@ -841,10 +881,10 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
/* Count the number of gRPC-LB addresses. There must be at least one. /* Count the number of gRPC-LB addresses. There must be at least one.
* TODO(roth): For now, we ignore non-balancer addresses, but in the * TODO(roth): For now, we ignore non-balancer addresses, but in the
* future, we may change the behavior such that we fall back to using * future, we may change the behavior such that we fall back to using
* the non-balancer addresses if we cannot reach any balancers. At that * the non-balancer addresses if we cannot reach any balancers. In the
* time, this should be changed to allow a list with no balancer addresses, * fallback case, we should use the LB policy indicated by
* since the resolver might fail to return a balancer address even when * GRPC_ARG_LB_POLICY_NAME (although if that specifies grpclb or is
* this is the right LB policy to use. */ * unset, we should default to pick_first). */
const grpc_arg *arg = const grpc_arg *arg =
grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES); grpc_channel_args_find(args->args, GRPC_ARG_LB_ADDRESSES);
if (arg == NULL || arg->type != GRPC_ARG_POINTER) { if (arg == NULL || arg->type != GRPC_ARG_POINTER) {
@ -874,9 +914,22 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
grpc_uri_destroy(uri); grpc_uri_destroy(uri);
glb_policy->cc_factory = args->client_channel_factory; glb_policy->cc_factory = args->client_channel_factory;
glb_policy->args = grpc_channel_args_copy(args->args);
GPR_ASSERT(glb_policy->cc_factory != NULL); GPR_ASSERT(glb_policy->cc_factory != NULL);
arg = grpc_channel_args_find(args->args, GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS);
glb_policy->lb_call_timeout_ms =
grpc_channel_arg_get_integer(arg, (grpc_integer_options){0, 0, INT_MAX});
// Make sure that GRPC_ARG_LB_POLICY_NAME is set in channel args,
// since we use this to trigger the client_load_reporting filter.
grpc_arg new_arg;
new_arg.key = GRPC_ARG_LB_POLICY_NAME;
new_arg.type = GRPC_ARG_STRING;
new_arg.value.string = "grpclb";
static const char *args_to_remove[] = {GRPC_ARG_LB_POLICY_NAME};
glb_policy->args = grpc_channel_args_copy_and_add_and_remove(
args->args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), &new_arg, 1);
grpc_slice_hash_table *targets_info = NULL; grpc_slice_hash_table *targets_info = NULL;
/* Create a client channel over them to communicate with a LB service */ /* Create a client channel over them to communicate with a LB service */
char *lb_service_target_addresses = char *lb_service_target_addresses =
@ -890,6 +943,8 @@ static grpc_lb_policy *glb_create(grpc_exec_ctx *exec_ctx,
grpc_channel_args_destroy(exec_ctx, lb_channel_args); grpc_channel_args_destroy(exec_ctx, lb_channel_args);
gpr_free(lb_service_target_addresses); gpr_free(lb_service_target_addresses);
if (glb_policy->lb_channel == NULL) { if (glb_policy->lb_channel == NULL) {
gpr_free((void *)glb_policy->server_name);
grpc_channel_args_destroy(exec_ctx, glb_policy->args);
gpr_free(glb_policy); gpr_free(glb_policy);
return NULL; return NULL;
} }
@ -905,6 +960,9 @@ static void glb_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
GPR_ASSERT(glb_policy->pending_pings == NULL); GPR_ASSERT(glb_policy->pending_pings == NULL);
gpr_free((void *)glb_policy->server_name); gpr_free((void *)glb_policy->server_name);
grpc_channel_args_destroy(exec_ctx, glb_policy->args); grpc_channel_args_destroy(exec_ctx, glb_policy->args);
if (glb_policy->client_stats != NULL) {
grpc_grpclb_client_stats_unref(glb_policy->client_stats);
}
grpc_channel_destroy(glb_policy->lb_channel); grpc_channel_destroy(glb_policy->lb_channel);
glb_policy->lb_channel = NULL; glb_policy->lb_channel = NULL;
grpc_connectivity_state_destroy(exec_ctx, &glb_policy->state_tracker); grpc_connectivity_state_destroy(exec_ctx, &glb_policy->state_tracker);
@ -1021,7 +1079,8 @@ static void glb_exit_idle_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static int glb_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, static int glb_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
const grpc_lb_policy_pick_args *pick_args, const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target, void **user_data, grpc_connected_subchannel **target,
grpc_call_context_element *context, void **user_data,
grpc_closure *on_complete) { grpc_closure *on_complete) {
if (pick_args->lb_token_mdelem_storage == NULL) { if (pick_args->lb_token_mdelem_storage == NULL) {
*target = NULL; *target = NULL;
@ -1033,7 +1092,6 @@ static int glb_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
} }
glb_lb_policy *glb_policy = (glb_lb_policy *)pol; glb_lb_policy *glb_policy = (glb_lb_policy *)pol;
glb_policy->deadline = pick_args->deadline;
bool pick_done; bool pick_done;
if (glb_policy->rr_policy != NULL) { if (glb_policy->rr_policy != NULL) {
@ -1049,6 +1107,10 @@ static int glb_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
wc_arg->rr_policy = glb_policy->rr_policy; wc_arg->rr_policy = glb_policy->rr_policy;
wc_arg->target = target; wc_arg->target = target;
wc_arg->context = context;
GPR_ASSERT(glb_policy->client_stats != NULL);
wc_arg->client_stats =
grpc_grpclb_client_stats_ref(glb_policy->client_stats);
wc_arg->wrapped_closure = on_complete; wc_arg->wrapped_closure = on_complete;
wc_arg->lb_token_mdelem_storage = pick_args->lb_token_mdelem_storage; wc_arg->lb_token_mdelem_storage = pick_args->lb_token_mdelem_storage;
wc_arg->initial_metadata = pick_args->initial_metadata; wc_arg->initial_metadata = pick_args->initial_metadata;
@ -1062,7 +1124,7 @@ static int glb_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
"picks", "picks",
(void *)(glb_policy)); (void *)(glb_policy));
} }
add_pending_pick(&glb_policy->pending_picks, pick_args, target, add_pending_pick(&glb_policy->pending_picks, pick_args, target, context,
on_complete); on_complete);
if (!glb_policy->started_picking) { if (!glb_policy->started_picking) {
@ -1103,6 +1165,104 @@ static void glb_notify_on_state_change_locked(grpc_exec_ctx *exec_ctx,
exec_ctx, &glb_policy->state_tracker, current, notify); exec_ctx, &glb_policy->state_tracker, current, notify);
} }
static void send_client_load_report_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error);
static void schedule_next_client_load_report(grpc_exec_ctx *exec_ctx,
glb_lb_policy *glb_policy) {
const gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
const gpr_timespec next_client_load_report_time =
gpr_time_add(now, glb_policy->client_stats_report_interval);
grpc_closure_init(&glb_policy->client_load_report_closure,
send_client_load_report_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner, false));
grpc_timer_init(exec_ctx, &glb_policy->client_load_report_timer,
next_client_load_report_time,
&glb_policy->client_load_report_closure, now);
}
static void client_load_report_done_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
glb_lb_policy *glb_policy = arg;
grpc_byte_buffer_destroy(glb_policy->client_load_report_payload);
glb_policy->client_load_report_payload = NULL;
if (error != GRPC_ERROR_NONE || glb_policy->lb_call == NULL) {
glb_policy->client_load_report_timer_pending = false;
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"client_load_report");
return;
}
schedule_next_client_load_report(exec_ctx, glb_policy);
}
static void do_send_client_load_report_locked(grpc_exec_ctx *exec_ctx,
glb_lb_policy *glb_policy) {
grpc_op op;
memset(&op, 0, sizeof(op));
op.op = GRPC_OP_SEND_MESSAGE;
op.data.send_message.send_message = glb_policy->client_load_report_payload;
grpc_closure_init(&glb_policy->client_load_report_closure,
client_load_report_done_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner, false));
grpc_call_error call_error = grpc_call_start_batch_and_execute(
exec_ctx, glb_policy->lb_call, &op, 1,
&glb_policy->client_load_report_closure);
GPR_ASSERT(GRPC_CALL_OK == call_error);
}
static bool load_report_counters_are_zero(grpc_grpclb_request *request) {
return request->client_stats.num_calls_started == 0 &&
request->client_stats.num_calls_finished == 0 &&
request->client_stats.num_calls_finished_with_drop_for_rate_limiting ==
0 &&
request->client_stats
.num_calls_finished_with_drop_for_load_balancing == 0 &&
request->client_stats.num_calls_finished_with_client_failed_to_send ==
0 &&
request->client_stats.num_calls_finished_known_received == 0;
}
static void send_client_load_report_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
glb_lb_policy *glb_policy = arg;
if (error == GRPC_ERROR_CANCELLED || glb_policy->lb_call == NULL) {
glb_policy->client_load_report_timer_pending = false;
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"client_load_report");
return;
}
// Construct message payload.
GPR_ASSERT(glb_policy->client_load_report_payload == NULL);
grpc_grpclb_request *request =
grpc_grpclb_load_report_request_create(glb_policy->client_stats);
// Skip client load report if the counters were all zero in the last
// report and they are still zero in this one.
if (load_report_counters_are_zero(request)) {
if (glb_policy->last_client_load_report_counters_were_zero) {
grpc_grpclb_request_destroy(request);
schedule_next_client_load_report(exec_ctx, glb_policy);
return;
}
glb_policy->last_client_load_report_counters_were_zero = true;
} else {
glb_policy->last_client_load_report_counters_were_zero = false;
}
grpc_slice request_payload_slice = grpc_grpclb_request_encode(request);
glb_policy->client_load_report_payload =
grpc_raw_byte_buffer_create(&request_payload_slice, 1);
grpc_slice_unref_internal(exec_ctx, request_payload_slice);
grpc_grpclb_request_destroy(request);
// If we've already sent the initial request, then we can go ahead and
// sent the load report. Otherwise, we need to wait until the initial
// request has been sent to send this
// (see lb_on_sent_initial_request_locked() below).
if (glb_policy->initial_request_sent) {
do_send_client_load_report_locked(exec_ctx, glb_policy);
}
}
static void lb_on_sent_initial_request_locked(grpc_exec_ctx *exec_ctx,
void *arg, grpc_error *error);
static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx, static void lb_on_server_status_received_locked(grpc_exec_ctx *exec_ctx,
void *arg, grpc_error *error); void *arg, grpc_error *error);
static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg,
@ -1117,13 +1277,24 @@ static void lb_call_init_locked(grpc_exec_ctx *exec_ctx,
* glb_policy->base.interested_parties, which is comprised of the polling * glb_policy->base.interested_parties, which is comprised of the polling
* entities from \a client_channel. */ * entities from \a client_channel. */
grpc_slice host = grpc_slice_from_copied_string(glb_policy->server_name); grpc_slice host = grpc_slice_from_copied_string(glb_policy->server_name);
gpr_timespec deadline =
glb_policy->lb_call_timeout_ms == 0
? gpr_inf_future(GPR_CLOCK_MONOTONIC)
: gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
gpr_time_from_millis(glb_policy->lb_call_timeout_ms,
GPR_TIMESPAN));
glb_policy->lb_call = grpc_channel_create_pollset_set_call( glb_policy->lb_call = grpc_channel_create_pollset_set_call(
exec_ctx, glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS, exec_ctx, glb_policy->lb_channel, NULL, GRPC_PROPAGATE_DEFAULTS,
glb_policy->base.interested_parties, glb_policy->base.interested_parties,
GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD, GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD,
&host, glb_policy->deadline, NULL); &host, deadline, NULL);
grpc_slice_unref_internal(exec_ctx, host); grpc_slice_unref_internal(exec_ctx, host);
if (glb_policy->client_stats != NULL) {
grpc_grpclb_client_stats_unref(glb_policy->client_stats);
}
glb_policy->client_stats = grpc_grpclb_client_stats_create();
grpc_metadata_array_init(&glb_policy->lb_initial_metadata_recv); grpc_metadata_array_init(&glb_policy->lb_initial_metadata_recv);
grpc_metadata_array_init(&glb_policy->lb_trailing_metadata_recv); grpc_metadata_array_init(&glb_policy->lb_trailing_metadata_recv);
@ -1135,6 +1306,9 @@ static void lb_call_init_locked(grpc_exec_ctx *exec_ctx,
grpc_slice_unref_internal(exec_ctx, request_payload_slice); grpc_slice_unref_internal(exec_ctx, request_payload_slice);
grpc_grpclb_request_destroy(request); grpc_grpclb_request_destroy(request);
grpc_closure_init(&glb_policy->lb_on_sent_initial_request,
lb_on_sent_initial_request_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner, false));
grpc_closure_init(&glb_policy->lb_on_server_status_received, grpc_closure_init(&glb_policy->lb_on_server_status_received,
lb_on_server_status_received_locked, glb_policy, lb_on_server_status_received_locked, glb_policy,
grpc_combiner_scheduler(glb_policy->base.combiner, false)); grpc_combiner_scheduler(glb_policy->base.combiner, false));
@ -1148,6 +1322,10 @@ static void lb_call_init_locked(grpc_exec_ctx *exec_ctx,
GRPC_GRPCLB_RECONNECT_JITTER, GRPC_GRPCLB_RECONNECT_JITTER,
GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS * 1000, GRPC_GRPCLB_MIN_CONNECT_TIMEOUT_SECONDS * 1000,
GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS * 1000); GRPC_GRPCLB_RECONNECT_MAX_BACKOFF_SECONDS * 1000);
glb_policy->initial_request_sent = false;
glb_policy->seen_initial_response = false;
glb_policy->last_client_load_report_counters_were_zero = false;
} }
static void lb_call_destroy_locked(grpc_exec_ctx *exec_ctx, static void lb_call_destroy_locked(grpc_exec_ctx *exec_ctx,
@ -1161,6 +1339,10 @@ static void lb_call_destroy_locked(grpc_exec_ctx *exec_ctx,
grpc_byte_buffer_destroy(glb_policy->lb_request_payload); grpc_byte_buffer_destroy(glb_policy->lb_request_payload);
grpc_slice_unref_internal(exec_ctx, glb_policy->lb_call_status_details); grpc_slice_unref_internal(exec_ctx, glb_policy->lb_call_status_details);
if (!glb_policy->client_load_report_timer_pending) {
grpc_timer_cancel(exec_ctx, &glb_policy->client_load_report_timer);
}
} }
/* /*
@ -1189,21 +1371,27 @@ static void query_for_backends_locked(grpc_exec_ctx *exec_ctx,
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA; op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata.recv_initial_metadata = op->data.recv_initial_metadata.recv_initial_metadata =
&glb_policy->lb_initial_metadata_recv; &glb_policy->lb_initial_metadata_recv;
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
GPR_ASSERT(glb_policy->lb_request_payload != NULL); GPR_ASSERT(glb_policy->lb_request_payload != NULL);
op->op = GRPC_OP_SEND_MESSAGE; op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = glb_policy->lb_request_payload; op->data.send_message.send_message = glb_policy->lb_request_payload;
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
/* take a weak ref (won't prevent calling of \a glb_shutdown if the strong ref
* count goes to zero) to be unref'd in lb_on_sent_initial_request_locked() */
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "lb_on_server_status_received");
call_error = grpc_call_start_batch_and_execute(
exec_ctx, glb_policy->lb_call, ops, (size_t)(op - ops),
&glb_policy->lb_on_sent_initial_request);
GPR_ASSERT(GRPC_CALL_OK == call_error);
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = op->data.recv_status_on_client.trailing_metadata =
&glb_policy->lb_trailing_metadata_recv; &glb_policy->lb_trailing_metadata_recv;
@ -1235,6 +1423,19 @@ static void query_for_backends_locked(grpc_exec_ctx *exec_ctx,
GPR_ASSERT(GRPC_CALL_OK == call_error); GPR_ASSERT(GRPC_CALL_OK == call_error);
} }
static void lb_on_sent_initial_request_locked(grpc_exec_ctx *exec_ctx,
void *arg, grpc_error *error) {
glb_lb_policy *glb_policy = arg;
glb_policy->initial_request_sent = true;
// If we attempted to send a client load report before the initial
// request was sent, send the load report now.
if (glb_policy->client_load_report_payload != NULL) {
do_send_client_load_report_locked(exec_ctx, glb_policy);
}
GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, &glb_policy->base,
"lb_on_response_received_locked");
}
static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg, static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) { grpc_error *error) {
glb_lb_policy *glb_policy = arg; glb_lb_policy *glb_policy = arg;
@ -1250,58 +1451,91 @@ static void lb_on_response_received_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_byte_buffer_reader_init(&bbr, glb_policy->lb_response_payload); grpc_byte_buffer_reader_init(&bbr, glb_policy->lb_response_payload);
grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr); grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr);
grpc_byte_buffer_destroy(glb_policy->lb_response_payload); grpc_byte_buffer_destroy(glb_policy->lb_response_payload);
grpc_grpclb_serverlist *serverlist =
grpc_grpclb_response_parse_serverlist(response_slice); grpc_grpclb_initial_response *response = NULL;
if (serverlist != NULL) { if (!glb_policy->seen_initial_response &&
GPR_ASSERT(glb_policy->lb_call != NULL); (response = grpc_grpclb_initial_response_parse(response_slice)) !=
grpc_slice_unref_internal(exec_ctx, response_slice); NULL) {
if (grpc_lb_glb_trace) { if (response->has_client_stats_report_interval) {
gpr_log(GPR_INFO, "Serverlist with %lu servers received", glb_policy->client_stats_report_interval =
(unsigned long)serverlist->num_servers); gpr_time_max(gpr_time_from_seconds(1, GPR_TIMESPAN),
for (size_t i = 0; i < serverlist->num_servers; ++i) { grpc_grpclb_duration_to_timespec(
grpc_resolved_address addr; &response->client_stats_report_interval));
parse_server(serverlist->servers[i], &addr); if (grpc_lb_glb_trace) {
char *ipport; gpr_log(GPR_INFO,
grpc_sockaddr_to_string(&ipport, &addr, false); "received initial LB response message; "
gpr_log(GPR_INFO, "Serverlist[%lu]: %s", (unsigned long)i, ipport); "client load reporting interval = %" PRId64 ".%09d sec",
gpr_free(ipport); glb_policy->client_stats_report_interval.tv_sec,
glb_policy->client_stats_report_interval.tv_nsec);
} }
/* take a weak ref (won't prevent calling of \a glb_shutdown() if the
* strong ref count goes to zero) to be unref'd in
* send_client_load_report() */
glb_policy->client_load_report_timer_pending = true;
GRPC_LB_POLICY_WEAK_REF(&glb_policy->base, "client_load_report");
schedule_next_client_load_report(exec_ctx, glb_policy);
} else if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO,
"received initial LB response message; "
"client load reporting NOT enabled");
} }
grpc_grpclb_initial_response_destroy(response);
glb_policy->seen_initial_response = true;
} else {
grpc_grpclb_serverlist *serverlist =
grpc_grpclb_response_parse_serverlist(response_slice);
if (serverlist != NULL) {
GPR_ASSERT(glb_policy->lb_call != NULL);
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Serverlist with %lu servers received",
(unsigned long)serverlist->num_servers);
for (size_t i = 0; i < serverlist->num_servers; ++i) {
grpc_resolved_address addr;
parse_server(serverlist->servers[i], &addr);
char *ipport;
grpc_sockaddr_to_string(&ipport, &addr, false);
gpr_log(GPR_INFO, "Serverlist[%lu]: %s", (unsigned long)i, ipport);
gpr_free(ipport);
}
}
/* update serverlist */ /* update serverlist */
if (serverlist->num_servers > 0) { if (serverlist->num_servers > 0) {
if (grpc_grpclb_serverlist_equals(glb_policy->serverlist, serverlist)) { if (grpc_grpclb_serverlist_equals(glb_policy->serverlist,
serverlist)) {
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO,
"Incoming server list identical to current, ignoring.");
}
grpc_grpclb_destroy_serverlist(serverlist);
} else { /* new serverlist */
if (glb_policy->serverlist != NULL) {
/* dispose of the old serverlist */
grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
}
/* and update the copy in the glb_lb_policy instance. This
* serverlist instance will be destroyed either upon the next
* update or in glb_destroy() */
glb_policy->serverlist = serverlist;
rr_handover_locked(exec_ctx, glb_policy);
}
} else {
if (grpc_lb_glb_trace) { if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"Incoming server list identical to current, ignoring."); "Received empty server list. Picks will stay pending until "
"a response with > 0 servers is received");
} }
grpc_grpclb_destroy_serverlist(serverlist); grpc_grpclb_destroy_serverlist(serverlist);
} else { /* new serverlist */
if (glb_policy->serverlist != NULL) {
/* dispose of the old serverlist */
grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
}
/* and update the copy in the glb_lb_policy instance. This serverlist
* instance will be destroyed either upon the next update or in
* glb_destroy() */
glb_policy->serverlist = serverlist;
rr_handover_locked(exec_ctx, glb_policy);
}
} else {
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO,
"Received empty server list. Picks will stay pending until a "
"response with > 0 servers is received");
} }
grpc_grpclb_destroy_serverlist(glb_policy->serverlist); } else { /* serverlist == NULL */
gpr_log(GPR_ERROR, "Invalid LB response received: '%s'. Ignoring.",
grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX));
} }
} else { /* serverlist == NULL */
gpr_log(GPR_ERROR, "Invalid LB response received: '%s'. Ignoring.",
grpc_dump_slice(response_slice, GPR_DUMP_ASCII | GPR_DUMP_HEX));
grpc_slice_unref_internal(exec_ctx, response_slice);
} }
grpc_slice_unref_internal(exec_ctx, response_slice);
if (!glb_policy->shutting_down) { if (!glb_policy->shutting_down) {
/* keep listening for serverlist updates */ /* keep listening for serverlist updates */
op->op = GRPC_OP_RECV_MESSAGE; op->op = GRPC_OP_RECV_MESSAGE;
@ -1413,9 +1647,29 @@ grpc_lb_policy_factory *grpc_glb_lb_factory_create() {
} }
/* Plugin registration */ /* Plugin registration */
// Only add client_load_reporting filter if the grpclb LB policy is used.
static bool maybe_add_client_load_reporting_filter(
grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) {
const grpc_channel_args *args =
grpc_channel_stack_builder_get_channel_arguments(builder);
const grpc_arg *channel_arg =
grpc_channel_args_find(args, GRPC_ARG_LB_POLICY_NAME);
if (channel_arg != NULL && channel_arg->type == GRPC_ARG_STRING &&
strcmp(channel_arg->value.string, "grpclb") == 0) {
return grpc_channel_stack_builder_append_filter(
builder, (const grpc_channel_filter *)arg, NULL, NULL);
}
return true;
}
void grpc_lb_policy_grpclb_init() { void grpc_lb_policy_grpclb_init() {
grpc_register_lb_policy(grpc_glb_lb_factory_create()); grpc_register_lb_policy(grpc_glb_lb_factory_create());
grpc_register_tracer("glb", &grpc_lb_glb_trace); grpc_register_tracer("glb", &grpc_lb_glb_trace);
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL,
GRPC_CHANNEL_INIT_BUILTIN_PRIORITY,
maybe_add_client_load_reporting_filter,
(void *)&grpc_client_load_reporting_filter);
} }
void grpc_lb_policy_grpclb_shutdown() {} void grpc_lb_policy_grpclb_shutdown() {}

@ -0,0 +1,133 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
#include "src/core/lib/channel/channel_args.h"
#define GRPC_ARG_GRPCLB_CLIENT_STATS "grpc.grpclb_client_stats"
struct grpc_grpclb_client_stats {
gpr_refcount refs;
gpr_atm num_calls_started;
gpr_atm num_calls_finished;
gpr_atm num_calls_finished_with_drop_for_rate_limiting;
gpr_atm num_calls_finished_with_drop_for_load_balancing;
gpr_atm num_calls_finished_with_client_failed_to_send;
gpr_atm num_calls_finished_known_received;
};
grpc_grpclb_client_stats* grpc_grpclb_client_stats_create() {
grpc_grpclb_client_stats* client_stats = gpr_zalloc(sizeof(*client_stats));
gpr_ref_init(&client_stats->refs, 1);
return client_stats;
}
grpc_grpclb_client_stats* grpc_grpclb_client_stats_ref(
grpc_grpclb_client_stats* client_stats) {
gpr_ref(&client_stats->refs);
return client_stats;
}
void grpc_grpclb_client_stats_unref(grpc_grpclb_client_stats* client_stats) {
if (gpr_unref(&client_stats->refs)) {
gpr_free(client_stats);
}
}
void grpc_grpclb_client_stats_add_call_started(
grpc_grpclb_client_stats* client_stats) {
gpr_atm_full_fetch_add(&client_stats->num_calls_started, (gpr_atm)1);
}
void grpc_grpclb_client_stats_add_call_finished(
bool finished_with_drop_for_rate_limiting,
bool finished_with_drop_for_load_balancing,
bool finished_with_client_failed_to_send, bool finished_known_received,
grpc_grpclb_client_stats* client_stats) {
gpr_atm_full_fetch_add(&client_stats->num_calls_finished, (gpr_atm)1);
if (finished_with_drop_for_rate_limiting) {
gpr_atm_full_fetch_add(
&client_stats->num_calls_finished_with_drop_for_rate_limiting,
(gpr_atm)1);
}
if (finished_with_drop_for_load_balancing) {
gpr_atm_full_fetch_add(
&client_stats->num_calls_finished_with_drop_for_load_balancing,
(gpr_atm)1);
}
if (finished_with_client_failed_to_send) {
gpr_atm_full_fetch_add(
&client_stats->num_calls_finished_with_client_failed_to_send,
(gpr_atm)1);
}
if (finished_known_received) {
gpr_atm_full_fetch_add(&client_stats->num_calls_finished_known_received,
(gpr_atm)1);
}
}
static void atomic_get_and_reset_counter(int64_t* value, gpr_atm* counter) {
*value = (int64_t)gpr_atm_acq_load(counter);
gpr_atm_full_fetch_add(counter, (gpr_atm)(-*value));
}
void grpc_grpclb_client_stats_get(
grpc_grpclb_client_stats* client_stats, int64_t* num_calls_started,
int64_t* num_calls_finished,
int64_t* num_calls_finished_with_drop_for_rate_limiting,
int64_t* num_calls_finished_with_drop_for_load_balancing,
int64_t* num_calls_finished_with_client_failed_to_send,
int64_t* num_calls_finished_known_received) {
atomic_get_and_reset_counter(num_calls_started,
&client_stats->num_calls_started);
atomic_get_and_reset_counter(num_calls_finished,
&client_stats->num_calls_finished);
atomic_get_and_reset_counter(
num_calls_finished_with_drop_for_rate_limiting,
&client_stats->num_calls_finished_with_drop_for_rate_limiting);
atomic_get_and_reset_counter(
num_calls_finished_with_drop_for_load_balancing,
&client_stats->num_calls_finished_with_drop_for_load_balancing);
atomic_get_and_reset_counter(
num_calls_finished_with_client_failed_to_send,
&client_stats->num_calls_finished_with_client_failed_to_send);
atomic_get_and_reset_counter(
num_calls_finished_known_received,
&client_stats->num_calls_finished_known_received);
}

@ -0,0 +1,65 @@
/*
*
* Copyright 2017, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_CLIENT_STATS_H
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_CLIENT_STATS_H
#include <stdbool.h>
#include <grpc/impl/codegen/grpc_types.h>
typedef struct grpc_grpclb_client_stats grpc_grpclb_client_stats;
grpc_grpclb_client_stats* grpc_grpclb_client_stats_create();
grpc_grpclb_client_stats* grpc_grpclb_client_stats_ref(
grpc_grpclb_client_stats* client_stats);
void grpc_grpclb_client_stats_unref(grpc_grpclb_client_stats* client_stats);
void grpc_grpclb_client_stats_add_call_started(
grpc_grpclb_client_stats* client_stats);
void grpc_grpclb_client_stats_add_call_finished(
bool finished_with_drop_for_rate_limiting,
bool finished_with_drop_for_load_balancing,
bool finished_with_client_failed_to_send, bool finished_known_received,
grpc_grpclb_client_stats* client_stats);
void grpc_grpclb_client_stats_get(
grpc_grpclb_client_stats* client_stats, int64_t* num_calls_started,
int64_t* num_calls_finished,
int64_t* num_calls_finished_with_drop_for_rate_limiting,
int64_t* num_calls_finished_with_drop_for_load_balancing,
int64_t* num_calls_finished_with_client_failed_to_send,
int64_t* num_calls_finished_known_received);
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_GRPCLB_GRPCLB_CLIENT_STATS_H \
*/

@ -80,15 +80,45 @@ static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name) { grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name) {
grpc_grpclb_request *req = gpr_malloc(sizeof(grpc_grpclb_request)); grpc_grpclb_request *req = gpr_malloc(sizeof(grpc_grpclb_request));
req->has_client_stats = false;
req->has_client_stats = 0; /* TODO(dgq): add support for stats once defined */ req->has_initial_request = true;
req->has_initial_request = 1; req->initial_request.has_name = true;
req->initial_request.has_name = 1;
strncpy(req->initial_request.name, lb_service_name, strncpy(req->initial_request.name, lb_service_name,
GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH); GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH);
return req; return req;
} }
static void populate_timestamp(gpr_timespec timestamp,
struct _grpc_lb_v1_Timestamp *timestamp_pb) {
timestamp_pb->has_seconds = true;
timestamp_pb->seconds = timestamp.tv_sec;
timestamp_pb->has_nanos = true;
timestamp_pb->nanos = timestamp.tv_nsec;
}
grpc_grpclb_request *grpc_grpclb_load_report_request_create(
grpc_grpclb_client_stats *client_stats) {
grpc_grpclb_request *req = gpr_zalloc(sizeof(grpc_grpclb_request));
req->has_client_stats = true;
req->client_stats.has_timestamp = true;
populate_timestamp(gpr_now(GPR_CLOCK_REALTIME), &req->client_stats.timestamp);
req->client_stats.has_num_calls_started = true;
req->client_stats.has_num_calls_finished = true;
req->client_stats.has_num_calls_finished_with_drop_for_rate_limiting = true;
req->client_stats.has_num_calls_finished_with_drop_for_load_balancing = true;
req->client_stats.has_num_calls_finished_with_client_failed_to_send = true;
req->client_stats.has_num_calls_finished_with_client_failed_to_send = true;
req->client_stats.has_num_calls_finished_known_received = true;
grpc_grpclb_client_stats_get(
client_stats, &req->client_stats.num_calls_started,
&req->client_stats.num_calls_finished,
&req->client_stats.num_calls_finished_with_drop_for_rate_limiting,
&req->client_stats.num_calls_finished_with_drop_for_load_balancing,
&req->client_stats.num_calls_finished_with_client_failed_to_send,
&req->client_stats.num_calls_finished_known_received);
return req;
}
grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) { grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) {
size_t encoded_length; size_t encoded_length;
pb_ostream_t sizestream; pb_ostream_t sizestream;
@ -98,7 +128,7 @@ grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) {
pb_encode(&sizestream, grpc_lb_v1_LoadBalanceRequest_fields, request); pb_encode(&sizestream, grpc_lb_v1_LoadBalanceRequest_fields, request);
encoded_length = sizestream.bytes_written; encoded_length = sizestream.bytes_written;
slice = grpc_slice_malloc(encoded_length); slice = GRPC_SLICE_MALLOC(encoded_length);
outputstream = outputstream =
pb_ostream_from_buffer(GRPC_SLICE_START_PTR(slice), encoded_length); pb_ostream_from_buffer(GRPC_SLICE_START_PTR(slice), encoded_length);
GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v1_LoadBalanceRequest_fields, GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v1_LoadBalanceRequest_fields,
@ -122,6 +152,9 @@ grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream)); gpr_log(GPR_ERROR, "nanopb error: %s", PB_GET_ERROR(&stream));
return NULL; return NULL;
} }
if (!res.has_initial_response) return NULL;
grpc_grpclb_initial_response *initial_res = grpc_grpclb_initial_response *initial_res =
gpr_malloc(sizeof(grpc_grpclb_initial_response)); gpr_malloc(sizeof(grpc_grpclb_initial_response));
memcpy(initial_res, &res.initial_response, memcpy(initial_res, &res.initial_response,
@ -243,6 +276,15 @@ int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
return 0; return 0;
} }
gpr_timespec grpc_grpclb_duration_to_timespec(
grpc_grpclb_duration *duration_pb) {
gpr_timespec duration;
duration.tv_sec = duration_pb->has_seconds ? duration_pb->seconds : 0;
duration.tv_nsec = duration_pb->has_nanos ? duration_pb->nanos : 0;
duration.clock_type = GPR_TIMESPAN;
return duration;
}
void grpc_grpclb_initial_response_destroy( void grpc_grpclb_initial_response_destroy(
grpc_grpclb_initial_response *response) { grpc_grpclb_initial_response *response) {
gpr_free(response); gpr_free(response);

@ -36,6 +36,7 @@
#include <grpc/slice_buffer.h> #include <grpc/slice_buffer.h>
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h"
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" #include "src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h"
#include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/ext/filters/client_channel/lb_policy_factory.h"
@ -58,6 +59,8 @@ typedef struct grpc_grpclb_serverlist {
/** Create a request for a gRPC LB service under \a lb_service_name */ /** Create a request for a gRPC LB service under \a lb_service_name */
grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name); grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name);
grpc_grpclb_request *grpc_grpclb_load_report_request_create(
grpc_grpclb_client_stats *client_stats);
/** Protocol Buffers v3-encode \a request */ /** Protocol Buffers v3-encode \a request */
grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request); grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request);
@ -93,6 +96,9 @@ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist);
int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs, int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
const grpc_grpclb_duration *rhs); const grpc_grpclb_duration *rhs);
gpr_timespec grpc_grpclb_duration_to_timespec(
grpc_grpclb_duration *duration_pb);
/** Destroy \a initial_response */ /** Destroy \a initial_response */
void grpc_grpclb_initial_response_destroy( void grpc_grpclb_initial_response_destroy(
grpc_grpclb_initial_response *response); grpc_grpclb_initial_response *response);

@ -189,7 +189,8 @@ static void pf_exit_idle_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static int pf_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, static int pf_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
const grpc_lb_policy_pick_args *pick_args, const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target, void **user_data, grpc_connected_subchannel **target,
grpc_call_context_element *context, void **user_data,
grpc_closure *on_complete) { grpc_closure *on_complete) {
pick_first_lb_policy *p = (pick_first_lb_policy *)pol; pick_first_lb_policy *p = (pick_first_lb_policy *)pol;
pending_pick *pp; pending_pick *pp;

@ -414,7 +414,8 @@ static void rr_exit_idle_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, static int rr_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
const grpc_lb_policy_pick_args *pick_args, const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target, void **user_data, grpc_connected_subchannel **target,
grpc_call_context_element *context, void **user_data,
grpc_closure *on_complete) { grpc_closure *on_complete) {
round_robin_lb_policy *p = (round_robin_lb_policy *)pol; round_robin_lb_policy *p = (round_robin_lb_policy *)pol;
pending_pick *pp; pending_pick *pp;

@ -615,7 +615,7 @@ void grpc_connected_subchannel_ping(grpc_exec_ctx *exec_ctx,
elem->filter->start_transport_op(exec_ctx, elem, op); elem->filter->start_transport_op(exec_ctx, elem, op);
} }
static void publish_transport_locked(grpc_exec_ctx *exec_ctx, static bool publish_transport_locked(grpc_exec_ctx *exec_ctx,
grpc_subchannel *c) { grpc_subchannel *c) {
grpc_connected_subchannel *con; grpc_connected_subchannel *con;
grpc_channel_stack *stk; grpc_channel_stack *stk;
@ -631,15 +631,16 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
if (!grpc_channel_init_create_stack(exec_ctx, builder, if (!grpc_channel_init_create_stack(exec_ctx, builder,
GRPC_CLIENT_SUBCHANNEL)) { GRPC_CLIENT_SUBCHANNEL)) {
grpc_channel_stack_builder_destroy(exec_ctx, builder); grpc_channel_stack_builder_destroy(exec_ctx, builder);
abort(); /* TODO(ctiller): what to do here (previously we just crashed) */ return false;
} }
grpc_error *error = grpc_channel_stack_builder_finish( grpc_error *error = grpc_channel_stack_builder_finish(
exec_ctx, builder, 0, 1, connection_destroy, NULL, (void **)&con); exec_ctx, builder, 0, 1, connection_destroy, NULL, (void **)&con);
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
grpc_transport_destroy(exec_ctx, c->connecting_result.transport);
gpr_log(GPR_ERROR, "error initializing subchannel stack: %s", gpr_log(GPR_ERROR, "error initializing subchannel stack: %s",
grpc_error_string(error)); grpc_error_string(error));
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
abort(); /* TODO(ctiller): what to do here? */ return false;
} }
stk = CHANNEL_STACK_FROM_CONNECTION(con); stk = CHANNEL_STACK_FROM_CONNECTION(con);
memset(&c->connecting_result, 0, sizeof(c->connecting_result)); memset(&c->connecting_result, 0, sizeof(c->connecting_result));
@ -656,7 +657,7 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
grpc_channel_stack_destroy(exec_ctx, stk); grpc_channel_stack_destroy(exec_ctx, stk);
gpr_free(con); gpr_free(con);
GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting"); GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
return; return false;
} }
/* publish */ /* publish */
@ -678,6 +679,7 @@ static void publish_transport_locked(grpc_exec_ctx *exec_ctx,
/* signal completion */ /* signal completion */
grpc_connectivity_state_set(exec_ctx, &c->state_tracker, GRPC_CHANNEL_READY, grpc_connectivity_state_set(exec_ctx, &c->state_tracker, GRPC_CHANNEL_READY,
GRPC_ERROR_NONE, "connected"); GRPC_ERROR_NONE, "connected");
return true;
} }
static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg, static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg,
@ -688,8 +690,9 @@ static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg,
GRPC_SUBCHANNEL_WEAK_REF(c, "connected"); GRPC_SUBCHANNEL_WEAK_REF(c, "connected");
gpr_mu_lock(&c->mu); gpr_mu_lock(&c->mu);
c->connecting = false; c->connecting = false;
if (c->connecting_result.transport != NULL) { if (c->connecting_result.transport != NULL &&
publish_transport_locked(exec_ctx, c); publish_transport_locked(exec_ctx, c)) {
/* do nothing, transport was published */
} else if (c->disconnected) { } else if (c->disconnected) {
GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting"); GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
} else { } else {
@ -778,7 +781,7 @@ grpc_error *grpc_connected_subchannel_create_call(
(*call)->connection = GRPC_CONNECTED_SUBCHANNEL_REF(con, "subchannel_call"); (*call)->connection = GRPC_CONNECTED_SUBCHANNEL_REF(con, "subchannel_call");
const grpc_call_element_args call_args = {.call_stack = callstk, const grpc_call_element_args call_args = {.call_stack = callstk,
.server_transport_data = NULL, .server_transport_data = NULL,
.context = NULL, .context = args->context,
.path = args->path, .path = args->path,
.start_time = args->start_time, .start_time = args->start_time,
.deadline = args->deadline, .deadline = args->deadline,

@ -119,6 +119,7 @@ typedef struct {
gpr_timespec start_time; gpr_timespec start_time;
gpr_timespec deadline; gpr_timespec deadline;
gpr_arena *arena; gpr_arena *arena;
grpc_call_context_element *context;
} grpc_connected_subchannel_call_args; } grpc_connected_subchannel_call_args;
grpc_error *grpc_connected_subchannel_create_call( grpc_error *grpc_connected_subchannel_create_call(

@ -323,7 +323,7 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx,
estimated_len += grpc_base64_estimate_encoded_size( estimated_len += grpc_base64_estimate_encoded_size(
op->payload->send_message.send_message->length, k_url_safe, op->payload->send_message.send_message->length, k_url_safe,
k_multi_line); k_multi_line);
grpc_slice path_with_query_slice = grpc_slice_malloc(estimated_len); grpc_slice path_with_query_slice = GRPC_SLICE_MALLOC(estimated_len);
/* memcopy individual pieces into this slice */ /* memcopy individual pieces into this slice */
uint8_t *write_ptr = uint8_t *write_ptr =

@ -49,8 +49,6 @@
#include "src/core/lib/support/string.h" #include "src/core/lib/support/string.h"
#include "src/core/lib/transport/static_metadata.h" #include "src/core/lib/transport/static_metadata.h"
int grpc_compression_trace = 0;
#define INITIAL_METADATA_UNSEEN 0 #define INITIAL_METADATA_UNSEEN 0
#define HAS_COMPRESSION_ALGORITHM 2 #define HAS_COMPRESSION_ALGORITHM 2
#define NO_COMPRESSION_ALGORITHM 4 #define NO_COMPRESSION_ALGORITHM 4
@ -279,13 +277,10 @@ static void compress_start_transport_stream_op_batch(
GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0); GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0);
if (op->cancel_stream) { if (op->cancel_stream) {
gpr_atm cur;
GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error); GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error);
do { gpr_atm cur = gpr_atm_full_xchg(
cur = gpr_atm_acq_load(&calld->send_initial_metadata_state); &calld->send_initial_metadata_state,
} while (!gpr_atm_rel_cas( CANCELLED_BIT | (gpr_atm)op->payload->cancel_stream.cancel_error);
&calld->send_initial_metadata_state, cur,
CANCELLED_BIT | (gpr_atm)op->payload->cancel_stream.cancel_error));
switch (cur) { switch (cur) {
case HAS_COMPRESSION_ALGORITHM: case HAS_COMPRESSION_ALGORITHM:
case NO_COMPRESSION_ALGORITHM: case NO_COMPRESSION_ALGORITHM:
@ -313,13 +308,18 @@ static void compress_start_transport_stream_op_batch(
grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error); grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error);
return; return;
} }
gpr_atm cur = gpr_atm_acq_load(&calld->send_initial_metadata_state); gpr_atm cur;
retry_send_im:
cur = gpr_atm_acq_load(&calld->send_initial_metadata_state);
GPR_ASSERT(cur != HAS_COMPRESSION_ALGORITHM && GPR_ASSERT(cur != HAS_COMPRESSION_ALGORITHM &&
cur != NO_COMPRESSION_ALGORITHM); cur != NO_COMPRESSION_ALGORITHM);
if ((cur & CANCELLED_BIT) == 0) { if ((cur & CANCELLED_BIT) == 0) {
gpr_atm_rel_store(&calld->send_initial_metadata_state, if (!gpr_atm_rel_cas(&calld->send_initial_metadata_state, cur,
has_compression_algorithm ? HAS_COMPRESSION_ALGORITHM has_compression_algorithm
: NO_COMPRESSION_ALGORITHM); ? HAS_COMPRESSION_ALGORITHM
: NO_COMPRESSION_ALGORITHM)) {
goto retry_send_im;
}
if (cur != INITIAL_METADATA_UNSEEN) { if (cur != INITIAL_METADATA_UNSEEN) {
grpc_call_next_op(exec_ctx, elem, grpc_call_next_op(exec_ctx, elem,
(grpc_transport_stream_op_batch *)cur); (grpc_transport_stream_op_batch *)cur);

@ -50,19 +50,10 @@ typedef struct message_size_limits {
int max_recv_size; int max_recv_size;
} message_size_limits; } message_size_limits;
static void* message_size_limits_copy(void* value) {
void* new_value = gpr_malloc(sizeof(message_size_limits));
memcpy(new_value, value, sizeof(message_size_limits));
return new_value;
}
static void message_size_limits_free(grpc_exec_ctx* exec_ctx, void* value) { static void message_size_limits_free(grpc_exec_ctx* exec_ctx, void* value) {
gpr_free(value); gpr_free(value);
} }
static const grpc_slice_hash_table_vtable message_size_limits_vtable = {
message_size_limits_free, message_size_limits_copy};
static void* message_size_limits_create_from_json(const grpc_json* json) { static void* message_size_limits_create_from_json(const grpc_json* json) {
int max_request_message_bytes = -1; int max_request_message_bytes = -1;
int max_response_message_bytes = -1; int max_response_message_bytes = -1;
@ -130,6 +121,8 @@ static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data,
GRPC_ERROR_UNREF(new_error); GRPC_ERROR_UNREF(new_error);
} }
gpr_free(message_string); gpr_free(message_string);
} else {
GRPC_ERROR_REF(error);
} }
// Invoke the next callback. // Invoke the next callback.
grpc_closure_run(exec_ctx, calld->next_recv_message_ready, error); grpc_closure_run(exec_ctx, calld->next_recv_message_ready, error);
@ -255,7 +248,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx,
chand->method_limit_table = chand->method_limit_table =
grpc_service_config_create_method_config_table( grpc_service_config_create_method_config_table(
exec_ctx, service_config, message_size_limits_create_from_json, exec_ctx, service_config, message_size_limits_create_from_json,
&message_size_limits_vtable); message_size_limits_free);
grpc_service_config_destroy(service_config); grpc_service_config_destroy(service_config);
} }
} }

@ -80,7 +80,7 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
gpr_mu_lock(&connection_state->server_state->mu); gpr_mu_lock(&connection_state->server_state->mu);
if (error != GRPC_ERROR_NONE || connection_state->server_state->shutdown) { if (error != GRPC_ERROR_NONE || connection_state->server_state->shutdown) {
const char *error_str = grpc_error_string(error); const char *error_str = grpc_error_string(error);
gpr_log(GPR_ERROR, "Handshaking failed: %s", error_str); gpr_log(GPR_DEBUG, "Handshaking failed: %s", error_str);
if (error == GRPC_ERROR_NONE && args->endpoint != NULL) { if (error == GRPC_ERROR_NONE && args->endpoint != NULL) {
// We were shut down after handshaking completed successfully, so // We were shut down after handshaking completed successfully, so

@ -169,7 +169,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_exec_ctx *exec_ctx,
} }
} }
} }
output = grpc_slice_malloc(output_length); output = GRPC_SLICE_MALLOC(output_length);
ctx.input_cur = GRPC_SLICE_START_PTR(input); ctx.input_cur = GRPC_SLICE_START_PTR(input);
ctx.input_end = GRPC_SLICE_END_PTR(input); ctx.input_end = GRPC_SLICE_END_PTR(input);
@ -193,7 +193,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_exec_ctx *exec_ctx,
grpc_slice input, grpc_slice input,
size_t output_length) { size_t output_length) {
size_t input_length = GRPC_SLICE_LENGTH(input); size_t input_length = GRPC_SLICE_LENGTH(input);
grpc_slice output = grpc_slice_malloc(output_length); grpc_slice output = GRPC_SLICE_MALLOC(output_length);
struct grpc_base64_decode_context ctx; struct grpc_base64_decode_context ctx;
// The length of a base64 string cannot be 4 * n + 1 // The length of a base64 string cannot be 4 * n + 1

@ -66,7 +66,7 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
size_t input_triplets = input_length / 3; size_t input_triplets = input_length / 3;
size_t tail_case = input_length % 3; size_t tail_case = input_length % 3;
size_t output_length = input_triplets * 4 + tail_xtra[tail_case]; size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
grpc_slice output = grpc_slice_malloc(output_length); grpc_slice output = GRPC_SLICE_MALLOC(output_length);
uint8_t *in = GRPC_SLICE_START_PTR(input); uint8_t *in = GRPC_SLICE_START_PTR(input);
char *out = (char *)GRPC_SLICE_START_PTR(output); char *out = (char *)GRPC_SLICE_START_PTR(output);
size_t i; size_t i;
@ -119,7 +119,7 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
nbits += grpc_chttp2_huffsyms[*in].length; nbits += grpc_chttp2_huffsyms[*in].length;
} }
output = grpc_slice_malloc(nbits / 8 + (nbits % 8 != 0)); output = GRPC_SLICE_MALLOC(nbits / 8 + (nbits % 8 != 0));
out = GRPC_SLICE_START_PTR(output); out = GRPC_SLICE_START_PTR(output);
for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input);
++in) { ++in) {
@ -184,7 +184,7 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(grpc_slice input) {
size_t output_syms = input_triplets * 4 + tail_xtra[tail_case]; size_t output_syms = input_triplets * 4 + tail_xtra[tail_case];
size_t max_output_bits = 11 * output_syms; size_t max_output_bits = 11 * output_syms;
size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0); size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0);
grpc_slice output = grpc_slice_malloc(max_output_length); grpc_slice output = GRPC_SLICE_MALLOC(max_output_length);
uint8_t *in = GRPC_SLICE_START_PTR(input); uint8_t *in = GRPC_SLICE_START_PTR(input);
uint8_t *start_out = GRPC_SLICE_START_PTR(output); uint8_t *start_out = GRPC_SLICE_START_PTR(output);
huff_out out; huff_out out;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save