Merge branch 'master' of https://github.com/grpc/grpc into channel-trace-size

pull/16767/head
ncteisen 6 years ago
commit 867192e29e
  1. 2
      BUILD
  2. 10
      CMakeLists.txt
  3. 10
      Makefile
  4. 2
      build.yaml
  5. 2
      gRPC-C++.podspec
  6. 2
      include/grpc/impl/codegen/grpc_types.h
  7. 14
      include/grpcpp/channel.h
  8. 21
      include/grpcpp/create_channel.h
  9. 17
      include/grpcpp/create_channel_posix.h
  10. 44
      include/grpcpp/impl/codegen/client_interceptor.h
  11. 67
      include/grpcpp/impl/codegen/interceptor.h
  12. 32
      include/grpcpp/security/credentials.h
  13. 25
      include/grpcpp/server.h
  14. 1
      src/core/ext/filters/client_channel/http_connect_handshaker.cc
  15. 6
      src/core/ext/filters/client_channel/subchannel.cc
  16. 2
      src/core/ext/transport/chttp2/client/chttp2_connector.cc
  17. 8
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  18. 9
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  19. 9
      src/core/lib/channel/channelz.h
  20. 5
      src/core/lib/channel/handshaker_factory.cc
  21. 2
      src/core/lib/channel/handshaker_factory.h
  22. 8
      src/core/lib/channel/handshaker_registry.cc
  23. 1
      src/core/lib/channel/handshaker_registry.h
  24. 3
      src/core/lib/http/httpcli_security_connector.cc
  25. 12
      src/core/lib/security/security_connector/alts_security_connector.cc
  26. 7
      src/core/lib/security/security_connector/security_connector.cc
  27. 5
      src/core/lib/security/security_connector/security_connector.h
  28. 10
      src/core/lib/security/transport/security_handshaker.cc
  29. 9
      src/core/lib/surface/channel.cc
  30. 7
      src/core/lib/surface/server.cc
  31. 3
      src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc
  32. 5
      src/core/tsi/alts/handshaker/alts_tsi_handshaker.h
  33. 10
      src/cpp/client/channel_cc.cc
  34. 42
      src/cpp/client/create_channel.cc
  35. 10
      src/cpp/client/create_channel_internal.cc
  36. 8
      src/cpp/client/create_channel_internal.h
  37. 28
      src/cpp/client/create_channel_posix.cc
  38. 19
      src/cpp/client/cronet_credentials.cc
  39. 11
      src/cpp/client/insecure_credentials.cc
  40. 12
      src/cpp/client/secure_credentials.cc
  41. 6
      src/cpp/client/secure_credentials.h
  42. 16
      src/cpp/server/server_cc.cc
  43. 4
      src/csharp/experimental/README.md
  44. 1
      test/core/handshake/readahead_handshaker_server_ssl.cc
  45. 5
      test/core/iomgr/resolve_address_test.cc
  46. 2
      test/core/tsi/alts/handshaker/alts_tsi_handshaker_test.cc
  47. 6
      test/cpp/microbenchmarks/bm_call_create.cc
  48. 2
      test/cpp/microbenchmarks/fullstack_fixtures.h
  49. 2
      test/cpp/performance/writes_per_rpc_test.cc
  50. 20
      test/cpp/util/BUILD
  51. 2
      test/cpp/util/cli_credentials.cc
  52. 2
      tools/doxygen/Doxyfile.c++
  53. 2
      tools/doxygen/Doxyfile.c++.internal
  54. 4
      tools/run_tests/generated/sources_and_headers.json

