Merge github.com:grpc/grpc into accounting

pull/5699/head
Craig Tiller 9 years ago
commit c1281850e2
  1. 8
      .clang_complete
  2. 2
      .gitmodules
  3. 15
      BUILD
  4. 14
      MANIFEST.md
  5. 142
      Makefile
  6. 3
      binding.gyp
  7. 18
      build.yaml
  8. 3
      config.m4
  9. 6
      examples/python/helloworld/greeter_client.py
  10. 36
      examples/python/route_guide/route_guide_client.py
  11. 7
      gRPC.podspec
  12. 5
      grpc.gemspec
  13. 4
      include/grpc++/support/byte_buffer.h
  14. 4
      include/grpc/impl/codegen/port_platform.h
  15. 5
      package.json
  16. 5
      package.xml
  17. 4
      setup.py
  18. 108
      src/compiler/cpp_generator.cc
  19. 6
      src/compiler/cpp_generator.h
  20. 14
      src/compiler/cpp_plugin.cc
  21. 2
      src/core/census/grpc_plugin.c
  22. 1
      src/core/channel/channel_stack_builder.c
  23. 233
      src/core/channel/client_uchannel.c
  24. 5
      src/core/channel/subchannel_call_holder.h
  25. 27
      src/core/client_config/resolvers/dns_resolver.c
  26. 35
      src/core/client_config/resolvers/sockaddr_resolver.c
  27. 5
      src/core/iomgr/endpoint_pair_posix.c
  28. 5
      src/core/iomgr/fd_posix.c
  29. 12
      src/core/iomgr/resolve_address_posix.c
  30. 21
      src/core/iomgr/sockaddr_utils.c
  31. 4
      src/core/iomgr/tcp_client_posix.c
  32. 21
      src/core/iomgr/tcp_server_posix.c
  33. 19
      src/core/iomgr/udp_server.c
  34. 9
      src/core/iomgr/udp_server.h
  35. 103
      src/core/iomgr/unix_sockets_posix.c
  36. 39
      src/core/iomgr/unix_sockets_posix.h
  37. 61
      src/core/iomgr/unix_sockets_posix_noop.c
  38. 11
      src/core/iomgr/wakeup_fd_pipe.c
  39. 5
      src/core/support/backoff.c
  40. 3
      src/core/support/backoff.h
  41. 17
      src/core/surface/channel_connectivity.c
  42. 2
      src/core/surface/channel_init.c
  43. 2
      src/core/surface/channel_stack_type.c
  44. 3
      src/core/surface/channel_stack_type.h
  45. 6
      src/core/surface/init.c
  46. 2
      src/core/transport/static_metadata.c
  47. 81
      src/node/ext/call_credentials.cc
  48. 18
      src/node/ext/call_credentials.h
  49. 2
      src/node/src/credentials.js
  50. 48
      src/objective-c/GRPCClient/GRPCCall.m
  51. 6
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m
  52. 19
      src/python/grpcio/grpc/_adapter/_types.py
  53. 4
      src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi
  54. 7
      src/python/grpcio/grpc/_links/invocation.py
  55. 22
      src/python/grpcio/grpc/beta/interfaces.py
  56. 14
      src/python/grpcio/grpc/framework/alpha/_face_utilities.py
  57. 6
      src/python/grpcio/grpc/framework/alpha/_reexport.py
  58. 7
      src/python/grpcio/grpc/framework/alpha/exceptions.py
  59. 34
      src/python/grpcio/grpc/framework/alpha/interfaces.py
  60. 7
      src/python/grpcio/grpc/framework/base/_ingestion.py
  61. 25
      src/python/grpcio/grpc/framework/base/_interfaces.py
  62. 7
      src/python/grpcio/grpc/framework/base/_reception.py
  63. 10
      src/python/grpcio/grpc/framework/base/_transmission.py
  64. 40
      src/python/grpcio/grpc/framework/base/interfaces.py
  65. 7
      src/python/grpcio/grpc/framework/core/_end.py
  66. 7
      src/python/grpcio/grpc/framework/core/_ingestion.py
  67. 28
      src/python/grpcio/grpc/framework/core/_interfaces.py
  68. 5
      src/python/grpcio/grpc/framework/core/_termination.py
  69. 5
      src/python/grpcio/grpc/framework/crust/_control.py
  70. 6
      src/python/grpcio/grpc/framework/crust/implementations.py
  71. 5
      src/python/grpcio/grpc/framework/face/_control.py
  72. 7
      src/python/grpcio/grpc/framework/face/exceptions.py
  73. 6
      src/python/grpcio/grpc/framework/face/implementations.py
  74. 40
      src/python/grpcio/grpc/framework/face/interfaces.py
  75. 6
      src/python/grpcio/grpc/framework/foundation/activated.py
  76. 7
      src/python/grpcio/grpc/framework/foundation/callable_util.py
  77. 7
      src/python/grpcio/grpc/framework/foundation/future.py
  78. 3
      src/python/grpcio/grpc/framework/foundation/relay.py
  79. 6
      src/python/grpcio/grpc/framework/foundation/stream.py
  80. 5
      src/python/grpcio/grpc/framework/foundation/stream_util.py
  81. 25
      src/python/grpcio/grpc/framework/interfaces/base/base.py
  82. 41
      src/python/grpcio/grpc/framework/interfaces/face/face.py
  83. 7
      src/python/grpcio/grpc/framework/interfaces/links/links.py
  84. 3
      src/python/grpcio/grpc_core_dependencies.py
  85. 4
      src/python/grpcio/tests/__init__.py
  86. 4
      src/python/grpcio/tests/_loader.py
  87. 8
      src/python/grpcio/tests/_result.py
  88. 7
      src/python/grpcio/tests/_runner.py
  89. 5
      src/python/grpcio/tests/interop/methods.py
  90. 7
      src/python/grpcio/tests/unit/_adapter/_proto_scenarios.py
  91. 6
      src/python/grpcio/tests/unit/_core_over_links_base_interface_test.py
  92. 8
      src/python/grpcio/tests/unit/_crust_over_core_over_links_face_interface_test.py
  93. 7
      src/python/grpcio/tests/unit/_links/_proto_scenarios.py
  94. 5
      src/python/grpcio/tests/unit/beta/_beta_features_test.py
  95. 8
      src/python/grpcio/tests/unit/beta/_face_interface_test.py
  96. 6
      src/python/grpcio/tests/unit/framework/_crust_over_core_face_interface_test.py
  97. 8
      src/python/grpcio/tests/unit/framework/common/test_control.py
  98. 7
      src/python/grpcio/tests/unit/framework/common/test_coverage.py
  99. 8
      src/python/grpcio/tests/unit/framework/face/testing/base_util.py
  100. 34
      src/python/grpcio/tests/unit/framework/face/testing/blocking_invocation_inline_service_test_case.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
[submodule "third_party/boringssl"]
path = third_party/boringssl
url = https://boringssl.googlesource.com/boringssl
url = https://github.com/google/boringssl.git
[submodule "third_party/nanopb"]
path = third_party/nanopb
url = https://github.com/nanopb/nanopb.git

15
BUILD

