Merge github.com:grpc/grpc into accounting

pull/5699/head
Craig Tiller 9 years ago
commit 1149649252
  1. 8
      .clang_complete
  2. 2
      .gitmodules
  3. 6
      BUILD
  4. 14
      MANIFEST.md
  5. 138
      Makefile
  6. 1
      binding.gyp
  7. 15
      build.yaml
  8. 1
      config.m4
  9. 6
      examples/python/helloworld/greeter_client.py
  10. 36
      examples/python/route_guide/route_guide_client.py
  11. 3
      gRPC.podspec
  12. 2
      grpc.gemspec
  13. 2
      package.json
  14. 2
      package.xml
  15. 100
      src/compiler/cpp_generator.cc
  16. 6
      src/compiler/cpp_generator.h
  17. 14
      src/compiler/cpp_plugin.cc
  18. 2
      src/core/census/grpc_plugin.c
  19. 1
      src/core/channel/channel_stack_builder.c
  20. 233
      src/core/channel/client_uchannel.c
  21. 60
      src/core/channel/client_uchannel.h
  22. 5
      src/core/channel/subchannel_call_holder.h
  23. 27
      src/core/client_config/resolvers/dns_resolver.c
  24. 5
      src/core/iomgr/fd_posix.c
  25. 9
      src/core/iomgr/udp_server.h
  26. 11
      src/core/iomgr/wakeup_fd_pipe.c
  27. 5
      src/core/support/backoff.c
  28. 3
      src/core/support/backoff.h
  29. 17
      src/core/surface/channel_connectivity.c
  30. 2
      src/core/surface/channel_init.c
  31. 2
      src/core/surface/channel_stack_type.c
  32. 3
      src/core/surface/channel_stack_type.h
  33. 6
      src/core/surface/init.c
  34. 2
      src/core/transport/static_metadata.c
  35. 53
      src/node/ext/call_credentials.cc
  36. 18
      src/node/ext/call_credentials.h
  37. 2
      src/node/src/credentials.js
  38. 24
      src/objective-c/GRPCClient/GRPCCall.m
  39. 6
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m
  40. 19
      src/python/grpcio/grpc/_adapter/_types.py
  41. 7
      src/python/grpcio/grpc/_links/invocation.py
  42. 22
      src/python/grpcio/grpc/beta/interfaces.py
  43. 14
      src/python/grpcio/grpc/framework/alpha/_face_utilities.py
  44. 6
      src/python/grpcio/grpc/framework/alpha/_reexport.py
  45. 7
      src/python/grpcio/grpc/framework/alpha/exceptions.py
  46. 34
      src/python/grpcio/grpc/framework/alpha/interfaces.py
  47. 7
      src/python/grpcio/grpc/framework/base/_ingestion.py
  48. 25
      src/python/grpcio/grpc/framework/base/_interfaces.py
  49. 7
      src/python/grpcio/grpc/framework/base/_reception.py
  50. 10
      src/python/grpcio/grpc/framework/base/_transmission.py
  51. 40
      src/python/grpcio/grpc/framework/base/interfaces.py
  52. 7
      src/python/grpcio/grpc/framework/core/_end.py
  53. 7
      src/python/grpcio/grpc/framework/core/_ingestion.py
  54. 28
      src/python/grpcio/grpc/framework/core/_interfaces.py
  55. 5
      src/python/grpcio/grpc/framework/core/_termination.py
  56. 5
      src/python/grpcio/grpc/framework/crust/_control.py
  57. 6
      src/python/grpcio/grpc/framework/crust/implementations.py
  58. 5
      src/python/grpcio/grpc/framework/face/_control.py
  59. 7
      src/python/grpcio/grpc/framework/face/exceptions.py
  60. 6
      src/python/grpcio/grpc/framework/face/implementations.py
  61. 40
      src/python/grpcio/grpc/framework/face/interfaces.py
  62. 6
      src/python/grpcio/grpc/framework/foundation/activated.py
  63. 7
      src/python/grpcio/grpc/framework/foundation/callable_util.py
  64. 7
      src/python/grpcio/grpc/framework/foundation/future.py
  65. 3
      src/python/grpcio/grpc/framework/foundation/relay.py
  66. 6
      src/python/grpcio/grpc/framework/foundation/stream.py
  67. 5
      src/python/grpcio/grpc/framework/foundation/stream_util.py
  68. 25
      src/python/grpcio/grpc/framework/interfaces/base/base.py
  69. 41
      src/python/grpcio/grpc/framework/interfaces/face/face.py
  70. 7
      src/python/grpcio/grpc/framework/interfaces/links/links.py
  71. 1
      src/python/grpcio/grpc_core_dependencies.py
  72. 5
      src/python/grpcio/tests/interop/methods.py
  73. 7
      src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
  74. 6
      src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py
  75. 8
      src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py
  76. 7
      src/python/grpcio/tests/unit/_links/_proto_scenarios.py
  77. 5
      src/python/grpcio/tests/unit/beta/_beta_features_test.py
  78. 8
      src/python/grpcio/tests/unit/beta/_face_interface_test.py
  79. 6
      src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py
  80. 8
      src/python/grpcio/tests/unit/framework/common/test_control.py
  81. 7
      src/python/grpcio/tests/unit/framework/common/test_coverage.py
  82. 8
      src/python/grpcio/tests/unit/framework/face/testing/base_util.py
  83. 34
      src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.py
  84. 8
      src/python/grpcio/tests/unit/framework/face/testing/control.py
  85. 12
      src/python/grpcio/tests/unit/framework/face/testing/coverage.py
  86. 6
      src/python/grpcio/tests/unit/framework/face/testing/digest.py
  87. 44
      src/python/grpcio/tests/unit/framework/face/testing/event_invocation_synchronous_event_service_test_case.py
  88. 47
      src/python/grpcio/tests/unit/framework/face/testing/future_invocation_asynchronous_event_service_test_case.py
  89. 7
      src/python/grpcio/tests/unit/framework/face/testing/interfaces.py
  90. 40
      src/python/grpcio/tests/unit/framework/face/testing/service.py
  91. 7
      src/python/grpcio/tests/unit/framework/face/testing/test_case.py
  92. 10
      src/python/grpcio/tests/unit/framework/interfaces/base/_control.py
  93. 10
      src/python/grpcio/tests/unit/framework/interfaces/base/test_interfaces.py
  94. 35
      src/python/grpcio/tests/unit/framework/interfaces/face/_blocking_invocation_inline_service.py
  95. 6
      src/python/grpcio/tests/unit/framework/interfaces/face/_digest.py
  96. 48
      src/python/grpcio/tests/unit/framework/interfaces/face/_future_invocation_asynchronous_event_service.py
  97. 10
      src/python/grpcio/tests/unit/framework/interfaces/face/_invocation.py
  98. 40
      src/python/grpcio/tests/unit/framework/interfaces/face/_service.py
  99. 10
      src/python/grpcio/tests/unit/framework/interfaces/face/test_interfaces.py
  100. 7
      src/python/grpcio/tests/unit/framework/interfaces/links/test_cases.py
  101. Some files were not shown because too many files have changed in this diff Show More

@ -0,0 +1,8 @@
-Ithird_party/googletest/include
-Ithird_party/googletest
-Iinclude
-Igens
-I.
-Ithird_party/boringssl/include
-Ithird_party/zlib
-Ithird_party/protobuf/src

2
.gitmodules vendored

@ -13,7 +13,7 @@
url = https://github.com/google/googletest.git url = https://github.com/google/googletest.git
[submodule "third_party/boringssl"] [submodule "third_party/boringssl"]
path = third_party/boringssl path = third_party/boringssl
url = https://boringssl.googlesource.com/boringssl url = https://github.com/google/boringssl.git
[submodule "third_party/nanopb"] [submodule "third_party/nanopb"]
path = third_party/nanopb path = third_party/nanopb
url = https://github.com/nanopb/nanopb.git url = https://github.com/nanopb/nanopb.git