@ -1982,6 +1982,7 @@ grpc_cc_library(
"include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/channel_interface.h",
"include/grpcpp/impl/codegen/client_callback.h", "include/grpcpp/impl/codegen/client_callback.h",
"include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context.h",
"include/grpcpp/impl/codegen/client_interceptor.h",
"include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/client_unary_call.h",
"include/grpcpp/impl/codegen/completion_queue.h", "include/grpcpp/impl/codegen/completion_queue.h",
"include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/completion_queue_tag.h",
@ -1989,6 +1990,7 @@ grpc_cc_library(
"include/grpcpp/impl/codegen/core_codegen_interface.h", "include/grpcpp/impl/codegen/core_codegen_interface.h",
"include/grpcpp/impl/codegen/create_auth_context.h", "include/grpcpp/impl/codegen/create_auth_context.h",
"include/grpcpp/impl/codegen/grpc_library.h", "include/grpcpp/impl/codegen/grpc_library.h",
"include/grpcpp/impl/codegen/interceptor.h",
"include/grpcpp/impl/codegen/metadata_map.h", "include/grpcpp/impl/codegen/metadata_map.h",
"include/grpcpp/impl/codegen/method_handler_impl.h", "include/grpcpp/impl/codegen/method_handler_impl.h",
"include/grpcpp/impl/codegen/rpc_method.h", "include/grpcpp/impl/codegen/rpc_method.h",

@ -3075,6 +3075,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/channel_interface.h
include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_callback.h
include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context.h
include/grpcpp/impl/codegen/client_interceptor.h
include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/client_unary_call.h
include/grpcpp/impl/codegen/completion_queue.h include/grpcpp/impl/codegen/completion_queue.h
include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/completion_queue_tag.h
@ -3082,6 +3083,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/core_codegen_interface.h
include/grpcpp/impl/codegen/create_auth_context.h include/grpcpp/impl/codegen/create_auth_context.h
include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/grpc_library.h
include/grpcpp/impl/codegen/interceptor.h
include/grpcpp/impl/codegen/metadata_map.h include/grpcpp/impl/codegen/metadata_map.h
include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/method_handler_impl.h
include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_method.h
@ -3644,6 +3646,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/channel_interface.h
include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_callback.h
include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context.h
include/grpcpp/impl/codegen/client_interceptor.h
include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/client_unary_call.h
include/grpcpp/impl/codegen/completion_queue.h include/grpcpp/impl/codegen/completion_queue.h
include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/completion_queue_tag.h
@ -3651,6 +3654,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/core_codegen_interface.h
include/grpcpp/impl/codegen/create_auth_context.h include/grpcpp/impl/codegen/create_auth_context.h
include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/grpc_library.h
include/grpcpp/impl/codegen/interceptor.h
include/grpcpp/impl/codegen/metadata_map.h include/grpcpp/impl/codegen/metadata_map.h
include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/method_handler_impl.h
include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_method.h
@ -4051,6 +4055,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/channel_interface.h
include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_callback.h
include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context.h
include/grpcpp/impl/codegen/client_interceptor.h
include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/client_unary_call.h
include/grpcpp/impl/codegen/completion_queue.h include/grpcpp/impl/codegen/completion_queue.h
include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/completion_queue_tag.h
@ -4058,6 +4063,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/core_codegen_interface.h
include/grpcpp/impl/codegen/create_auth_context.h include/grpcpp/impl/codegen/create_auth_context.h
include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/grpc_library.h
include/grpcpp/impl/codegen/interceptor.h
include/grpcpp/impl/codegen/metadata_map.h include/grpcpp/impl/codegen/metadata_map.h
include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/method_handler_impl.h
include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_method.h
@ -4230,6 +4236,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/channel_interface.h
include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_callback.h
include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context.h
include/grpcpp/impl/codegen/client_interceptor.h
include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/client_unary_call.h
include/grpcpp/impl/codegen/completion_queue.h include/grpcpp/impl/codegen/completion_queue.h
include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/completion_queue_tag.h
@ -4237,6 +4244,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/core_codegen_interface.h
include/grpcpp/impl/codegen/create_auth_context.h include/grpcpp/impl/codegen/create_auth_context.h
include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/grpc_library.h
include/grpcpp/impl/codegen/interceptor.h
include/grpcpp/impl/codegen/metadata_map.h include/grpcpp/impl/codegen/metadata_map.h
include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/method_handler_impl.h
include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_method.h
@ -4550,6 +4558,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/channel_interface.h include/grpcpp/impl/codegen/channel_interface.h
include/grpcpp/impl/codegen/client_callback.h include/grpcpp/impl/codegen/client_callback.h
include/grpcpp/impl/codegen/client_context.h include/grpcpp/impl/codegen/client_context.h
include/grpcpp/impl/codegen/client_interceptor.h
include/grpcpp/impl/codegen/client_unary_call.h include/grpcpp/impl/codegen/client_unary_call.h
include/grpcpp/impl/codegen/completion_queue.h include/grpcpp/impl/codegen/completion_queue.h
include/grpcpp/impl/codegen/completion_queue_tag.h include/grpcpp/impl/codegen/completion_queue_tag.h
@ -4557,6 +4566,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/core_codegen_interface.h include/grpcpp/impl/codegen/core_codegen_interface.h
include/grpcpp/impl/codegen/create_auth_context.h include/grpcpp/impl/codegen/create_auth_context.h
include/grpcpp/impl/codegen/grpc_library.h include/grpcpp/impl/codegen/grpc_library.h
include/grpcpp/impl/codegen/interceptor.h
include/grpcpp/impl/codegen/metadata_map.h include/grpcpp/impl/codegen/metadata_map.h
include/grpcpp/impl/codegen/method_handler_impl.h include/grpcpp/impl/codegen/method_handler_impl.h
include/grpcpp/impl/codegen/rpc_method.h include/grpcpp/impl/codegen/rpc_method.h

@ -5428,6 +5428,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/channel_interface.h \
include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_callback.h \
include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context.h \
include/grpcpp/impl/codegen/client_interceptor.h \
include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/client_unary_call.h \
include/grpcpp/impl/codegen/completion_queue.h \ include/grpcpp/impl/codegen/completion_queue.h \
include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \
@ -5435,6 +5436,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \ include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/metadata_map.h \ include/grpcpp/impl/codegen/metadata_map.h \
include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/method_handler_impl.h \
include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_method.h \
@ -6006,6 +6008,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/channel_interface.h \
include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_callback.h \
include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context.h \
include/grpcpp/impl/codegen/client_interceptor.h \
include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/client_unary_call.h \
include/grpcpp/impl/codegen/completion_queue.h \ include/grpcpp/impl/codegen/completion_queue.h \
include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \
@ -6013,6 +6016,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \ include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/metadata_map.h \ include/grpcpp/impl/codegen/metadata_map.h \
include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/method_handler_impl.h \
include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_method.h \
@ -6398,6 +6402,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/channel_interface.h \
include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_callback.h \
include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context.h \
include/grpcpp/impl/codegen/client_interceptor.h \
include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/client_unary_call.h \
include/grpcpp/impl/codegen/completion_queue.h \ include/grpcpp/impl/codegen/completion_queue.h \
include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \
@ -6405,6 +6410,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \ include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/metadata_map.h \ include/grpcpp/impl/codegen/metadata_map.h \
include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/method_handler_impl.h \
include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_method.h \
@ -6554,6 +6560,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/channel_interface.h \
include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_callback.h \
include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context.h \
include/grpcpp/impl/codegen/client_interceptor.h \
include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/client_unary_call.h \
include/grpcpp/impl/codegen/completion_queue.h \ include/grpcpp/impl/codegen/completion_queue.h \
include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \
@ -6561,6 +6568,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \ include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/metadata_map.h \ include/grpcpp/impl/codegen/metadata_map.h \
include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/method_handler_impl.h \
include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_method.h \
@ -6879,6 +6887,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/channel_interface.h \
include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_callback.h \
include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context.h \
include/grpcpp/impl/codegen/client_interceptor.h \
include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/client_unary_call.h \
include/grpcpp/impl/codegen/completion_queue.h \ include/grpcpp/impl/codegen/completion_queue.h \
include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \
@ -6886,6 +6895,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \ include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/metadata_map.h \ include/grpcpp/impl/codegen/metadata_map.h \
include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/method_handler_impl.h \
include/grpcpp/impl/codegen/rpc_method.h \ include/grpcpp/impl/codegen/rpc_method.h \

@ -1171,6 +1171,7 @@ filegroups:
- include/grpcpp/impl/codegen/channel_interface.h - include/grpcpp/impl/codegen/channel_interface.h
- include/grpcpp/impl/codegen/client_callback.h - include/grpcpp/impl/codegen/client_callback.h
- include/grpcpp/impl/codegen/client_context.h - include/grpcpp/impl/codegen/client_context.h
- include/grpcpp/impl/codegen/client_interceptor.h
- include/grpcpp/impl/codegen/client_unary_call.h - include/grpcpp/impl/codegen/client_unary_call.h
- include/grpcpp/impl/codegen/completion_queue.h - include/grpcpp/impl/codegen/completion_queue.h
- include/grpcpp/impl/codegen/completion_queue_tag.h - include/grpcpp/impl/codegen/completion_queue_tag.h
@ -1178,6 +1179,7 @@ filegroups:
- include/grpcpp/impl/codegen/core_codegen_interface.h - include/grpcpp/impl/codegen/core_codegen_interface.h
- include/grpcpp/impl/codegen/create_auth_context.h - include/grpcpp/impl/codegen/create_auth_context.h
- include/grpcpp/impl/codegen/grpc_library.h - include/grpcpp/impl/codegen/grpc_library.h
- include/grpcpp/impl/codegen/interceptor.h
- include/grpcpp/impl/codegen/metadata_map.h - include/grpcpp/impl/codegen/metadata_map.h
- include/grpcpp/impl/codegen/method_handler_impl.h - include/grpcpp/impl/codegen/method_handler_impl.h
- include/grpcpp/impl/codegen/rpc_method.h - include/grpcpp/impl/codegen/rpc_method.h

@ -132,6 +132,7 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/codegen/channel_interface.h', 'include/grpcpp/impl/codegen/channel_interface.h',
'include/grpcpp/impl/codegen/client_callback.h', 'include/grpcpp/impl/codegen/client_callback.h',
'include/grpcpp/impl/codegen/client_context.h', 'include/grpcpp/impl/codegen/client_context.h',
'include/grpcpp/impl/codegen/client_interceptor.h',
'include/grpcpp/impl/codegen/client_unary_call.h', 'include/grpcpp/impl/codegen/client_unary_call.h',
'include/grpcpp/impl/codegen/completion_queue.h', 'include/grpcpp/impl/codegen/completion_queue.h',
'include/grpcpp/impl/codegen/completion_queue_tag.h', 'include/grpcpp/impl/codegen/completion_queue_tag.h',
@ -139,6 +140,7 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/codegen/core_codegen_interface.h', 'include/grpcpp/impl/codegen/core_codegen_interface.h',
'include/grpcpp/impl/codegen/create_auth_context.h', 'include/grpcpp/impl/codegen/create_auth_context.h',
'include/grpcpp/impl/codegen/grpc_library.h', 'include/grpcpp/impl/codegen/grpc_library.h',
'include/grpcpp/impl/codegen/interceptor.h',
'include/grpcpp/impl/codegen/metadata_map.h', 'include/grpcpp/impl/codegen/metadata_map.h',
'include/grpcpp/impl/codegen/method_handler_impl.h', 'include/grpcpp/impl/codegen/method_handler_impl.h',
'include/grpcpp/impl/codegen/rpc_method.h', 'include/grpcpp/impl/codegen/rpc_method.h',

@ -290,7 +290,7 @@ typedef struct {
* oldest events from the buffer. The unit for this knob is bytes. Setting * oldest events from the buffer. The unit for this knob is bytes. Setting
* it to zero causes channel tracing to be disabled. */ * it to zero causes channel tracing to be disabled. */
#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \ #define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \
"grpc.max_channel_trace_events_per_node" "grpc.max_channel_trace_event_memory_per_node"
/** If non-zero, gRPC library will track stats and information at at per channel /** If non-zero, gRPC library will track stats and information at at per channel
* level. Disabling channelz naturally disables channel tracing. The default * level. Disabling channelz naturally disables channel tracing. The default
* is for channelz to be disabled. */ * is for channelz to be disabled. */

@ -24,6 +24,7 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpcpp/impl/call.h> #include <grpcpp/impl/call.h>
#include <grpcpp/impl/codegen/channel_interface.h> #include <grpcpp/impl/codegen/channel_interface.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/impl/codegen/config.h> #include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/grpc_library.h> #include <grpcpp/impl/codegen/grpc_library.h>
@ -62,8 +63,14 @@ class Channel final : public ChannelInterface,
friend class internal::BlockingUnaryCallImpl; friend class internal::BlockingUnaryCallImpl;
friend void experimental::ChannelResetConnectionBackoff(Channel* channel); friend void experimental::ChannelResetConnectionBackoff(Channel* channel);
friend std::shared_ptr<Channel> CreateChannelInternal( friend std::shared_ptr<Channel> CreateChannelInternal(
const grpc::string& host, grpc_channel* c_channel); const grpc::string& host, grpc_channel* c_channel,
Channel(const grpc::string& host, grpc_channel* c_channel); std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
Channel(const grpc::string& host, grpc_channel* c_channel,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
internal::Call CreateCall(const internal::RpcMethod& method, internal::Call CreateCall(const internal::RpcMethod& method,
ClientContext* context, ClientContext* context,
@ -91,6 +98,9 @@ class Channel final : public ChannelInterface,
// It is _not owned_ by the channel; ownership belongs with its internal // It is _not owned_ by the channel; ownership belongs with its internal
// shutdown callback tag (invoked when the CQ is fully shutdown). // shutdown callback tag (invoked when the CQ is fully shutdown).
CompletionQueue* callback_cq_ = nullptr; CompletionQueue* callback_cq_ = nullptr;
std::vector<std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
interceptor_creators_;
}; };
} // namespace grpc } // namespace grpc

@ -22,6 +22,7 @@
#include <memory> #include <memory>
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/security/credentials.h> #include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h> #include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/config.h> #include <grpcpp/support/config.h>
@ -53,6 +54,26 @@ std::shared_ptr<Channel> CreateCustomChannel(
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args); const ChannelArguments& args);
namespace experimental {
/// Create a new \em custom \a Channel pointing to \a target with \a
/// interceptors being invoked per call.
///
/// \warning For advanced use and testing ONLY. Override default channel
/// arguments only if necessary.
///
/// \param target The URI of the endpoint to connect to.
/// \param creds Credentials to use for the created channel. If it does not
/// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned.
/// \param args Options for channel creation.
std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
} // namespace experimental
} // namespace grpc } // namespace grpc
#endif // GRPCPP_CREATE_CHANNEL_H #endif // GRPCPP_CREATE_CHANNEL_H

@ -45,6 +45,23 @@ std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target,
std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd( std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
const grpc::string& target, int fd, const ChannelArguments& args); const grpc::string& target, int fd, const ChannelArguments& args);
namespace experimental {
/// Create a new \a Channel communicating over given file descriptor with custom
/// channel arguments.
///
/// \param target The name of the target.
/// \param fd The file descriptor representing a socket.
/// \param args Options for channel creation.
/// \param interceptor_creators Vector of interceptor factory objects.
std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
const grpc::string& target, int fd, const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
} // namespace experimental
#endif // GPR_SUPPORT_CHANNELS_FROM_FD #endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc } // namespace grpc

@ -0,0 +1,44 @@
/*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H
#define GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H
#include <grpcpp/impl/codegen/interceptor.h>
namespace grpc {
namespace experimental {
class ClientInterceptor {
public:
virtual ~ClientInterceptor() {}
virtual void Intercept(InterceptorBatchMethods* methods) = 0;
};
class ClientRpcInfo {};
class ClientInterceptorFactoryInterface {
public:
virtual ~ClientInterceptorFactoryInterface() {}
virtual ClientInterceptor* CreateClientInterceptor(ClientRpcInfo* info) = 0;
};
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H

@ -0,0 +1,67 @@
/*
*
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H
#define GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H
namespace grpc {
namespace experimental {
class InterceptedMessage {
public:
template <class M>
bool Extract(M* msg); // returns false if definitely invalid extraction
template <class M>
M* MutableExtract();
uint64_t length(); // length on wire
};
enum class InterceptionHookPoints {
/* The first two in this list are for clients and servers */
PRE_SEND_INITIAL_METADATA,
PRE_SEND_MESSAGE,
PRE_SEND_STATUS /* server only */,
/* The following three are for hijacked clients only and can only be
registered by the global interceptor */
PRE_RECV_INITIAL_METADATA,
PRE_RECV_MESSAGE,
PRE_RECV_STATUS,
/* The following two are for all clients and servers */
POST_RECV_INITIAL_METADATA,
POST_RECV_MESSAGE,
POST_RECV_STATUS /* client only */,
POST_RECV_CLOSE /* server only */,
NUM_INTERCEPTION_HOOKS
};
class InterceptorBatchMethods {
public:
virtual ~InterceptorBatchMethods();
// Queries to check whether the current batch has an interception hook point
// of type \a type
virtual bool QueryInterceptionHookPoint(InterceptionHookPoints type) = 0;
// Calling this will signal that the interceptor is done intercepting the
// current batch of the RPC
virtual void Proceed() = 0;
// Calling this indicates that the interceptor has hijacked the RPC (only
// valid if the batch contains send_initial_metadata on the client side)
virtual void Hijack() = 0;
};
} // namespace experimental
} // namespace grpc
#endif // GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H