@ -163,7 +163,6 @@ cc_library(
"src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
@ -225,6 +224,7 @@ cc_library(
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",
@ -305,7 +305,6 @@ cc_library(
"src/core/channel/channel_stack.c",
"src/core/channel/channel_stack_builder.c",
"src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
@ -370,6 +369,8 @@ cc_library(
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
@ -537,7 +538,6 @@ cc_library(
"src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
@ -599,6 +599,7 @@ cc_library(
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",
@ -666,7 +667,6 @@ cc_library(
"src/core/channel/channel_stack.c",
"src/core/channel/channel_stack_builder.c",
"src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
@ -731,6 +731,8 @@ cc_library(
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
@ -1367,7 +1369,6 @@ objc_library(
"src/core/channel/channel_stack.c",
"src/core/channel/channel_stack_builder.c",
"src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
@ -1432,6 +1433,8 @@ objc_library(
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",
@ -1544,7 +1547,6 @@ objc_library(
"src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
@ -1606,6 +1608,7 @@ objc_library(
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",

@ -1,14 +1,28 @@
# Top-level Items by language
## Bazel
* [grpc.bzl](grpc.bzl)
## Node
* [binding.gyp](binding.gyp)
* [package.json](package.json)
## Objective-C
* [gRPC.podspec](gRPC.podspec)
## PHP
* [composer.json](composer.json)
* [config.m4](config.m4)
* [package.xml](package.xml)
## Python
* [requirements.txt](requirements.txt)
* [setup.cfg](setup.cfg)
* [setup.py](setup.py)
* [tox.ini](tox.ini)
* [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++
LD_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
LDFLAGS_tsan = -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
CPPFLAGS_tsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_tsan = -fsanitize=thread
DEFINES_tsan += GRPC_TEST_SLOWDOWN_BUILD_FACTOR=5
VALID_CONFIG_stapprof = 1
@ -225,8 +225,8 @@ CC_etsan = clang
CXX_etsan = clang++
LD_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
LDFLAGS_etsan = -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
CPPFLAGS_etsan = -O0 -fsanitize=thread -fno-omit-frame-pointer -Wno-unused-command-line-argument -DGPR_NO_DIRECT_SYSCALLS
LDFLAGS_etsan = -fsanitize=thread
DEFINES_etsan = _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER
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
public_headers_must_be_c89: $(BINDIR)/$(CONFIG)/public_headers_must_be_c89
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_bio_test: $(BINDIR)/$(CONFIG)/boringssl_bio_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+poll_test: $(BINDIR)/$(CONFIG)/h2_ssl+poll_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+poll_test: $(BINDIR)/$(CONFIG)/h2_uds+poll_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+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_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+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
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)
privatelibs_zookeeper:
@ -1306,7 +1305,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/h2_ssl_test \
$(BINDIR)/$(CONFIG)/h2_ssl+poll_test \
$(BINDIR)/$(CONFIG)/h2_ssl_proxy_test \
$(BINDIR)/$(CONFIG)/h2_uchannel_test \
$(BINDIR)/$(CONFIG)/h2_uds_test \
$(BINDIR)/$(CONFIG)/h2_uds+poll_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+trace_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+poll_nosec_test \
@ -1369,6 +1366,7 @@ buildtests_cxx: buildtests_zookeeper privatelibs_cxx \
$(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test \
$(BINDIR)/$(CONFIG)/thread_stress_test \
$(BINDIR)/$(CONFIG)/boringssl_aes_test \
$(BINDIR)/$(CONFIG)/boringssl_asn1_test \
$(BINDIR)/$(CONFIG)/boringssl_base64_test \
$(BINDIR)/$(CONFIG)/boringssl_bio_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 )
$(E) "[RUN] Testing message_compress_test"
$(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"
$(Q) $(BINDIR)/$(CONFIG)/multiple_server_queues_test || ( echo test multiple_server_queues_test failed ; exit 1 )
$(E) "[RUN] Testing murmur_hash_test"
@ -1627,6 +1623,8 @@ test_c: buildtests_c
flaky_test_c: buildtests_c
$(E) "[RUN] Testing lb_policies_test"
$(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
@ -2412,7 +2410,6 @@ LIBGRPC_SRC = \
src/core/channel/channel_stack.c \
src/core/channel/channel_stack_builder.c \
src/core/channel/client_channel.c \
src/core/channel/client_uchannel.c \
src/core/channel/compress_filter.c \
src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \
@ -2477,6 +2474,8 @@ LIBGRPC_SRC = \
src/core/iomgr/timer.c \
src/core/iomgr/timer_heap.c \
src/core/iomgr/udp_server.c \
src/core/iomgr/unix_sockets_posix.c \
src/core/iomgr/unix_sockets_posix_noop.c \
src/core/iomgr/wakeup_fd_eventfd.c \
src/core/iomgr/wakeup_fd_nospecial.c \
src/core/iomgr/wakeup_fd_pipe.c \
@ -2773,7 +2772,6 @@ LIBGRPC_UNSECURE_SRC = \
src/core/channel/channel_stack.c \
src/core/channel/channel_stack_builder.c \
src/core/channel/client_channel.c \
src/core/channel/client_uchannel.c \
src/core/channel/compress_filter.c \
src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \
@ -2838,6 +2836,8 @@ LIBGRPC_UNSECURE_SRC = \
src/core/iomgr/timer.c \
src/core/iomgr/timer_heap.c \
src/core/iomgr/udp_server.c \
src/core/iomgr/unix_sockets_posix.c \
src/core/iomgr/unix_sockets_posix_noop.c \
src/core/iomgr/wakeup_fd_eventfd.c \
src/core/iomgr/wakeup_fd_nospecial.c \
src/core/iomgr/wakeup_fd_pipe.c \
@ -4389,6 +4389,43 @@ ifneq ($(NO_DEPS),true)
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 = \
third_party/boringssl/crypto/base64/base64_test.cc \
@ -11242,6 +11279,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
# system openssl headers regardless of other configuration
# we do so here with a target specific variable assignment
@ -12986,38 +13050,6 @@ 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 = \
test/core/end2end/fixtures/h2_uds.c \
@ -13302,26 +13334,6 @@ ifneq ($(NO_DEPS),true)
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 = \
test/core/end2end/fixtures/h2_uds.c \

@ -565,7 +565,6 @@
'src/core/channel/channel_stack.c',
'src/core/channel/channel_stack_builder.c',
'src/core/channel/client_channel.c',
'src/core/channel/client_uchannel.c',
'src/core/channel/compress_filter.c',
'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c',
@ -630,6 +629,8 @@
'src/core/iomgr/timer.c',
'src/core/iomgr/timer_heap.c',
'src/core/iomgr/udp_server.c',
'src/core/iomgr/unix_sockets_posix.c',
'src/core/iomgr/unix_sockets_posix_noop.c',
'src/core/iomgr/wakeup_fd_eventfd.c',
'src/core/iomgr/wakeup_fd_nospecial.c',
'src/core/iomgr/wakeup_fd_pipe.c',

@ -253,7 +253,6 @@ filegroups:
- src/core/channel/channel_stack.h
- src/core/channel/channel_stack_builder.h
- src/core/channel/client_channel.h
- src/core/channel/client_uchannel.h
- src/core/channel/compress_filter.h
- src/core/channel/connected_channel.h
- src/core/channel/context.h
@ -315,6 +314,7 @@ filegroups:
- src/core/iomgr/timer.h
- src/core/iomgr/timer_heap.h
- src/core/iomgr/udp_server.h
- src/core/iomgr/unix_sockets_posix.h
- src/core/iomgr/wakeup_fd_pipe.h
- src/core/iomgr/wakeup_fd_posix.h
- src/core/iomgr/workqueue.h
@ -375,7 +375,6 @@ filegroups:
- src/core/channel/channel_stack.c
- src/core/channel/channel_stack_builder.c
- src/core/channel/client_channel.c
- src/core/channel/client_uchannel.c
- src/core/channel/compress_filter.c
- src/core/channel/connected_channel.c
- src/core/channel/http_client_filter.c
@ -440,6 +439,8 @@ filegroups:
- src/core/iomgr/timer.c
- src/core/iomgr/timer_heap.c
- src/core/iomgr/udp_server.c
- src/core/iomgr/unix_sockets_posix.c
- src/core/iomgr/unix_sockets_posix_noop.c
- src/core/iomgr/wakeup_fd_eventfd.c
- src/core/iomgr/wakeup_fd_nospecial.c
- src/core/iomgr/wakeup_fd_pipe.c
@ -1716,6 +1717,7 @@ targets:
- gpr_test_util
- gpr
- name: mlog_test
flaky: true
build: test
language: c
src:
@ -2471,8 +2473,6 @@ targets:
- gpr_test_util
- gpr
- grpc++_test_config
exclude_configs:
- tsan
platforms:
- mac
- linux
@ -2492,8 +2492,6 @@ targets:
- gpr_test_util
- gpr
- grpc++_test_config
exclude_configs:
- tsan
platforms:
- mac
- linux
@ -2826,11 +2824,11 @@ configs:
etsan:
CC: clang
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++
DEFINES: _DEBUG DEBUG GRPC_EXECUTION_CONTEXT_SANITIZER
LD: clang
LDFLAGS: -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
LDFLAGS: -fsanitize=thread
LDXX: clang++
compile_the_world: true
test_environ:
@ -2882,10 +2880,10 @@ configs:
tsan:
CC: clang
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++
LD: clang
LDFLAGS: -fsanitize=thread -fPIE -pie $(if $(JENKINS_BUILD),-Wl$(comma)-Ttext-segment=0x7e0000000000,)
LDFLAGS: -fsanitize=thread
LDXX: clang++
compile_the_world: true
test_environ:

@ -87,7 +87,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/channel/channel_stack.c \
src/core/channel/channel_stack_builder.c \
src/core/channel/client_channel.c \
src/core/channel/client_uchannel.c \
src/core/channel/compress_filter.c \
src/core/channel/connected_channel.c \
src/core/channel/http_client_filter.c \
@ -152,6 +151,8 @@ if test "$PHP_GRPC" != "no"; then
src/core/iomgr/timer.c \
src/core/iomgr/timer_heap.c \
src/core/iomgr/udp_server.c \
src/core/iomgr/unix_sockets_posix.c \
src/core/iomgr/unix_sockets_posix_noop.c \
src/core/iomgr/wakeup_fd_eventfd.c \
src/core/iomgr/wakeup_fd_nospecial.c \
src/core/iomgr/wakeup_fd_pipe.c \

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -29,6 +29,8 @@
"""The Python implementation of the GRPC helloworld.Greeter client."""
from __future__ import print_function
from grpc.beta import implementations
import helloworld_pb2
@ -40,7 +42,7 @@ def run():
channel = implementations.insecure_channel('localhost', 50051)
stub = helloworld_pb2.beta_create_Greeter_stub(channel)
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__':

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

@ -167,7 +167,6 @@ Pod::Spec.new do |s|
'src/core/channel/channel_stack.h',
'src/core/channel/channel_stack_builder.h',
'src/core/channel/client_channel.h',
'src/core/channel/client_uchannel.h',
'src/core/channel/compress_filter.h',
'src/core/channel/connected_channel.h',
'src/core/channel/context.h',
@ -229,6 +228,7 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.h',
'src/core/iomgr/timer_heap.h',
'src/core/iomgr/udp_server.h',
'src/core/iomgr/unix_sockets_posix.h',
'src/core/iomgr/wakeup_fd_pipe.h',
'src/core/iomgr/wakeup_fd_posix.h',
'src/core/iomgr/workqueue.h',
@ -322,7 +322,6 @@ Pod::Spec.new do |s|
'src/core/channel/channel_stack.c',
'src/core/channel/channel_stack_builder.c',
'src/core/channel/client_channel.c',
'src/core/channel/client_uchannel.c',
'src/core/channel/compress_filter.c',
'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c',
@ -387,6 +386,8 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.c',
'src/core/iomgr/timer_heap.c',
'src/core/iomgr/udp_server.c',
'src/core/iomgr/unix_sockets_posix.c',
'src/core/iomgr/unix_sockets_posix_noop.c',
'src/core/iomgr/wakeup_fd_eventfd.c',
'src/core/iomgr/wakeup_fd_nospecial.c',
'src/core/iomgr/wakeup_fd_pipe.c',
@ -497,7 +498,6 @@ Pod::Spec.new do |s|
'src/core/channel/channel_stack.h',
'src/core/channel/channel_stack_builder.h',
'src/core/channel/client_channel.h',
'src/core/channel/client_uchannel.h',
'src/core/channel/compress_filter.h',
'src/core/channel/connected_channel.h',
'src/core/channel/context.h',
@ -559,6 +559,7 @@ Pod::Spec.new do |s|
'src/core/iomgr/timer.h',
'src/core/iomgr/timer_heap.h',
'src/core/iomgr/udp_server.h',
'src/core/iomgr/unix_sockets_posix.h',
'src/core/iomgr/wakeup_fd_pipe.h',
'src/core/iomgr/wakeup_fd_posix.h',
'src/core/iomgr/workqueue.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_builder.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/connected_channel.h )
s.files += %w( src/core/channel/context.h )
@ -225,6 +224,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/iomgr/timer.h )
s.files += %w( src/core/iomgr/timer_heap.h )
s.files += %w( src/core/iomgr/udp_server.h )
s.files += %w( src/core/iomgr/unix_sockets_posix.h )
s.files += %w( src/core/iomgr/wakeup_fd_pipe.h )
s.files += %w( src/core/iomgr/wakeup_fd_posix.h )
s.files += %w( src/core/iomgr/workqueue.h )
@ -305,7 +305,6 @@ Gem::Specification.new do |s|
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/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/connected_channel.c )
s.files += %w( src/core/channel/http_client_filter.c )
@ -370,6 +369,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/iomgr/timer.c )
s.files += %w( src/core/iomgr/timer_heap.c )
s.files += %w( src/core/iomgr/udp_server.c )
s.files += %w( src/core/iomgr/unix_sockets_posix.c )
s.files += %w( src/core/iomgr/unix_sockets_posix_noop.c )
s.files += %w( src/core/iomgr/wakeup_fd_eventfd.c )
s.files += %w( src/core/iomgr/wakeup_fd_nospecial.c )
s.files += %w( src/core/iomgr/wakeup_fd_pipe.c )

@ -99,8 +99,8 @@ class SerializationTraits<ByteBuffer, void> {
}
static Status Serialize(const ByteBuffer& source, grpc_byte_buffer** buffer,
bool* own_buffer) {
*buffer = source.buffer();
*own_buffer = false;
*buffer = grpc_byte_buffer_copy(source.buffer());
*own_buffer = true;
return Status::OK;
}
};

@ -133,6 +133,7 @@
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_MSG_NOSIGNAL 1
#define GPR_HAVE_UNIX_SOCKET 1
#elif defined(__linux__)
#define GPR_POSIX_CRASH_HANDLER 1
#define GPR_PLATFORM_STRING "linux"
@ -154,6 +155,7 @@
#define GPR_POSIX_WAKEUP_FD 1
#define GPR_POSIX_SOCKET 1
#define GPR_POSIX_SOCKETADDR 1
#define GPR_HAVE_UNIX_SOCKET 1
#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 9)
#define GPR_LINUX_EVENTFD 1
@ -214,6 +216,7 @@
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_SO_NOSIGPIPE 1
#define GPR_HAVE_UNIX_SOCKET 1
#ifdef _LP64
#define GPR_ARCH_64 1
#else /* _LP64 */
@ -242,6 +245,7 @@
#define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1
#define GPR_HAVE_SO_NOSIGPIPE 1
#define GPR_HAVE_UNIX_SOCKET 1
#ifdef _LP64
#define GPR_ARCH_64 1
#else /* _LP64 */

@ -105,7 +105,6 @@
"src/core/channel/channel_stack.h",
"src/core/channel/channel_stack_builder.h",
"src/core/channel/client_channel.h",
"src/core/channel/client_uchannel.h",
"src/core/channel/compress_filter.h",
"src/core/channel/connected_channel.h",
"src/core/channel/context.h",
@ -167,6 +166,7 @@
"src/core/iomgr/timer.h",
"src/core/iomgr/timer_heap.h",
"src/core/iomgr/udp_server.h",
"src/core/iomgr/unix_sockets_posix.h",
"src/core/iomgr/wakeup_fd_pipe.h",
"src/core/iomgr/wakeup_fd_posix.h",
"src/core/iomgr/workqueue.h",
@ -247,7 +247,6 @@
"src/core/channel/channel_stack.c",
"src/core/channel/channel_stack_builder.c",
"src/core/channel/client_channel.c",
"src/core/channel/client_uchannel.c",
"src/core/channel/compress_filter.c",
"src/core/channel/connected_channel.c",
"src/core/channel/http_client_filter.c",
@ -312,6 +311,8 @@
"src/core/iomgr/timer.c",
"src/core/iomgr/timer_heap.c",
"src/core/iomgr/udp_server.c",
"src/core/iomgr/unix_sockets_posix.c",
"src/core/iomgr/unix_sockets_posix_noop.c",
"src/core/iomgr/wakeup_fd_eventfd.c",
"src/core/iomgr/wakeup_fd_nospecial.c",
"src/core/iomgr/wakeup_fd_pipe.c",

@ -167,7 +167,6 @@
<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/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/connected_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/channel/context.h" role="src" />
@ -229,6 +228,7 @@
<file baseinstalldir="/" name="src/core/iomgr/timer.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/timer_heap.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/udp_server.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_pipe.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/workqueue.h" role="src" />
@ -309,7 +309,6 @@
<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/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/connected_channel.c" role="src" />
<file baseinstalldir="/" name="src/core/channel/http_client_filter.c" role="src" />
@ -374,6 +373,8 @@
<file baseinstalldir="/" name="src/core/iomgr/timer.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/timer_heap.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/udp_server.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/unix_sockets_posix_noop.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_eventfd.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_nospecial.c" role="src" />
<file baseinstalldir="/" name="src/core/iomgr/wakeup_fd_pipe.c" role="src" />

@ -111,7 +111,7 @@ if "linux" in sys.platform or "darwin" in sys.platform:
DEFINE_MACROS += (('PyMODINIT_FUNC', pymodinit),)
def cython_extensions(package_names, module_names, extra_sources, include_dirs,
def cython_extensions(module_names, extra_sources, include_dirs,
libraries, define_macros, build_with_cython=False):
# Set compiler directives linetrace argument only if we care about tracing;
# this is due to Cython having different behavior between linetrace being
@ -144,7 +144,7 @@ def cython_extensions(package_names, module_names, extra_sources, include_dirs,
return extensions
CYTHON_EXTENSION_MODULES = cython_extensions(
list(CYTHON_EXTENSION_PACKAGE_NAMES), list(CYTHON_EXTENSION_MODULE_NAMES),
list(CYTHON_EXTENSION_MODULE_NAMES),
list(CYTHON_HELPER_C_FILES) + list(CORE_C_FILES),
list(EXTENSION_INCLUDE_DIRECTORIES), list(EXTENSION_LIBRARIES),
list(DEFINE_MACROS), bool(BUILD_WITH_CYTHON))

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

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -42,6 +42,10 @@ namespace grpc_cpp_generator {
struct Parameters {
// Puts the service into a 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.

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

@ -63,8 +63,6 @@ void census_grpc_plugin_init(void) {
}
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
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,
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
size_t num_filters = 0;
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++;
}

@ -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);
}

@ -55,15 +55,14 @@ typedef enum {
for initial metadata before trying to create a call object,
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 {
/** either 0 for no call, 1 for cancelled, or a pointer to a
grpc_subchannel_call */
gpr_atm subchannel_call;
/** Helper function to choose the subchannel on which to create
the call object. Channel filter delegates to the load
balancing policy (once it's ready); uchannel returns
immediately */
balancing policy (once it's ready). */
grpc_subchannel_call_holder_pick_subchannel pick_subchannel;
void *pick_subchannel_arg;

@ -42,8 +42,14 @@
#include "src/core/client_config/lb_policy_registry.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/timer.h"
#include "src/core/support/backoff.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 {
/** base class: must be first */
grpc_resolver base;
@ -75,6 +81,8 @@ typedef struct {
/** retry timer */
bool have_retry_timer;
grpc_timer retry_timer;
/** retry backoff state */
gpr_backoff backoff_state;
} dns_resolver;
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;
gpr_mu_lock(&r->mu);
if (!r->resolving) {
gpr_backoff_reset(&r->backoff_state);
dns_start_resolving_locked(r);
}
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->target_config = target_config;
if (r->resolved_version == 0 && !r->resolving) {
gpr_backoff_reset(&r->backoff_state);
dns_start_resolving_locked(r);
} else {
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);
gpr_free(subchannels);
} else {
int retry_seconds = 15;
gpr_log(GPR_DEBUG, "dns resolution failed: retrying in %d seconds",
retry_seconds);
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
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);
r->have_retry_timer = true;
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
GRPC_RESOLVER_REF(&r->base, "retry-timer");
grpc_timer_init(
exec_ctx, &r->retry_timer,
gpr_time_add(now, gpr_time_from_seconds(retry_seconds, GPR_TIMESPAN)),
dns_on_retry_timer, r, now);
grpc_timer_init(exec_ctx, &r->retry_timer, next_try, dns_on_retry_timer, r,
now);
}
if (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->default_port = gpr_strdup(default_port);
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);
r->lb_policy_name = gpr_strdup(lb_policy_name);
return &r->base;

@ -37,9 +37,6 @@
#include <stdio.h>
#include <string.h>
#ifdef GPR_POSIX_SOCKET
#include <sys/un.h>
#endif
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
@ -47,6 +44,7 @@
#include "src/core/client_config/lb_policy_registry.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
typedef struct {
@ -168,24 +166,6 @@ static void sockaddr_destroy(grpc_exec_ctx *exec_ctx, grpc_resolver *gr) {
gpr_free(r);
}
#ifdef GPR_POSIX_SOCKET
static int parse_unix(grpc_uri *uri, struct sockaddr_storage *addr,
size_t *len) {
struct sockaddr_un *un = (struct sockaddr_un *)addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, uri->path);
*len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return 1;
}
static char *unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return gpr_strdup("localhost");
}
#endif
static char *ip_get_default_authority(grpc_uri *uri) {
const char *path = uri->path;
if (path[0] == '/') ++path;
@ -371,21 +351,22 @@ static void sockaddr_factory_ref(grpc_resolver_factory *factory) {}
static void sockaddr_factory_unref(grpc_resolver_factory *factory) {}
#define DECL_FACTORY(name) \
#define DECL_FACTORY(name, prefix) \
static grpc_resolver *name##_factory_create_resolver( \
grpc_resolver_factory *factory, grpc_resolver_args *args) { \
return sockaddr_create(args, "pick_first", parse_##name); \
return sockaddr_create(args, "pick_first", prefix##parse_##name); \
} \
static const grpc_resolver_factory_vtable name##_factory_vtable = { \
sockaddr_factory_ref, sockaddr_factory_unref, \
name##_factory_create_resolver, name##_get_default_authority, #name}; \
name##_factory_create_resolver, prefix##name##_get_default_authority, \
#name}; \
static grpc_resolver_factory name##_resolver_factory = { \
&name##_factory_vtable}; \
grpc_resolver_factory *grpc_##name##_resolver_factory_create() { \
return &name##_resolver_factory; \
}
#ifdef GPR_POSIX_SOCKET
DECL_FACTORY(unix)
#ifdef GPR_HAVE_UNIX_SOCKET
DECL_FACTORY(unix, grpc_)
#endif
DECL_FACTORY(ipv4) DECL_FACTORY(ipv6)
DECL_FACTORY(ipv4, ) DECL_FACTORY(ipv6, )

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -37,6 +37,7 @@
#include "src/core/iomgr/endpoint_pair.h"
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include <errno.h>
#include <fcntl.h>
@ -52,7 +53,7 @@
static void create_sockets(int sv[2]) {
int flags;
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
grpc_create_socketpair_if_unix(sv);
flags = fcntl(sv[0], F_GETFL, 0);
GPR_ASSERT(fcntl(sv[0], F_SETFL, flags | O_NONBLOCK) == 0);
flags = fcntl(sv[1], F_GETFL, 0);

@ -92,7 +92,7 @@ static grpc_fd *alloc_fd(int fd) {
gpr_mu_init(&r->mu);
}
gpr_atm_rel_store(&r->refst, 1);
gpr_mu_lock(&r->mu);
r->shutdown = 0;
r->read_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->closed = 0;
r->released = 0;
gpr_atm_rel_store(&r->refst, 1);
gpr_mu_unlock(&r->mu);
return r;
}

@ -39,7 +39,6 @@
#include <string.h>
#include <sys/types.h>
#include <sys/un.h>
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
@ -51,6 +50,7 @@
#include "src/core/iomgr/executor.h"
#include "src/core/iomgr/iomgr_internal.h"
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/block_annotate.h"
#include "src/core/support/string.h"
@ -71,18 +71,10 @@ static grpc_resolved_addresses *blocking_resolve_address_impl(
int s;
size_t i;
grpc_resolved_addresses *addrs = NULL;
struct sockaddr_un *un;
if (name[0] == 'u' && name[1] == 'n' && name[2] == 'i' && name[3] == 'x' &&
name[4] == ':' && name[5] != 0) {
addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
addrs->naddrs = 1;
addrs->addrs = gpr_malloc(sizeof(grpc_resolved_address));
un = (struct sockaddr_un *)addrs->addrs->addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, name + 5);
addrs->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return addrs;
return grpc_resolve_unix_domain_address(name + 5);
}
/* parse name, splitting it into host and port parts */

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -36,16 +36,13 @@
#include <errno.h>
#include <string.h>
#ifdef GPR_POSIX_SOCKET
#include <sys/un.h>
#endif
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/string_util.h>
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
static const uint8_t kV4MappedPrefix[] = {0, 0, 0, 0, 0, 0,
@ -191,14 +188,9 @@ char *grpc_sockaddr_to_uri(const struct sockaddr *addr) {
gpr_asprintf(&result, "ipv6:%s", temp);
gpr_free(temp);
return result;
#ifdef GPR_POSIX_SOCKET
case AF_UNIX:
gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un *)addr)->sun_path);
return result;
#endif
default:
return grpc_sockaddr_to_uri_unix_if_possible(addr);
}
return NULL;
}
int grpc_sockaddr_get_port(const struct sockaddr *addr) {
@ -207,9 +199,10 @@ int grpc_sockaddr_get_port(const struct sockaddr *addr) {
return ntohs(((struct sockaddr_in *)addr)->sin_port);
case AF_INET6:
return ntohs(((struct sockaddr_in6 *)addr)->sin6_port);
case AF_UNIX:
return 1;
default:
if (grpc_is_unix_socket(addr)) {
return 1;
}
gpr_log(GPR_ERROR, "Unknown socket family %d in grpc_sockaddr_get_port",
addr->sa_family);
return 0;

@ -54,6 +54,7 @@
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/tcp_posix.h"
#include "src/core/iomgr/timer.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
extern int grpc_tcp_trace;
@ -77,13 +78,12 @@ static int prepare_socket(const struct sockaddr *addr, int fd) {
}
if (!grpc_set_socket_nonblocking(fd, 1) || !grpc_set_socket_cloexec(fd, 1) ||
(addr->sa_family != AF_UNIX && !grpc_set_socket_low_latency(fd, 1)) ||
(!grpc_is_unix_socket(addr) && !grpc_set_socket_low_latency(fd, 1)) ||
!grpc_set_socket_no_sigpipe_if_possible(fd)) {
gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd,
strerror(errno));
goto error;
}
return 1;
error:

@ -52,7 +52,6 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include "src/core/iomgr/pollset_posix.h"
@ -60,6 +59,7 @@
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/tcp_posix.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -81,7 +81,6 @@ struct grpc_tcp_listener {
union {
uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr;
struct sockaddr_un un;
} addr;
size_t addr_len;
int port;
@ -98,14 +97,6 @@ struct grpc_tcp_listener {
int is_sibling;
};
static void unlink_if_unix_domain_socket(const struct sockaddr_un *un) {
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
unlink(un->sun_path);
}
}
/* the overall server */
struct grpc_tcp_server {
gpr_refcount refs;
@ -203,9 +194,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s) {
if (s->head) {
grpc_tcp_listener *sp;
for (sp = s->head; sp; sp = sp->next) {
if (sp->addr.sockaddr.sa_family == AF_UNIX) {
unlink_if_unix_domain_socket(&sp->addr.un);
}
grpc_unlink_if_unix_domain_socket(&sp->addr.sockaddr);
sp->destroyed_closure.cb = destroyed_port;
sp->destroyed_closure.cb_arg = s;
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
@ -281,7 +270,7 @@ static int prepare_socket(int fd, const struct sockaddr *addr,
}
if (!grpc_set_socket_nonblocking(fd, 1) || !grpc_set_socket_cloexec(fd, 1) ||
(addr->sa_family != AF_UNIX && (!grpc_set_socket_low_latency(fd, 1) ||
(!grpc_is_unix_socket(addr) && (!grpc_set_socket_low_latency(fd, 1) ||
!grpc_set_socket_reuse_addr(fd, 1))) ||
!grpc_set_socket_no_sigpipe_if_possible(fd)) {
gpr_log(GPR_ERROR, "Unable to configure socket %d: %s", fd,
@ -451,9 +440,7 @@ int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
if (s->tail != NULL) {
port_index = s->tail->port_index + 1;
}
if (((struct sockaddr *)addr)->sa_family == AF_UNIX) {
unlink_if_unix_domain_socket(addr);
}
grpc_unlink_if_unix_domain_socket((struct sockaddr *)addr);
/* Check if this is a wildcard port, and if so, try to keep the port the same
as some previously created listener. */

@ -52,7 +52,6 @@
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
#include "src/core/iomgr/fd_posix.h"
@ -60,6 +59,7 @@
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/sockaddr_utils.h"
#include "src/core/iomgr/socket_utils_posix.h"
#include "src/core/iomgr/unix_sockets_posix.h"
#include "src/core/support/string.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@ -77,7 +77,6 @@ typedef struct {
union {
uint8_t untyped[GRPC_MAX_SOCKADDR_SIZE];
struct sockaddr sockaddr;
struct sockaddr_un un;
} addr;
size_t addr_len;
grpc_closure read_closure;
@ -85,14 +84,6 @@ typedef struct {
grpc_udp_server_read_cb read_cb;
} server_port;
static void unlink_if_unix_domain_socket(const struct sockaddr_un *un) {
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
unlink(un->sun_path);
}
}
/* the overall server */
struct grpc_udp_server {
gpr_mu mu;
@ -176,9 +167,7 @@ static void deactivated_all_ports(grpc_exec_ctx *exec_ctx, grpc_udp_server *s) {
if (s->nports) {
for (i = 0; i < s->nports; i++) {
server_port *sp = &s->ports[i];
if (sp->addr.sockaddr.sa_family == AF_UNIX) {
unlink_if_unix_domain_socket(&sp->addr.un);
}
grpc_unlink_if_unix_domain_socket(&sp->addr.sockaddr);
sp->destroyed_closure.cb = destroyed_port;
sp->destroyed_closure.cb_arg = s;
grpc_fd_orphan(exec_ctx, sp->emfd, &sp->destroyed_closure, NULL,
@ -336,9 +325,7 @@ int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
socklen_t sockname_len;
int port;
if (((struct sockaddr *)addr)->sa_family == AF_UNIX) {
unlink_if_unix_domain_socket(addr);
}
grpc_unlink_if_unix_domain_socket((struct sockaddr *)addr);
/* Check if this is a wildcard port, and if so, try to keep the port the same
as some previously created listener. */

@ -37,15 +37,16 @@
#include "src/core/iomgr/endpoint.h"
#include "src/core/iomgr/fd_posix.h"
/* Forward decl of grpc_server */
typedef struct grpc_server grpc_server;
/* Forward decl of struct grpc_server */
/* This is not typedef'ed to avoid a typedef-redefinition error */
struct grpc_server;
/* Forward decl of grpc_udp_server */
typedef struct grpc_udp_server grpc_udp_server;
/* 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,
grpc_server *server);
struct grpc_server *server);
/* Create a server, initially not bound to any ports */
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 */
void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *udp_server,
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);

@ -0,0 +1,103 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/iomgr/unix_sockets_posix.h"
#ifdef GPR_HAVE_UNIX_SOCKET
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/un.h>
#include <grpc/support/alloc.h>
void grpc_create_socketpair_if_unix(int sv[2]) {
GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
}
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name) {
struct sockaddr_un *un;
grpc_resolved_addresses *addrs = gpr_malloc(sizeof(grpc_resolved_addresses));
addrs->naddrs = 1;
addrs->addrs = gpr_malloc(sizeof(grpc_resolved_address));
un = (struct sockaddr_un *)addrs->addrs->addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, name);
addrs->addrs->len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return addrs;
}
int grpc_is_unix_socket(const struct sockaddr *addr) {
return addr->sa_family == AF_UNIX;
}
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return;
}
struct sockaddr_un *un = (struct sockaddr_un *)addr;
struct stat st;
if (stat(un->sun_path, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
unlink(un->sun_path);
}
}
int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
struct sockaddr_un *un = (struct sockaddr_un *)addr;
un->sun_family = AF_UNIX;
strcpy(un->sun_path, uri->path);
*len = strlen(un->sun_path) + sizeof(un->sun_family) + 1;
return 1;
}
char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return gpr_strdup("localhost");
}
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
if (addr->sa_family != AF_UNIX) {
return NULL;
}
char *result;
gpr_asprintf(&result, "unix:%s", ((struct sockaddr_un *)addr)->sun_path);
return result;
}
#endif

@ -1,6 +1,6 @@
/*
*
* Copyright 2015-2016, Google Inc.
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -31,30 +31,31 @@
*
*/
#ifndef GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H
#define GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H
#ifndef GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H
#define GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H
#include "src/core/channel/channel_stack.h"
#include "src/core/client_config/resolver.h"
#include <grpc/support/port_platform.h>
#define GRPC_MICROCHANNEL_SUBCHANNEL_ARG "grpc.microchannel_subchannel_key"
#include <grpc/support/string_util.h>
/* A client microchannel (aka uchannel) is a channel wrapping a subchannel, for
* the purposes of lightweight RPC communications from within the core.*/
#include "src/core/client_config/resolver_factory.h"
#include "src/core/client_config/uri_parser.h"
#include "src/core/iomgr/resolve_address.h"
#include "src/core/iomgr/sockaddr.h"
extern const grpc_channel_filter grpc_client_uchannel_filter;
void grpc_create_socketpair_if_unix(int sv[2]);
grpc_connectivity_state grpc_client_uchannel_check_connectivity_state(
grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect);
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name);
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);
int grpc_is_unix_socket(const struct sockaddr *addr);
grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
grpc_channel_args *args);
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr);
void grpc_client_uchannel_set_connected_subchannel(
grpc_channel *uchannel, grpc_connected_subchannel *connected_subchannel);
int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len);
#endif /* GRPC_CORE_CHANNEL_CLIENT_UCHANNEL_H */
char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri);
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr);
#endif /* GRPC_CORE_IOMGR_UNIX_SOCKETS_POSIX_H */

@ -0,0 +1,61 @@
/*
*
* Copyright 2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/iomgr/unix_sockets_posix.h"
#ifndef GPR_HAVE_UNIX_SOCKET
void grpc_create_socketpair_if_unix(int sv[2]) {}
grpc_resolved_addresses *grpc_resolve_unix_domain_address(const char *name) {
return NULL;
}
int grpc_is_unix_socket(const struct sockaddr *addr) { return false; }
void grpc_unlink_if_unix_domain_socket(const struct sockaddr *addr) {}
int grpc_parse_unix(grpc_uri *uri, struct sockaddr_storage *addr, size_t *len) {
return 0;
}
char *grpc_unix_get_default_authority(grpc_resolver_factory *factory,
grpc_uri *uri) {
return NULL;
}
char *grpc_sockaddr_to_uri_unix_if_possible(const struct sockaddr *addr) {
return NULL;
}
#endif

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -41,13 +41,18 @@
#include <string.h>
#include <unistd.h>
#include "src/core/iomgr/socket_utils_posix.h"
#include <grpc/support/log.h>
#include "src/core/iomgr/socket_utils_posix.h"
static void pipe_init(grpc_wakeup_fd* fd_info) {
int pipefd[2];
/* 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[1], 1));
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(
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);
/// Step a retry loop: returns a timespec for the NEXT retry
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 */

@ -37,7 +37,6 @@
#include <grpc/support/log.h>
#include "src/core/channel/client_channel.h"
#include "src/core/channel/client_uchannel.h"
#include "src/core/iomgr/timer.h"
#include "src/core/surface/api_trace.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);
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,
"grpc_channel_check_connectivity_state called on something that is "
"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) {
GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, w->channel,
"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 {
abort();
}
@ -209,11 +199,8 @@ void grpc_channel_watch_connectivity_state(
grpc_client_channel_watch_connectivity_state(&exec_ctx, client_channel_elem,
grpc_cq_pollset(cq), &w->state,
&w->on_complete);
} else if (client_channel_elem->filter == &grpc_client_uchannel_filter) {
GRPC_CHANNEL_INTERNAL_REF(channel, "watch_uchannel_connectivity");
grpc_client_uchannel_watch_connectivity_state(
&exec_ctx, client_channel_elem, grpc_cq_pollset(cq), &w->state,
&w->on_complete);
} else {
abort();
}
grpc_exec_ctx_finish(&exec_ctx);

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

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

@ -39,9 +39,6 @@
typedef enum {
// normal top-half client channel with load-balancing, connection management
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
// balancing (bound to a specific transport)
GRPC_CLIENT_SUBCHANNEL,

@ -45,7 +45,6 @@
#include "src/core/channel/compress_filter.h"
#include "src/core/channel/connected_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_server_filter.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,
prepend_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,
(void *)&grpc_compress_filter);
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_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, append_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,
append_filter, (void *)&grpc_lame_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];
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, 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};

@ -35,6 +35,8 @@
#include <nan.h>
#include <uv.h>
#include <list>
#include "grpc/grpc.h"
#include "grpc/grpc_security.h"
#include "grpc/support/log.h"
@ -161,6 +163,15 @@ NAN_METHOD(CallCredentials::CreateFromPlugin) {
grpc_metadata_credentials_plugin plugin;
plugin_state *state = new plugin_state;
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.destroy = plugin_destroy_state;
plugin.state = reinterpret_cast<void*>(state);
@ -208,48 +219,60 @@ NAN_METHOD(PluginCallback) {
NAUV_WORK_CB(SendPluginCallback) {
Nan::HandleScope scope;
plugin_callback_data *data = reinterpret_cast<plugin_callback_data*>(
async->data);
// Attach cb and user_data to plugin_callback so that it can access them later
v8::Local<v8::Function> plugin_callback = Nan::GetFunction(
Nan::New<v8::FunctionTemplate>(PluginCallback)).ToLocalChecked();
Nan::Set(plugin_callback, Nan::New("cb").ToLocalChecked(),
Nan::New<v8::External>(reinterpret_cast<void*>(data->cb)));
Nan::Set(plugin_callback, Nan::New("user_data").ToLocalChecked(),
Nan::New<v8::External>(data->user_data));
const int argc = 2;
v8::Local<v8::Value> argv[argc] = {
Nan::New(data->service_url).ToLocalChecked(),
plugin_callback
};
Nan::Callback *callback = data->state->callback;
callback->Call(argc, argv);
delete data;
uv_unref((uv_handle_t *)async);
uv_close((uv_handle_t *)async, (uv_close_cb)free);
plugin_state *state = reinterpret_cast<plugin_state*>(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
v8::Local<v8::Function> plugin_callback = Nan::GetFunction(
Nan::New<v8::FunctionTemplate>(PluginCallback)).ToLocalChecked();
Nan::Set(plugin_callback, Nan::New("cb").ToLocalChecked(),
Nan::New<v8::External>(reinterpret_cast<void*>(data->cb)));
Nan::Set(plugin_callback, Nan::New("user_data").ToLocalChecked(),
Nan::New<v8::External>(data->user_data));
const int argc = 2;
v8::Local<v8::Value> argv[argc] = {
Nan::New(data->service_url).ToLocalChecked(),
plugin_callback
};
Nan::Callback *callback = state->callback;
callback->Call(argc, argv);
delete data;
}
}
void plugin_get_metadata(void *state, grpc_auth_metadata_context context,
grpc_credentials_plugin_metadata_cb cb,
void *user_data) {
uv_async_t *async = static_cast<uv_async_t*>(malloc(sizeof(uv_async_t)));
uv_async_init(uv_default_loop(),
async,
SendPluginCallback);
plugin_state *p_state = reinterpret_cast<plugin_state*>(state);
plugin_callback_data *data = new plugin_callback_data;
data->state = reinterpret_cast<plugin_state*>(state);
data->service_url = context.service_url;
data->cb = cb;
data->user_data = user_data;
async->data = data;
/* libuv says that it will coalesce calls to uv_async_send. If there is ever a
* problem with a callback not getting called, that is probably the reason */
uv_async_send(async);
uv_mutex_lock(&p_state->plugin_mutex);
p_state->pending_callbacks->push_back(data);
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) {
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

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -34,8 +34,11 @@
#ifndef GRPC_NODE_CALL_CREDENTIALS_H_
#define GRPC_NODE_CALL_CREDENTIALS_H_
#include <list>
#include <node.h>
#include <nan.h>
#include <uv.h>
#include "grpc/grpc_security.h"
namespace grpc {
@ -73,17 +76,20 @@ class CallCredentials : public Nan::ObjectWrap {
/* Auth metadata plugin functionality */
typedef struct plugin_state {
Nan::Callback *callback;
} plugin_state;
typedef struct plugin_callback_data {
plugin_state *state;
const char *service_url;
grpc_credentials_plugin_metadata_cb cb;
void *user_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,
grpc_credentials_plugin_metadata_cb cb,
void *user_data);

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

@ -1,6 +1,6 @@
/*
*
* Copyright 2015, Google Inc.
* Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -308,37 +308,30 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
}
- (void)invokeCall {
__weak GRPCCall *weakSelf = self;
[self invokeCallWithHeadersHandler:^(NSDictionary *headers) {
// Response headers received.
GRPCCall *strongSelf = weakSelf;
if (strongSelf) {
strongSelf.responseHeaders = headers;
[strongSelf startNextRead];
}
self.responseHeaders = headers;
[self startNextRead];
} completionHandler:^(NSError *error, NSDictionary *trailers) {
GRPCCall *strongSelf = weakSelf;
if (strongSelf) {
strongSelf.responseTrailers = trailers;
if (error) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (error.userInfo) {
[userInfo addEntriesFromDictionary:error.userInfo];
}
userInfo[kGRPCTrailersKey] = strongSelf.responseTrailers;
// 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
// 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
// way.
if (strongSelf.responseHeaders) {
userInfo[kGRPCHeadersKey] = strongSelf.responseHeaders;
}
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
self.responseTrailers = trailers;
if (error) {
NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
if (error.userInfo) {
[userInfo addEntriesFromDictionary:error.userInfo];
}
userInfo[kGRPCTrailersKey] = self.responseTrailers;
// 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
// 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
// way.
if (self.responseHeaders) {
userInfo[kGRPCHeadersKey] = self.responseHeaders;
}
[strongSelf finishWithError:error];
error = [NSError errorWithDomain:error.domain code:error.code userInfo:userInfo];
}
[self finishWithError:error];
}];
// Now that the RPC has been initiated, request writes can start.
@synchronized(_requestWriter) {
@ -377,7 +370,6 @@ NSString * const kGRPCTrailersKey = @"io.grpc.TrailersKey";
[strongSelf finishWithError:[NSError errorWithDomain:kGRPCErrorDomain
code:GRPCErrorCodeUnavailable
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.
*
* Redistribution and use in source and binary forms, with or without
@ -54,7 +54,9 @@
- (void)finish {
if (_handler) {
_handler();
void(^handler)() = _handler;
_handler = nil;
handler();
}
}
@end

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

@ -254,7 +254,7 @@ cdef class ByteBuffer:
if self.c_byte_buffer != NULL:
with nogil:
grpc_byte_buffer_reader_init(&reader, self.c_byte_buffer)
result = b""
result = bytearray()
with nogil:
while grpc_byte_buffer_reader_next(&reader, &data_slice):
data_slice_pointer = gpr_slice_start_ptr(data_slice)
@ -263,7 +263,7 @@ cdef class ByteBuffer:
result += (<char *>data_slice_pointer)[:data_slice_length]
with nogil:
grpc_byte_buffer_reader_destroy(&reader)
return result
return bytes(result)
else:
return None

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -35,6 +35,8 @@ import logging
import threading
import time
import six
from grpc._adapter import _intermediary_low
from grpc._links import _constants
from grpc.beta import interfaces as beta_interfaces
@ -372,12 +374,11 @@ class _Kernel(object):
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.
Implementations of this interface are only valid for use when activated.
"""
__metaclass__ = abc.ABCMeta
class _InvocationLink(InvocationLink):

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

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

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# 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
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import six
from grpc.framework.common import cardinality
from grpc.framework.face import exceptions as face_exceptions
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):
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[
early_adopter_cardinality]
return common_cardinalities

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

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

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -32,6 +32,8 @@
import abc
import collections
import six
from grpc.framework.base import _constants
from grpc.framework.base import _interfaces
from grpc.framework.base import exceptions
@ -72,9 +74,8 @@ class _EmptyConsumer(stream.Consumer):
"""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."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def create_consumer(self, requirement):

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

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
import abc
import six
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."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def abort_if_abortive(self, ticket):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
import abc
import six
from grpc.framework.base import _constants
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."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def ticketize(self, operation_id, sequence_number, payload, complete):
@ -187,9 +188,8 @@ class _BackTicketizer(_Ticketizer):
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."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_ingestion_and_expiration_managers(

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

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@ import abc
import threading
import uuid
import six
from grpc.framework.core import _operation
from grpc.framework.core import _utilities
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!'
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.
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
into tickets sent to a joined link.
"""
__metaclass__ = abc.ABCMeta
class _Cycle(object):

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

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

@ -31,6 +31,8 @@
import abc
import six
from grpc.framework.core import _constants
from grpc.framework.core import _interfaces
from grpc.framework.core import _utilities
@ -50,9 +52,8 @@ def _service_completion_predicate(
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."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def set_expiration_manager(self, expiration_manager):

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# 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):
return self
def __next__(self):
return self.next()
def next(self):
with self._condition:
while True:

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -29,6 +29,8 @@
"""Entry points into the Crust layer of RPC Framework."""
import six
from grpc.framework.common import cardinality
from grpc.framework.common import style
from grpc.framework.crust import _calls
@ -271,7 +273,7 @@ class _DynamicStub(face.DynamicStub):
def _adapt_method_implementations(method_implementations, pool):
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.cardinality is cardinality.Cardinality.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.
#
# Redistribution and use in source and binary forms, with or without
@ -120,6 +120,9 @@ class Rendezvous(stream.Consumer):
def __iter__(self):
return self
def __next__(self):
return self.next()
def next(self):
with self._condition:
while ((self._abortion is None) and

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
import abc
import six
class NoSuchMethodError(Exception):
"""Raised by customer code to indicate an unrecognized RPC method name.
@ -49,12 +51,11 @@ class NoSuchMethodError(Exception):
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.
Only RPC Framework should instantiate and raise these exceptions.
"""
__metaclass__ = abc.ABCMeta
class CancellationError(RpcError):

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

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

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

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# 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 six
class TimeoutError(Exception):
"""Indicates that a particular call timed out."""
@ -58,13 +60,12 @@ class CancelledError(Exception):
"""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.
Computations represented by a Future may be yet to be begun, may be ongoing,
or may have already completed.
"""
__metaclass__ = abc.ABCMeta
# 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

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# 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
thread pool.
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def add_value(self, value):

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

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

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

@ -33,6 +33,8 @@ import abc
import collections
import enum
import six
# cardinality, style, abandonment, future, and stream are
# referenced from specification in this module.
from grpc.framework.common import cardinality # pylint: disable=unused-import
@ -96,7 +98,7 @@ class Abortion(
REMOTE_FAILURE = 'remote failure'
class AbortionError(Exception):
class AbortionError(six.with_metaclass(abc.ABCMeta, Exception)):
"""Common super type for exceptions indicating RPC abortion.
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 value was received.
"""
__metaclass__ = abc.ABCMeta
def __init__(self, initial_metadata, terminal_metadata, code, details):
super(AbortionError, self).__init__()
@ -150,9 +151,8 @@ class RemoteError(AbortionError):
"""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."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def is_active(self):
@ -199,9 +199,8 @@ class RpcContext(object):
raise NotImplementedError()
class Call(RpcContext):
class Call(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""Invocation-side utility object for an RPC."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def initial_metadata(self):
@ -256,9 +255,8 @@ class Call(RpcContext):
raise NotImplementedError()
class ServicerContext(RpcContext):
class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)):
"""A context object passed to method implementations."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def invocation_metadata(self):
@ -326,9 +324,8 @@ class ServicerContext(RpcContext):
raise NotImplementedError()
class ResponseReceiver(object):
class ResponseReceiver(six.with_metaclass(abc.ABCMeta)):
"""Invocation-side object used to accept the output of an RPC."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def initial_metadata(self, initial_metadata):
@ -362,9 +359,8 @@ class ResponseReceiver(object):
raise NotImplementedError()
class UnaryUnaryMultiCallable(object):
class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-unary RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@ -434,9 +430,8 @@ class UnaryUnaryMultiCallable(object):
raise NotImplementedError()
class UnaryStreamMultiCallable(object):
class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a unary-stream RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(self, request, timeout, metadata=None, protocol_options=None):
@ -480,9 +475,8 @@ class UnaryStreamMultiCallable(object):
raise NotImplementedError()
class StreamUnaryMultiCallable(object):
class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-unary RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@ -553,9 +547,8 @@ class StreamUnaryMultiCallable(object):
raise NotImplementedError()
class StreamStreamMultiCallable(object):
class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)):
"""Affords invoking a stream-stream RPC in any call style."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __call__(
@ -600,7 +593,7 @@ class StreamStreamMultiCallable(object):
raise NotImplementedError()
class MethodImplementation(object):
class MethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A sum type that describes a method implementation.
Attributes:
@ -643,12 +636,10 @@ class MethodImplementation(object):
is cardinality.Cardinality.STREAM_STREAM and style is
style.Service.EVENT.
"""
__metaclass__ = abc.ABCMeta
class MultiMethodImplementation(object):
class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)):
"""A general type able to service many methods."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def service(self, group, method, response_consumer, context):
@ -678,9 +669,8 @@ class MultiMethodImplementation(object):
raise NotImplementedError()
class GenericStub(object):
class GenericStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via generic methods."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def blocking_unary_unary(
@ -977,7 +967,7 @@ class GenericStub(object):
raise NotImplementedError()
class DynamicStub(object):
class DynamicStub(six.with_metaclass(abc.ABCMeta)):
"""Affords RPC invocation via attributes corresponding to afforded methods.
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
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.
#
# Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@ import abc
import collections
import enum
import six
class Protocol(collections.namedtuple('Protocol', ('kind', 'value',))):
"""A sum type for handles to a system that transmits tickets.
@ -123,9 +125,8 @@ class Ticket(
REMOTE_FAILURE = 'remote failure'
class Link(object):
class Link(six.with_metaclass(abc.ABCMeta)):
"""Accepts and emits tickets."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def accept_ticket(self, ticket):

@ -81,7 +81,6 @@ CORE_SOURCE_FILES = [
'src/core/channel/channel_stack.c',
'src/core/channel/channel_stack_builder.c',
'src/core/channel/client_channel.c',
'src/core/channel/client_uchannel.c',
'src/core/channel/compress_filter.c',
'src/core/channel/connected_channel.c',
'src/core/channel/http_client_filter.c',
@ -146,6 +145,8 @@ CORE_SOURCE_FILES = [
'src/core/iomgr/timer.c',
'src/core/iomgr/timer_heap.c',
'src/core/iomgr/udp_server.c',
'src/core/iomgr/unix_sockets_posix.c',
'src/core/iomgr/unix_sockets_posix_noop.c',
'src/core/iomgr/wakeup_fd_eventfd.c',
'src/core/iomgr/wakeup_fd_nospecial.c',
'src/core/iomgr/wakeup_fd_pipe.c',

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# 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
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from __future__ import absolute_import
from tests import _loader
from tests import _runner

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# 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
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from __future__ import absolute_import
import importlib
import pkgutil
import re

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -27,7 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import cStringIO as StringIO
from __future__ import absolute_import
import collections
import itertools
import traceback
@ -35,6 +36,7 @@ import unittest
from xml.etree import ElementTree
import coverage
from six import moves
from tests import _loader
@ -356,7 +358,7 @@ def _traceback_string(type, value, trace):
Returns:
str: Formatted exception descriptive string.
"""
buffer = StringIO.StringIO()
buffer = moves.cStringIO()
traceback.print_exception(type, value, trace, file=buffer)
return buffer.getvalue()

@ -27,7 +27,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import cStringIO as StringIO
from __future__ import absolute_import
import collections
import fcntl
import multiprocessing
@ -41,6 +42,8 @@ import time
import unittest
import uuid
from six import moves
from tests import _loader
from tests import _result
@ -143,7 +146,7 @@ class Runner(object):
for case in filtered_cases]
case_id_by_case = dict((augmented_case.case, augmented_case.id)
for augmented_case in augmented_cases)
result_out = StringIO.StringIO()
result_out = moves.cStringIO()
result = _result.TerminalResult(
result_out, id_map=lambda case: case_id_by_case[case])
stdout_pipe = CaptureFile(sys.stdout.fileno())

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

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

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

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

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -32,13 +32,14 @@
import abc
import threading
import six
from tests.unit._junkdrawer import math_pb2
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."""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def group_and_method(self):

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

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

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

@ -1,4 +1,4 @@
# Copyright 2015, Google Inc.
# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -33,6 +33,8 @@ import abc
import contextlib
import threading
import six
class Defect(Exception):
"""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.
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.
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def control(self):
"""Potentially does anything."""

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

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

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

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

Loading…
Cancel
Save