@ -163,7 +163,6 @@ cc_library(
"src/core/channel/channel_stack.h", "src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h", "src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h", "src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h", "src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h", "src/core/channel/connected_channel.h",
"src/core/channel/context.h", "src/core/channel/context.h",
@ -305,7 +304,6 @@ cc_library(
"src/core/channel/channel_stack.c", "src/core/channel/channel_stack.c",
"src/core/channel/channel_stack_builder.c", "src/core/channel/channel_stack_builder.c",
"src/core/channel/client_channel.c", "src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c", "src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c", "src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c", "src/core/channel/http_client_filter.c",
@ -537,7 +535,6 @@ cc_library(
"src/core/channel/channel_stack.h", "src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h", "src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h", "src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h", "src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h", "src/core/channel/connected_channel.h",
"src/core/channel/context.h", "src/core/channel/context.h",
@ -666,7 +663,6 @@ cc_library(
"src/core/channel/channel_stack.c", "src/core/channel/channel_stack.c",
"src/core/channel/channel_stack_builder.c", "src/core/channel/channel_stack_builder.c",
"src/core/channel/client_channel.c", "src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c", "src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c", "src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c", "src/core/channel/http_client_filter.c",
@ -1367,7 +1363,6 @@ objc_library(
"src/core/channel/channel_stack.c", "src/core/channel/channel_stack.c",
"src/core/channel/channel_stack_builder.c", "src/core/channel/channel_stack_builder.c",
"src/core/channel/client_channel.c", "src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c", "src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c", "src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c", "src/core/channel/http_client_filter.c",
@ -1544,7 +1539,6 @@ objc_library(
"src/core/channel/channel_stack.h", "src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h", "src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h", "src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h", "src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h", "src/core/channel/connected_channel.h",
"src/core/channel/context.h", "src/core/channel/context.h",

@ -1,14 +1,28 @@
# Top-level Items by language # Top-level Items by language
## Bazel
* [grpc.bzl](grpc.bzl)
## Node ## Node
* [binding.gyp](binding.gyp) * [binding.gyp](binding.gyp)
* [package.json](package.json)
## Objective-C ## Objective-C
* [gRPC.podspec](gRPC.podspec) * [gRPC.podspec](gRPC.podspec)
## PHP
* [composer.json](composer.json)
* [config.m4](config.m4)
* [package.xml](package.xml)
## Python ## Python
* [requirements.txt](requirements.txt) * [requirements.txt](requirements.txt)
* [setup.cfg](setup.cfg) * [setup.cfg](setup.cfg)
* [setup.py](setup.py) * [setup.py](setup.py)
* [tox.ini](tox.ini) * [tox.ini](tox.ini)
* [PYTHON-MANIFEST.in](PYTHON-MANIFEST.in) * [PYTHON-MANIFEST.in](PYTHON-MANIFEST.in)
## Ruby
* [Gemfile](Gemfile)
* [grpc.gemspec](grpc.gemspec)
* [Rakefile](Rakefile)

@ -188,8 +188,8 @@ 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 -fPIE -pie -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 -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) LDFLAGS_tsan = -fsanitize=thread
DEFINES_tsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 DEFINES_tsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5
VALID_CONFIG_stapprof = 1 VALID_CONFIG_stapprof = 1
@ -225,8 +225,8 @@ CC_etsan = clang
CXX_etsan = clang++ CXX_etsan = clang++
LD_etsan = clang LD_etsan = clang
LDXX_etsan = clang++ LDXX_etsan = clang++
CPPFLAGS_etsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -fPIE -pie -DGPR_NO_DIRECT_SYSCALLS CPPFLAGS_etsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_etsan = -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) LDFLAGS_etsan = -fsanitize=thread
DEFINES_etsan = _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER DEFINES_etsan = _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER
DEFINES_etsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5 DEFINES_etsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5
@ -1020,6 +1020,7 @@ thread_stress_test: $(BINDIR)/$(CONFIG)/thread_stress_test
zookeeper_test: $(BINDIR)/$(CONFIG)/zookeeper_test zookeeper_test: $(BINDIR)/$(CONFIG)/zookeeper_test
public_headers_must_be_c89: $(BINDIR)/$(CONFIG)/public_headers_must_be_c89 public_headers_must_be_c89: $(BINDIR)/$(CONFIG)/public_headers_must_be_c89
boringssl_aes_test: $(BINDIR)/$(CONFIG)/boringssl_aes_test boringssl_aes_test: $(BINDIR)/$(CONFIG)/boringssl_aes_test
boringssl_asn1_test: $(BINDIR)/$(CONFIG)/boringssl_asn1_test
boringssl_base64_test: $(BINDIR)/$(CONFIG)/boringssl_base64_test boringssl_base64_test: $(BINDIR)/$(CONFIG)/boringssl_base64_test
boringssl_bio_test: $(BINDIR)/$(CONFIG)/boringssl_bio_test boringssl_bio_test: $(BINDIR)/$(CONFIG)/boringssl_bio_test
boringssl_bn_test: $(BINDIR)/$(CONFIG)/boringssl_bn_test boringssl_bn_test: $(BINDIR)/$(CONFIG)/boringssl_bn_test
@ -1083,7 +1084,6 @@ h2_sockpair_1byte_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_test
h2_ssl_test: $(BINDIR)/$(CONFIG)/h2_ssl_test h2_ssl_test: $(BINDIR)/$(CONFIG)/h2_ssl_test
h2_ssl+poll_test: $(BINDIR)/$(CONFIG)/h2_ssl+poll_test h2_ssl+poll_test: $(BINDIR)/$(CONFIG)/h2_ssl+poll_test
h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test h2_ssl_proxy_test: $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test
h2_uchannel_test: $(BINDIR)/$(CONFIG)/h2_uchannel_test
h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test h2_uds_test: $(BINDIR)/$(CONFIG)/h2_uds_test
h2_uds+poll_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_test h2_uds+poll_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_test
h2_census_nosec_test: $(BINDIR)/$(CONFIG)/h2_census_nosec_test h2_census_nosec_test: $(BINDIR)/$(CONFIG)/h2_census_nosec_test
@ -1097,7 +1097,6 @@ h2_proxy_nosec_test: $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test
h2_sockpair_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test h2_sockpair_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test
h2_sockpair+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test h2_sockpair+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test
h2_sockpair_1byte_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test h2_sockpair_1byte_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test
h2_uchannel_nosec_test: $(BINDIR)/$(CONFIG)/h2_uchannel_nosec_test
h2_uds_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds_nosec_test h2_uds_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds_nosec_test
h2_uds+poll_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_nosec_test h2_uds+poll_nosec_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_nosec_test
@ -1171,7 +1170,7 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a
ifeq ($(HAS_ZOOKEEPER),true) ifeq ($(HAS_ZOOKEEPER),true)
privatelibs_zookeeper: privatelibs_zookeeper:
@ -1306,7 +1305,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_ssl_test \ $(BINDIR)/$(CONFIG)/h2_ssl_test \
$(BINDIR)/$(CONFIG)/h2_ssl+poll_test \ $(BINDIR)/$(CONFIG)/h2_ssl+poll_test \
$(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \ $(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \
$(BINDIR)/$(CONFIG)/h2_uchannel_test \
$(BINDIR)/$(CONFIG)/h2_uds_test \ $(BINDIR)/$(CONFIG)/h2_uds_test \
$(BINDIR)/$(CONFIG)/h2_uds+poll_test \ $(BINDIR)/$(CONFIG)/h2_uds+poll_test \
$(BINDIR)/$(CONFIG)/h2_census_nosec_test \ $(BINDIR)/$(CONFIG)/h2_census_nosec_test \
@ -1320,7 +1318,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test \ $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test \
$(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test \ $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test \
$(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test \ $(BINDIR)/$(CONFIG)/h2_sockpair_1byte_nosec_test \
$(BINDIR)/$(CONFIG)/h2_uchannel_nosec_test \
$(BINDIR)/$(CONFIG)/h2_uds_nosec_test \ $(BINDIR)/$(CONFIG)/h2_uds_nosec_test \
$(BINDIR)/$(CONFIG)/h2_uds+poll_nosec_test \ $(BINDIR)/$(CONFIG)/h2_uds+poll_nosec_test \
@ -1369,6 +1366,7 @@ buildtests_cxx: buildtests_zookeeper privatelibs_cxx \
$(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test \ $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/thread_stress_test \ $(BINDIR)/$(CONFIG)/thread_stress_test \
$(BINDIR)/$(CONFIG)/boringssl_aes_test \ $(BINDIR)/$(CONFIG)/boringssl_aes_test \
$(BINDIR)/$(CONFIG)/boringssl_asn1_test \
$(BINDIR)/$(CONFIG)/boringssl_base64_test \ $(BINDIR)/$(CONFIG)/boringssl_base64_test \
$(BINDIR)/$(CONFIG)/boringssl_bio_test \ $(BINDIR)/$(CONFIG)/boringssl_bio_test \
$(BINDIR)/$(CONFIG)/boringssl_bn_test \ $(BINDIR)/$(CONFIG)/boringssl_bn_test \
@ -1546,8 +1544,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/lame_client_test || ( echo test lame_client_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/lame_client_test || ( echo test lame_client_test failed ; exit 1 )
$(E) "[RUN] Testing message_compress_test" $(E) "[RUN] Testing message_compress_test"
$(Q) $(BINDIR)/$(CONFIG)/message_compress_test || ( echo test message_compress_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/message_compress_test || ( echo test message_compress_test failed ; exit 1 )
$(E) "[RUN] Testing mlog_test"
$(Q) $(BINDIR)/$(CONFIG)/mlog_test || ( echo test mlog_test failed ; exit 1 )
$(E) "[RUN] Testing multiple_server_queues_test" $(E) "[RUN] Testing multiple_server_queues_test"
$(Q) $(BINDIR)/$(CONFIG)/multiple_server_queues_test || ( echo test multiple_server_queues_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/multiple_server_queues_test || ( echo test multiple_server_queues_test failed ; exit 1 )
$(E) "[RUN] Testing murmur_hash_test" $(E) "[RUN] Testing murmur_hash_test"
@ -1627,6 +1623,8 @@ test_c: buildtests_c
flaky_test_c: buildtests_c flaky_test_c: buildtests_c
$(E) "[RUN] Testing lb_policies_test" $(E) "[RUN] Testing lb_policies_test"
$(Q) $(BINDIR)/$(CONFIG)/lb_policies_test || ( echo test lb_policies_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/lb_policies_test || ( echo test lb_policies_test failed ; exit 1 )
$(E) "[RUN] Testing mlog_test"
$(Q) $(BINDIR)/$(CONFIG)/mlog_test || ( echo test mlog_test failed ; exit 1 )
test_cxx: test_zookeeper buildtests_cxx test_cxx: test_zookeeper buildtests_cxx
@ -2412,7 +2410,6 @@ LIBGRPC_SRC = \
src/core/channel/channel_stack.c \ src/core/channel/channel_stack.c \
src/core/channel/channel_stack_builder.c \ src/core/channel/channel_stack_builder.c \
src/core/channel/client_channel.c \ src/core/channel/client_channel.c \
src/core/channel/client_uchannel.c \
src/core/channel/compress_filter.c \ src/core/channel/compress_filter.c \
src/core/channel/connected_channel.c \ src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \ src/core/channel/http_client_filter.c \
@ -2773,7 +2770,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/channel/channel_stack.c \ src/core/channel/channel_stack.c \
src/core/channel/channel_stack_builder.c \ src/core/channel/channel_stack_builder.c \
src/core/channel/client_channel.c \ src/core/channel/client_channel.c \
src/core/channel/client_uchannel.c \
src/core/channel/compress_filter.c \ src/core/channel/compress_filter.c \
src/core/channel/connected_channel.c \ src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \ src/core/channel/http_client_filter.c \
@ -4389,6 +4385,43 @@ ifneq ($(NO_DEPS),true)
endif endif
LIBBORINGSSL_ASN1_TEST_LIB_SRC = \
third_party/boringssl/crypto/asn1/asn1_test.cc \
LIBBORINGSSL_ASN1_TEST_LIB_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBBORINGSSL_ASN1_TEST_LIB_SRC))))
$(LIBBORINGSSL_ASN1_TEST_LIB_OBJS): CPPFLAGS += -Ithird_party/boringssl/include -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX
$(LIBBORINGSSL_ASN1_TEST_LIB_OBJS): CFLAGS += -Wno-sign-conversion -Wno-conversion -Wno-unused-value -Wno-unknown-pragmas -Wno-implicit-function-declaration -Wno-unused-variable -Wno-sign-compare
ifeq ($(NO_PROTOBUF),true)
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
$(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a: protobuf_dep_error
else
$(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a: $(ZLIB_DEP) $(PROTOBUF_DEP) $(LIBBORINGSSL_ASN1_TEST_LIB_OBJS)
$(E) "[AR] Creating $@"
$(Q) mkdir -p `dirname $@`
$(Q) rm -f $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a
$(Q) $(AR) $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBBORINGSSL_ASN1_TEST_LIB_OBJS)
ifeq ($(SYSTEM),Darwin)
$(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a
endif
endif
ifneq ($(NO_DEPS),true)
-include $(LIBBORINGSSL_ASN1_TEST_LIB_OBJS:.o=.dep)
endif
LIBBORINGSSL_BASE64_TEST_LIB_SRC = \ LIBBORINGSSL_BASE64_TEST_LIB_SRC = \
third_party/boringssl/crypto/base64/base64_test.cc \ third_party/boringssl/crypto/base64/base64_test.cc \
@ -11242,6 +11275,33 @@ endif
# boringssl needs an override to ensure that it does not include
# system openssl headers regardless of other configuration
# we do so here with a target specific variable assignment
$(BORINGSSL_ASN1_TEST_OBJS): CFLAGS := -Ithird_party/boringssl/include $(CFLAGS) -Wno-sign-conversion -Wno-conversion -Wno-unused-value
$(BORINGSSL_ASN1_TEST_OBJS): CXXFLAGS := -Ithird_party/boringssl/include $(CXXFLAGS)
$(BORINGSSL_ASN1_TEST_OBJS): CPPFLAGS += -DOPENSSL_NO_ASM -D_GNU_SOURCE
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)/boringssl_asn1_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/boringssl_asn1_test: $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/boringssl_asn1_test
endif
# boringssl needs an override to ensure that it does not include # boringssl needs an override to ensure that it does not include
# system openssl headers regardless of other configuration # system openssl headers regardless of other configuration
# we do so here with a target specific variable assignment # we do so here with a target specific variable assignment
@ -12986,38 +13046,6 @@ endif
endif endif
H2_UCHANNEL_TEST_SRC = \
test/core/end2end/fixtures/h2_uchannel.c \
H2_UCHANNEL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_UCHANNEL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/h2_uchannel_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/h2_uchannel_test: $(H2_UCHANNEL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(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) $(H2_UCHANNEL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(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)/h2_uchannel_test
endif
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_uchannel.o: $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_h2_uchannel_test: $(H2_UCHANNEL_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(H2_UCHANNEL_TEST_OBJS:.o=.dep)
endif
endif
H2_UDS_TEST_SRC = \ H2_UDS_TEST_SRC = \
test/core/end2end/fixtures/h2_uds.c \ test/core/end2end/fixtures/h2_uds.c \
@ -13302,26 +13330,6 @@ ifneq ($(NO_DEPS),true)
endif endif
H2_UCHANNEL_NOSEC_TEST_SRC = \
test/core/end2end/fixtures/h2_uchannel.c \
H2_UCHANNEL_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_UCHANNEL_NOSEC_TEST_SRC))))
$(BINDIR)/$(CONFIG)/h2_uchannel_nosec_test: $(H2_UCHANNEL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(H2_UCHANNEL_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_uchannel_nosec_test
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_uchannel.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_h2_uchannel_nosec_test: $(H2_UCHANNEL_NOSEC_TEST_OBJS:.o=.dep)
ifneq ($(NO_DEPS),true)
-include $(H2_UCHANNEL_NOSEC_TEST_OBJS:.o=.dep)
endif
H2_UDS_NOSEC_TEST_SRC = \ H2_UDS_NOSEC_TEST_SRC = \
test/core/end2end/fixtures/h2_uds.c \ test/core/end2end/fixtures/h2_uds.c \

@ -565,7 +565,6 @@
'src/core/channel/channel_stack.c', 'src/core/channel/channel_stack.c',
'src/core/channel/channel_stack_builder.c', 'src/core/channel/channel_stack_builder.c',
'src/core/channel/client_channel.c', 'src/core/channel/client_channel.c',
'src/core/channel/client_uchannel.c',
'src/core/channel/compress_filter.c', 'src/core/channel/compress_filter.c',
'src/core/channel/connected_channel.c', 'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c', 'src/core/channel/http_client_filter.c',

@ -253,7 +253,6 @@ filegroups:
- src/core/channel/channel_stack.h - src/core/channel/channel_stack.h
- src/core/channel/channel_stack_builder.h - src/core/channel/channel_stack_builder.h
- src/core/channel/client_channel.h - src/core/channel/client_channel.h
- src/core/channel/client_uchannel.h
- src/core/channel/compress_filter.h - src/core/channel/compress_filter.h
- src/core/channel/connected_channel.h - src/core/channel/connected_channel.h
- src/core/channel/context.h - src/core/channel/context.h
@ -375,7 +374,6 @@ filegroups:
- src/core/channel/channel_stack.c - src/core/channel/channel_stack.c
- src/core/channel/channel_stack_builder.c - src/core/channel/channel_stack_builder.c
- src/core/channel/client_channel.c - src/core/channel/client_channel.c
- src/core/channel/client_uchannel.c
- src/core/channel/compress_filter.c - src/core/channel/compress_filter.c
- src/core/channel/connected_channel.c - src/core/channel/connected_channel.c
- src/core/channel/http_client_filter.c - src/core/channel/http_client_filter.c
@ -1716,6 +1714,7 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- name: mlog_test - name: mlog_test
flaky: true
build: test build: test
language: c language: c
src: src:
@ -2471,8 +2470,6 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- grpc++_test_config - grpc++_test_config
exclude_configs:
- tsan
platforms: platforms:
- mac - mac
- linux - linux
@ -2492,8 +2489,6 @@ targets:
- gpr_test_util - gpr_test_util
- gpr - gpr
- grpc++_test_config - grpc++_test_config
exclude_configs:
- tsan
platforms: platforms:
- mac - mac
- linux - linux
@ -2826,11 +2821,11 @@ configs:
etsan: etsan:
CC: clang CC: clang
CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument
-fPIE -pie -DGPR_NO_DIRECT_SYSCALLS -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++ CXX: clang++
DEFINES: _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER DEFINES: _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER
LD: clang LD: clang
LDFLAGS: -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) LDFLAGS: -fsanitize=thread
LDXX: clang++ LDXX: clang++
compile_the_world: true compile_the_world: true
test_environ: test_environ:
@ -2882,10 +2877,10 @@ configs:
tsan: tsan:
CC: clang CC: clang
CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument CPPFLAGS: -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument
-fPIE -pie -DGPR_NO_DIRECT_SYSCALLS -DGPR_NO_DIRECT_SYSCALLS
CXX: clang++ CXX: clang++
LD: clang LD: clang
LDFLAGS: -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,) LDFLAGS: -fsanitize=thread
LDXX: clang++ LDXX: clang++
compile_the_world: true compile_the_world: true
test_environ: test_environ:

@ -87,7 +87,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/channel/channel_stack.c \ src/core/channel/channel_stack.c \
src/core/channel/channel_stack_builder.c \ src/core/channel/channel_stack_builder.c \
src/core/channel/client_channel.c \ src/core/channel/client_channel.c \
src/core/channel/client_uchannel.c \
src/core/channel/compress_filter.c \ src/core/channel/compress_filter.c \
src/core/channel/connected_channel.c \ src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \ src/core/channel/http_client_filter.c \

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -29,6 +29,8 @@
"""The Python implementation of the GRPC helloworld.Greeter client.""" """The Python implementation of the GRPC helloworld.Greeter client."""
from __future__ import print_function
from grpc.beta import implementations from grpc.beta import implementations
import helloworld_pb2 import helloworld_pb2
@ -40,7 +42,7 @@ def run():
channel = implementations.insecure_channel('localhost', 50051) channel = implementations.insecure_channel('localhost', 50051)
stub = helloworld_pb2.beta_create_Greeter_stub(channel) stub = helloworld_pb2.beta_create_Greeter_stub(channel)
response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'), _TIMEOUT_SECONDS) response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'), _TIMEOUT_SECONDS)
print "Greeter client received: " + response.message print("Greeter client received: " + response.message)
if __name__ == '__main__': if __name__ == '__main__':

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -29,6 +29,8 @@
"""The Python implementation of the gRPC route guide client.""" """The Python implementation of the gRPC route guide client."""
from __future__ import print_function
import random import random
import time import time
@ -49,13 +51,13 @@ def make_route_note(message, latitude, longitude):
def guide_get_one_feature(stub, point): def guide_get_one_feature(stub, point):
feature = stub.GetFeature(point, _TIMEOUT_SECONDS) feature = stub.GetFeature(point, _TIMEOUT_SECONDS)
if not feature.location: if not feature.location:
print "Server returned incomplete feature" print("Server returned incomplete feature")
return return
if feature.name: if feature.name:
print "Feature called %s at %s" % (feature.name, feature.location) print("Feature called %s at %s" % (feature.name, feature.location))
else: else:
print "Found no feature at %s" % feature.location print("Found no feature at %s" % feature.location)
def guide_get_feature(stub): def guide_get_feature(stub):
@ -69,18 +71,18 @@ def guide_list_features(stub):
latitude=400000000, longitude = -750000000), latitude=400000000, longitude = -750000000),
hi=route_guide_pb2.Point( hi=route_guide_pb2.Point(
latitude = 420000000, longitude = -730000000)) latitude = 420000000, longitude = -730000000))
print "Looking for features between 40, -75 and 42, -73" print("Looking for features between 40, -75 and 42, -73")
features = stub.ListFeatures(rect, _TIMEOUT_SECONDS) features = stub.ListFeatures(rect, _TIMEOUT_SECONDS)
for feature in features: for feature in features:
print "Feature called %s at %s" % (feature.name, feature.location) print("Feature called %s at %s" % (feature.name, feature.location))
def generate_route(feature_list): def generate_route(feature_list):
for _ in range(0, 10): for _ in range(0, 10):
random_feature = feature_list[random.randint(0, len(feature_list) - 1)] random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
print "Visiting point %s" % random_feature.location print("Visiting point %s" % random_feature.location)
yield random_feature.location yield random_feature.location
time.sleep(random.uniform(0.5, 1.5)) time.sleep(random.uniform(0.5, 1.5))
@ -90,10 +92,10 @@ def guide_record_route(stub):
route_iter = generate_route(feature_list) route_iter = generate_route(feature_list)
route_summary = stub.RecordRoute(route_iter, _TIMEOUT_SECONDS) route_summary = stub.RecordRoute(route_iter, _TIMEOUT_SECONDS)
print "Finished trip with %s points " % route_summary.point_count print("Finished trip with %s points " % route_summary.point_count)
print "Passed %s features " % route_summary.feature_count print("Passed %s features " % route_summary.feature_count)
print "Travelled %s meters " % route_summary.distance print("Travelled %s meters " % route_summary.distance)
print "It took %s seconds " % route_summary.elapsed_time print("It took %s seconds " % route_summary.elapsed_time)
def generate_messages(): def generate_messages():
@ -105,7 +107,7 @@ def generate_messages():
make_route_note("Fifth message", 1, 0), make_route_note("Fifth message", 1, 0),
] ]
for msg in messages: for msg in messages:
print "Sending %s at %s" % (msg.message, msg.location) print("Sending %s at %s" % (msg.message, msg.location))
yield msg yield msg
time.sleep(random.uniform(0.5, 1.0)) time.sleep(random.uniform(0.5, 1.0))
@ -113,19 +115,19 @@ def generate_messages():
def guide_route_chat(stub): def guide_route_chat(stub):
responses = stub.RouteChat(generate_messages(), _TIMEOUT_SECONDS) responses = stub.RouteChat(generate_messages(), _TIMEOUT_SECONDS)
for response in responses: for response in responses:
print "Received message %s at %s" % (response.message, response.location) print("Received message %s at %s" % (response.message, response.location))
def run(): def run():
channel = implementations.insecure_channel('localhost', 50051) channel = implementations.insecure_channel('localhost', 50051)
stub = route_guide_pb2.beta_create_RouteGuide_stub(channel) stub = route_guide_pb2.beta_create_RouteGuide_stub(channel)
print "-------------- GetFeature --------------" print("-------------- GetFeature --------------")
guide_get_feature(stub) guide_get_feature(stub)
print "-------------- ListFeatures --------------" print("-------------- ListFeatures --------------")
guide_list_features(stub) guide_list_features(stub)
print "-------------- RecordRoute --------------" print("-------------- RecordRoute --------------")
guide_record_route(stub) guide_record_route(stub)
print "-------------- RouteChat --------------" print("-------------- RouteChat --------------")
guide_route_chat(stub) guide_route_chat(stub)

@ -167,7 +167,6 @@ Pod::Spec.new do |s|
'src/core/channel/channel_stack.h', 'src/core/channel/channel_stack.h',
'src/core/channel/channel_stack_builder.h', 'src/core/channel/channel_stack_builder.h',
'src/core/channel/client_channel.h', 'src/core/channel/client_channel.h',
'src/core/channel/client_uchannel.h',
'src/core/channel/compress_filter.h', 'src/core/channel/compress_filter.h',
'src/core/channel/connected_channel.h', 'src/core/channel/connected_channel.h',
'src/core/channel/context.h', 'src/core/channel/context.h',
@ -322,7 +321,6 @@ Pod::Spec.new do |s|
'src/core/channel/channel_stack.c', 'src/core/channel/channel_stack.c',
'src/core/channel/channel_stack_builder.c', 'src/core/channel/channel_stack_builder.c',
'src/core/channel/client_channel.c', 'src/core/channel/client_channel.c',
'src/core/channel/client_uchannel.c',
'src/core/channel/compress_filter.c', 'src/core/channel/compress_filter.c',
'src/core/channel/connected_channel.c', 'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c', 'src/core/channel/http_client_filter.c',
@ -497,7 +495,6 @@ Pod::Spec.new do |s|
'src/core/channel/channel_stack.h', 'src/core/channel/channel_stack.h',
'src/core/channel/channel_stack_builder.h', 'src/core/channel/channel_stack_builder.h',
'src/core/channel/client_channel.h', 'src/core/channel/client_channel.h',
'src/core/channel/client_uchannel.h',
'src/core/channel/compress_filter.h', 'src/core/channel/compress_filter.h',
'src/core/channel/connected_channel.h', 'src/core/channel/connected_channel.h',
'src/core/channel/context.h', 'src/core/channel/context.h',

@ -163,7 +163,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/channel/channel_stack.h ) s.files += %w( src/core/channel/channel_stack.h )
s.files += %w( src/core/channel/channel_stack_builder.h ) s.files += %w( src/core/channel/channel_stack_builder.h )
s.files += %w( src/core/channel/client_channel.h ) s.files += %w( src/core/channel/client_channel.h )
s.files += %w( src/core/channel/client_uchannel.h )
s.files += %w( src/core/channel/compress_filter.h ) s.files += %w( src/core/channel/compress_filter.h )
s.files += %w( src/core/channel/connected_channel.h ) s.files += %w( src/core/channel/connected_channel.h )
s.files += %w( src/core/channel/context.h ) s.files += %w( src/core/channel/context.h )
@ -305,7 +304,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/channel/channel_stack.c ) s.files += %w( src/core/channel/channel_stack.c )
s.files += %w( src/core/channel/channel_stack_builder.c ) s.files += %w( src/core/channel/channel_stack_builder.c )
s.files += %w( src/core/channel/client_channel.c ) s.files += %w( src/core/channel/client_channel.c )
s.files += %w( src/core/channel/client_uchannel.c )
s.files += %w( src/core/channel/compress_filter.c ) s.files += %w( src/core/channel/compress_filter.c )
s.files += %w( src/core/channel/connected_channel.c ) s.files += %w( src/core/channel/connected_channel.c )
s.files += %w( src/core/channel/http_client_filter.c ) s.files += %w( src/core/channel/http_client_filter.c )

@ -105,7 +105,6 @@
"src/core/channel/channel_stack.h", "src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h", "src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h", "src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h", "src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h", "src/core/channel/connected_channel.h",
"src/core/channel/context.h", "src/core/channel/context.h",
@ -247,7 +246,6 @@
"src/core/channel/channel_stack.c", "src/core/channel/channel_stack.c",
"src/core/channel/channel_stack_builder.c", "src/core/channel/channel_stack_builder.c",
"src/core/channel/client_channel.c", "src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c", "src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c", "src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c", "src/core/channel/http_client_filter.c",

@ -167,7 +167,6 @@
<file baseinstalldir="/" name="src/core/channel/channel_stack.h" role="src" /> <file baseinstalldir="/" name="src/core/channel/channel_stack.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/channel_stack_builder.h" role="src" /> <file baseinstalldir="/" name="src/core/channel/channel_stack_builder.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/client_channel.h" role="src" /> <file baseinstalldir="/" name="src/core/channel/client_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/client_uchannel.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/compress_filter.h" role="src" /> <file baseinstalldir="/" name="src/core/channel/compress_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/connected_channel.h" role="src" /> <file baseinstalldir="/" name="src/core/channel/connected_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/context.h" role="src" /> <file baseinstalldir="/" name="src/core/channel/context.h" role="src" />
@ -309,7 +308,6 @@
<file baseinstalldir="/" name="src/core/channel/channel_stack.c" role="src" /> <file baseinstalldir="/" name="src/core/channel/channel_stack.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/channel_stack_builder.c" role="src" /> <file baseinstalldir="/" name="src/core/channel/channel_stack_builder.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/client_channel.c" role="src" /> <file baseinstalldir="/" name="src/core/channel/client_channel.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/client_uchannel.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/compress_filter.c" role="src" /> <file baseinstalldir="/" name="src/core/channel/compress_filter.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/connected_channel.c" role="src" /> <file baseinstalldir="/" name="src/core/channel/connected_channel.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/http_client_filter.c" role="src" /> <file baseinstalldir="/" name="src/core/channel/http_client_filter.c" role="src" />