@ -24,6 +24,7 @@
#include <vector> #include <vector>
#include <grpc/grpc_security_constants.h> #include <grpc/grpc_security_constants.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/impl/codegen/grpc_library.h> #include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/security/auth_context.h> #include <grpcpp/security/auth_context.h>
#include <grpcpp/support/status.h> #include <grpcpp/support/status.h>
@ -38,6 +39,18 @@ class SecureChannelCredentials;
class CallCredentials; class CallCredentials;
class SecureCallCredentials; class SecureCallCredentials;
class ChannelCredentials;
namespace experimental {
std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
} // namespace experimental
/// A channel credentials object encapsulates all the state needed by a client /// A channel credentials object encapsulates all the state needed by a client
/// to authenticate with a server for a given channel. /// to authenticate with a server for a given channel.
/// It can make various assertions, e.g., about the client’s identity, role /// It can make various assertions, e.g., about the client’s identity, role
@ -62,8 +75,27 @@ class ChannelCredentials : private GrpcLibraryCodegen {
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args); const ChannelArguments& args);
friend std::shared_ptr<Channel>
experimental::CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
virtual std::shared_ptr<Channel> CreateChannel( virtual std::shared_ptr<Channel> CreateChannel(
const grpc::string& target, const ChannelArguments& args) = 0; const grpc::string& target, const ChannelArguments& args) = 0;
// This function should have been a pure virtual function, but it is
// implemented as a virtual function so that it does not break API.
virtual std::shared_ptr<Channel> CreateChannelWithInterceptors(
const grpc::string& target, const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) {
return nullptr;
};
}; };
/// A call credentials object encapsulates the state needed by a client to /// A call credentials object encapsulates the state needed by a client to