@ -83,6 +83,28 @@ grpc::string FilenameIdentifier(const grpc::string &filename) {
} }
} // namespace } // namespace
template<class T, size_t N>
T *array_end(T (&array)[N]) { return array + N; }
void PrintIncludes(grpc::protobuf::io::Printer *printer, const std::vector<grpc::string>& headers, const Parameters &params) {
std::map<grpc::string, grpc::string> vars;
vars["l"] = params.use_system_headers ? '<' : '"';
vars["r"] = params.use_system_headers ? '>' : '"';
if (!params.grpc_search_path.empty()) {
vars["l"] += params.grpc_search_path;
if (params.grpc_search_path.back() != '/') {
vars["l"] += '/';
}
}
for (auto i = headers.begin(); i != headers.end(); i++) {
vars["h"] = *i;
printer->Print(vars, "#include $l$$h$$r$\n");
}
}
grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file, grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) { const Parameters &params) {
grpc::string output; grpc::string output;
@ -111,36 +133,46 @@ grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file,
grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file, grpc::string GetHeaderIncludes(const grpc::protobuf::FileDescriptor *file,
const Parameters &params) { const Parameters &params) {
grpc::string temp = grpc::string output;
"#include <grpc++/impl/codegen/async_stream.h>\n" {
"#include <grpc++/impl/codegen/async_unary_call.h>\n" // Scope the output stream so it closes and finalizes output to the string.
"#include <grpc++/impl/codegen/proto_utils.h>\n" grpc::protobuf::io::StringOutputStream output_stream(&output);
"#include <grpc++/impl/codegen/rpc_method.h>\n" grpc::protobuf::io::Printer printer(&output_stream, '$');
"#include <grpc++/impl/codegen/service_type.h>\n" std::map<grpc::string, grpc::string> vars;
"#include <grpc++/impl/codegen/status.h>\n"
"#include <grpc++/impl/codegen/stub_options.h>\n" static const char *headers_strs[] = {
"#include <grpc++/impl/codegen/sync_stream.h>\n" "grpc++/impl/codegen/async_stream.h",
"\n" "grpc++/impl/codegen/async_unary_call.h",
"namespace grpc {\n" "grpc++/impl/codegen/proto_utils.h",
"class CompletionQueue;\n" "grpc++/impl/codegen/rpc_method.h",
"class RpcService;\n" "grpc++/impl/codegen/service_type.h",
"class ServerCompletionQueue;\n" "grpc++/impl/codegen/status.h",
"class ServerContext;\n" "grpc++/impl/codegen/stub_options.h",
"} // namespace grpc\n\n"; "grpc++/impl/codegen/sync_stream.h"
};
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
PrintIncludes(&printer, headers, params);
printer.Print(vars, "\n");
printer.Print(vars, "namespace grpc {\n");
printer.Print(vars, "class CompletionQueue;\n");
printer.Print(vars, "class Channel;\n");
printer.Print(vars, "class RpcService;\n");
printer.Print(vars, "class ServerCompletionQueue;\n");
printer.Print(vars, "class ServerContext;\n");
printer.Print(vars, "} // namespace grpc\n\n");
if (!file->package().empty()) { if (!file->package().empty()) {
std::vector<grpc::string> parts = std::vector<grpc::string> parts =
grpc_generator::tokenize(file->package(), "."); grpc_generator::tokenize(file->package(), ".");
for (auto part = parts.begin(); part != parts.end(); part++) { for (auto part = parts.begin(); part != parts.end(); part++) {
temp.append("namespace "); vars["part"] = *part;
temp.append(*part); printer.Print(vars, "namespace $part$ {\n");
temp.append(" {\n");
} }
temp.append("\n"); printer.Print(vars, "\n");
} }
}
return temp; return output;
} }
void PrintHeaderClientMethodInterfaces( void PrintHeaderClientMethodInterfaces(
@ -852,7 +884,7 @@ grpc::string GetSourcePrologue(const grpc::protobuf::FileDescriptor *file,
} }
grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file, grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
const Parameters &param) { const Parameters &params) {
grpc::string output; grpc::string output;
{ {
// Scope the output stream so it closes and finalizes output to the string. // Scope the output stream so it closes and finalizes output to the string.
@ -860,16 +892,18 @@ grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file,
grpc::protobuf::io::Printer printer(&output_stream, '$'); grpc::protobuf::io::Printer printer(&output_stream, '$');
std::map<grpc::string, grpc::string> vars; std::map<grpc::string, grpc::string> vars;
printer.Print(vars, "#include <grpc++/impl/codegen/async_stream.h>\n"); static const char *headers_strs[] = {
printer.Print(vars, "#include <grpc++/impl/codegen/async_unary_call.h>\n"); "grpc++/impl/codegen/async_stream.h",
printer.Print(vars, "#include <grpc++/impl/codegen/channel_interface.h>\n"); "grpc++/impl/codegen/async_unary_call.h",
printer.Print(vars, "#include <grpc++/impl/codegen/client_unary_call.h>\n"); "grpc++/impl/codegen/channel_interface.h",
printer.Print(vars, "grpc++/impl/codegen/client_unary_call.h",
"#include <grpc++/impl/codegen/method_handler_impl.h>\n"); "grpc++/impl/codegen/method_handler_impl.h",
printer.Print(vars, "grpc++/impl/codegen/rpc_service_method.h",
"#include <grpc++/impl/codegen/rpc_service_method.h>\n"); "grpc++/impl/codegen/service_type.h",
printer.Print(vars, "#include <grpc++/impl/codegen/service_type.h>\n"); "grpc++/impl/codegen/sync_stream.h"
printer.Print(vars, "#include <grpc++/impl/codegen/sync_stream.h>\n"); };
std::vector<grpc::string> headers(headers_strs, array_end(headers_strs));
PrintIncludes(&printer, headers, params);
if (!file->package().empty()) { if (!file->package().empty()) {
std::vector<grpc::string> parts = std::vector<grpc::string> parts =

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -42,6 +42,10 @@ namespace grpc_cpp_generator {
struct Parameters { struct Parameters {
// Puts the service into a namespace // Puts the service into a namespace
grpc::string services_namespace; grpc::string services_namespace;
// Use system includes (<>) or local includes ("")
bool use_system_headers;
// Prefix to any grpc include
grpc::string grpc_search_path;
}; };
// Return the prologue of the generated header file. // Return the prologue of the generated header file.

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -59,6 +59,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;
if (!parameter.empty()) { if (!parameter.empty()) {
std::vector<grpc::string> parameters_list = std::vector<grpc::string> parameters_list =
@ -70,6 +71,17 @@ class CppGrpcGenerator : public grpc::protobuf::compiler::CodeGenerator {
grpc_generator::tokenize(*parameter_string, "="); grpc_generator::tokenize(*parameter_string, "=");
if (param[0] == "services_namespace") { if (param[0] == "services_namespace") {
generator_parameters.services_namespace = param[1]; generator_parameters.services_namespace = param[1];
} else if (param[0] == "use_system_headers") {
if (param[1] == "true") {
generator_parameters.use_system_headers = true;
} else if (param[1] == "false") {
generator_parameters.use_system_headers = false;
} else {
*error = grpc::string("Invalid parameter: ") + *parameter_string;
return false;
}
} else if (param[0] == "grpc_search_path") {
generator_parameters.grpc_search_path = param[1];
} else { } else {
*error = grpc::string("Unknown parameter: ") + *parameter_string; *error = grpc::string("Unknown parameter: ") + *parameter_string;
return false; return false;

@ -63,8 +63,6 @@ void census_grpc_plugin_init(void) {
} }
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
maybe_add_census_filter, NULL); maybe_add_census_filter, NULL);
grpc_channel_init_register_stage(GRPC_CLIENT_UCHANNEL, INT_MAX,
maybe_add_census_filter, NULL);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
maybe_add_census_filter, NULL); maybe_add_census_filter, NULL);
} }

@ -216,7 +216,6 @@ void *grpc_channel_stack_builder_finish(grpc_exec_ctx *exec_ctx,
// count the number of filters // count the number of filters
size_t num_filters = 0; size_t num_filters = 0;
for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) { for (filter_node *p = builder->begin.next; p != &builder->end; p = p->next) {
gpr_log(GPR_DEBUG, "%d: %s", num_filters, p->filter->name);
num_filters++; num_filters++;
} }

@ -1,233 +0,0 @@
/*
*
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/channel/client_uchannel.h"
#include <string.h>
#include "src/core/census/grpc_filter.h"
#include "src/core/channel/channel_args.h"
#include "src/core/channel/client_channel.h"
#include "src/core/channel/compress_filter.h"
#include "src/core/channel/subchannel_call_holder.h"
#include "src/core/iomgr/iomgr.h"
#include "src/core/support/string.h"
#include "src/core/surface/channel.h"
#include "src/core/transport/connectivity_state.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/useful.h>
/** Microchannel (uchannel) implementation: a lightweight channel without any
* load-balancing mechanisms meant for communication from within the core. */
typedef struct client_uchannel_channel_data {
/** master channel - the grpc_channel instance that ultimately owns
this channel_data via its channel stack.
We occasionally use this to bump the refcount on the master channel
to keep ourselves alive through an asynchronous operation. */
grpc_channel_stack *owning_stack;
/** connectivity state being tracked */
grpc_connectivity_state_tracker state_tracker;
/** the subchannel wrapped by the microchannel */
grpc_connected_subchannel *connected_subchannel;
/** the callback used to stay subscribed to subchannel connectivity
* notifications */
grpc_closure connectivity_cb;
/** the current connectivity state of the wrapped subchannel */
grpc_connectivity_state subchannel_connectivity;
gpr_mu mu_state;
} channel_data;
typedef grpc_subchannel_call_holder call_data;
static void monitor_subchannel(grpc_exec_ctx *exec_ctx, void *arg,
bool iomgr_success) {
channel_data *chand = arg;
grpc_connectivity_state_set(exec_ctx, &chand->state_tracker,
chand->subchannel_connectivity,
"uchannel_monitor_subchannel");
grpc_connected_subchannel_notify_on_state_change(
exec_ctx, chand->connected_subchannel, NULL,
&chand->subchannel_connectivity, &chand->connectivity_cb);
}
static char *cuc_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {
return grpc_subchannel_call_holder_get_peer(exec_ctx, elem->call_data);
}
static void cuc_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
grpc_transport_stream_op *op) {
GRPC_CALL_LOG_OP(GPR_INFO, elem, op);
grpc_subchannel_call_holder_perform_op(exec_ctx, elem->call_data, op);
}
static void cuc_start_transport_op(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_transport_op *op) {
channel_data *chand = elem->channel_data;
grpc_exec_ctx_enqueue(exec_ctx, op->on_consumed, true, NULL);
GPR_ASSERT(op->set_accept_stream == false);
GPR_ASSERT(op->bind_pollset == NULL);
if (op->on_connectivity_state_change != NULL) {
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &chand->state_tracker, op->connectivity_state,
op->on_connectivity_state_change);
op->on_connectivity_state_change = NULL;
op->connectivity_state = NULL;
}
if (op->disconnect) {
grpc_connectivity_state_set(exec_ctx, &chand->state_tracker,
GRPC_CHANNEL_FATAL_FAILURE, "disconnect");
}
}
static int cuc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *arg,
grpc_metadata_batch *initial_metadata,
grpc_connected_subchannel **connected_subchannel,
grpc_closure *on_ready) {
channel_data *chand = arg;
GPR_ASSERT(initial_metadata != NULL);
*connected_subchannel = chand->connected_subchannel;
return 1;
}
/* Constructor for call_data */
static void cuc_init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_call_element_args *args) {
grpc_subchannel_call_holder_init(elem->call_data, cuc_pick_subchannel,
elem->channel_data, args->call_stack);
}
/* Destructor for call_data */
static void cuc_destroy_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem) {
grpc_subchannel_call_holder_destroy(exec_ctx, elem->call_data);
}
/* Constructor for channel_data */
static void cuc_init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_channel_element_args *args) {
channel_data *chand = elem->channel_data;
memset(chand, 0, sizeof(*chand));
grpc_closure_init(&chand->connectivity_cb, monitor_subchannel, chand);
GPR_ASSERT(args->is_last);
GPR_ASSERT(elem->filter == &grpc_client_uchannel_filter);
chand->owning_stack = args->channel_stack;
grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE,
"client_uchannel");
gpr_mu_init(&chand->mu_state);
}
/* Destructor for channel_data */
static void cuc_destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {
channel_data *chand = elem->channel_data;
/* cancel subscription */
grpc_connected_subchannel_notify_on_state_change(
exec_ctx, chand->connected_subchannel, NULL, NULL,
&chand->connectivity_cb);
grpc_connectivity_state_destroy(exec_ctx, &chand->state_tracker);
gpr_mu_destroy(&chand->mu_state);
GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, chand->connected_subchannel,
"uchannel");
}
static void cuc_set_pollset(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_pollset *pollset) {
call_data *calld = elem->call_data;
calld->pollset = pollset;
}
const grpc_channel_filter grpc_client_uchannel_filter = {
cuc_start_transport_stream_op, cuc_start_transport_op, sizeof(call_data),
cuc_init_call_elem, cuc_set_pollset, cuc_destroy_call_elem,
sizeof(channel_data), cuc_init_channel_elem, cuc_destroy_channel_elem,
cuc_get_peer, "client-uchannel",
};
grpc_connectivity_state grpc_client_uchannel_check_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect) {
channel_data *chand = elem->channel_data;
grpc_connectivity_state out;
gpr_mu_lock(&chand->mu_state);
out = grpc_connectivity_state_check(&chand->state_tracker);
gpr_mu_unlock(&chand->mu_state);
return out;
}
void grpc_client_uchannel_watch_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset,
grpc_connectivity_state *state, grpc_closure *on_complete) {
channel_data *chand = elem->channel_data;
gpr_mu_lock(&chand->mu_state);
grpc_connectivity_state_notify_on_state_change(
exec_ctx, &chand->state_tracker, state, on_complete);
gpr_mu_unlock(&chand->mu_state);
}
grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
grpc_channel_args *args) {
grpc_channel *channel = NULL;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
channel =
grpc_channel_create(&exec_ctx, NULL, args, GRPC_CLIENT_UCHANNEL, NULL);
return channel;
}
void grpc_client_uchannel_set_connected_subchannel(
grpc_channel *uchannel, grpc_connected_subchannel *connected_subchannel) {
grpc_channel_element *elem =
grpc_channel_stack_last_element(grpc_channel_get_channel_stack(uchannel));
channel_data *chand = elem->channel_data;
GPR_ASSERT(elem->filter == &grpc_client_uchannel_filter);
gpr_mu_lock(&chand->mu_state);
chand->connected_subchannel = connected_subchannel;
GRPC_CONNECTED_SUBCHANNEL_REF(connected_subchannel, "uchannel");
gpr_mu_unlock(&chand->mu_state);
}

@ -1,60 +0,0 @@
/*
*
* Copyright 2015-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 GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H
#define GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H
#include "src/core/channel/channel_stack.h"
#include "src/core/client_config/resolver.h"
#define GRPC_MICROCHANNEL_SUBCHANNEL_ARG "grpc.microchannel_subchannel_key"
/* A client microchannel (aka uchannel) is a channel wrapping a subchannel, for
* the purposes of lightweight RPC communications from within the core.*/
extern const grpc_channel_filter grpc_client_uchannel_filter;
grpc_connectivity_state grpc_client_uchannel_check_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect);
void grpc_client_uchannel_watch_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset,
grpc_connectivity_state *state, grpc_closure *on_complete);
grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
grpc_channel_args *args);
void grpc_client_uchannel_set_connected_subchannel(
grpc_channel *uchannel, grpc_connected_subchannel *connected_subchannel);
#endif /* GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H */

@ -55,15 +55,14 @@ typedef enum {
for initial metadata before trying to create a call object, for initial metadata before trying to create a call object,
and handling cancellation gracefully. and handling cancellation gracefully.
Both the channel and uchannel filter use this as their call_data. */ The channel filter uses this as their call_data. */
typedef struct grpc_subchannel_call_holder { typedef struct grpc_subchannel_call_holder {
/** either 0 for no call, 1 for cancelled, or a pointer to a /** either 0 for no call, 1 for cancelled, or a pointer to a
grpc_subchannel_call */ grpc_subchannel_call */
gpr_atm subchannel_call; gpr_atm subchannel_call;
/** Helper function to choose the subchannel on which to create /** Helper function to choose the subchannel on which to create
the call object. Channel filter delegates to the load the call object. Channel filter delegates to the load
balancing policy (once it's ready); uchannel returns balancing policy (once it's ready). */
immediately */
grpc_subchannel_call_holder_pick_subchannel pick_subchannel; grpc_subchannel_call_holder_pick_subchannel pick_subchannel;
void *pick_subchannel_arg; void *pick_subchannel_arg;

@ -42,8 +42,14 @@
#include "src/core/client_config/lb_policy_registry.h" #include "src/core/client_config/lb_policy_registry.h"
#include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/timer.h" #include "src/core/iomgr/timer.h"
#include "src/core/support/backoff.h"
#include "src/core/support/string.h" #include "src/core/support/string.h"
#define BACKOFF_MULTIPLIER 1.6
#define BACKOFF_JITTER 0.2
#define BACKOFF_MIN_SECONDS 1
#define BACKOFF_MAX_SECONDS 120
typedef struct { typedef struct {
/** base class: must be first */ /** base class: must be first */
grpc_resolver base; grpc_resolver base;
@ -75,6 +81,8 @@ typedef struct {
/** retry timer */ /** retry timer */
bool have_retry_timer; bool have_retry_timer;
grpc_timer retry_timer; grpc_timer retry_timer;
/** retry backoff state */
gpr_backoff backoff_state;
} dns_resolver; } dns_resolver;
static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r); static void dns_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *r);
@ -111,6 +119,7 @@ static void dns_channel_saw_error(grpc_exec_ctx *exec_ctx,
dns_resolver *r = (dns_resolver *)resolver; dns_resolver *r = (dns_resolver *)resolver;
gpr_mu_lock(&r->mu); gpr_mu_lock(&r->mu);
if (!r->resolving) { if (!r->resolving) {
gpr_backoff_reset(&r->backoff_state);
dns_start_resolving_locked(r); dns_start_resolving_locked(r);
} }
gpr_mu_unlock(&r->mu); gpr_mu_unlock(&r->mu);
@ -125,6 +134,7 @@ static void dns_next(grpc_exec_ctx *exec_ctx, grpc_resolver *resolver,
r->next_completion = on_complete; r->next_completion = on_complete;
r->target_config = target_config; r->target_config = target_config;
if (r->resolved_version == 0 && !r->resolving) { if (r->resolved_version == 0 && !r->resolving) {
gpr_backoff_reset(&r->backoff_state);
dns_start_resolving_locked(r); dns_start_resolving_locked(r);
} else { } else {
dns_maybe_finish_next_locked(exec_ctx, r); dns_maybe_finish_next_locked(exec_ctx, r);
@ -185,17 +195,16 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
grpc_resolved_addresses_destroy(addresses); grpc_resolved_addresses_destroy(addresses);
gpr_free(subchannels); gpr_free(subchannels);
} else { } else {
int retry_seconds = 15; gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_log(GPR_DEBUG, "dns resolution failed: retrying in %d seconds", gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
retry_seconds); gpr_timespec timeout = gpr_time_sub(next_try, now);
gpr_log(GPR_DEBUG, "dns resolution failed: retrying in %d.%09d seconds",
timeout.tv_sec, timeout.tv_nsec);
GPR_ASSERT(!r->have_retry_timer); GPR_ASSERT(!r->have_retry_timer);
r->have_retry_timer = true; r->have_retry_timer = true;
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
GRPC_RESOLVER_REF(&r->base, "retry-timer"); GRPC_RESOLVER_REF(&r->base, "retry-timer");
grpc_timer_init( grpc_timer_init(exec_ctx, &r->retry_timer, next_try, dns_on_retry_timer, r,
exec_ctx, &r->retry_timer, now);
gpr_time_add(now, gpr_time_from_seconds(retry_seconds, GPR_TIMESPAN)),
dns_on_retry_timer, r, now);
} }
if (r->resolved_config) { if (r->resolved_config) {
grpc_client_config_unref(exec_ctx, r->resolved_config); grpc_client_config_unref(exec_ctx, r->resolved_config);
@ -263,6 +272,8 @@ static grpc_resolver *dns_create(grpc_resolver_args *args,
r->name = gpr_strdup(path); r->name = gpr_strdup(path);
r->default_port = gpr_strdup(default_port); r->default_port = gpr_strdup(default_port);
r->subchannel_factory = args->subchannel_factory; r->subchannel_factory = args->subchannel_factory;
gpr_backoff_init(&r->backoff_state, BACKOFF_MULTIPLIER, BACKOFF_JITTER,
BACKOFF_MIN_SECONDS * 1000, BACKOFF_MAX_SECONDS * 1000);
grpc_subchannel_factory_ref(r->subchannel_factory); grpc_subchannel_factory_ref(r->subchannel_factory);
r->lb_policy_name = gpr_strdup(lb_policy_name); r->lb_policy_name = gpr_strdup(lb_policy_name);
return &r->base; return &r->base;

@ -92,7 +92,7 @@ static grpc_fd *alloc_fd(int fd) {
gpr_mu_init(&r->mu); gpr_mu_init(&r->mu);
} }
gpr_atm_rel_store(&r->refst, 1); gpr_mu_lock(&r->mu);
r->shutdown = 0; r->shutdown = 0;
r->read_closure = CLOSURE_NOT_READY; r->read_closure = CLOSURE_NOT_READY;
r->write_closure = CLOSURE_NOT_READY; r->write_closure = CLOSURE_NOT_READY;
@ -104,6 +104,9 @@ static grpc_fd *alloc_fd(int fd) {
r->on_done_closure = NULL; r->on_done_closure = NULL;
r->closed = 0; r->closed = 0;
r->released = 0; r->released = 0;
gpr_atm_rel_store(&r->refst, 1);
gpr_mu_unlock(&r->mu);
return r; return r;
} }

@ -37,15 +37,16 @@
#include "src/core/iomgr/endpoint.h" #include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/fd_posix.h" #include "src/core/iomgr/fd_posix.h"
/* Forward decl of grpc_server */ /* Forward decl of struct grpc_server */
typedef struct grpc_server grpc_server; /* This is not typedef'ed to avoid a typedef-redefinition error */
struct grpc_server;
/* Forward decl of grpc_udp_server */ /* Forward decl of grpc_udp_server */
typedef struct grpc_udp_server grpc_udp_server; typedef struct grpc_udp_server grpc_udp_server;
/* Called when data is available to read from the socket. */ /* Called when data is available to read from the socket. */
typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd,
grpc_server *server); struct grpc_server *server);
/* Create a server, initially not bound to any ports */ /* Create a server, initially not bound to any ports */
grpc_udp_server *grpc_udp_server_create(void); grpc_udp_server *grpc_udp_server_create(void);
@ -53,7 +54,7 @@ grpc_udp_server *grpc_udp_server_create(void);
/* Start listening to bound ports */ /* Start listening to bound ports */
void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server, void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server,
grpc_pollset **pollsets, size_t pollset_count, grpc_pollset **pollsets, size_t pollset_count,
grpc_server *server); struct grpc_server *server);
int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index); int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index);

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -41,13 +41,18 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "src/core/iomgr/socket_utils_posix.h"
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/iomgr/socket_utils_posix.h"
static void pipe_init(grpc_wakeup_fd* fd_info) { static void pipe_init(grpc_wakeup_fd* fd_info) {
int pipefd[2]; int pipefd[2];
/* TODO(klempner): Make this nonfatal */ /* TODO(klempner): Make this nonfatal */
GPR_ASSERT(0 == pipe(pipefd)); int r = pipe(pipefd);
if (0 != r) {
gpr_log(GPR_ERROR, "pipe creation failed (%d): %s", errno, strerror(errno));
abort();
}
GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1)); GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[0], 1));
GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1)); GPR_ASSERT(grpc_set_socket_nonblocking(pipefd[1], 1));
fd_info->read_fd = pipefd[0]; fd_info->read_fd = pipefd[0];

@ -69,3 +69,8 @@ gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now) {
return gpr_time_add( return gpr_time_add(
now, gpr_time_from_millis(backoff->current_timeout_millis, GPR_TIMESPAN)); now, gpr_time_from_millis(backoff->current_timeout_millis, GPR_TIMESPAN));
} }
void gpr_backoff_reset(gpr_backoff *backoff) {
// forces step() to return a timeout of min_timeout_millis
backoff->current_timeout_millis = 0;
}