@ -28,6 +28,7 @@
#include <grpc/compression.h> #include <grpc/compression.h>
#include <grpcpp/completion_queue.h> #include <grpcpp/completion_queue.h>
#include <grpcpp/impl/call.h> #include <grpcpp/impl/call.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/impl/codegen/grpc_library.h> #include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/impl/codegen/server_interface.h> #include <grpcpp/impl/codegen/server_interface.h>
#include <grpcpp/impl/rpc_service_method.h> #include <grpcpp/impl/rpc_service_method.h>
@ -99,6 +100,30 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
/// Establish a channel for in-process communication /// Establish a channel for in-process communication
std::shared_ptr<Channel> InProcessChannel(const ChannelArguments& args); std::shared_ptr<Channel> InProcessChannel(const ChannelArguments& args);
/// NOTE: class experimental_type is not part of the public API of this class.
/// TODO(yashykt): Integrate into public API when this is no longer
/// experimental.
class experimental_type {
public:
explicit experimental_type(Server* server) : server_(server) {}
/// Establish a channel for in-process communication with client
/// interceptors
std::shared_ptr<Channel> InProcessChannelWithInterceptors(
const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
private:
Server* server_;
};
/// NOTE: The function experimental() is not stable public API. It is a view
/// to the experimental components of this class. It may be changed or removed
/// at any time.
experimental_type experimental() { return experimental_type(this); }
protected: protected:
/// Register a service. This call does not take ownership of the service. /// Register a service. This call does not take ownership of the service.
/// The service must exist for the lifetime of the Server instance. /// The service must exist for the lifetime of the Server instance.

@ -351,6 +351,7 @@ static grpc_handshaker* grpc_http_connect_handshaker_create() {
static void handshaker_factory_add_handshakers( static void handshaker_factory_add_handshakers(
grpc_handshaker_factory* factory, const grpc_channel_args* args, grpc_handshaker_factory* factory, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) { grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(handshake_mgr, grpc_handshake_manager_add(handshake_mgr,
grpc_http_connect_handshaker_create()); grpc_http_connect_handshaker_create());

@ -388,10 +388,12 @@ grpc_subchannel* grpc_subchannel_create(grpc_connector* connector,
const grpc_arg* arg = const grpc_arg* arg =
grpc_channel_args_find(c->args, GRPC_ARG_ENABLE_CHANNELZ); grpc_channel_args_find(c->args, GRPC_ARG_ENABLE_CHANNELZ);
bool channelz_enabled = grpc_channel_arg_get_bool(arg, false); bool channelz_enabled =
grpc_channel_arg_get_bool(arg, GRPC_ENABLE_CHANNELZ_DEFAULT);
arg = grpc_channel_args_find( arg = grpc_channel_args_find(
c->args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE); c->args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE);
const grpc_integer_options options = {0, 0, INT_MAX}; const grpc_integer_options options = {
GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX};
size_t channel_tracer_max_memory = size_t channel_tracer_max_memory =
(size_t)grpc_channel_arg_get_integer(arg, options); (size_t)grpc_channel_arg_get_integer(arg, options);
if (channelz_enabled) { if (channelz_enabled) {

@ -160,7 +160,7 @@ static void on_handshake_done(void* arg, grpc_error* error) {
static void start_handshake_locked(chttp2_connector* c) { static void start_handshake_locked(chttp2_connector* c) {
c->handshake_mgr = grpc_handshake_manager_create(); c->handshake_mgr = grpc_handshake_manager_create();
grpc_handshakers_add(HANDSHAKER_CLIENT, c->args.channel_args, grpc_handshakers_add(HANDSHAKER_CLIENT, c->args.channel_args,
c->handshake_mgr); c->args.interested_parties, c->handshake_mgr);
grpc_endpoint_add_to_pollset_set(c->endpoint, c->args.interested_parties); grpc_endpoint_add_to_pollset_set(c->endpoint, c->args.interested_parties);
grpc_handshake_manager_do_handshake( grpc_handshake_manager_do_handshake(
c->handshake_mgr, c->args.interested_parties, c->endpoint, c->handshake_mgr, c->args.interested_parties, c->endpoint,

@ -67,6 +67,7 @@ typedef struct {
grpc_timer timer; grpc_timer timer;
grpc_closure on_timeout; grpc_closure on_timeout;
grpc_closure on_receive_settings; grpc_closure on_receive_settings;
grpc_pollset_set* interested_parties;
} server_connection_state; } server_connection_state;
static void server_connection_state_unref( static void server_connection_state_unref(
@ -76,6 +77,9 @@ static void server_connection_state_unref(
GRPC_CHTTP2_UNREF_TRANSPORT(connection_state->transport, GRPC_CHTTP2_UNREF_TRANSPORT(connection_state->transport,
"receive settings timeout"); "receive settings timeout");
} }
grpc_pollset_set_del_pollset(connection_state->interested_parties,
connection_state->accepting_pollset);
grpc_pollset_set_destroy(connection_state->interested_parties);
gpr_free(connection_state); gpr_free(connection_state);
} }
} }
@ -189,7 +193,11 @@ static void on_accept(void* arg, grpc_endpoint* tcp,
connection_state->accepting_pollset = accepting_pollset; connection_state->accepting_pollset = accepting_pollset;
connection_state->acceptor = acceptor; connection_state->acceptor = acceptor;
connection_state->handshake_mgr = handshake_mgr; connection_state->handshake_mgr = handshake_mgr;
connection_state->interested_parties = grpc_pollset_set_create();
grpc_pollset_set_add_pollset(connection_state->interested_parties,
connection_state->accepting_pollset);
grpc_handshakers_add(HANDSHAKER_SERVER, state->args, grpc_handshakers_add(HANDSHAKER_SERVER, state->args,
connection_state->interested_parties,
connection_state->handshake_mgr); connection_state->handshake_mgr);
const grpc_arg* timeout_arg = const grpc_arg* timeout_arg =
grpc_channel_args_find(state->args, GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS); grpc_channel_args_find(state->args, GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS);

@ -239,6 +239,7 @@ static bool read_channel_args(grpc_chttp2_transport* t,
const grpc_channel_args* channel_args, const grpc_channel_args* channel_args,
bool is_client) { bool is_client) {
bool enable_bdp = true; bool enable_bdp = true;
bool channelz_enabled = GRPC_ENABLE_CHANNELZ_DEFAULT;
size_t i; size_t i;
int j; int j;
@ -341,8 +342,8 @@ static bool read_channel_args(grpc_chttp2_transport* t,
} }
} else if (0 == } else if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_ENABLE_CHANNELZ)) { strcmp(channel_args->args[i].key, GRPC_ARG_ENABLE_CHANNELZ)) {
t->channelz_socket = channelz_enabled = grpc_channel_arg_get_bool(
grpc_core::MakeRefCounted<grpc_core::channelz::SocketNode>(); &channel_args->args[i], GRPC_ENABLE_CHANNELZ_DEFAULT);
} else { } else {
static const struct { static const struct {
const char* channel_arg_name; const char* channel_arg_name;
@ -393,6 +394,10 @@ static bool read_channel_args(grpc_chttp2_transport* t,
} }
} }
} }
if (channelz_enabled) {
t->channelz_socket =
grpc_core::MakeRefCounted<grpc_core::channelz::SocketNode>();
}
return enable_bdp; return enable_bdp;
} }

@ -39,6 +39,15 @@
#define GRPC_ARG_CHANNELZ_CHANNEL_IS_INTERNAL_CHANNEL \ #define GRPC_ARG_CHANNELZ_CHANNEL_IS_INTERNAL_CHANNEL \
"grpc.channelz_channel_is_internal_channel" "grpc.channelz_channel_is_internal_channel"
/** This is the default value for whether or not to enable channelz. If
* GRPC_ARG_ENABLE_CHANNELZ is set, it will override this default value. */
#define GRPC_ENABLE_CHANNELZ_DEFAULT false
/** This is the default value for TODO. If
* GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE is set, it will override
* this default value. */
#define GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT 0
namespace grpc_core { namespace grpc_core {
namespace channelz { namespace channelz {

@ -24,11 +24,12 @@
void grpc_handshaker_factory_add_handshakers( void grpc_handshaker_factory_add_handshakers(
grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args, grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) { grpc_handshake_manager* handshake_mgr) {
if (handshaker_factory != nullptr) { if (handshaker_factory != nullptr) {
GPR_ASSERT(handshaker_factory->vtable != nullptr); GPR_ASSERT(handshaker_factory->vtable != nullptr);
handshaker_factory->vtable->add_handshakers(handshaker_factory, args, handshaker_factory->vtable->add_handshakers(
handshake_mgr); handshaker_factory, args, interested_parties, handshake_mgr);
} }
} }

@ -32,6 +32,7 @@ typedef struct grpc_handshaker_factory grpc_handshaker_factory;
typedef struct { typedef struct {
void (*add_handshakers)(grpc_handshaker_factory* handshaker_factory, void (*add_handshakers)(grpc_handshaker_factory* handshaker_factory,
const grpc_channel_args* args, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr); grpc_handshake_manager* handshake_mgr);
void (*destroy)(grpc_handshaker_factory* handshaker_factory); void (*destroy)(grpc_handshaker_factory* handshaker_factory);
} grpc_handshaker_factory_vtable; } grpc_handshaker_factory_vtable;
@ -42,6 +43,7 @@ struct grpc_handshaker_factory {
void grpc_handshaker_factory_add_handshakers( void grpc_handshaker_factory_add_handshakers(
grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args, grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr); grpc_handshake_manager* handshake_mgr);
void grpc_handshaker_factory_destroy( void grpc_handshaker_factory_destroy(

@ -51,9 +51,11 @@ static void grpc_handshaker_factory_list_register(
static void grpc_handshaker_factory_list_add_handshakers( static void grpc_handshaker_factory_list_add_handshakers(
grpc_handshaker_factory_list* list, const grpc_channel_args* args, grpc_handshaker_factory_list* list, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) { grpc_handshake_manager* handshake_mgr) {
for (size_t i = 0; i < list->num_factories; ++i) { for (size_t i = 0; i < list->num_factories; ++i) {
grpc_handshaker_factory_add_handshakers(list->list[i], args, handshake_mgr); grpc_handshaker_factory_add_handshakers(list->list[i], args,
interested_parties, handshake_mgr);
} }
} }
@ -91,7 +93,9 @@ void grpc_handshaker_factory_register(bool at_start,
void grpc_handshakers_add(grpc_handshaker_type handshaker_type, void grpc_handshakers_add(grpc_handshaker_type handshaker_type,
const grpc_channel_args* args, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) { grpc_handshake_manager* handshake_mgr) {
grpc_handshaker_factory_list_add_handshakers( grpc_handshaker_factory_list_add_handshakers(
&g_handshaker_factory_lists[handshaker_type], args, handshake_mgr); &g_handshaker_factory_lists[handshaker_type], args, interested_parties,
handshake_mgr);
} }

@ -43,6 +43,7 @@ void grpc_handshaker_factory_register(bool at_start,
void grpc_handshakers_add(grpc_handshaker_type handshaker_type, void grpc_handshakers_add(grpc_handshaker_type handshaker_type,
const grpc_channel_args* args, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr); grpc_handshake_manager* handshake_mgr);
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */ #endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */

@ -189,7 +189,8 @@ static void ssl_handshake(void* arg, grpc_endpoint* tcp, const char* host,
grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base); grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base);
grpc_channel_args args = {1, &channel_arg}; grpc_channel_args args = {1, &channel_arg};
c->handshake_mgr = grpc_handshake_manager_create(); c->handshake_mgr = grpc_handshake_manager_create();
grpc_handshakers_add(HANDSHAKER_CLIENT, &args, c->handshake_mgr); grpc_handshakers_add(HANDSHAKER_CLIENT, &args,
nullptr /* interested_parties */, c->handshake_mgr);
grpc_handshake_manager_do_handshake( grpc_handshake_manager_do_handshake(
c->handshake_mgr, nullptr /* interested_parties */, tcp, c->handshake_mgr, nullptr /* interested_parties */, tcp,
nullptr /* channel_args */, deadline, nullptr /* acceptor */, nullptr /* channel_args */, deadline, nullptr /* acceptor */,

@ -70,9 +70,9 @@ static void alts_channel_add_handshakers(
auto c = reinterpret_cast<grpc_alts_channel_security_connector*>(sc); auto c = reinterpret_cast<grpc_alts_channel_security_connector*>(sc);
grpc_alts_credentials* creds = grpc_alts_credentials* creds =
reinterpret_cast<grpc_alts_credentials*>(c->base.channel_creds); reinterpret_cast<grpc_alts_credentials*>(c->base.channel_creds);
GPR_ASSERT(alts_tsi_handshaker_create(creds->options, c->target_name, GPR_ASSERT(alts_tsi_handshaker_create(
creds->handshaker_service_url, true, creds->options, c->target_name, creds->handshaker_service_url,
&handshaker) == TSI_OK); true, sc->base.interested_parties, &handshaker) == TSI_OK);
grpc_handshake_manager_add(handshake_manager, grpc_security_handshaker_create( grpc_handshake_manager_add(handshake_manager, grpc_security_handshaker_create(
handshaker, &sc->base)); handshaker, &sc->base));
} }
@ -84,9 +84,9 @@ static void alts_server_add_handshakers(
auto c = reinterpret_cast<grpc_alts_server_security_connector*>(sc); auto c = reinterpret_cast<grpc_alts_server_security_connector*>(sc);
grpc_alts_server_credentials* creds = grpc_alts_server_credentials* creds =
reinterpret_cast<grpc_alts_server_credentials*>(c->base.server_creds); reinterpret_cast<grpc_alts_server_credentials*>(c->base.server_creds);
GPR_ASSERT(alts_tsi_handshaker_create(creds->options, nullptr, GPR_ASSERT(alts_tsi_handshaker_create(
creds->handshaker_service_url, false, creds->options, nullptr, creds->handshaker_service_url, false,
&handshaker) == TSI_OK); sc->base.interested_parties, &handshaker) == TSI_OK);
grpc_handshake_manager_add(handshake_manager, grpc_security_handshaker_create( grpc_handshake_manager_add(handshake_manager, grpc_security_handshaker_create(
handshaker, &sc->base)); handshaker, &sc->base));
} }

@ -156,6 +156,13 @@ int grpc_security_connector_cmp(grpc_security_connector* sc,
return sc->vtable->cmp(sc, other); return sc->vtable->cmp(sc, other);
} }
void grpc_security_connector_set_interested_parties(
grpc_security_connector* sc, grpc_pollset_set* interested_parties) {
if (sc != nullptr) {
sc->interested_parties = interested_parties;
}
}
int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1, int grpc_channel_security_connector_cmp(grpc_channel_security_connector* sc1,
grpc_channel_security_connector* sc2) { grpc_channel_security_connector* sc2) {
GPR_ASSERT(sc1->channel_creds != nullptr); GPR_ASSERT(sc1->channel_creds != nullptr);

@ -63,6 +63,7 @@ struct grpc_security_connector {
const grpc_security_connector_vtable* vtable; const grpc_security_connector_vtable* vtable;
gpr_refcount refcount; gpr_refcount refcount;
const char* url_scheme; const char* url_scheme;
grpc_pollset_set* interested_parties;
}; };
/* Refcounting. */ /* Refcounting. */
@ -106,6 +107,10 @@ grpc_security_connector* grpc_security_connector_from_arg(const grpc_arg* arg);
grpc_security_connector* grpc_security_connector_find_in_args( grpc_security_connector* grpc_security_connector_find_in_args(
const grpc_channel_args* args); const grpc_channel_args* args);
/* Util to set the interested_parties whose ownership is not transferred. */
void grpc_security_connector_set_interested_parties(
grpc_security_connector* sc, grpc_pollset_set* interested_parties);
/* --- channel_security_connector object. --- /* --- channel_security_connector object. ---
A channel security connector object represents a way to configure the A channel security connector object represents a way to configure the

@ -475,20 +475,30 @@ static grpc_handshaker* fail_handshaker_create() {
static void client_handshaker_factory_add_handshakers( static void client_handshaker_factory_add_handshakers(
grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args, grpc_handshaker_factory* handshaker_factory, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) { grpc_handshake_manager* handshake_mgr) {
grpc_channel_security_connector* security_connector = grpc_channel_security_connector* security_connector =
reinterpret_cast<grpc_channel_security_connector*>( reinterpret_cast<grpc_channel_security_connector*>(
grpc_security_connector_find_in_args(args)); grpc_security_connector_find_in_args(args));
if (security_connector != nullptr) {
grpc_security_connector_set_interested_parties(&security_connector->base,
interested_parties);
}
grpc_channel_security_connector_add_handshakers(security_connector, grpc_channel_security_connector_add_handshakers(security_connector,
handshake_mgr); handshake_mgr);
} }
static void server_handshaker_factory_add_handshakers( static void server_handshaker_factory_add_handshakers(
grpc_handshaker_factory* hf, const grpc_channel_args* args, grpc_handshaker_factory* hf, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) { grpc_handshake_manager* handshake_mgr) {
grpc_server_security_connector* security_connector = grpc_server_security_connector* security_connector =
reinterpret_cast<grpc_server_security_connector*>( reinterpret_cast<grpc_server_security_connector*>(
grpc_security_connector_find_in_args(args)); grpc_security_connector_find_in_args(args));
if (security_connector != nullptr) {
grpc_security_connector_set_interested_parties(&security_connector->base,
interested_parties);
}
grpc_server_security_connector_add_handshakers(security_connector, grpc_server_security_connector_add_handshakers(security_connector,
handshake_mgr); handshake_mgr);
} }

@ -102,8 +102,8 @@ grpc_channel* grpc_channel_create_with_builder(
channel->target = target; channel->target = target;
channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type);
bool channelz_enabled = GRPC_ENABLE_CHANNELZ_DEFAULT;
size_t channel_tracer_max_memory = 0; // default to off size_t channel_tracer_max_memory = 0; // default to off
bool channelz_enabled = false;
bool internal_channel = false; bool internal_channel = false;
// this creates the default ChannelNode. Different types of channels may // this creates the default ChannelNode. Different types of channels may
// override this to ensure a correct ChannelNode is created. // override this to ensure a correct ChannelNode is created.
@ -143,14 +143,15 @@ grpc_channel* grpc_channel_create_with_builder(
} else if (0 == strcmp(args->args[i].key, } else if (0 == strcmp(args->args[i].key,
GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE)) { GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE)) {
GPR_ASSERT(channel_tracer_max_memory == 0); GPR_ASSERT(channel_tracer_max_memory == 0);
// max_nodes defaults to 0 (which is off), clamped between 0 and INT_MAX const grpc_integer_options options = {
const grpc_integer_options options = {0, 0, INT_MAX}; GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX};
channel_tracer_max_memory = channel_tracer_max_memory =
(size_t)grpc_channel_arg_get_integer(&args->args[i], options); (size_t)grpc_channel_arg_get_integer(&args->args[i], options);
} else if (0 == strcmp(args->args[i].key, GRPC_ARG_ENABLE_CHANNELZ)) { } else if (0 == strcmp(args->args[i].key, GRPC_ARG_ENABLE_CHANNELZ)) {
// channelz will not be enabled by default until all concerns in // channelz will not be enabled by default until all concerns in
// https://github.com/grpc/grpc/issues/15986 are addressed. // https://github.com/grpc/grpc/issues/15986 are addressed.
channelz_enabled = grpc_channel_arg_get_bool(&args->args[i], false); channelz_enabled = grpc_channel_arg_get_bool(
&args->args[i], GRPC_ENABLE_CHANNELZ_DEFAULT);
} else if (0 == strcmp(args->args[i].key, } else if (0 == strcmp(args->args[i].key,
GRPC_ARG_CHANNELZ_CHANNEL_NODE_CREATION_FUNC)) { GRPC_ARG_CHANNELZ_CHANNEL_NODE_CREATION_FUNC)) {
GPR_ASSERT(args->args[i].type == GRPC_ARG_POINTER); GPR_ASSERT(args->args[i].type == GRPC_ARG_POINTER);

@ -1008,11 +1008,12 @@ grpc_server* grpc_server_create(const grpc_channel_args* args, void* reserved) {
server->channel_args = grpc_channel_args_copy(args); server->channel_args = grpc_channel_args_copy(args);
const grpc_arg* arg = grpc_channel_args_find(args, GRPC_ARG_ENABLE_CHANNELZ); const grpc_arg* arg = grpc_channel_args_find(args, GRPC_ARG_ENABLE_CHANNELZ);
if (grpc_channel_arg_get_bool(arg, false)) { if (grpc_channel_arg_get_bool(arg, GRPC_ENABLE_CHANNELZ_DEFAULT)) {
arg = grpc_channel_args_find( arg = grpc_channel_args_find(
args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE); args, GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE);
size_t channel_tracer_max_memory = size_t channel_tracer_max_memory = grpc_channel_arg_get_integer(
grpc_channel_arg_get_integer(arg, {0, 0, INT_MAX}); arg,
{GRPC_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE_DEFAULT, 0, INT_MAX});
server->channelz_server = server->channelz_server =
grpc_core::MakeRefCounted<grpc_core::channelz::ServerNode>( grpc_core::MakeRefCounted<grpc_core::channelz::ServerNode>(
channel_tracer_max_memory); channel_tracer_max_memory);

@ -347,7 +347,8 @@ static void init_shared_resources(const char* handshaker_service_url) {
tsi_result alts_tsi_handshaker_create( tsi_result alts_tsi_handshaker_create(
const grpc_alts_credentials_options* options, const char* target_name, const grpc_alts_credentials_options* options, const char* target_name,
const char* handshaker_service_url, bool is_client, tsi_handshaker** self) { const char* handshaker_service_url, bool is_client,
grpc_pollset_set* interested_parties, tsi_handshaker** self) {
if (handshaker_service_url == nullptr || self == nullptr || if (handshaker_service_url == nullptr || self == nullptr ||
options == nullptr || (is_client && target_name == nullptr)) { options == nullptr || (is_client && target_name == nullptr)) {
gpr_log(GPR_ERROR, "Invalid arguments to alts_tsi_handshaker_create()"); gpr_log(GPR_ERROR, "Invalid arguments to alts_tsi_handshaker_create()");

@ -23,6 +23,7 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h" #include "src/core/lib/security/credentials/alts/grpc_alts_credentials_options.h"
#include "src/core/tsi/alts_transport_security.h" #include "src/core/tsi/alts_transport_security.h"
#include "src/core/tsi/transport_security.h" #include "src/core/tsi/transport_security.h"
@ -51,6 +52,7 @@ typedef struct alts_tsi_handshaker alts_tsi_handshaker;
* "host:port". * "host:port".
* - is_client: boolean value indicating if the handshaker is used at the client * - is_client: boolean value indicating if the handshaker is used at the client
* (is_client = true) or server (is_client = false) side. * (is_client = true) or server (is_client = false) side.
* - interested_parties: set of pollsets interested in this connection.
* - self: address of ALTS TSI handshaker instance to be returned from the * - self: address of ALTS TSI handshaker instance to be returned from the
* method. * method.
* *
@ -58,7 +60,8 @@ typedef struct alts_tsi_handshaker alts_tsi_handshaker;
*/ */
tsi_result alts_tsi_handshaker_create( tsi_result alts_tsi_handshaker_create(
const grpc_alts_credentials_options* options, const char* target_name, const grpc_alts_credentials_options* options, const char* target_name,
const char* handshaker_service_url, bool is_client, tsi_handshaker** self); const char* handshaker_service_url, bool is_client,
grpc_pollset_set* interested_parties, tsi_handshaker** self);
/** /**
* This method handles handshaker response returned from ALTS handshaker * This method handles handshaker response returned from ALTS handshaker

@ -51,8 +51,16 @@
namespace grpc { namespace grpc {
static internal::GrpcLibraryInitializer g_gli_initializer; static internal::GrpcLibraryInitializer g_gli_initializer;
Channel::Channel(const grpc::string& host, grpc_channel* channel) Channel::Channel(
const grpc::string& host, grpc_channel* channel,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators)
: host_(host), c_channel_(channel) { : host_(host), c_channel_(channel) {
auto* vector = interceptor_creators.release();
if (vector != nullptr) {
interceptor_creators_ = std::move(*vector);
}
g_gli_initializer.summon(); g_gli_initializer.summon();
} }

@ -39,11 +39,43 @@ std::shared_ptr<Channel> CreateCustomChannel(
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args) { const ChannelArguments& args) {
GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds. GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds.
return creds ? creds->CreateChannel(target, args) return creds
: CreateChannelInternal( ? creds->CreateChannel(target, args)
"", grpc_lame_client_channel_create( : CreateChannelInternal("",
nullptr, GRPC_STATUS_INVALID_ARGUMENT, grpc_lame_client_channel_create(
"Invalid credentials.")); nullptr, GRPC_STATUS_INVALID_ARGUMENT,
"Invalid credentials."),
nullptr);
} }
namespace experimental {
/// Create a new \em custom \a Channel pointing to \a target with \a
/// interceptors being invoked per call.
///
/// \warning For advanced use and testing ONLY. Override default channel
/// arguments only if necessary.
///
/// \param target The URI of the endpoint to connect to.
/// \param creds Credentials to use for the created channel. If it does not
/// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned.
/// \param args Options for channel creation.
std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) {
return creds
? creds->CreateChannelWithInterceptors(
target, args, std::move(interceptor_creators))
: CreateChannelInternal("",
grpc_lame_client_channel_create(
nullptr, GRPC_STATUS_INVALID_ARGUMENT,
"Invalid credentials."),
nullptr);
}
} // namespace experimental
} // namespace grpc } // namespace grpc

@ -24,8 +24,12 @@ struct grpc_channel;
namespace grpc { namespace grpc {
std::shared_ptr<Channel> CreateChannelInternal(const grpc::string& host, std::shared_ptr<Channel> CreateChannelInternal(
grpc_channel* c_channel) { const grpc::string& host, grpc_channel* c_channel,
return std::shared_ptr<Channel>(new Channel(host, c_channel)); std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) {
return std::shared_ptr<Channel>(
new Channel(host, c_channel, std::move(interceptor_creators)));
} }
} // namespace grpc } // namespace grpc

@ -21,6 +21,7 @@
#include <memory> #include <memory>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/support/config.h> #include <grpcpp/support/config.h>
struct grpc_channel; struct grpc_channel;
@ -28,8 +29,11 @@ struct grpc_channel;
namespace grpc { namespace grpc {
class Channel; class Channel;
std::shared_ptr<Channel> CreateChannelInternal(const grpc::string& host, std::shared_ptr<Channel> CreateChannelInternal(
grpc_channel* c_channel); const grpc::string& host, grpc_channel* c_channel,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
} // namespace grpc } // namespace grpc

@ -33,7 +33,8 @@ std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target,
internal::GrpcLibrary init_lib; internal::GrpcLibrary init_lib;
init_lib.init(); init_lib.init();
return CreateChannelInternal( return CreateChannelInternal(
"", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr)); "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr),
nullptr);
} }
std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd( std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
@ -42,10 +43,31 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
init_lib.init(); init_lib.init();
grpc_channel_args channel_args; grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args); args.SetChannelArgs(&channel_args);
return CreateChannelInternal("", grpc_insecure_channel_create_from_fd( return CreateChannelInternal(
target.c_str(), fd, &channel_args)); "",
grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args),
nullptr);
}
namespace experimental {
std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
const grpc::string& target, int fd, const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) {
internal::GrpcLibrary init_lib;
init_lib.init();
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return CreateChannelInternal(
"",
grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args),
std::move(interceptor_creators));
} }
} // namespace experimental
#endif // GPR_SUPPORT_CHANNELS_FROM_FD #endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc } // namespace grpc

@ -31,16 +31,25 @@ class CronetChannelCredentialsImpl final : public ChannelCredentials {
std::shared_ptr<grpc::Channel> CreateChannel( std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) override { const string& target, const grpc::ChannelArguments& args) override {
grpc_channel_args channel_args; return CreateChannelWithInterceptors(target, args, nullptr);
args.SetChannelArgs(&channel_args);
return CreateChannelInternal(
"", grpc_cronet_secure_channel_create(engine_, target.c_str(),
&channel_args, nullptr));
} }
SecureChannelCredentials* AsSecureCredentials() override { return nullptr; } SecureChannelCredentials* AsSecureCredentials() override { return nullptr; }
private: private:
std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
const string& target, const grpc::ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) override {
grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args);
return CreateChannelInternal(
"",
grpc_cronet_secure_channel_create(engine_, target.c_str(),
&channel_args, nullptr),
std::move(interceptor_creators));
}
void* engine_; void* engine_;
}; };

@ -32,11 +32,20 @@ class InsecureChannelCredentialsImpl final : public ChannelCredentials {
public: public:
std::shared_ptr<grpc::Channel> CreateChannel( std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) override { const string& target, const grpc::ChannelArguments& args) override {
return CreateChannelWithInterceptors(target, args, nullptr);
}
std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
const string& target, const grpc::ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) override {
grpc_channel_args channel_args; grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args); args.SetChannelArgs(&channel_args);
return CreateChannelInternal( return CreateChannelInternal(
"", "",
grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr)); grpc_insecure_channel_create(target.c_str(), &channel_args, nullptr),
std::move(interceptor_creators));
} }
SecureChannelCredentials* AsSecureCredentials() override { return nullptr; } SecureChannelCredentials* AsSecureCredentials() override { return nullptr; }

@ -36,12 +36,22 @@ SecureChannelCredentials::SecureChannelCredentials(
std::shared_ptr<grpc::Channel> SecureChannelCredentials::CreateChannel( std::shared_ptr<grpc::Channel> SecureChannelCredentials::CreateChannel(
const string& target, const grpc::ChannelArguments& args) { const string& target, const grpc::ChannelArguments& args) {
return CreateChannelWithInterceptors(target, args, nullptr);
}
std::shared_ptr<grpc::Channel>
SecureChannelCredentials::CreateChannelWithInterceptors(
const string& target, const grpc::ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) {
grpc_channel_args channel_args; grpc_channel_args channel_args;
args.SetChannelArgs(&channel_args); args.SetChannelArgs(&channel_args);
return CreateChannelInternal( return CreateChannelInternal(
args.GetSslTargetNameOverride(), args.GetSslTargetNameOverride(),
grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args, grpc_secure_channel_create(c_creds_, target.c_str(), &channel_args,
nullptr)); nullptr),
std::move(interceptor_creators));
} }
SecureCallCredentials::SecureCallCredentials(grpc_call_credentials* c_creds) SecureCallCredentials::SecureCallCredentials(grpc_call_credentials* c_creds)

@ -36,9 +36,15 @@ class SecureChannelCredentials final : public ChannelCredentials {
std::shared_ptr<grpc::Channel> CreateChannel( std::shared_ptr<grpc::Channel> CreateChannel(
const string& target, const grpc::ChannelArguments& args) override; const string& target, const grpc::ChannelArguments& args) override;
SecureChannelCredentials* AsSecureCredentials() override { return this; } SecureChannelCredentials* AsSecureCredentials() override { return this; }
private: private:
std::shared_ptr<grpc::Channel> CreateChannelWithInterceptors(
const string& target, const grpc::ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) override;
grpc_channel_credentials* const c_creds_; grpc_channel_credentials* const c_creds_;
}; };

@ -473,7 +473,21 @@ std::shared_ptr<Channel> Server::InProcessChannel(
const ChannelArguments& args) { const ChannelArguments& args) {
grpc_channel_args channel_args = args.c_channel_args(); grpc_channel_args channel_args = args.c_channel_args();
return CreateChannelInternal( return CreateChannelInternal(
"inproc", grpc_inproc_channel_create(server_, &channel_args, nullptr)); "inproc", grpc_inproc_channel_create(server_, &channel_args, nullptr),
nullptr);
}
std::shared_ptr<Channel>
Server::experimental_type::InProcessChannelWithInterceptors(
const ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators) {
grpc_channel_args channel_args = args.c_channel_args();
return CreateChannelInternal(
"inproc",
grpc_inproc_channel_create(server_->server_, &channel_args, nullptr),
std::move(interceptor_creators));
} }
static grpc_server_register_method_payload_handling PayloadHandlingForMethod( static grpc_server_register_method_payload_handling PayloadHandlingForMethod(

@ -22,10 +22,14 @@ gRPC C# now has experimental support for Unity. Please try using gRPC with
Unity and provide feedback! Unity and provide feedback!
How to test gRPC in a Unity project How to test gRPC in a Unity project
1. Create a Unity project that targets .NET 4.x (Edit -> Project Settings -> Editor -> Scripting Runtime Version). gRPC uses APIs that are only available in .NET4.5+ so this is a requirement. 1. Create a Unity project that targets .NET 4.x (Edit -> Project Settings -> Editor -> Scripting Runtime Version). gRPC uses APIs that are only available in .NET4.5+ so this is a requirement.
2. Download the latest development build of `grpc_unity_package.VERSION.zip` from 2. Download the latest development build of `grpc_unity_package.VERSION.zip` from
[daily builds](https://packages.grpc.io/) [daily builds](https://packages.grpc.io/)
3. Extract the `.zip` file in the `Assets` directory in your Unity project 3. Extract the `.zip` file in the `Assets` directory in your Unity project
4. Unity IDE will pick up all the bundled files and add them to project automatically. 4. Unity IDE will pick up all the bundled files and add them to project automatically.
You should be able to use gRPC and Protobuf in your scripts from now on. You should be able to use gRPC and Protobuf in your scripts from now on.

@ -75,6 +75,7 @@ static grpc_handshaker* readahead_handshaker_create() {
static void readahead_handshaker_factory_add_handshakers( static void readahead_handshaker_factory_add_handshakers(
grpc_handshaker_factory* hf, const grpc_channel_args* args, grpc_handshaker_factory* hf, const grpc_channel_args* args,
grpc_pollset_set* interested_parties,
grpc_handshake_manager* handshake_mgr) { grpc_handshake_manager* handshake_mgr) {
grpc_handshake_manager_add(handshake_mgr, readahead_handshaker_create()); grpc_handshake_manager_add(handshake_mgr, readahead_handshaker_create());
} }

@ -251,7 +251,10 @@ int main(int argc, char** argv) {
gpr_cmdline* cl = gpr_cmdline_create("resolve address test"); gpr_cmdline* cl = gpr_cmdline_create("resolve address test");
gpr_cmdline_add_string(cl, "resolver", "Resolver type (ares or native)", gpr_cmdline_add_string(cl, "resolver", "Resolver type (ares or native)",
&resolver_type); &resolver_type);
gpr_cmdline_parse(cl, argc, argv); // In case that there are more than one argument on the command line,
// --resolver will always be the first one, so only parse the first argument
// (other arguments may be unknown to cl)
gpr_cmdline_parse(cl, argc > 2 ? 2 : argc, argv);
const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER"); const char* cur_resolver = gpr_getenv("GRPC_DNS_RESOLVER");
if (cur_resolver != nullptr && strlen(cur_resolver) != 0) { if (cur_resolver != nullptr && strlen(cur_resolver) != 0) {
gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s", gpr_log(GPR_INFO, "Warning: overriding resolver setting of %s",

@ -421,7 +421,7 @@ static tsi_handshaker* create_test_handshaker(bool used_for_success_test,
alts_mock_handshaker_client_create(used_for_success_test); alts_mock_handshaker_client_create(used_for_success_test);
grpc_alts_credentials_options* options = grpc_alts_credentials_options* options =
grpc_alts_credentials_client_options_create(); grpc_alts_credentials_client_options_create();
alts_tsi_handshaker_create(options, "target_name", "lame", is_client, alts_tsi_handshaker_create(options, "target_name", "lame", is_client, nullptr,
&handshaker); &handshaker);
alts_tsi_handshaker* alts_handshaker = alts_tsi_handshaker* alts_handshaker =
reinterpret_cast<alts_tsi_handshaker*>(handshaker); reinterpret_cast<alts_tsi_handshaker*>(handshaker);

@ -133,8 +133,10 @@ static void BM_LameChannelCallCreateCpp(benchmark::State& state) {
TrackCounters track_counters; TrackCounters track_counters;
auto stub = auto stub =
grpc::testing::EchoTestService::NewStub(grpc::CreateChannelInternal( grpc::testing::EchoTestService::NewStub(grpc::CreateChannelInternal(
"", grpc_lame_client_channel_create( "",
"localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah"))); grpc_lame_client_channel_create("localhost:1234",
GRPC_STATUS_UNAUTHENTICATED, "blah"),
nullptr));
grpc::CompletionQueue cq; grpc::CompletionQueue cq;
grpc::testing::EchoRequest send_request; grpc::testing::EchoRequest send_request;
grpc::testing::EchoResponse recv_response; grpc::testing::EchoResponse recv_response;

@ -218,7 +218,7 @@ class EndpointPairFixture : public BaseFixture {
"target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_); "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_);
grpc_chttp2_transport_start_reading(client_transport_, nullptr, nullptr); grpc_chttp2_transport_start_reading(client_transport_, nullptr, nullptr);
channel_ = CreateChannelInternal("", channel); channel_ = CreateChannelInternal("", channel, nullptr);
} }
} }

@ -118,7 +118,7 @@ class EndpointPairFixture {
"target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport);
grpc_chttp2_transport_start_reading(transport, nullptr, nullptr); grpc_chttp2_transport_start_reading(transport, nullptr, nullptr);
channel_ = CreateChannelInternal("", channel); channel_ = CreateChannelInternal("", channel, nullptr);
} }
} }

@ -117,11 +117,10 @@ grpc_cc_library(
) )
grpc_cc_library( grpc_cc_library(
name = "grpc_cli_libs", name = "grpc_cli_utils",
srcs = [ srcs = [
"cli_call.cc", "cli_call.cc",
"cli_credentials.cc", "cli_credentials.cc",
"grpc_tool.cc",
"proto_file_parser.cc", "proto_file_parser.cc",
"service_describer.cc", "service_describer.cc",
], ],
@ -129,7 +128,6 @@ grpc_cc_library(
"cli_call.h", "cli_call.h",
"cli_credentials.h", "cli_credentials.h",
"config_grpc_cli.h", "config_grpc_cli.h",
"grpc_tool.h",
"proto_file_parser.h", "proto_file_parser.h",
"service_describer.h", "service_describer.h",
], ],
@ -145,6 +143,22 @@ grpc_cc_library(
], ],
) )
grpc_cc_library(
name = "grpc_cli_libs",
srcs = [
"grpc_tool.cc",
],
hdrs = [
"grpc_tool.h",
],
external_deps = [
"gflags",
],
deps = [
":grpc_cli_utils",
],
)
grpc_cc_library( grpc_cc_library(
name = "metrics_server_lib", name = "metrics_server_lib",
srcs = [ srcs = [

@ -151,7 +151,7 @@ std::shared_ptr<grpc::CallCredentials> CliCredentials::GetCallCredentials()
if (IsAccessToken(FLAGS_call_creds)) { if (IsAccessToken(FLAGS_call_creds)) {
return grpc::AccessTokenCredentials(AccessToken(FLAGS_call_creds)); return grpc::AccessTokenCredentials(AccessToken(FLAGS_call_creds));
} }
if (FLAGS_call_creds.compare("none") != 0) { if (FLAGS_call_creds.compare("none") == 0) {
// Nothing to do; creds, if any, are baked into the channel. // Nothing to do; creds, if any, are baked into the channel.
return std::shared_ptr<grpc::CallCredentials>(); return std::shared_ptr<grpc::CallCredentials>();
} }

@ -949,6 +949,7 @@ include/grpcpp/impl/codegen/callback_common.h \
include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/channel_interface.h \
include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_callback.h \
include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context.h \
include/grpcpp/impl/codegen/client_interceptor.h \
include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/client_unary_call.h \
include/grpcpp/impl/codegen/completion_queue.h \ include/grpcpp/impl/codegen/completion_queue.h \
include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \
@ -958,6 +959,7 @@ include/grpcpp/impl/codegen/core_codegen.h \
include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \ include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/metadata_map.h \ include/grpcpp/impl/codegen/metadata_map.h \
include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/method_handler_impl.h \
include/grpcpp/impl/codegen/proto_buffer_reader.h \ include/grpcpp/impl/codegen/proto_buffer_reader.h \

@ -950,6 +950,7 @@ include/grpcpp/impl/codegen/callback_common.h \
include/grpcpp/impl/codegen/channel_interface.h \ include/grpcpp/impl/codegen/channel_interface.h \
include/grpcpp/impl/codegen/client_callback.h \ include/grpcpp/impl/codegen/client_callback.h \
include/grpcpp/impl/codegen/client_context.h \ include/grpcpp/impl/codegen/client_context.h \
include/grpcpp/impl/codegen/client_interceptor.h \
include/grpcpp/impl/codegen/client_unary_call.h \ include/grpcpp/impl/codegen/client_unary_call.h \
include/grpcpp/impl/codegen/completion_queue.h \ include/grpcpp/impl/codegen/completion_queue.h \
include/grpcpp/impl/codegen/completion_queue_tag.h \ include/grpcpp/impl/codegen/completion_queue_tag.h \
@ -960,6 +961,7 @@ include/grpcpp/impl/codegen/core_codegen.h \
include/grpcpp/impl/codegen/core_codegen_interface.h \ include/grpcpp/impl/codegen/core_codegen_interface.h \
include/grpcpp/impl/codegen/create_auth_context.h \ include/grpcpp/impl/codegen/create_auth_context.h \
include/grpcpp/impl/codegen/grpc_library.h \ include/grpcpp/impl/codegen/grpc_library.h \
include/grpcpp/impl/codegen/interceptor.h \
include/grpcpp/impl/codegen/metadata_map.h \ include/grpcpp/impl/codegen/metadata_map.h \
include/grpcpp/impl/codegen/method_handler_impl.h \ include/grpcpp/impl/codegen/method_handler_impl.h \
include/grpcpp/impl/codegen/proto_buffer_reader.h \ include/grpcpp/impl/codegen/proto_buffer_reader.h \

@ -11071,6 +11071,7 @@
"include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/channel_interface.h",
"include/grpcpp/impl/codegen/client_callback.h", "include/grpcpp/impl/codegen/client_callback.h",
"include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context.h",
"include/grpcpp/impl/codegen/client_interceptor.h",
"include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/client_unary_call.h",
"include/grpcpp/impl/codegen/completion_queue.h", "include/grpcpp/impl/codegen/completion_queue.h",
"include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/completion_queue_tag.h",
@ -11078,6 +11079,7 @@
"include/grpcpp/impl/codegen/core_codegen_interface.h", "include/grpcpp/impl/codegen/core_codegen_interface.h",
"include/grpcpp/impl/codegen/create_auth_context.h", "include/grpcpp/impl/codegen/create_auth_context.h",
"include/grpcpp/impl/codegen/grpc_library.h", "include/grpcpp/impl/codegen/grpc_library.h",
"include/grpcpp/impl/codegen/interceptor.h",
"include/grpcpp/impl/codegen/metadata_map.h", "include/grpcpp/impl/codegen/metadata_map.h",
"include/grpcpp/impl/codegen/method_handler_impl.h", "include/grpcpp/impl/codegen/method_handler_impl.h",
"include/grpcpp/impl/codegen/rpc_method.h", "include/grpcpp/impl/codegen/rpc_method.h",
@ -11139,6 +11141,7 @@
"include/grpcpp/impl/codegen/channel_interface.h", "include/grpcpp/impl/codegen/channel_interface.h",
"include/grpcpp/impl/codegen/client_callback.h", "include/grpcpp/impl/codegen/client_callback.h",
"include/grpcpp/impl/codegen/client_context.h", "include/grpcpp/impl/codegen/client_context.h",
"include/grpcpp/impl/codegen/client_interceptor.h",
"include/grpcpp/impl/codegen/client_unary_call.h", "include/grpcpp/impl/codegen/client_unary_call.h",
"include/grpcpp/impl/codegen/completion_queue.h", "include/grpcpp/impl/codegen/completion_queue.h",
"include/grpcpp/impl/codegen/completion_queue_tag.h", "include/grpcpp/impl/codegen/completion_queue_tag.h",
@ -11146,6 +11149,7 @@
"include/grpcpp/impl/codegen/core_codegen_interface.h", "include/grpcpp/impl/codegen/core_codegen_interface.h",
"include/grpcpp/impl/codegen/create_auth_context.h", "include/grpcpp/impl/codegen/create_auth_context.h",
"include/grpcpp/impl/codegen/grpc_library.h", "include/grpcpp/impl/codegen/grpc_library.h",
"include/grpcpp/impl/codegen/interceptor.h",
"include/grpcpp/impl/codegen/metadata_map.h", "include/grpcpp/impl/codegen/metadata_map.h",
"include/grpcpp/impl/codegen/method_handler_impl.h", "include/grpcpp/impl/codegen/method_handler_impl.h",
"include/grpcpp/impl/codegen/rpc_method.h", "include/grpcpp/impl/codegen/rpc_method.h",

Loading…
Cancel
Save