@ -61,5 +61,8 @@ void gpr_backoff_init(gpr_backoff *backoff, double multiplier, double jitter,
gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now); gpr_timespec gpr_backoff_begin(gpr_backoff *backoff, gpr_timespec now);
/// Step a retry loop: returns a timespec for the NEXT retry /// Step a retry loop: returns a timespec for the NEXT retry
gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now); gpr_timespec gpr_backoff_step(gpr_backoff *backoff, gpr_timespec now);
/// Reset the backoff, so the next gpr_backoff_step will be a gpr_backoff_begin
/// instead
void gpr_backoff_reset(gpr_backoff *backoff);
#endif /* GRPC_CORE_SUPPORT_BACKOFF_H */ #endif /* GRPC_CORE_SUPPORT_BACKOFF_H */

@ -37,7 +37,6 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include "src/core/channel/client_channel.h" #include "src/core/channel/client_channel.h"
#include "src/core/channel/client_uchannel.h"
#include "src/core/iomgr/timer.h" #include "src/core/iomgr/timer.h"
#include "src/core/surface/api_trace.h" #include "src/core/surface/api_trace.h"
#include "src/core/surface/completion_queue.h" #include "src/core/surface/completion_queue.h"
@ -58,12 +57,6 @@ grpc_connectivity_state grpc_channel_check_connectivity_state(
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
return state; return state;
} }
if (client_channel_elem->filter == &grpc_client_uchannel_filter) {
state = grpc_client_uchannel_check_connectivity_state(
&exec_ctx, client_channel_elem, try_to_connect);
grpc_exec_ctx_finish(&exec_ctx);
return state;
}
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"grpc_channel_check_connectivity_state called on something that is " "grpc_channel_check_connectivity_state called on something that is "
"not a (u)client channel, but '%s'", "not a (u)client channel, but '%s'",
@ -98,9 +91,6 @@ static void delete_state_watcher(grpc_exec_ctx *exec_ctx, state_watcher *w) {
if (client_channel_elem->filter == &grpc_client_channel_filter) { if (client_channel_elem->filter == &grpc_client_channel_filter) {
GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel, GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
"watch_channel_connectivity"); "watch_channel_connectivity");
} else if (client_channel_elem->filter == &grpc_client_uchannel_filter) {
GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
"watch_uchannel_connectivity");
} else { } else {
abort(); abort();
} }
@ -209,11 +199,8 @@ void grpc_channel_watch_connectivity_state(
grpc_client_channel_watch_connectivity_state(&exec_ctx, client_channel_elem, grpc_client_channel_watch_connectivity_state(&exec_ctx, client_channel_elem,
grpc_cq_pollset(cq), &w->state, grpc_cq_pollset(cq), &w->state,
&w->on_complete); &w->on_complete);
} else if (client_channel_elem->filter == &grpc_client_uchannel_filter) { } else {
GRPC_CHANNEL_INTERNAL_REF(channel, "watch_uchannel_connectivity"); abort();
grpc_client_uchannel_watch_connectivity_state(
&exec_ctx, client_channel_elem, grpc_cq_pollset(cq), &w->state,
&w->on_complete);
} }
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);

@ -112,8 +112,6 @@ static const char *name_for_type(grpc_channel_stack_type type) {
return "CLIENT_SUBCHANNEL"; return "CLIENT_SUBCHANNEL";
case GRPC_SERVER_CHANNEL: case GRPC_SERVER_CHANNEL:
return "SERVER_CHANNEL"; return "SERVER_CHANNEL";
case GRPC_CLIENT_UCHANNEL:
return "CLIENT_UCHANNEL";
case GRPC_CLIENT_LAME_CHANNEL: case GRPC_CLIENT_LAME_CHANNEL:
return "CLIENT_LAME_CHANNEL"; return "CLIENT_LAME_CHANNEL";
case GRPC_CLIENT_DIRECT_CHANNEL: case GRPC_CLIENT_DIRECT_CHANNEL:

@ -39,8 +39,6 @@ bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type) {
switch (type) { switch (type) {
case GRPC_CLIENT_CHANNEL: case GRPC_CLIENT_CHANNEL:
return true; return true;
case GRPC_CLIENT_UCHANNEL:
return true;
case GRPC_CLIENT_SUBCHANNEL: case GRPC_CLIENT_SUBCHANNEL:
return true; return true;
case GRPC_CLIENT_LAME_CHANNEL: case GRPC_CLIENT_LAME_CHANNEL:

@ -39,9 +39,6 @@
typedef enum { typedef enum {
// normal top-half client channel with load-balancing, connection management // normal top-half client channel with load-balancing, connection management
GRPC_CLIENT_CHANNEL, GRPC_CLIENT_CHANNEL,
// abbreviated top-half client channel bound to one subchannel - for internal
// load balancing implementation
GRPC_CLIENT_UCHANNEL,
// bottom-half of a client channel: everything that happens post-load // bottom-half of a client channel: everything that happens post-load
// balancing (bound to a specific transport) // balancing (bound to a specific transport)
GRPC_CLIENT_SUBCHANNEL, GRPC_CLIENT_SUBCHANNEL,

@ -45,7 +45,6 @@
#include "src/core/channel/compress_filter.h" #include "src/core/channel/compress_filter.h"
#include "src/core/channel/connected_channel.h" #include "src/core/channel/connected_channel.h"
#include "src/core/channel/client_channel.h" #include "src/core/channel/client_channel.h"
#include "src/core/channel/client_uchannel.h"
#include "src/core/channel/http_client_filter.h" #include "src/core/channel/http_client_filter.h"
#include "src/core/channel/http_server_filter.h" #include "src/core/channel/http_server_filter.h"
#include "src/core/client_config/lb_policy_registry.h" #include "src/core/client_config/lb_policy_registry.h"
@ -112,9 +111,6 @@ static void register_builtin_channel_init() {
grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX,
prepend_filter, prepend_filter,
(void *)&grpc_compress_filter); (void *)&grpc_compress_filter);
grpc_channel_init_register_stage(GRPC_CLIENT_UCHANNEL, INT_MAX,
prepend_filter,
(void *)&grpc_compress_filter);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter, grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter,
(void *)&grpc_compress_filter); (void *)&grpc_compress_filter);
grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX,
@ -134,8 +130,6 @@ static void register_builtin_channel_init() {
grpc_add_connected_filter, NULL); grpc_add_connected_filter, NULL);
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, append_filter, grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, append_filter,
(void *)&grpc_client_channel_filter); (void *)&grpc_client_channel_filter);
grpc_channel_init_register_stage(GRPC_CLIENT_UCHANNEL, INT_MAX, append_filter,
(void *)&grpc_client_uchannel_filter);
grpc_channel_init_register_stage(GRPC_CLIENT_LAME_CHANNEL, INT_MAX, grpc_channel_init_register_stage(GRPC_CLIENT_LAME_CHANNEL, INT_MAX,
append_filter, (void *)&grpc_lame_filter); append_filter, (void *)&grpc_lame_filter);
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter, grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter,

@ -50,7 +50,7 @@ grpc_mdstr grpc_static_mdstr_table[GRPC_STATIC_MDSTR_COUNT];
grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 3, 7, 5, 2, 4, 8, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 8, 6, 2, 4, 8, 6, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

@ -35,6 +35,8 @@
#include <nan.h> #include <nan.h>
#include <uv.h> #include <uv.h>
#include <list>
#include "grpc/grpc.h" #include "grpc/grpc.h"
#include "grpc/grpc_security.h" #include "grpc/grpc_security.h"
#include "grpc/support/log.h" #include "grpc/support/log.h"
@ -161,6 +163,15 @@ NAN_METHOD(CallCredentials::CreateFromPlugin) {
grpc_metadata_credentials_plugin plugin; grpc_metadata_credentials_plugin plugin;
plugin_state *state = new plugin_state; plugin_state *state = new plugin_state;
state->callback = new Nan::Callback(info[0].As<Function>()); state->callback = new Nan::Callback(info[0].As<Function>());
state->pending_callbacks = new std::list<plugin_callback_data*>();
uv_mutex_init(&state->plugin_mutex);
uv_async_init(uv_default_loop(),
&state->plugin_async,
SendPluginCallback);
uv_unref((uv_handle_t*)&state->plugin_async);
state->plugin_async.data = state;
plugin.get_metadata = plugin_get_metadata; plugin.get_metadata = plugin_get_metadata;
plugin.destroy = plugin_destroy_state; plugin.destroy = plugin_destroy_state;
plugin.state = reinterpret_cast<void*>(state); plugin.state = reinterpret_cast<void*>(state);
@ -208,8 +219,14 @@ NAN_METHOD(PluginCallback) {
NAUV_WORK_CB(SendPluginCallback) { NAUV_WORK_CB(SendPluginCallback) {
Nan::HandleScope scope; Nan::HandleScope scope;
plugin_callback_data *data = reinterpret_cast<plugin_callback_data*>( plugin_state *state = reinterpret_cast<plugin_state*>(async->data);
async->data); std::list<plugin_callback_data*> callbacks;
uv_mutex_lock(&state->plugin_mutex);
callbacks.splice(callbacks.begin(), *state->pending_callbacks);
uv_mutex_unlock(&state->plugin_mutex);
while (!callbacks.empty()) {
plugin_callback_data *data = callbacks.front();
callbacks.pop_front();
// Attach cb and user_data to plugin_callback so that it can access them later // Attach cb and user_data to plugin_callback so that it can access them later
v8::Local<v8::Function> plugin_callback = Nan::GetFunction( v8::Local<v8::Function> plugin_callback = Nan::GetFunction(
Nan::New<v8::FunctionTemplate>(PluginCallback)).ToLocalChecked(); Nan::New<v8::FunctionTemplate>(PluginCallback)).ToLocalChecked();
@ -222,34 +239,40 @@ NAUV_WORK_CB(SendPluginCallback) {
Nan::New(data->service_url).ToLocalChecked(), Nan::New(data->service_url).ToLocalChecked(),
plugin_callback plugin_callback
}; };
Nan::Callback *callback = data->state->callback; Nan::Callback *callback = state->callback;
callback->Call(argc, argv); callback->Call(argc, argv);
delete data; delete data;
uv_unref((uv_handle_t *)async); }
uv_close((uv_handle_t *)async, (uv_close_cb)free);
} }
void plugin_get_metadata(void *state, grpc_auth_metadata_context context, void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb, grpc_credentials_plugin_metadata_cb cb,
void *user_data) { void *user_data) {
uv_async_t *async = static_cast<uv_async_t*>(malloc(sizeof(uv_async_t))); plugin_state *p_state = reinterpret_cast<plugin_state*>(state);
uv_async_init(uv_default_loop(),
async,
SendPluginCallback);
plugin_callback_data *data = new plugin_callback_data; plugin_callback_data *data = new plugin_callback_data;
data->state = reinterpret_cast<plugin_state*>(state);
data->service_url = context.service_url; data->service_url = context.service_url;
data->cb = cb; data->cb = cb;
data->user_data = user_data; data->user_data = user_data;
async->data = data;
/* libuv says that it will coalesce calls to uv_async_send. If there is ever a uv_mutex_lock(&p_state->plugin_mutex);
* problem with a callback not getting called, that is probably the reason */ p_state->pending_callbacks->push_back(data);
uv_async_send(async); uv_mutex_unlock(&p_state->plugin_mutex);
uv_async_send(&p_state->plugin_async);
}
void plugin_uv_close_cb(uv_handle_t *handle) {
uv_async_t *async = reinterpret_cast<uv_async_t*>(handle);
plugin_state *state = reinterpret_cast<plugin_state *>(async->data);
uv_mutex_destroy(&state->plugin_mutex);
delete state->pending_callbacks;
delete state->callback;
delete state;
} }
void plugin_destroy_state(void *ptr) { void plugin_destroy_state(void *ptr) {
plugin_state *state = reinterpret_cast<plugin_state *>(ptr); plugin_state *state = reinterpret_cast<plugin_state *>(ptr);
delete state->callback; uv_close((uv_handle_t*)&state->plugin_async, plugin_uv_close_cb);
} }
} // namespace node } // namespace node

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -34,8 +34,11 @@
#ifndef GRPC_NODE_CALL_CREDENTIALS_H_ #ifndef GRPC_NODE_CALL_CREDENTIALS_H_
#define GRPC_NODE_CALL_CREDENTIALS_H_ #define GRPC_NODE_CALL_CREDENTIALS_H_
#include <list>
#include <node.h> #include <node.h>
#include <nan.h> #include <nan.h>
#include <uv.h>
#include "grpc/grpc_security.h" #include "grpc/grpc_security.h"
namespace grpc { namespace grpc {
@ -73,17 +76,20 @@ class CallCredentials : public Nan::ObjectWrap {
/* Auth metadata plugin functionality */ /* Auth metadata plugin functionality */
typedef struct plugin_state {
Nan::Callback *callback;
} plugin_state;
typedef struct plugin_callback_data { typedef struct plugin_callback_data {
plugin_state *state;
const char *service_url; const char *service_url;
grpc_credentials_plugin_metadata_cb cb; grpc_credentials_plugin_metadata_cb cb;
void *user_data; void *user_data;
} plugin_callback_data; } plugin_callback_data;
typedef struct plugin_state {
Nan::Callback *callback;
std::list<plugin_callback_data*> *pending_callbacks;
uv_mutex_t plugin_mutex;
// async.data == this
uv_async_t plugin_async;
} plugin_state;
void plugin_get_metadata(void *state, grpc_auth_metadata_context context, void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb, grpc_credentials_plugin_metadata_cb cb,
void *user_data); void *user_data);

@ -118,7 +118,6 @@ exports.createFromMetadataGenerator = function(metadata_generator) {
exports.createFromGoogleCredential = function(google_credential) { exports.createFromGoogleCredential = function(google_credential) {
return exports.createFromMetadataGenerator(function(auth_context, callback) { return exports.createFromMetadataGenerator(function(auth_context, callback) {
var service_url = auth_context.service_url; var service_url = auth_context.service_url;
console.log('Service URL:', service_url);
google_credential.getRequestMetadata(service_url, function(err, header) { google_credential.getRequestMetadata(service_url, function(err, header) {
if (err) { if (err) {
console.log('Auth error:', err); console.log('Auth error:', err);
@ -127,7 +126,6 @@ exports.createFromGoogleCredential = function(google_credential) {
} }
var metadata = new Metadata(); var metadata = new Metadata();
metadata.add('authorization', header.Authorization); metadata.add('authorization', header.Authorization);
console.log(header.Authorization);
callback(null, metadata); callback(null, metadata);
}); });
}); });

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -308,37 +308,30 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
} }
- (void)invokeCall { - (void)invokeCall {
__weak GRPCCall *weakSelf = self;
[self invokeCallWithHeadersHandler:^(NSDictionary *headers) { [self invokeCallWithHeadersHandler:^(NSDictionary *headers) {
// Response headers received. // Response headers received.
GRPCCall *strongSelf = weakSelf; self.responseHeaders = headers;
if (strongSelf) { [self startNextRead];
strongSelf.responseHeaders = headers;
[strongSelf startNextRead];
}
} completionHandler:^(NSError *error, NSDictionary *trailers) { } completionHandler:^(NSError *error, NSDictionary *trailers) {
GRPCCall *strongSelf = weakSelf; self.responseTrailers = trailers;
if (strongSelf) {
strongSelf.responseTrailers = trailers;
if (error) { if (error) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (error.userInfo) { if (error.userInfo) {
[userInfo addEntriesFromDictionary:error.userInfo]; [userInfo addEntriesFromDictionary:error.userInfo];
} }
userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers; userInfo[kGRPCTrailersKey] = self.responseTrailers;
// TODO(jcanizales): The C gRPC library doesn't guarantee that the headers block will be // TODO(jcanizales): The C gRPC library doesn't guarantee that the headers block will be
// called before this one, so an error might end up with trailers but no headers. We // called before this one, so an error might end up with trailers but no headers. We
// shouldn't call finishWithError until ater both blocks are called. It is also when this is // shouldn't call finishWithError until ater both blocks are called. It is also when this is
// done that we can provide a merged view of response headers and trailers in a thread-safe // done that we can provide a merged view of response headers and trailers in a thread-safe
// way. // way.
if (strongSelf.responseHeaders) { if (self.responseHeaders) {
userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders; userInfo[kGRPCHeadersKey] = self.responseHeaders;
} }
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo]; error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
} }
[strongSelf finishWithError:error]; [self finishWithError:error];
}
}]; }];
// Now that the RPC has been initiated, request writes can start. // Now that the RPC has been initiated, request writes can start.
@synchronized(_requestWriter) { @synchronized(_requestWriter) {
@ -377,7 +370,6 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
[strongSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain [strongSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeUnavailable code:GRPCErrorCodeUnavailable
userInfo:@{NSLocalizedDescriptionKey: @"Connectivity lost."}]]; userInfo:@{NSLocalizedDescriptionKey: @"Connectivity lost."}]];
[[GRPCHost hostWithAddress:strongSelf->_host] disconnect];
} }
}]; }];
} }

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015, Google Inc. * Copyright 2015-2016, Google Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -54,7 +54,9 @@
- (void)finish { - (void)finish {
if (_handler) { if (_handler) {
_handler(); void(^handler)() = _handler;
_handler = nil;
handler();
} }
} }
@end @end

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@ import abc
import collections import collections
import enum import enum
import six
from grpc._cython import cygrpc from grpc._cython import cygrpc
@ -247,8 +249,7 @@ class Event(collections.namedtuple(
""" """
class CompletionQueue: class CompletionQueue(six.with_metaclass(abc.ABCMeta)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
@ -262,6 +263,9 @@ class CompletionQueue:
""" """
return self return self
def __next__(self):
return self.next()
@abc.abstractmethod @abc.abstractmethod
def next(self, deadline=float('+inf')): def next(self, deadline=float('+inf')):
"""Get the next event on this completion queue. """Get the next event on this completion queue.
@ -285,8 +289,7 @@ class CompletionQueue:
return None return None
class Call: class Call(six.with_metaclass(abc.ABCMeta)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def start_batch(self, ops, tag): def start_batch(self, ops, tag):
@ -334,8 +337,7 @@ class Call:
return None return None
class Channel: class Channel(six.with_metaclass(abc.ABCMeta)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self, target, args, credentials=None): def __init__(self, target, args, credentials=None):
@ -399,8 +401,7 @@ class Channel:
return None return None
class Server: class Server(six.with_metaclass(abc.ABCMeta)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self, completion_queue, args): def __init__(self, completion_queue, args):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -35,6 +35,8 @@ import logging
import threading import threading
import time import time
import six
from grpc._adapter import _intermediary_low from grpc._adapter import _intermediary_low
from grpc._links import _constants from grpc._links import _constants
from grpc.beta import interfaces as beta_interfaces from grpc.beta import interfaces as beta_interfaces
@ -372,12 +374,11 @@ class _Kernel(object):
pool.shutdown(wait=True) pool.shutdown(wait=True)
class InvocationLink(links.Link, activated.Activated): class InvocationLink(six.with_metaclass(abc.ABCMeta, links.Link, activated.Activated)):
"""A links.Link for use on the invocation-side of a gRPC connection. """A links.Link for use on the invocation-side of a gRPC connection.
Implementations of this interface are only valid for use when activated. Implementations of this interface are only valid for use when activated.
""" """
__metaclass__ = abc.ABCMeta
class _InvocationLink(InvocationLink): class _InvocationLink(InvocationLink):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import abc import abc
import enum import enum
import six
from grpc._adapter import _types from grpc._adapter import _types
@ -105,19 +107,17 @@ def grpc_call_options(disable_compression=False, credentials=None):
return GRPCCallOptions(disable_compression, None, credentials) return GRPCCallOptions(disable_compression, None, credentials)
class GRPCAuthMetadataContext(object): class GRPCAuthMetadataContext(six.with_metaclass(abc.ABCMeta)):
"""Provides information to call credentials metadata plugins. """Provides information to call credentials metadata plugins.
Attributes: Attributes:
service_url: A string URL of the service being called into. service_url: A string URL of the service being called into.
method_name: A string of the fully qualified method name being called. method_name: A string of the fully qualified method name being called.
""" """
__metaclass__ = abc.ABCMeta
class GRPCAuthMetadataPluginCallback(object): class GRPCAuthMetadataPluginCallback(six.with_metaclass(abc.ABCMeta)):
"""Callback object received by a metadata plugin.""" """Callback object received by a metadata plugin."""
__metaclass__ = abc.ABCMeta
def __call__(self, metadata, error): def __call__(self, metadata, error):
"""Inform the gRPC runtime of the metadata to construct a CallCredentials. """Inform the gRPC runtime of the metadata to construct a CallCredentials.
@ -130,10 +130,9 @@ class GRPCAuthMetadataPluginCallback(object):
raise NotImplementedError() raise NotImplementedError()
class GRPCAuthMetadataPlugin(object): class GRPCAuthMetadataPlugin(six.with_metaclass(abc.ABCMeta)):
""" """
""" """
__metaclass__ = abc.ABCMeta
def __call__(self, context, callback): def __call__(self, context, callback):
"""Invoke the plugin. """Invoke the plugin.
@ -149,9 +148,8 @@ class GRPCAuthMetadataPlugin(object):
raise NotImplementedError() raise NotImplementedError()
class GRPCServicerContext(object): class GRPCServicerContext(six.with_metaclass(abc.ABCMeta)):
"""Exposes gRPC-specific options and behaviors to code servicing RPCs.""" """Exposes gRPC-specific options and behaviors to code servicing RPCs."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def peer(self): def peer(self):
@ -168,9 +166,8 @@ class GRPCServicerContext(object):
raise NotImplementedError() raise NotImplementedError()
class GRPCInvocationContext(object): class GRPCInvocationContext(six.with_metaclass(abc.ABCMeta)):
"""Exposes gRPC-specific options and behaviors to code invoking RPCs.""" """Exposes gRPC-specific options and behaviors to code invoking RPCs."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def disable_next_request_compression(self): def disable_next_request_compression(self):
@ -178,9 +175,8 @@ class GRPCInvocationContext(object):
raise NotImplementedError() raise NotImplementedError()
class Server(object): class Server(six.with_metaclass(abc.ABCMeta)):
"""Services RPCs.""" """Services RPCs."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def add_insecure_port(self, address): def add_insecure_port(self, address):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -30,6 +30,8 @@
import abc import abc
import collections import collections
import six
# face_interfaces is referenced from specification in this module. # face_interfaces is referenced from specification in this module.
from grpc.framework.common import cardinality from grpc.framework.common import cardinality
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
@ -45,7 +47,7 @@ def _qualified_name(service_name, method_name):
# TODO(nathaniel): This structure is getting bloated; it could be shrunk if # TODO(nathaniel): This structure is getting bloated; it could be shrunk if
# implementations._Stub used a generic rather than a dynamic underlying # implementations._Stub used a generic rather than a dynamic underlying
# face-layer stub. # face-layer stub.
class InvocationBreakdown(object): class InvocationBreakdown(six.with_metaclass(abc.ABCMeta)):
"""An intermediate representation of invocation-side views of RPC methods. """An intermediate representation of invocation-side views of RPC methods.
Attributes: Attributes:
@ -61,7 +63,6 @@ class InvocationBreakdown(object):
to callable behavior to be used deserializing response values for the to callable behavior to be used deserializing response values for the
RPC. RPC.
""" """
__metaclass__ = abc.ABCMeta
class _EasyInvocationBreakdown( class _EasyInvocationBreakdown(
@ -73,7 +74,7 @@ class _EasyInvocationBreakdown(
pass pass
class ServiceBreakdown(object): class ServiceBreakdown(six.with_metaclass(abc.ABCMeta)):
"""An intermediate representation of service-side views of RPC methods. """An intermediate representation of service-side views of RPC methods.
Attributes: Attributes:
@ -84,7 +85,6 @@ class ServiceBreakdown(object):
response_serializers: A dictionary from service-qualified RPC method name response_serializers: A dictionary from service-qualified RPC method name
to callable behavior to be used serializing response values for the RPC. to callable behavior to be used serializing response values for the RPC.
""" """
__metaclass__ = abc.ABCMeta
class _EasyServiceBreakdown( class _EasyServiceBreakdown(
@ -111,7 +111,7 @@ def break_down_invocation(service_name, method_descriptions):
face_cardinalities = {} face_cardinalities = {}
request_serializers = {} request_serializers = {}
response_deserializers = {} response_deserializers = {}
for name, method_description in method_descriptions.iteritems(): for name, method_description in six.iteritems(method_descriptions):
qualified_name = _qualified_name(service_name, name) qualified_name = _qualified_name(service_name, name)
method_cardinality = method_description.cardinality() method_cardinality = method_description.cardinality()
cardinalities[name] = method_description.cardinality() cardinalities[name] = method_description.cardinality()
@ -139,7 +139,7 @@ def break_down_service(service_name, method_descriptions):
implementations = {} implementations = {}
request_deserializers = {} request_deserializers = {}
response_serializers = {} response_serializers = {}
for name, method_description in method_descriptions.iteritems(): for name, method_description in six.iteritems(method_descriptions):
qualified_name = _qualified_name(service_name, name) qualified_name = _qualified_name(service_name, name)
method_cardinality = method_description.cardinality() method_cardinality = method_description.cardinality()
if method_cardinality is interfaces.Cardinality.UNARY_UNARY: if method_cardinality is interfaces.Cardinality.UNARY_UNARY:

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -27,6 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import six
from grpc.framework.common import cardinality from grpc.framework.common import cardinality
from grpc.framework.face import exceptions as face_exceptions from grpc.framework.face import exceptions as face_exceptions
from grpc.framework.face import interfaces as face_interfaces from grpc.framework.face import interfaces as face_interfaces
@ -181,7 +183,7 @@ def common_cardinality(early_adopter_cardinality):
def common_cardinalities(early_adopter_cardinalities): def common_cardinalities(early_adopter_cardinalities):
common_cardinalities = {} common_cardinalities = {}
for name, early_adopter_cardinality in early_adopter_cardinalities.iteritems(): for name, early_adopter_cardinality in six.iteritems(early_adopter_cardinalities):
common_cardinalities[name] = _EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY[ common_cardinalities[name] = _EARLY_ADOPTER_CARDINALITY_TO_COMMON_CARDINALITY[
early_adopter_cardinality] early_adopter_cardinality]
return common_cardinalities return common_cardinalities

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,13 +31,12 @@
Only GRPC should instantiate and raise these exceptions. Only GRPC should instantiate and raise these exceptions.
""" """
import abc import abc
import six
class RpcError(Exception): class RpcError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for all exceptions raised by GRPC.""" """Common super type for all exceptions raised by GRPC."""
__metaclass__ = abc.ABCMeta
class CancellationError(RpcError): class CancellationError(RpcError):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import abc import abc
import enum import enum
import six
# exceptions is referenced from specification in this module. # exceptions is referenced from specification in this module.
from grpc.framework.alpha import exceptions # pylint: disable=unused-import from grpc.framework.alpha import exceptions # pylint: disable=unused-import
from grpc.framework.foundation import activated from grpc.framework.foundation import activated
@ -59,15 +61,17 @@ class Abortion(enum.Enum):
SERVICER_FAILURE = 'servicer failure' SERVICER_FAILURE = 'servicer failure'
class CancellableIterator(object): class CancellableIterator(six.with_metaclass(abc.ABCMeta)):
"""Implements the Iterator protocol and affords a cancel method.""" """Implements the Iterator protocol and affords a cancel method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __iter__(self): def __iter__(self):
"""Returns the self object in accordance with the Iterator protocol.""" """Returns the self object in accordance with the Iterator protocol."""
raise NotImplementedError() raise NotImplementedError()
def __next__(self):
return self.next()
@abc.abstractmethod @abc.abstractmethod
def next(self): def next(self):
"""Returns a value or raises StopIteration per the Iterator protocol.""" """Returns a value or raises StopIteration per the Iterator protocol."""
@ -79,9 +83,8 @@ class CancellableIterator(object):
raise NotImplementedError() raise NotImplementedError()
class RpcContext(object): class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action.""" """Provides RPC-related information and action."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def is_active(self): def is_active(self):
@ -108,7 +111,7 @@ class RpcContext(object):
raise NotImplementedError() raise NotImplementedError()
class UnaryUnarySyncAsync(object): class UnaryUnarySyncAsync(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC synchronously or asynchronously. """Affords invoking a unary-unary RPC synchronously or asynchronously.
Values implementing this interface are directly callable and present an Values implementing this interface are directly callable and present an
"async" method. Both calls take a request value and a numeric timeout. "async" method. Both calls take a request value and a numeric timeout.
@ -117,7 +120,6 @@ class UnaryUnarySyncAsync(object):
of a value of this type invokes its associated RPC and immediately returns a of a value of this type invokes its associated RPC and immediately returns a
future.Future bound to the asynchronous execution of the RPC. future.Future bound to the asynchronous execution of the RPC.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__(self, request, timeout): def __call__(self, request, timeout):
@ -147,7 +149,7 @@ class UnaryUnarySyncAsync(object):
raise NotImplementedError() raise NotImplementedError()
class StreamUnarySyncAsync(object): class StreamUnarySyncAsync(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC synchronously or asynchronously. """Affords invoking a stream-unary RPC synchronously or asynchronously.
Values implementing this interface are directly callable and present an Values implementing this interface are directly callable and present an
"async" method. Both calls take an iterator of request values and a numeric "async" method. Both calls take an iterator of request values and a numeric
@ -156,7 +158,6 @@ class StreamUnarySyncAsync(object):
of a value of this type invokes its associated RPC and immediately returns a of a value of this type invokes its associated RPC and immediately returns a
future.Future bound to the asynchronous execution of the RPC. future.Future bound to the asynchronous execution of the RPC.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__(self, request_iterator, timeout): def __call__(self, request_iterator, timeout):
@ -191,9 +192,8 @@ class StreamUnarySyncAsync(object):
raise NotImplementedError() raise NotImplementedError()
class RpcMethodDescription(object): class RpcMethodDescription(six.with_metaclass(abc.ABCMeta)):
"""A type for the common aspects of RPC method descriptions.""" """A type for the common aspects of RPC method descriptions."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def cardinality(self): def cardinality(self):
@ -207,9 +207,8 @@ class RpcMethodDescription(object):
raise NotImplementedError() raise NotImplementedError()
class RpcMethodInvocationDescription(RpcMethodDescription): class RpcMethodInvocationDescription(six.with_metaclass(abc.ABCMeta, RpcMethodDescription)):
"""Invocation-side description of an RPC method.""" """Invocation-side description of an RPC method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def serialize_request(self, request): def serialize_request(self, request):
@ -240,9 +239,8 @@ class RpcMethodInvocationDescription(RpcMethodDescription):
raise NotImplementedError() raise NotImplementedError()
class RpcMethodServiceDescription(RpcMethodDescription): class RpcMethodServiceDescription(six.with_metaclass(abc.ABCMeta, RpcMethodDescription)):
"""Service-side description of an RPC method.""" """Service-side description of an RPC method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def deserialize_request(self, serialized_request): def deserialize_request(self, serialized_request):
@ -345,7 +343,7 @@ class RpcMethodServiceDescription(RpcMethodDescription):
raise NotImplementedError() raise NotImplementedError()
class Stub(object): class Stub(six.with_metaclass(abc.ABCMeta)):
"""A stub with callable RPC method names for attributes. """A stub with callable RPC method names for attributes.
Instances of this type are context managers and only afford RPC invocation Instances of this type are context managers and only afford RPC invocation
@ -369,12 +367,10 @@ class Stub(object):
exceptions.RpcError, exceptions.CancellationError, exceptions.RpcError, exceptions.CancellationError,
and exceptions.ExpirationError. and exceptions.ExpirationError.
""" """
__metaclass__ = abc.ABCMeta
class Server(activated.Activated): class Server(six.with_metaclass(abc.ABCMeta, activated.Activated)):
"""A GRPC Server.""" """A GRPC Server."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def port(self): def port(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import abc import abc
import collections import collections
import six
from grpc.framework.base import _constants from grpc.framework.base import _constants
from grpc.framework.base import _interfaces from grpc.framework.base import _interfaces
from grpc.framework.base import exceptions from grpc.framework.base import exceptions
@ -72,9 +74,8 @@ class _EmptyConsumer(stream.Consumer):
"""See stream.Consumer.consume_and_terminate for specification.""" """See stream.Consumer.consume_and_terminate for specification."""
class _ConsumerCreator(object): class _ConsumerCreator(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different consumer-creating behavior.""" """Common specification of different consumer-creating behavior."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def create_consumer(self, requirement): def create_consumer(self, requirement):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,14 +31,15 @@
import abc import abc
import six
# interfaces is referenced from specification in this module. # interfaces is referenced from specification in this module.
from grpc.framework.base import interfaces # pylint: disable=unused-import from grpc.framework.base import interfaces # pylint: disable=unused-import
from grpc.framework.foundation import stream from grpc.framework.foundation import stream
class TerminationManager(object): class TerminationManager(six.with_metaclass(abc.ABCMeta)):
"""An object responsible for handling the termination of an operation.""" """An object responsible for handling the termination of an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def set_expiration_manager(self, expiration_manager): def set_expiration_manager(self, expiration_manager):
@ -91,9 +92,8 @@ class TerminationManager(object):
raise NotImplementedError() raise NotImplementedError()
class TransmissionManager(object): class TransmissionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for transmitting to the other end of an operation.""" """A manager responsible for transmitting to the other end of an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def inmit(self, emission, complete): def inmit(self, emission, complete):
@ -117,9 +117,8 @@ class TransmissionManager(object):
raise NotImplementedError() raise NotImplementedError()
class EmissionManager(stream.Consumer): class EmissionManager(six.with_metaclass(abc.ABCMeta, stream.Consumer)):
"""A manager of values emitted by customer code.""" """A manager of values emitted by customer code."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def set_ingestion_manager_and_expiration_manager( def set_ingestion_manager_and_expiration_manager(
@ -166,9 +165,8 @@ class EmissionManager(stream.Consumer):
raise NotImplementedError() raise NotImplementedError()
class IngestionManager(stream.Consumer): class IngestionManager(six.with_metaclass(abc.ABCMeta, stream.Consumer)):
"""A manager responsible for executing customer code.""" """A manager responsible for executing customer code."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def set_expiration_manager(self, expiration_manager): def set_expiration_manager(self, expiration_manager):
@ -214,9 +212,8 @@ class IngestionManager(stream.Consumer):
raise NotImplementedError() raise NotImplementedError()
class ExpirationManager(object): class ExpirationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for aborting the operation if it runs out of time.""" """A manager responsible for aborting the operation if it runs out of time."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def change_timeout(self, timeout): def change_timeout(self, timeout):
@ -246,9 +243,8 @@ class ExpirationManager(object):
raise NotImplementedError() raise NotImplementedError()
class ReceptionManager(object): class ReceptionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for receiving tickets from the other end.""" """A manager responsible for receiving tickets from the other end."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def receive_ticket(self, ticket): def receive_ticket(self, ticket):
@ -261,9 +257,8 @@ class ReceptionManager(object):
raise NotImplementedError() raise NotImplementedError()
class CancellationManager(object): class CancellationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager of operation cancellation.""" """A manager of operation cancellation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def cancel(self): def cancel(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
import abc import abc
import six
from grpc.framework.base import interfaces from grpc.framework.base import interfaces
from grpc.framework.base import _interfaces from grpc.framework.base import _interfaces
@ -40,9 +42,8 @@ _INITIAL_FRONT_TO_BACK_TICKET_KINDS = (
) )
class _Receiver(object): class _Receiver(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different ticket-handling behavior.""" """Common specification of different ticket-handling behavior."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def abort_if_abortive(self, ticket): def abort_if_abortive(self, ticket):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
import abc import abc
import six
from grpc.framework.base import _constants from grpc.framework.base import _constants
from grpc.framework.base import _interfaces from grpc.framework.base import _interfaces
from grpc.framework.base import interfaces from grpc.framework.base import interfaces
@ -77,9 +79,8 @@ _ABORTION_OUTCOME_TO_BACK_TO_FRONT_TICKET_KIND = {
} }
class _Ticketizer(object): class _Ticketizer(six.with_metaclass(abc.ABCMeta)):
"""Common specification of different ticket-creating behavior.""" """Common specification of different ticket-creating behavior."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def ticketize(self, operation_id, sequence_number, payload, complete): def ticketize(self, operation_id, sequence_number, payload, complete):
@ -187,9 +188,8 @@ class _BackTicketizer(_Ticketizer):
operation_id, sequence_number, kind, None) operation_id, sequence_number, kind, None)
class TransmissionManager(_interfaces.TransmissionManager): class TransmissionManager(six.with_metaclass(abc.ABCMeta, _interfaces.TransmissionManager)):
"""A _interfaces.TransmissionManager on which other managers may be set.""" """A _interfaces.TransmissionManager on which other managers may be set."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def set_ingestion_and_expiration_managers( def set_ingestion_and_expiration_managers(

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@ import abc
import collections import collections
import enum import enum
import six
# stream is referenced from specification in this module. # stream is referenced from specification in this module.
from grpc.framework.foundation import stream # pylint: disable=unused-import from grpc.framework.foundation import stream # pylint: disable=unused-import
@ -50,13 +52,12 @@ class Outcome(enum.Enum):
SERVICED_FAILURE = 'serviced failure' SERVICED_FAILURE = 'serviced failure'
class OperationContext(object): class OperationContext(six.with_metaclass(abc.ABCMeta)):
"""Provides operation-related information and action. """Provides operation-related information and action.
Attributes: Attributes:
trace_id: A uuid.UUID identifying a particular set of related operations. trace_id: A uuid.UUID identifying a particular set of related operations.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def is_active(self): def is_active(self):
@ -93,9 +94,8 @@ class OperationContext(object):
raise NotImplementedError() raise NotImplementedError()
class Servicer(object): class Servicer(six.with_metaclass(abc.ABCMeta)):
"""Interface for service implementations.""" """Interface for service implementations."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, name, context, output_consumer): def service(self, name, context, output_consumer):
@ -120,7 +120,7 @@ class Servicer(object):
raise NotImplementedError() raise NotImplementedError()
class Operation(object): class Operation(six.with_metaclass(abc.ABCMeta)):
"""Representation of an in-progress operation. """Representation of an in-progress operation.
Attributes: Attributes:
@ -129,7 +129,6 @@ class Operation(object):
context: An OperationContext affording information and action about the context: An OperationContext affording information and action about the
operation. operation.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def cancel(self): def cancel(self):
@ -137,9 +136,8 @@ class Operation(object):
raise NotImplementedError() raise NotImplementedError()
class ServicedIngestor(object): class ServicedIngestor(six.with_metaclass(abc.ABCMeta)):
"""Responsible for accepting the result of an operation.""" """Responsible for accepting the result of an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def consumer(self, operation_context): def consumer(self, operation_context):
@ -159,7 +157,7 @@ class ServicedIngestor(object):
raise NotImplementedError() raise NotImplementedError()
class ServicedSubscription(object): class ServicedSubscription(six.with_metaclass(abc.ABCMeta)):
"""A sum type representing a serviced's interest in an operation. """A sum type representing a serviced's interest in an operation.
Attributes: Attributes:
@ -167,7 +165,6 @@ class ServicedSubscription(object):
ingestor: A ServicedIngestor. Must be present if kind is Kind.FULL. Must ingestor: A ServicedIngestor. Must be present if kind is Kind.FULL. Must
be None if kind is Kind.TERMINATION_ONLY or Kind.NONE. be None if kind is Kind.TERMINATION_ONLY or Kind.NONE.
""" """
__metaclass__ = abc.ABCMeta
@enum.unique @enum.unique
class Kind(enum.Enum): class Kind(enum.Enum):
@ -178,9 +175,8 @@ class ServicedSubscription(object):
NONE = 'none' NONE = 'none'
class End(object): class End(six.with_metaclass(abc.ABCMeta)):
"""Common type for entry-point objects on both sides of an operation.""" """Common type for entry-point objects on both sides of an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def operation_stats(self): def operation_stats(self):
@ -202,9 +198,8 @@ class End(object):
raise NotImplementedError() raise NotImplementedError()
class Front(End): class Front(six.with_metaclass(abc.ABCMeta, End)):
"""Clientish objects that afford the invocation of operations.""" """Clientish objects that afford the invocation of operations."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def operate( def operate(
@ -228,9 +223,8 @@ class Front(End):
raise NotImplementedError() raise NotImplementedError()
class Back(End): class Back(six.with_metaclass(abc.ABCMeta, End)):
"""Serverish objects that perform the work of operations.""" """Serverish objects that perform the work of operations."""
__metaclass__ = abc.ABCMeta
class FrontToBackTicket( class FrontToBackTicket(
@ -315,9 +309,8 @@ class BackToFrontTicket(
TRANSMISSION_FAILURE = 'transmission failure' TRANSMISSION_FAILURE = 'transmission failure'
class ForeLink(object): class ForeLink(six.with_metaclass(abc.ABCMeta)):
"""Accepts back-to-front tickets and emits front-to-back tickets.""" """Accepts back-to-front tickets and emits front-to-back tickets."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def accept_back_to_front_ticket(self, ticket): def accept_back_to_front_ticket(self, ticket):
@ -334,9 +327,8 @@ class ForeLink(object):
raise NotImplementedError() raise NotImplementedError()
class RearLink(object): class RearLink(six.with_metaclass(abc.ABCMeta)):
"""Accepts front-to-back tickets and emits back-to-front tickets.""" """Accepts front-to-back tickets and emits back-to-front tickets."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def accept_front_to_back_ticket(self, ticket): def accept_front_to_back_ticket(self, ticket):
@ -353,11 +345,9 @@ class RearLink(object):
raise NotImplementedError() raise NotImplementedError()
class FrontLink(Front, ForeLink): class FrontLink(six.with_metaclass(abc.ABCMeta, Front, ForeLink)):
"""Clientish objects that operate by sending and receiving tickets.""" """Clientish objects that operate by sending and receiving tickets."""
__metaclass__ = abc.ABCMeta
class BackLink(Back, RearLink): class BackLink(six.with_metaclass(abc.ABCMeta, Back, RearLink)):
"""Serverish objects that operate by sending and receiving tickets.""" """Serverish objects that operate by sending and receiving tickets."""
__metaclass__ = abc.ABCMeta

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@ import abc
import threading import threading
import uuid import uuid
import six
from grpc.framework.core import _operation from grpc.framework.core import _operation
from grpc.framework.core import _utilities from grpc.framework.core import _utilities
from grpc.framework.foundation import callable_util from grpc.framework.foundation import callable_util
@ -45,7 +47,7 @@ from grpc.framework.interfaces.links import utilities
_IDLE_ACTION_EXCEPTION_LOG_MESSAGE = 'Exception calling idle action!' _IDLE_ACTION_EXCEPTION_LOG_MESSAGE = 'Exception calling idle action!'
class End(base.End, links.Link): class End(six.with_metaclass(abc.ABCMeta, base.End, links.Link)):
"""A bridge between base.End and links.Link. """A bridge between base.End and links.Link.
Implementations of this interface translate arriving tickets into Implementations of this interface translate arriving tickets into
@ -53,7 +55,6 @@ class End(base.End, links.Link):
translate calls from application objects implementing base interfaces translate calls from application objects implementing base interfaces
into tickets sent to a joined link. into tickets sent to a joined link.
""" """
__metaclass__ = abc.ABCMeta
class _Cycle(object): class _Cycle(object):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@ import abc
import collections import collections
import enum import enum
import six
from grpc.framework.core import _constants from grpc.framework.core import _constants
from grpc.framework.core import _interfaces from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities from grpc.framework.core import _utilities
@ -70,9 +72,8 @@ class _SubscriptionCreation(
ABANDONED = 'abandoned' ABANDONED = 'abandoned'
class _SubscriptionCreator(object): class _SubscriptionCreator(six.with_metaclass(abc.ABCMeta)):
"""Common specification of subscription-creating behavior.""" """Common specification of subscription-creating behavior."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def create(self, group, method): def create(self, group, method):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,17 +31,18 @@
import abc import abc
import six
from grpc.framework.interfaces.base import base from grpc.framework.interfaces.base import base
class TerminationManager(object): class TerminationManager(six.with_metaclass(abc.ABCMeta)):
"""An object responsible for handling the termination of an operation. """An object responsible for handling the termination of an operation.
Attributes: Attributes:
outcome: None if the operation is active or a base.Outcome value if it has outcome: None if the operation is active or a base.Outcome value if it has
terminated. terminated.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def add_callback(self, callback): def add_callback(self, callback):
@ -105,9 +106,8 @@ class TerminationManager(object):
raise NotImplementedError() raise NotImplementedError()
class TransmissionManager(object): class TransmissionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for transmitting to the other end of an operation.""" """A manager responsible for transmitting to the other end of an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def kick_off( def kick_off(
@ -171,9 +171,8 @@ class TransmissionManager(object):
raise NotImplementedError() raise NotImplementedError()
class ExpirationManager(object): class ExpirationManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for aborting the operation if it runs out of time.""" """A manager responsible for aborting the operation if it runs out of time."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def change_timeout(self, timeout): def change_timeout(self, timeout):
@ -203,9 +202,8 @@ class ExpirationManager(object):
raise NotImplementedError() raise NotImplementedError()
class ProtocolManager(object): class ProtocolManager(six.with_metaclass(abc.ABCMeta)):
"""A manager of protocol-specific values passing through an operation.""" """A manager of protocol-specific values passing through an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def set_protocol_receiver(self, protocol_receiver): def set_protocol_receiver(self, protocol_receiver):
@ -228,9 +226,8 @@ class ProtocolManager(object):
raise NotImplementedError() raise NotImplementedError()
class EmissionManager(base.Operator): class EmissionManager(six.with_metaclass(abc.ABCMeta, base.Operator)):
"""A manager of values emitted by customer code.""" """A manager of values emitted by customer code."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def advance( def advance(
@ -254,14 +251,13 @@ class EmissionManager(base.Operator):
raise NotImplementedError() raise NotImplementedError()
class IngestionManager(object): class IngestionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for executing customer code. """A manager responsible for executing customer code.
This name of this manager comes from its responsibility to pass successive This name of this manager comes from its responsibility to pass successive
values from the other side of the operation into the code of the local values from the other side of the operation into the code of the local
customer. customer.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def set_group_and_method(self, group, method): def set_group_and_method(self, group, method):
@ -294,9 +290,8 @@ class IngestionManager(object):
raise NotImplementedError() raise NotImplementedError()
class ReceptionManager(object): class ReceptionManager(six.with_metaclass(abc.ABCMeta)):
"""A manager responsible for receiving tickets from the other end.""" """A manager responsible for receiving tickets from the other end."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def receive_ticket(self, ticket): def receive_ticket(self, ticket):
@ -308,7 +303,7 @@ class ReceptionManager(object):
raise NotImplementedError() raise NotImplementedError()
class Operation(object): class Operation(six.with_metaclass(abc.ABCMeta)):
"""An ongoing operation. """An ongoing operation.
Attributes: Attributes:
@ -316,7 +311,6 @@ class Operation(object):
operator: A base.Operator object for the operation for use by the customer operator: A base.Operator object for the operation for use by the customer
of the operation. of the operation.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def handle_ticket(self, ticket): def handle_ticket(self, ticket):

@ -31,6 +31,8 @@
import abc import abc
import six
from grpc.framework.core import _constants from grpc.framework.core import _constants
from grpc.framework.core import _interfaces from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities from grpc.framework.core import _utilities
@ -50,9 +52,8 @@ def _service_completion_predicate(
return transmission_complete and ingestion_complete return transmission_complete and ingestion_complete
class TerminationManager(_interfaces.TerminationManager): class TerminationManager(six.with_metaclass(abc.ABCMeta, _interfaces.TerminationManager)):
"""A _interfaces.TransmissionManager on which another manager may be set.""" """A _interfaces.TransmissionManager on which another manager may be set."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def set_expiration_manager(self, expiration_manager): def set_expiration_manager(self, expiration_manager):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -405,6 +405,9 @@ class Rendezvous(base.Operator, future.Future, stream.Consumer, face.Call):
def __iter__(self): def __iter__(self):
return self return self
def __next__(self):
return self.next()
def next(self): def next(self):
with self._condition: with self._condition:
while True: while True:

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -29,6 +29,8 @@
"""Entry points into the Crust layer of RPC Framework.""" """Entry points into the Crust layer of RPC Framework."""
import six
from grpc.framework.common import cardinality from grpc.framework.common import cardinality
from grpc.framework.common import style from grpc.framework.common import style
from grpc.framework.crust import _calls from grpc.framework.crust import _calls
@ -271,7 +273,7 @@ class _DynamicStub(face.DynamicStub):
def _adapt_method_implementations(method_implementations, pool): def _adapt_method_implementations(method_implementations, pool):
adapted_implementations = {} adapted_implementations = {}
for name, method_implementation in method_implementations.iteritems(): for name, method_implementation in six.iteritems(method_implementations):
if method_implementation.style is style.Service.INLINE: if method_implementation.style is style.Service.INLINE:
if method_implementation.cardinality is cardinality.Cardinality.UNARY_UNARY: if method_implementation.cardinality is cardinality.Cardinality.UNARY_UNARY:
adapted_implementations[name] = _service.adapt_inline_unary_unary( adapted_implementations[name] = _service.adapt_inline_unary_unary(

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -120,6 +120,9 @@ class Rendezvous(stream.Consumer):
def __iter__(self): def __iter__(self):
return self return self
def __next__(self):
return self.next()
def next(self): def next(self):
with self._condition: with self._condition:
while ((self._abortion is None) and while ((self._abortion is None) and

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
import abc import abc
import six
class NoSuchMethodError(Exception): class NoSuchMethodError(Exception):
"""Raised by customer code to indicate an unrecognized RPC method name. """Raised by customer code to indicate an unrecognized RPC method name.
@ -49,12 +51,11 @@ class NoSuchMethodError(Exception):
self.name = name self.name = name
class RpcError(Exception): class RpcError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for all exceptions raised by the Face layer. """Common super type for all exceptions raised by the Face layer.
Only RPC Framework should instantiate and raise these exceptions. Only RPC Framework should instantiate and raise these exceptions.
""" """
__metaclass__ = abc.ABCMeta
class CancellationError(RpcError): class CancellationError(RpcError):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -29,6 +29,8 @@
"""Entry points into the Face layer of RPC Framework.""" """Entry points into the Face layer of RPC Framework."""
import six
from grpc.framework.common import cardinality from grpc.framework.common import cardinality
from grpc.framework.common import style from grpc.framework.common import style
from grpc.framework.base import exceptions as _base_exceptions from grpc.framework.base import exceptions as _base_exceptions
@ -228,7 +230,7 @@ class _DynamicStub(interfaces.DynamicStub):
def _adapt_method_implementations(method_implementations, pool): def _adapt_method_implementations(method_implementations, pool):
adapted_implementations = {} adapted_implementations = {}
for name, method_implementation in method_implementations.iteritems(): for name, method_implementation in six.iteritems(method_implementations):
if method_implementation.style is style.Service.INLINE: if method_implementation.style is style.Service.INLINE:
if method_implementation.cardinality is cardinality.Cardinality.UNARY_UNARY: if method_implementation.cardinality is cardinality.Cardinality.UNARY_UNARY:
adapted_implementations[name] = _service.adapt_inline_value_in_value_out( adapted_implementations[name] = _service.adapt_inline_value_in_value_out(

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import abc import abc
import enum import enum
import six
# cardinality, style, exceptions, abandonment, future, and stream are # cardinality, style, exceptions, abandonment, future, and stream are
# referenced from specification in this module. # referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import from grpc.framework.common import cardinality # pylint: disable=unused-import
@ -52,15 +54,17 @@ class Abortion(enum.Enum):
SERVICER_FAILURE = 'servicer failure' SERVICER_FAILURE = 'servicer failure'
class CancellableIterator(object): class CancellableIterator(six.with_metaclass(abc.ABCMeta)):
"""Implements the Iterator protocol and affords a cancel method.""" """Implements the Iterator protocol and affords a cancel method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __iter__(self): def __iter__(self):
"""Returns the self object in accordance with the Iterator protocol.""" """Returns the self object in accordance with the Iterator protocol."""
raise NotImplementedError() raise NotImplementedError()
def __next__(self):
return self.next()
@abc.abstractmethod @abc.abstractmethod
def next(self): def next(self):
"""Returns a value or raises StopIteration per the Iterator protocol.""" """Returns a value or raises StopIteration per the Iterator protocol."""
@ -72,9 +76,8 @@ class CancellableIterator(object):
raise NotImplementedError() raise NotImplementedError()
class RpcContext(object): class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action.""" """Provides RPC-related information and action."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def is_active(self): def is_active(self):
@ -103,13 +106,12 @@ class RpcContext(object):
raise NotImplementedError() raise NotImplementedError()
class Call(object): class Call(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side representation of an RPC. """Invocation-side representation of an RPC.
Attributes: Attributes:
context: An RpcContext affording information about the RPC. context: An RpcContext affording information about the RPC.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def cancel(self): def cancel(self):
@ -117,9 +119,8 @@ class Call(object):
raise NotImplementedError() raise NotImplementedError()
class UnaryUnaryMultiCallable(object): class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style.""" """Affords invoking a unary-unary RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__(self, request, timeout): def __call__(self, request, timeout):
@ -171,9 +172,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError() raise NotImplementedError()
class UnaryStreamMultiCallable(object): class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style.""" """Affords invoking a unary-stream RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__(self, request, timeout): def __call__(self, request, timeout):
@ -209,9 +209,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError() raise NotImplementedError()
class StreamUnaryMultiCallable(object): class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style.""" """Affords invoking a stream-unary RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__(self, request_iterator, timeout): def __call__(self, request_iterator, timeout):
@ -264,9 +263,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError() raise NotImplementedError()
class StreamStreamMultiCallable(object): class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style.""" """Affords invoking a stream-stream RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__(self, request_iterator, timeout): def __call__(self, request_iterator, timeout):
@ -302,7 +300,7 @@ l Args:
raise NotImplementedError() raise NotImplementedError()
class MethodImplementation(object): class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes an RPC method implementation. """A sum type that describes an RPC method implementation.
Attributes: Attributes:
@ -347,12 +345,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT. style.Service.EVENT.
""" """
__metaclass__ = abc.ABCMeta
class MultiMethodImplementation(object): class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many RPC methods.""" """A general type able to service many RPC methods."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, name, response_consumer, context): def service(self, name, response_consumer, context):
@ -381,9 +377,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError() raise NotImplementedError()
class GenericStub(object): class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC methods to callers.""" """Affords RPC methods to callers."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def blocking_value_in_value_out(self, name, request, timeout): def blocking_value_in_value_out(self, name, request, timeout):
@ -622,7 +617,7 @@ class GenericStub(object):
raise NotImplementedError() raise NotImplementedError()
class DynamicStub(object): class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""A stub with RPC-method-bound multi-callable attributes. """A stub with RPC-method-bound multi-callable attributes.
Instances of this type responsd to attribute access as follows: if the Instances of this type responsd to attribute access as follows: if the
@ -637,4 +632,3 @@ class DynamicStub(object):
the attribute will be a StreamStreamMultiCallable with which to invoke the the attribute will be a StreamStreamMultiCallable with which to invoke the
RPC method. RPC method.
""" """
__metaclass__ = abc.ABCMeta

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,14 +31,14 @@
import abc import abc
import six
class Activated(object): class Activated(six.with_metaclass(abc.ABCMeta)):
"""Interface for objects that may be started and stopped. """Interface for objects that may be started and stopped.
Values implementing this type must also implement the context manager Values implementing this type must also implement the context manager
protocol. protocol.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __enter__(self): def __enter__(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -35,8 +35,10 @@ import enum
import functools import functools
import logging import logging
import six
class Outcome(object):
class Outcome(six.with_metaclass(abc.ABCMeta)):
"""A sum type describing the outcome of some call. """A sum type describing the outcome of some call.
Attributes: Attributes:
@ -47,7 +49,6 @@ class Outcome(object):
exception: The exception raised by the call. Must be present if kind is exception: The exception raised by the call. Must be present if kind is
Kind.RAISED. Kind.RAISED.
""" """
__metaclass__ = abc.ABCMeta
@enum.unique @enum.unique
class Kind(enum.Enum): class Kind(enum.Enum):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -49,6 +49,8 @@ built-in-but-only-in-3.3-and-later TimeoutError.
import abc import abc
import six
class TimeoutError(Exception): class TimeoutError(Exception):
"""Indicates that a particular call timed out.""" """Indicates that a particular call timed out."""
@ -58,13 +60,12 @@ class CancelledError(Exception):
"""Indicates that the computation underlying a Future was cancelled.""" """Indicates that the computation underlying a Future was cancelled."""
class Future(object): class Future(six.with_metaclass(abc.ABCMeta)):
"""A representation of a computation in another control flow. """A representation of a computation in another control flow.
Computations represented by a Future may be yet to be begun, may be ongoing, Computations represented by a Future may be yet to be begun, may be ongoing,
or may have already completed. or may have already completed.
""" """
__metaclass__ = abc.ABCMeta
# NOTE(nathaniel): This isn't the return type that I would want to have if it # NOTE(nathaniel): This isn't the return type that I would want to have if it
# were up to me. Were this interface being written from scratch, the return # were up to me. Were this interface being written from scratch, the return

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -46,7 +46,6 @@ class Relay(object):
would be no reason to use an implementation of this interface instead of a would be no reason to use an implementation of this interface instead of a
thread pool. thread pool.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def add_value(self, value): def add_value(self, value):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,10 +31,10 @@
import abc import abc
import six
class Consumer(object): class Consumer(six.with_metaclass(abc.ABCMeta)):
"""Interface for consumers of finite streams of values or objects.""" """Interface for consumers of finite streams of values or objects."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def consume(self, value): def consume(self, value):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -83,6 +83,9 @@ class IterableConsumer(stream.Consumer):
def __iter__(self): def __iter__(self):
return self return self
def __next__(self):
return self.next()
def next(self): def next(self):
with self._condition: with self._condition:
while self._active and not self._values: while self._active and not self._values:

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -42,6 +42,8 @@ import abc
import enum import enum
import threading # pylint: disable=unused-import import threading # pylint: disable=unused-import
import six
# abandonment is referenced from specification in this module. # abandonment is referenced from specification in this module.
from grpc.framework.foundation import abandonment # pylint: disable=unused-import from grpc.framework.foundation import abandonment # pylint: disable=unused-import
@ -95,7 +97,7 @@ class Outcome(object):
REMOTE_FAILURE = 'remote failure' REMOTE_FAILURE = 'remote failure'
class Completion(object): class Completion(six.with_metaclass(abc.ABCMeta)):
"""An aggregate of the values exchanged upon operation completion. """An aggregate of the values exchanged upon operation completion.
Attributes: Attributes:
@ -103,12 +105,10 @@ class Completion(object):
code: A code value for the operation. code: A code value for the operation.
message: A message value for the operation. message: A message value for the operation.
""" """
__metaclass__ = abc.ABCMeta
class OperationContext(object): class OperationContext(six.with_metaclass(abc.ABCMeta)):
"""Provides operation-related information and action.""" """Provides operation-related information and action."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def outcome(self): def outcome(self):
@ -162,9 +162,8 @@ class OperationContext(object):
raise NotImplementedError() raise NotImplementedError()
class Operator(object): class Operator(six.with_metaclass(abc.ABCMeta)):
"""An interface through which to participate in an operation.""" """An interface through which to participate in an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def advance( def advance(
@ -184,9 +183,8 @@ class Operator(object):
""" """
raise NotImplementedError() raise NotImplementedError()
class ProtocolReceiver(object): class ProtocolReceiver(six.with_metaclass(abc.ABCMeta)):
"""A means of receiving protocol values during an operation.""" """A means of receiving protocol values during an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def context(self, protocol_context): def context(self, protocol_context):
@ -198,7 +196,7 @@ class ProtocolReceiver(object):
raise NotImplementedError() raise NotImplementedError()
class Subscription(object): class Subscription(six.with_metaclass(abc.ABCMeta)):
"""Describes customer code's interest in values from the other side. """Describes customer code's interest in values from the other side.
Attributes: Attributes:
@ -216,7 +214,6 @@ class Subscription(object):
become available during the operation. Must be non-None if kind is become available during the operation. Must be non-None if kind is
Kind.FULL. Kind.FULL.
""" """
__metaclass__ = abc.ABCMeta
@enum.unique @enum.unique
class Kind(enum.Enum): class Kind(enum.Enum):
@ -226,9 +223,8 @@ class Subscription(object):
FULL = 'full' FULL = 'full'
class Servicer(object): class Servicer(six.with_metaclass(abc.ABCMeta)):
"""Interface for service implementations.""" """Interface for service implementations."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, group, method, context, output_operator): def service(self, group, method, context, output_operator):
@ -255,9 +251,8 @@ class Servicer(object):
raise NotImplementedError() raise NotImplementedError()
class End(object): class End(six.with_metaclass(abc.ABCMeta)):
"""Common type for entry-point objects on both sides of an operation.""" """Common type for entry-point objects on both sides of an operation."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def start(self): def start(self):

@ -33,6 +33,8 @@ import abc
import collections import collections
import enum import enum
import six
# cardinality, style, abandonment, future, and stream are # cardinality, style, abandonment, future, and stream are
# referenced from specification in this module. # referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import from grpc.framework.common import cardinality # pylint: disable=unused-import
@ -96,7 +98,7 @@ class Abortion(
REMOTE_FAILURE = 'remote failure' REMOTE_FAILURE = 'remote failure'
class AbortionError(Exception): class AbortionError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for exceptions indicating RPC abortion. """Common super type for exceptions indicating RPC abortion.
initial_metadata: The initial metadata from the other side of the RPC or initial_metadata: The initial metadata from the other side of the RPC or
@ -108,7 +110,6 @@ class AbortionError(Exception):
details: The details value from the other side of the RPC or None if no details: The details value from the other side of the RPC or None if no
details value was received. details value was received.
""" """
__metaclass__ = abc.ABCMeta
def __init__(self, initial_metadata, terminal_metadata, code, details): def __init__(self, initial_metadata, terminal_metadata, code, details):
super(AbortionError, self).__init__() super(AbortionError, self).__init__()
@ -150,9 +151,8 @@ class RemoteError(AbortionError):
"""Indicates that an RPC has terminated due to a remote defect.""" """Indicates that an RPC has terminated due to a remote defect."""
class RpcContext(object): class RpcContext(six.with_metaclass(abc.ABCMeta)):
"""Provides RPC-related information and action.""" """Provides RPC-related information and action."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def is_active(self): def is_active(self):
@ -199,9 +199,8 @@ class RpcContext(object):
raise NotImplementedError() raise NotImplementedError()
class Call(RpcContext): class Call(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""Invocation-side utility object for an RPC.""" """Invocation-side utility object for an RPC."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def initial_metadata(self): def initial_metadata(self):
@ -256,9 +255,8 @@ class Call(RpcContext):
raise NotImplementedError() raise NotImplementedError()
class ServicerContext(RpcContext): class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""A context object passed to method implementations.""" """A context object passed to method implementations."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def invocation_metadata(self): def invocation_metadata(self):
@ -326,9 +324,8 @@ class ServicerContext(RpcContext):
raise NotImplementedError() raise NotImplementedError()
class ResponseReceiver(object): class ResponseReceiver(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side object used to accept the output of an RPC.""" """Invocation-side object used to accept the output of an RPC."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def initial_metadata(self, initial_metadata): def initial_metadata(self, initial_metadata):
@ -362,9 +359,8 @@ class ResponseReceiver(object):
raise NotImplementedError() raise NotImplementedError()
class UnaryUnaryMultiCallable(object): class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style.""" """Affords invoking a unary-unary RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__( def __call__(
@ -434,9 +430,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError() raise NotImplementedError()
class UnaryStreamMultiCallable(object): class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style.""" """Affords invoking a unary-stream RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__(self, request, timeout, metadata=None, protocol_options=None): def __call__(self, request, timeout, metadata=None, protocol_options=None):
@ -480,9 +475,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError() raise NotImplementedError()
class StreamUnaryMultiCallable(object): class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style.""" """Affords invoking a stream-unary RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__( def __call__(
@ -553,9 +547,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError() raise NotImplementedError()
class StreamStreamMultiCallable(object): class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style.""" """Affords invoking a stream-stream RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __call__( def __call__(
@ -600,7 +593,7 @@ class StreamStreamMultiCallable(object):
raise NotImplementedError() raise NotImplementedError()
class MethodImplementation(object): class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes a method implementation. """A sum type that describes a method implementation.
Attributes: Attributes:
@ -643,12 +636,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT. style.Service.EVENT.
""" """
__metaclass__ = abc.ABCMeta
class MultiMethodImplementation(object): class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many methods.""" """A general type able to service many methods."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, group, method, response_consumer, context): def service(self, group, method, response_consumer, context):
@ -678,9 +669,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError() raise NotImplementedError()
class GenericStub(object): class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via generic methods.""" """Affords RPC invocation via generic methods."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def blocking_unary_unary( def blocking_unary_unary(
@ -977,7 +967,7 @@ class GenericStub(object):
raise NotImplementedError() raise NotImplementedError()
class DynamicStub(object): class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via attributes corresponding to afforded methods. """Affords RPC invocation via attributes corresponding to afforded methods.
Instances of this type may be scoped to a single group so that attribute Instances of this type may be scoped to a single group so that attribute
@ -993,4 +983,3 @@ class DynamicStub(object):
if the requested attribute is the name of a stream-stream method, the value of if the requested attribute is the name of a stream-stream method, the value of
the attribute will be a StreamStreamMultiCallable with which to invoke an RPC. the attribute will be a StreamStreamMultiCallable with which to invoke an RPC.
""" """
__metaclass__ = abc.ABCMeta

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@ import abc
import collections import collections
import enum import enum
import six
class Protocol(collections.namedtuple('Protocol', ('kind', 'value',))): class Protocol(collections.namedtuple('Protocol', ('kind', 'value',))):
"""A sum type for handles to a system that transmits tickets. """A sum type for handles to a system that transmits tickets.
@ -123,9 +125,8 @@ class Ticket(
REMOTE_FAILURE = 'remote failure' REMOTE_FAILURE = 'remote failure'
class Link(object): class Link(six.with_metaclass(abc.ABCMeta)):
"""Accepts and emits tickets.""" """Accepts and emits tickets."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def accept_ticket(self, ticket): def accept_ticket(self, ticket):

@ -81,7 +81,6 @@ CORE_SOURCE_FILES = [
'src/core/channel/channel_stack.c', 'src/core/channel/channel_stack.c',
'src/core/channel/channel_stack_builder.c', 'src/core/channel/channel_stack_builder.c',
'src/core/channel/client_channel.c', 'src/core/channel/client_channel.c',
'src/core/channel/client_uchannel.c',
'src/core/channel/compress_filter.c', 'src/core/channel/compress_filter.c',
'src/core/channel/connected_channel.c', 'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c', 'src/core/channel/http_client_filter.c',

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -173,6 +173,9 @@ class _Pipe(object):
def __iter__(self): def __iter__(self):
return self return self
def __next__(self):
return self.next()
def next(self): def next(self):
with self._condition: with self._condition:
while not self._values and self._open: while not self._values and self._open:

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,12 +32,13 @@
import abc import abc
import threading import threading
import six
from tests.unit._junkdrawer import math_pb2 from tests.unit._junkdrawer import math_pb2
class ProtoScenario(object): class ProtoScenario(six.with_metaclass(abc.ABCMeta)):
"""An RPC test scenario using protocol buffers.""" """An RPC test scenario using protocol buffers."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def method(self): def method(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -35,6 +35,8 @@ import random
import time import time
import unittest import unittest
import six
from grpc._adapter import _intermediary_low from grpc._adapter import _intermediary_low
from grpc._links import invocation from grpc._links import invocation
from grpc._links import service from grpc._links import service
@ -68,7 +70,7 @@ def _serialization_behaviors_from_serializations(serializations):
request_deserializers = {} request_deserializers = {}
response_serializers = {} response_serializers = {}
response_deserializers = {} response_deserializers = {}
for (group, method), serialization in serializations.iteritems(): for (group, method), serialization in six.iteritems(serializations):
request_serializers[group, method] = serialization.serialize_request request_serializers[group, method] = serialization.serialize_request
request_deserializers[group, method] = serialization.deserialize_request request_deserializers[group, method] = serialization.deserialize_request
response_serializers[group, method] = serialization.serialize_response response_serializers[group, method] = serialization.serialize_response

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import collections import collections
import unittest import unittest
import six
from grpc._adapter import _intermediary_low from grpc._adapter import _intermediary_low
from grpc._links import invocation from grpc._links import invocation
from grpc._links import service from grpc._links import service
@ -59,7 +61,7 @@ def _serialization_behaviors_from_test_methods(test_methods):
request_deserializers = {} request_deserializers = {}
response_serializers = {} response_serializers = {}
response_deserializers = {} response_deserializers = {}
for (group, method), test_method in test_methods.iteritems(): for (group, method), test_method in six.iteritems(test_methods):
request_serializers[group, method] = test_method.serialize_request request_serializers[group, method] = test_method.serialize_request
request_deserializers[group, method] = test_method.deserialize_request request_deserializers[group, method] = test_method.deserialize_request
response_serializers[group, method] = test_method.serialize_response response_serializers[group, method] = test_method.serialize_response
@ -108,7 +110,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest. # _digest.TestServiceDigest.
cardinalities = { cardinalities = {
method: method_object.cardinality() method: method_object.cardinality()
for (group, method), method_object in methods.iteritems()} for (group, method), method_object in six.iteritems(methods)}
dynamic_stub = crust_implementations.dynamic_stub( dynamic_stub = crust_implementations.dynamic_stub(
invocation_end_link, group, cardinalities, pool) invocation_end_link, group, cardinalities, pool)

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,13 +32,14 @@
import abc import abc
import threading import threading
import six
from tests.unit._junkdrawer import math_pb2 from tests.unit._junkdrawer import math_pb2
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
class ProtoScenario(object): class ProtoScenario(six.with_metaclass(abc.ABCMeta)):
"""An RPC test scenario using protocol buffers.""" """An RPC test scenario using protocol buffers."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def group_and_method(self): def group_and_method(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -125,6 +125,9 @@ class _BlockingIterator(object):
def __iter__(self): def __iter__(self):
return self return self
def __next__(self):
return self.next()
def next(self): def next(self):
with self._condition: with self._condition:
while True: while True:

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import collections import collections
import unittest import unittest
import six
from grpc.beta import implementations from grpc.beta import implementations
from grpc.beta import interfaces from grpc.beta import interfaces
from tests.unit import resources from tests.unit import resources
@ -57,7 +59,7 @@ def _serialization_behaviors_from_test_methods(test_methods):
request_deserializers = {} request_deserializers = {}
response_serializers = {} response_serializers = {}
response_deserializers = {} response_deserializers = {}
for (group, method), test_method in test_methods.iteritems(): for (group, method), test_method in six.iteritems(test_methods):
request_serializers[group, method] = test_method.serialize_request request_serializers[group, method] = test_method.serialize_request
request_deserializers[group, method] = test_method.deserialize_request request_deserializers[group, method] = test_method.deserialize_request
response_serializers[group, method] = test_method.serialize_response response_serializers[group, method] = test_method.serialize_response
@ -79,7 +81,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest. # _digest.TestServiceDigest.
cardinalities = { cardinalities = {
method: method_object.cardinality() method: method_object.cardinality()
for (group, method), method_object in methods.iteritems()} for (group, method), method_object in six.iteritems(methods)}
server_options = implementations.server_options( server_options = implementations.server_options(
request_deserializers=serialization_behaviors.request_deserializers, request_deserializers=serialization_behaviors.request_deserializers,

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import collections import collections
import unittest import unittest
import six
from grpc.framework.core import implementations as core_implementations from grpc.framework.core import implementations as core_implementations
from grpc.framework.crust import implementations as crust_implementations from grpc.framework.crust import implementations as crust_implementations
from grpc.framework.foundation import logging_pool from grpc.framework.foundation import logging_pool
@ -66,7 +68,7 @@ class _Implementation(test_interfaces.Implementation):
# _digest.TestServiceDigest. # _digest.TestServiceDigest.
cardinalities = { cardinalities = {
method: method_object.cardinality() method: method_object.cardinality()
for (group, method), method_object in methods.iteritems()} for (group, method), method_object in six.iteritems(methods)}
dynamic_stub = crust_implementations.dynamic_stub( dynamic_stub = crust_implementations.dynamic_stub(
invocation_end_link, group, cardinalities, pool) invocation_end_link, group, cardinalities, pool)

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@ import abc
import contextlib import contextlib
import threading import threading
import six
class Defect(Exception): class Defect(Exception):
"""Simulates a programming defect raised into in a system under test. """Simulates a programming defect raised into in a system under test.
@ -42,7 +44,7 @@ class Defect(Exception):
""" """
class Control(object): class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test. """An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method Systems under test passed a Control should call its control() method
@ -51,8 +53,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning. the system under test to simulate hanging, failing, or functioning.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def control(self): def control(self):
"""Potentially does anything.""" """Potentially does anything."""

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,13 +31,14 @@
import abc import abc
import six
# This code is designed for use with the unittest module. # This code is designed for use with the unittest module.
# pylint: disable=invalid-name # pylint: disable=invalid-name
class Coverage(object): class Coverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage.""" """Specification of test coverage."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self): def testSuccessfulUnaryRequestUnaryResponse(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
import abc import abc
import six
# interfaces is referenced from specification in this module. # interfaces is referenced from specification in this module.
from grpc.framework.base import util as _base_util from grpc.framework.base import util as _base_util
from grpc.framework.base import implementations from grpc.framework.base import implementations
@ -43,7 +45,7 @@ _POOL_SIZE_LIMIT = 5
_MAXIMUM_TIMEOUT = 90 _MAXIMUM_TIMEOUT = 90
class LinkedPair(object): class LinkedPair(six.with_metaclass(abc.ABCMeta)):
"""A Front and Back that are linked to one another. """A Front and Back that are linked to one another.
Attributes: Attributes:
@ -51,8 +53,6 @@ class LinkedPair(object):
back: An interfaces.Back. back: An interfaces.Back.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def shut_down(self): def shut_down(self):
"""Shuts down this object and releases its resources.""" """Shuts down this object and releases its resources."""

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@
import abc import abc
import unittest # pylint: disable=unused-import import unittest # pylint: disable=unused-import
import six
from grpc.framework.face import exceptions from grpc.framework.face import exceptions
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import control from tests.unit.framework.face.testing import control
@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class BlockingInvocationInlineServiceTestCase( class BlockingInvocationInlineServiceTestCase(
test_case.FaceTestCase, coverage.BlockingCoverage): six.with_metaclass(abc.ABCMeta,
test_case.FaceTestCase, coverage.BlockingCoverage)):
"""A test of the Face layer of RPC Framework. """A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase. Concrete subclasses must also extend unittest.TestCase.
""" """
__metaclass__ = abc.ABCMeta
def setUp(self): def setUp(self):
"""See unittest.TestCase.setUp for full specification. """See unittest.TestCase.setUp for full specification.
@ -72,7 +74,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self): def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -83,7 +85,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self): def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -95,7 +97,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self): def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -106,7 +108,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self): def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -118,7 +120,7 @@ class BlockingInvocationInlineServiceTestCase(
def testSequentialInvocations(self): def testSequentialInvocations(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
first_request = test_messages.request() first_request = test_messages.request()
second_request = test_messages.request() second_request = test_messages.request()
@ -135,7 +137,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self): def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -146,7 +148,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self): def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -158,7 +160,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self): def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -169,7 +171,7 @@ class BlockingInvocationInlineServiceTestCase(
def testExpiredStreamRequestStreamResponse(self): def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -181,7 +183,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self): def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -191,7 +193,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedUnaryRequestStreamResponse(self): def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -202,7 +204,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedStreamRequestUnaryResponse(self): def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -212,7 +214,7 @@ class BlockingInvocationInlineServiceTestCase(
def testFailedStreamRequestStreamResponse(self): def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,8 +33,10 @@ import abc
import contextlib import contextlib
import threading import threading
import six
class Control(object):
class Control(six.with_metaclass(abc.ABCMeta)):
"""An object that accepts program control from a system under test. """An object that accepts program control from a system under test.
Systems under test passed a Control should call its control() method Systems under test passed a Control should call its control() method
@ -43,8 +45,6 @@ class Control(object):
the system under test to simulate hanging, failing, or functioning. the system under test to simulate hanging, failing, or functioning.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def control(self): def control(self):
"""Potentially does anything.""" """Potentially does anything."""

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,15 +31,15 @@
import abc import abc
import six
# These classes are only valid when inherited by unittest.TestCases. # These classes are only valid when inherited by unittest.TestCases.
# pylint: disable=invalid-name # pylint: disable=invalid-name
class BlockingCoverage(object): class BlockingCoverage(six.with_metaclass(abc.ABCMeta)):
"""Specification of test coverage for blocking behaviors.""" """Specification of test coverage for blocking behaviors."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def testSuccessfulUnaryRequestUnaryResponse(self): def testSuccessfulUnaryRequestUnaryResponse(self):
raise NotImplementedError() raise NotImplementedError()
@ -93,11 +93,9 @@ class BlockingCoverage(object):
raise NotImplementedError() raise NotImplementedError()
class FullCoverage(BlockingCoverage): class FullCoverage(six.with_metaclass(abc.ABCMeta, BlockingCoverage)):
"""Specification of test coverage for non-blocking behaviors.""" """Specification of test coverage for non-blocking behaviors."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def testParallelInvocations(self): def testParallelInvocations(self):
raise NotImplementedError() raise NotImplementedError()

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import collections import collections
import threading import threading
import six
# testing_control, interfaces, and testing_service are referenced from # testing_control, interfaces, and testing_service are referenced from
# specification in this module. # specification in this module.
from grpc.framework.common import cardinality from grpc.framework.common import cardinality
@ -368,7 +370,7 @@ def _assemble(
events = {} events = {}
adaptations = {} adaptations = {}
messages = {} messages = {}
for name, scenario in scenarios.iteritems(): for name, scenario in six.iteritems(scenarios):
if name in names: if name in names:
raise ValueError('Repeated name "%s"!' % name) raise ValueError('Repeated name "%s"!' % name)

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import abc import abc
import unittest import unittest
import six
from grpc.framework.face import interfaces from grpc.framework.face import interfaces
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
from tests.unit.framework.face.testing import callback as testing_callback from tests.unit.framework.face.testing import callback as testing_callback
@ -43,12 +45,12 @@ from tests.unit.framework.face.testing import test_case
class EventInvocationSynchronousEventServiceTestCase( class EventInvocationSynchronousEventServiceTestCase(
test_case.FaceTestCase, coverage.FullCoverage): six.with_metaclass(abc.ABCMeta,
test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework. """A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase. Concrete subclasses must also extend unittest.TestCase.
""" """
__metaclass__ = abc.ABCMeta
def setUp(self): def setUp(self):
"""See unittest.TestCase.setUp for full specification. """See unittest.TestCase.setUp for full specification.
@ -72,7 +74,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self): def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -87,7 +89,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self): def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -102,7 +104,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self): def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -120,7 +122,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self): def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -138,7 +140,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testSequentialInvocations(self): def testSequentialInvocations(self):
# pylint: disable=cell-var-from-loop # pylint: disable=cell-var-from-loop
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
first_request = test_messages.request() first_request = test_messages.request()
second_request = test_messages.request() second_request = test_messages.request()
@ -163,7 +165,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self): def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -178,7 +180,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self): def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -193,7 +195,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self): def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for unused_test_messages in test_messages_sequence: for unused_test_messages in test_messages_sequence:
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -206,7 +208,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testExpiredStreamRequestStreamResponse(self): def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -221,7 +223,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self): def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -237,7 +239,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedUnaryRequestStreamResponse(self): def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -253,7 +255,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedStreamRequestUnaryResponse(self): def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -272,7 +274,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testFailedStreamRequestStreamResponse(self): def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -289,7 +291,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testParallelInvocations(self): def testParallelInvocations(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
first_request = test_messages.request() first_request = test_messages.request()
first_callback = testing_callback.Callback() first_callback = testing_callback.Callback()
@ -316,7 +318,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledUnaryRequestUnaryResponse(self): def testCancelledUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -332,7 +334,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledUnaryRequestStreamResponse(self): def testCancelledUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -347,7 +349,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledStreamRequestUnaryResponse(self): def testCancelledStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = testing_callback.Callback() callback = testing_callback.Callback()
@ -364,7 +366,7 @@ class EventInvocationSynchronousEventServiceTestCase(
def testCancelledStreamRequestStreamResponse(self): def testCancelledStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for unused_test_messages in test_messages_sequence: for unused_test_messages in test_messages_sequence:
callback = testing_callback.Callback() callback = testing_callback.Callback()

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -34,6 +34,8 @@ import contextlib
import threading import threading
import unittest import unittest
import six
from grpc.framework.face import exceptions from grpc.framework.face import exceptions
from grpc.framework.foundation import future from grpc.framework.foundation import future
from grpc.framework.foundation import logging_pool from grpc.framework.foundation import logging_pool
@ -66,6 +68,9 @@ class _PauseableIterator(object):
def __iter__(self): def __iter__(self):
return self return self
def __next__(self):
return self.next()
def next(self): def next(self):
with self._condition: with self._condition:
while self._paused: while self._paused:
@ -74,12 +79,12 @@ class _PauseableIterator(object):
class FutureInvocationAsynchronousEventServiceTestCase( class FutureInvocationAsynchronousEventServiceTestCase(
test_case.FaceTestCase, coverage.FullCoverage): six.with_metaclass(abc.ABCMeta,
test_case.FaceTestCase, coverage.FullCoverage)):
"""A test of the Face layer of RPC Framework. """A test of the Face layer of RPC Framework.
Concrete subclasses must also extend unittest.TestCase. Concrete subclasses must also extend unittest.TestCase.
""" """
__metaclass__ = abc.ABCMeta
def setUp(self): def setUp(self):
"""See unittest.TestCase.setUp for full specification. """See unittest.TestCase.setUp for full specification.
@ -105,7 +110,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestUnaryResponse(self): def testSuccessfulUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -117,7 +122,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulUnaryRequestStreamResponse(self): def testSuccessfulUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -129,7 +134,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulStreamRequestUnaryResponse(self): def testSuccessfulStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests)) request_iterator = _PauseableIterator(iter(requests))
@ -145,7 +150,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSuccessfulStreamRequestStreamResponse(self): def testSuccessfulStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests)) request_iterator = _PauseableIterator(iter(requests))
@ -161,7 +166,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testSequentialInvocations(self): def testSequentialInvocations(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
first_request = test_messages.request() first_request = test_messages.request()
second_request = test_messages.request() second_request = test_messages.request()
@ -180,7 +185,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredUnaryRequestUnaryResponse(self): def testExpiredUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -195,7 +200,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredUnaryRequestStreamResponse(self): def testExpiredUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -207,7 +212,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredStreamRequestUnaryResponse(self): def testExpiredStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -222,7 +227,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testExpiredStreamRequestStreamResponse(self): def testExpiredStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -234,7 +239,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedUnaryRequestUnaryResponse(self): def testFailedUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -253,7 +258,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedUnaryRequestStreamResponse(self): def testFailedUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -268,7 +273,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedStreamRequestUnaryResponse(self): def testFailedStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -287,7 +292,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testFailedStreamRequestStreamResponse(self): def testFailedStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -302,7 +307,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testParallelInvocations(self): def testParallelInvocations(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
first_request = test_messages.request() first_request = test_messages.request()
second_request = test_messages.request() second_request = test_messages.request()
@ -324,7 +329,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledUnaryRequestUnaryResponse(self): def testCancelledUnaryRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self.digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -338,7 +343,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledUnaryRequestStreamResponse(self): def testCancelledUnaryRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self.digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -352,7 +357,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledStreamRequestUnaryResponse(self): def testCancelledStreamRequestUnaryResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self.digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -366,7 +371,7 @@ class FutureInvocationAsynchronousEventServiceTestCase(
def testCancelledStreamRequestStreamResponse(self): def testCancelledStreamRequestStreamResponse(self):
for name, test_messages_sequence in ( for name, test_messages_sequence in (
self.digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self.digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,13 +31,14 @@
import abc import abc
import six
# cardinality is referenced from specification in this module. # cardinality is referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import from grpc.framework.common import cardinality # pylint: disable=unused-import
class Method(object): class Method(six.with_metaclass(abc.ABCMeta)):
"""An RPC method to be used in tests of RPC implementations.""" """An RPC method to be used in tests of RPC implementations."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def name(self): def name(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,16 +31,16 @@
import abc import abc
import six
# interfaces is referenced from specification in this module. # interfaces is referenced from specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces from tests.unit.framework.face.testing import interfaces
class UnaryUnaryTestMethodImplementation(interfaces.Method): class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-unary RPC method.""" """A controllable implementation of a unary-unary RPC method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, request, response_callback, context, control): def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message. """Services an RPC that accepts one message and produces one message.
@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(interfaces.Method):
raise NotImplementedError() raise NotImplementedError()
class UnaryUnaryTestMessages(object): class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings.""" """A type for unary-request-unary-response message pairings."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def request(self): def request(self):
"""Affords a request message. """Affords a request message.
@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError() raise NotImplementedError()
class UnaryStreamTestMethodImplementation(interfaces.Method): class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a unary-stream RPC method.""" """A controllable implementation of a unary-stream RPC method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, request, response_consumer, context, control): def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages. """Services an RPC that takes one message and produces a stream of messages.
@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(interfaces.Method):
raise NotImplementedError() raise NotImplementedError()
class UnaryStreamTestMessages(object): class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings.""" """A type for unary-request-stream-response message pairings."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def request(self): def request(self):
"""Affords a request message. """Affords a request message.
@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError() raise NotImplementedError()
class StreamUnaryTestMethodImplementation(interfaces.Method): class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-unary RPC method.""" """A controllable implementation of a stream-unary RPC method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, response_callback, context, control): def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message. """Services an RPC that takes a stream of messages and produces one message.
@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(interfaces.Method):
raise NotImplementedError() raise NotImplementedError()
class StreamUnaryTestMessages(object): class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings.""" """A type for stream-request-unary-response message pairings."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def requests(self): def requests(self):
"""Affords a sequence of request messages. """Affords a sequence of request messages.
@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError() raise NotImplementedError()
class StreamStreamTestMethodImplementation(interfaces.Method): class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, interfaces.Method)):
"""A controllable implementation of a stream-stream RPC method.""" """A controllable implementation of a stream-stream RPC method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, response_consumer, context, control): def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages. """Services an RPC that accepts and produces streams of messages.
@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(interfaces.Method):
raise NotImplementedError() raise NotImplementedError()
class StreamStreamTestMessages(object): class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings.""" """A type for stream-request-stream-response message pairings."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def requests(self): def requests(self):
"""Affords a sequence of request messages. """Affords a sequence of request messages.
@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError() raise NotImplementedError()
class TestService(object): class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented RPC methods to use in tests.""" """A specification of implemented RPC methods to use in tests."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def name(self): def name(self):
"""Identifies the RPC service name used during the test. """Identifies the RPC service name used during the test.

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,18 +31,19 @@
import abc import abc
import six
# face_interfaces and interfaces are referenced in specification in this module. # face_interfaces and interfaces are referenced in specification in this module.
from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import from grpc.framework.face import interfaces as face_interfaces # pylint: disable=unused-import
from tests.unit.framework.face.testing import interfaces # pylint: disable=unused-import from tests.unit.framework.face.testing import interfaces # pylint: disable=unused-import
class FaceTestCase(object): class FaceTestCase(six.with_metaclass(abc.ABCMeta)):
"""Describes a test of the Face Layer of RPC Framework. """Describes a test of the Face Layer of RPC Framework.
Concrete subclasses must also inherit from unittest.TestCase and from at least Concrete subclasses must also inherit from unittest.TestCase and from at least
one class that defines test methods. one class that defines test methods.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def set_up_implementation( def set_up_implementation(

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -36,6 +36,8 @@ import random # pylint: disable=unused-import
import threading import threading
import time import time
import six
from grpc.framework.interfaces.base import base from grpc.framework.interfaces.base import base
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.base import _sequence from tests.unit.framework.interfaces.base import _sequence
@ -247,8 +249,7 @@ class Instruction(
CONCLUDE = 'CONCLUDE' CONCLUDE = 'CONCLUDE'
class Controller(object): class Controller(six.with_metaclass(abc.ABCMeta)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def failed(self, message): def failed(self, message):
@ -308,8 +309,7 @@ class Controller(object):
raise NotImplementedError() raise NotImplementedError()
class ControllerCreator(object): class ControllerCreator(six.with_metaclass(abc.ABCMeta)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def name(self): def name(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,12 +31,13 @@
import abc import abc
import six
from grpc.framework.interfaces.base import base # pylint: disable=unused-import from grpc.framework.interfaces.base import base # pylint: disable=unused-import
class Serialization(object): class Serialization(six.with_metaclass(abc.ABCMeta)):
"""Specifies serialization and deserialization of test payloads.""" """Specifies serialization and deserialization of test payloads."""
__metaclass__ = abc.ABCMeta
def serialize_request(self, request): def serialize_request(self, request):
"""Serializes a request value used in a test. """Serializes a request value used in a test.
@ -85,9 +86,8 @@ class Serialization(object):
raise NotImplementedError() raise NotImplementedError()
class Implementation(object): class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Base layer.""" """Specifies an implementation of the Base layer."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def instantiate(self, serializations, servicer): def instantiate(self, serializations, servicer):

@ -34,6 +34,8 @@ import itertools
import unittest import unittest
from concurrent import futures from concurrent import futures
import six
# test_interfaces is referenced from specification in this module. # test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face from grpc.framework.interfaces.face import face
@ -46,14 +48,13 @@ from tests.unit.framework.interfaces.face import _stock_service
from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import from tests.unit.framework.interfaces.face import test_interfaces # pylint: disable=unused-import
class TestCase(test_coverage.Coverage, unittest.TestCase): class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework. """A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor. _invocation.InvokerConstructor.
""" """
__metaclass__ = abc.ABCMeta
NAME = 'BlockingInvocationInlineServiceTest' NAME = 'BlockingInvocationInlineServiceTest'
@ -81,7 +82,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestUnaryResponse(self): def testSuccessfulUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -92,7 +93,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestStreamResponse(self): def testSuccessfulUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -104,7 +105,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestUnaryResponse(self): def testSuccessfulStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -115,7 +116,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestStreamResponse(self): def testSuccessfulStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -127,7 +128,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSequentialInvocations(self): def testSequentialInvocations(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
first_request = test_messages.request() first_request = test_messages.request()
second_request = test_messages.request() second_request = test_messages.request()
@ -145,7 +146,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testParallelInvocations(self): def testParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM) pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = [] requests = []
response_futures = [] response_futures = []
@ -167,7 +168,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testWaitingForSomeButNotAllParallelInvocations(self): def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM) pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = [] requests = []
response_futures_to_indices = {} response_futures_to_indices = {}
@ -205,7 +206,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestUnaryResponse(self): def testExpiredUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -216,7 +217,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestStreamResponse(self): def testExpiredUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -228,7 +229,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestUnaryResponse(self): def testExpiredStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -239,7 +240,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestStreamResponse(self): def testExpiredStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -251,7 +252,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestUnaryResponse(self): def testFailedUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -261,7 +262,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestStreamResponse(self): def testFailedUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -272,7 +273,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestUnaryResponse(self): def testFailedStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -282,7 +283,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestStreamResponse(self): def testFailedStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import collections import collections
import threading import threading
import six
# test_control, _service, and test_interfaces are referenced from specification # test_control, _service, and test_interfaces are referenced from specification
# in this module. # in this module.
from grpc.framework.common import cardinality from grpc.framework.common import cardinality
@ -363,7 +365,7 @@ def _assemble(
events = {} events = {}
adaptations = {} adaptations = {}
messages = {} messages = {}
for identifier, scenario in scenarios.iteritems(): for identifier, scenario in six.iteritems(scenarios):
if identifier in identifiers: if identifier in identifiers:
raise ValueError('Repeated identifier "(%s, %s)"!' % identifier) raise ValueError('Repeated identifier "(%s, %s)"!' % identifier)

@ -36,6 +36,8 @@ import threading
import unittest import unittest
from concurrent import futures from concurrent import futures
import six
# test_interfaces is referenced from specification in this module. # test_interfaces is referenced from specification in this module.
from grpc.framework.foundation import logging_pool from grpc.framework.foundation import logging_pool
from grpc.framework.interfaces.face import face from grpc.framework.interfaces.face import face
@ -67,6 +69,9 @@ class _PauseableIterator(object):
def __iter__(self): def __iter__(self):
return self return self
def __next__(self):
return self.next()
def next(self): def next(self):
with self._condition: with self._condition:
while self._paused: while self._paused:
@ -104,14 +109,13 @@ class _Callback(object):
self._condition.wait() self._condition.wait()
class TestCase(test_coverage.Coverage, unittest.TestCase): class TestCase(six.with_metaclass(abc.ABCMeta, test_coverage.Coverage, unittest.TestCase)):
"""A test of the Face layer of RPC Framework. """A test of the Face layer of RPC Framework.
Concrete subclasses must have an "implementation" attribute of type Concrete subclasses must have an "implementation" attribute of type
test_interfaces.Implementation and an "invoker_constructor" attribute of type test_interfaces.Implementation and an "invoker_constructor" attribute of type
_invocation.InvokerConstructor. _invocation.InvokerConstructor.
""" """
__metaclass__ = abc.ABCMeta
NAME = 'FutureInvocationAsynchronousEventServiceTest' NAME = 'FutureInvocationAsynchronousEventServiceTest'
@ -141,7 +145,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestUnaryResponse(self): def testSuccessfulUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = _Callback() callback = _Callback()
@ -156,7 +160,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulUnaryRequestStreamResponse(self): def testSuccessfulUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -168,7 +172,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestUnaryResponse(self): def testSuccessfulStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests)) request_iterator = _PauseableIterator(iter(requests))
@ -188,7 +192,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSuccessfulStreamRequestStreamResponse(self): def testSuccessfulStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
request_iterator = _PauseableIterator(iter(requests)) request_iterator = _PauseableIterator(iter(requests))
@ -204,7 +208,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testSequentialInvocations(self): def testSequentialInvocations(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
first_request = test_messages.request() first_request = test_messages.request()
second_request = test_messages.request() second_request = test_messages.request()
@ -223,7 +227,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testParallelInvocations(self): def testParallelInvocations(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
first_request = test_messages.request() first_request = test_messages.request()
second_request = test_messages.request() second_request = test_messages.request()
@ -239,7 +243,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
test_messages.verify(second_request, second_response, self) test_messages.verify(second_request, second_response, self)
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = [] requests = []
response_futures = [] response_futures = []
@ -259,7 +263,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testWaitingForSomeButNotAllParallelInvocations(self): def testWaitingForSomeButNotAllParallelInvocations(self):
pool = logging_pool.pool(test_constants.PARALLELISM) pool = logging_pool.pool(test_constants.PARALLELISM)
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = [] requests = []
response_futures_to_indices = {} response_futures_to_indices = {}
@ -281,7 +285,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledUnaryRequestUnaryResponse(self): def testCancelledUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = _Callback() callback = _Callback()
@ -298,7 +302,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledUnaryRequestStreamResponse(self): def testCancelledUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -312,7 +316,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledStreamRequestUnaryResponse(self): def testCancelledStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = _Callback() callback = _Callback()
@ -329,7 +333,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testCancelledStreamRequestStreamResponse(self): def testCancelledStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -343,7 +347,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestUnaryResponse(self): def testExpiredUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = _Callback() callback = _Callback()
@ -360,7 +364,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredUnaryRequestStreamResponse(self): def testExpiredUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -372,7 +376,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestUnaryResponse(self): def testExpiredStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = _Callback() callback = _Callback()
@ -389,7 +393,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testExpiredStreamRequestStreamResponse(self): def testExpiredStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
@ -401,7 +405,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestUnaryResponse(self): def testFailedUnaryRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_unary_messages_sequences.iteritems()): six.iteritems(self._digest.unary_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
callback = _Callback() callback = _Callback()
@ -423,7 +427,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedUnaryRequestStreamResponse(self): def testFailedUnaryRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.unary_stream_messages_sequences.iteritems()): six.iteritems(self._digest.unary_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
request = test_messages.request() request = test_messages.request()
@ -438,7 +442,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestUnaryResponse(self): def testFailedStreamRequestUnaryResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_unary_messages_sequences.iteritems()): six.iteritems(self._digest.stream_unary_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()
callback = _Callback() callback = _Callback()
@ -460,7 +464,7 @@ class TestCase(test_coverage.Coverage, unittest.TestCase):
def testFailedStreamRequestStreamResponse(self): def testFailedStreamRequestStreamResponse(self):
for (group, method), test_messages_sequence in ( for (group, method), test_messages_sequence in (
self._digest.stream_stream_messages_sequences.iteritems()): six.iteritems(self._digest.stream_stream_messages_sequences)):
for test_messages in test_messages_sequence: for test_messages in test_messages_sequence:
requests = test_messages.requests() requests = test_messages.requests()

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
import abc import abc
import six
from grpc.framework.common import cardinality from grpc.framework.common import cardinality
_CARDINALITY_TO_GENERIC_BLOCKING_BEHAVIOR = { _CARDINALITY_TO_GENERIC_BLOCKING_BEHAVIOR = {
@ -62,9 +64,8 @@ _CARDINALITY_TO_MULTI_CALLABLE_ATTRIBUTE = {
} }
class Invoker(object): class Invoker(six.with_metaclass(abc.ABCMeta)):
"""A type used to invoke test RPCs.""" """A type used to invoke test RPCs."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def blocking(self, group, name): def blocking(self, group, name):
@ -82,9 +83,8 @@ class Invoker(object):
raise NotImplementedError() raise NotImplementedError()
class InvokerConstructor(object): class InvokerConstructor(six.with_metaclass(abc.ABCMeta)):
"""A type used to create Invokers.""" """A type used to create Invokers."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def name(self): def name(self):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,16 +31,16 @@
import abc import abc
import six
# face is referenced from specification in this module. # face is referenced from specification in this module.
from grpc.framework.interfaces.face import face # pylint: disable=unused-import from grpc.framework.interfaces.face import face # pylint: disable=unused-import
from tests.unit.framework.interfaces.face import test_interfaces from tests.unit.framework.interfaces.face import test_interfaces
class UnaryUnaryTestMethodImplementation(test_interfaces.Method): class UnaryUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-unary method.""" """A controllable implementation of a unary-unary method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, request, response_callback, context, control): def service(self, request, response_callback, context, control):
"""Services an RPC that accepts one message and produces one message. """Services an RPC that accepts one message and produces one message.
@ -59,11 +59,9 @@ class UnaryUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError() raise NotImplementedError()
class UnaryUnaryTestMessages(object): class UnaryUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-unary-response message pairings.""" """A type for unary-request-unary-response message pairings."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def request(self): def request(self):
"""Affords a request message. """Affords a request message.
@ -93,11 +91,9 @@ class UnaryUnaryTestMessages(object):
raise NotImplementedError() raise NotImplementedError()
class UnaryStreamTestMethodImplementation(test_interfaces.Method): class UnaryStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a unary-stream method.""" """A controllable implementation of a unary-stream method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, request, response_consumer, context, control): def service(self, request, response_consumer, context, control):
"""Services an RPC that takes one message and produces a stream of messages. """Services an RPC that takes one message and produces a stream of messages.
@ -116,11 +112,9 @@ class UnaryStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError() raise NotImplementedError()
class UnaryStreamTestMessages(object): class UnaryStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for unary-request-stream-response message pairings.""" """A type for unary-request-stream-response message pairings."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def request(self): def request(self):
"""Affords a request message. """Affords a request message.
@ -150,11 +144,9 @@ class UnaryStreamTestMessages(object):
raise NotImplementedError() raise NotImplementedError()
class StreamUnaryTestMethodImplementation(test_interfaces.Method): class StreamUnaryTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-unary method.""" """A controllable implementation of a stream-unary method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, response_callback, context, control): def service(self, response_callback, context, control):
"""Services an RPC that takes a stream of messages and produces one message. """Services an RPC that takes a stream of messages and produces one message.
@ -180,11 +172,9 @@ class StreamUnaryTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError() raise NotImplementedError()
class StreamUnaryTestMessages(object): class StreamUnaryTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-unary-response message pairings.""" """A type for stream-request-unary-response message pairings."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def requests(self): def requests(self):
"""Affords a sequence of request messages. """Affords a sequence of request messages.
@ -214,11 +204,9 @@ class StreamUnaryTestMessages(object):
raise NotImplementedError() raise NotImplementedError()
class StreamStreamTestMethodImplementation(test_interfaces.Method): class StreamStreamTestMethodImplementation(six.with_metaclass(abc.ABCMeta, test_interfaces.Method)):
"""A controllable implementation of a stream-stream method.""" """A controllable implementation of a stream-stream method."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def service(self, response_consumer, context, control): def service(self, response_consumer, context, control):
"""Services an RPC that accepts and produces streams of messages. """Services an RPC that accepts and produces streams of messages.
@ -244,11 +232,9 @@ class StreamStreamTestMethodImplementation(test_interfaces.Method):
raise NotImplementedError() raise NotImplementedError()
class StreamStreamTestMessages(object): class StreamStreamTestMessages(six.with_metaclass(abc.ABCMeta)):
"""A type for stream-request-stream-response message pairings.""" """A type for stream-request-stream-response message pairings."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def requests(self): def requests(self):
"""Affords a sequence of request messages. """Affords a sequence of request messages.
@ -278,11 +264,9 @@ class StreamStreamTestMessages(object):
raise NotImplementedError() raise NotImplementedError()
class TestService(object): class TestService(six.with_metaclass(abc.ABCMeta)):
"""A specification of implemented methods to use in tests.""" """A specification of implemented methods to use in tests."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def unary_unary_scenarios(self): def unary_unary_scenarios(self):
"""Affords unary-request-unary-response test methods and their messages. """Affords unary-request-unary-response test methods and their messages.

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -31,13 +31,14 @@
import abc import abc
import six
from grpc.framework.common import cardinality # pylint: disable=unused-import from grpc.framework.common import cardinality # pylint: disable=unused-import
from grpc.framework.interfaces.face import face # pylint: disable=unused-import from grpc.framework.interfaces.face import face # pylint: disable=unused-import
class Method(object): class Method(six.with_metaclass(abc.ABCMeta)):
"""Specifies a method to be used in tests.""" """Specifies a method to be used in tests."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def group(self): def group(self):
@ -126,9 +127,8 @@ class Method(object):
raise NotImplementedError() raise NotImplementedError()
class Implementation(object): class Implementation(six.with_metaclass(abc.ABCMeta)):
"""Specifies an implementation of the Face layer.""" """Specifies an implementation of the Face layer."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def instantiate( def instantiate(

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc. # Copyright 2015-2016, Google Inc.
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@
import abc import abc
import unittest # pylint: disable=unused-import import unittest # pylint: disable=unused-import
import six
from grpc.framework.interfaces.links import links from grpc.framework.interfaces.links import links
from tests.unit.framework.common import test_constants from tests.unit.framework.common import test_constants
from tests.unit.framework.interfaces.links import test_utilities from tests.unit.framework.interfaces.links import test_utilities
@ -58,13 +60,12 @@ _TRANSMISSION_GROUP = 'test.Group'
_TRANSMISSION_METHOD = 'TestMethod' _TRANSMISSION_METHOD = 'TestMethod'
class TransmissionTest(object): class TransmissionTest(six.with_metaclass(abc.ABCMeta)):
"""Tests ticket transmission between two connected links. """Tests ticket transmission between two connected links.
This class must be mixed into a unittest.TestCase that implements the abstract This class must be mixed into a unittest.TestCase that implements the abstract
methods it provides. methods it provides.
""" """
__metaclass__ = abc.ABCMeta
# This is a unittest.TestCase mix-in. # This is a unittest.TestCase mix-in.
# pylint: disable=invalid-name # pylint: disable=invalid-name

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

Loading…
Cancel
Save