Merge branch 'master' into svc_cfg1

reviewable/pr18586/r6
Yash Tibrewal 6 years ago
commit 3dc6eae912
  1. 88
      BUILD
  2. 14
      BUILD.gn
  3. 75
      CMakeLists.txt
  4. 85
      Makefile
  5. 40
      WORKSPACE
  6. 24
      bazel/grpc_build_system.bzl
  7. 16
      bazel/grpc_python_deps.bzl
  8. 35
      build.yaml
  9. 4
      doc/PROTOCOL-HTTP2.md
  10. 3
      doc/g_stands_for.md
  11. 112
      examples/BUILD
  12. 4
      examples/cpp/helloworld/greeter_async_client.cc
  13. 4
      examples/cpp/helloworld/greeter_async_client2.cc
  14. 4
      examples/cpp/helloworld/greeter_async_server.cc
  15. 31
      examples/cpp/route_guide/helper.cc
  16. 4
      examples/cpp/route_guide/route_guide_client.cc
  17. 13
      examples/cpp/route_guide/route_guide_server.cc
  18. 18
      gRPC-C++.podspec
  19. 37
      gRPC-Core.podspec
  20. 8
      gRPC-ProtoRPC.podspec
  21. 2
      gRPC-RxLibrary.podspec
  22. 9
      gRPC.podspec
  23. 4
      grpc.gemspec
  24. 2
      include/grpc/impl/codegen/port_platform.h
  25. 58
      include/grpcpp/create_channel.h
  26. 79
      include/grpcpp/create_channel_impl.h
  27. 46
      include/grpcpp/create_channel_posix.h
  28. 70
      include/grpcpp/create_channel_posix_impl.h
  29. 13
      include/grpcpp/ext/channelz_service_plugin.h
  30. 41
      include/grpcpp/ext/channelz_service_plugin_impl.h
  31. 31
      include/grpcpp/ext/proto_server_reflection_plugin.h
  32. 55
      include/grpcpp/ext/proto_server_reflection_plugin_impl.h
  33. 30
      include/grpcpp/ext/server_load_reporting.h
  34. 54
      include/grpcpp/ext/server_load_reporting_impl.h
  35. 78
      include/grpcpp/generic/generic_stub.h
  36. 108
      include/grpcpp/generic/generic_stub_impl.h
  37. 39
      include/grpcpp/health_check_service_interface.h
  38. 55
      include/grpcpp/health_check_service_interface_impl.h
  39. 7
      include/grpcpp/impl/codegen/server_interface.h
  40. 19
      include/grpcpp/impl/server_builder_option.h
  41. 43
      include/grpcpp/impl/server_builder_option_impl.h
  42. 9
      include/grpcpp/impl/server_builder_plugin.h
  43. 31
      include/grpcpp/impl/server_initializer.h
  44. 57
      include/grpcpp/impl/server_initializer_impl.h
  45. 31
      include/grpcpp/opencensus.h
  46. 51
      include/grpcpp/opencensus_impl.h
  47. 45
      include/grpcpp/resource_quota.h
  48. 68
      include/grpcpp/resource_quota_impl.h
  49. 37
      include/grpcpp/security/auth_metadata_processor.h
  50. 61
      include/grpcpp/security/auth_metadata_processor_impl.h
  51. 38
      include/grpcpp/security/credentials.h
  52. 66
      include/grpcpp/security/server_credentials.h
  53. 85
      include/grpcpp/security/server_credentials_impl.h
  54. 13
      include/grpcpp/server.h
  55. 22
      include/grpcpp/server_builder.h
  56. 14
      include/grpcpp/server_posix.h
  57. 42
      include/grpcpp/server_posix_impl.h
  58. 9
      include/grpcpp/support/channel_arguments.h
  59. 22
      include/grpcpp/support/error_details.h
  60. 48
      include/grpcpp/support/error_details_impl.h
  61. 6
      package.xml
  62. 4
      src/compiler/csharp_generator.cc
  63. 16
      src/compiler/objective_c_generator.cc
  64. 323
      src/core/ext/filters/client_channel/client_channel.cc
  65. 28
      src/core/ext/filters/client_channel/health/health_check_client.cc
  66. 12
      src/core/ext/filters/client_channel/health/health_check_client.h
  67. 4
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
  68. 8
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc
  69. 20
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h
  70. 4
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc
  71. 2
      src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h
  72. 27
      src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
  73. 535
      src/core/ext/filters/client_channel/lb_policy/xds/xds.cc
  74. 24
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  75. 6
      src/core/ext/transport/chttp2/transport/internal.h
  76. 13
      src/core/lib/gpr/time_posix.cc
  77. 419
      src/core/lib/gprpp/map.h
  78. 38
      src/core/lib/gprpp/pair.h
  79. 7
      src/core/lib/iomgr/cfstream_handle.cc
  80. 1
      src/core/lib/security/credentials/google_default/google_default_credentials.cc
  81. 5
      src/core/lib/security/credentials/jwt/jwt_verifier.cc
  82. 17
      src/core/lib/security/security_connector/ssl/ssl_security_connector.cc
  83. 2
      src/core/lib/surface/init.cc
  84. 2
      src/core/lib/surface/version.cc
  85. 16
      src/core/lib/transport/transport.cc
  86. 26
      src/core/lib/transport/transport.h
  87. 7
      src/cpp/client/channel_cc.cc
  88. 41
      src/cpp/client/create_channel.cc
  89. 39
      src/cpp/client/create_channel_posix.cc
  90. 82
      src/cpp/client/generic_stub.cc
  91. 2
      src/cpp/common/channel_arguments.cc
  92. 4
      src/cpp/common/resource_quota_cc.cc
  93. 2
      src/cpp/common/version_cc.cc
  94. 65
      src/cpp/ext/filters/census/grpc_plugin.cc
  95. 1
      src/cpp/ext/filters/census/grpc_plugin.h
  96. 32
      src/cpp/ext/filters/census/views.cc
  97. 4
      src/cpp/ext/proto_server_reflection_plugin.cc
  98. 27
      src/cpp/server/channelz/channelz_service.cc
  99. 12
      src/cpp/server/channelz/channelz_service_plugin.cc
  100. 6
      src/cpp/server/health/health_check_service.cc
  101. Some files were not shown because too many files have changed in this diff Show More

88
BUILD

@ -74,11 +74,11 @@ config_setting(
) )
# This should be updated along with build.yaml # This should be updated along with build.yaml
g_stands_for = "godric" g_stands_for = "gandalf"
core_version = "7.0.0" core_version = "7.0.0"
version = "1.20.0-dev" version = "1.21.0-dev"
GPR_PUBLIC_HDRS = [ GPR_PUBLIC_HDRS = [
"include/grpc/support/alloc.h", "include/grpc/support/alloc.h",
@ -192,8 +192,8 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpc++/impl/service_type.h", "include/grpc++/impl/service_type.h",
"include/grpc++/impl/sync_cxx11.h", "include/grpc++/impl/sync_cxx11.h",
"include/grpc++/impl/sync_no_cxx11.h", "include/grpc++/impl/sync_no_cxx11.h",
"include/grpc++/resource_quota.h",
"include/grpc++/security/auth_context.h", "include/grpc++/security/auth_context.h",
"include/grpc++/resource_quota.h",
"include/grpc++/security/auth_metadata_processor.h", "include/grpc++/security/auth_metadata_processor.h",
"include/grpc++/security/credentials.h", "include/grpc++/security/credentials.h",
"include/grpc++/security/server_credentials.h", "include/grpc++/security/server_credentials.h",
@ -219,12 +219,16 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/client_context.h", "include/grpcpp/client_context.h",
"include/grpcpp/completion_queue.h", "include/grpcpp/completion_queue.h",
"include/grpcpp/create_channel.h", "include/grpcpp/create_channel.h",
"include/grpcpp/create_channel_impl.h",
"include/grpcpp/create_channel_posix.h", "include/grpcpp/create_channel_posix.h",
"include/grpcpp/create_channel_posix_impl.h",
"include/grpcpp/ext/health_check_service_server_builder_option.h", "include/grpcpp/ext/health_check_service_server_builder_option.h",
"include/grpcpp/generic/async_generic_service.h", "include/grpcpp/generic/async_generic_service.h",
"include/grpcpp/generic/generic_stub.h", "include/grpcpp/generic/generic_stub.h",
"include/grpcpp/generic/generic_stub_impl.h",
"include/grpcpp/grpcpp.h", "include/grpcpp/grpcpp.h",
"include/grpcpp/health_check_service_interface.h", "include/grpcpp/health_check_service_interface.h",
"include/grpcpp/health_check_service_interface_impl.h",
"include/grpcpp/impl/call.h", "include/grpcpp/impl/call.h",
"include/grpcpp/impl/channel_argument_option.h", "include/grpcpp/impl/channel_argument_option.h",
"include/grpcpp/impl/client_unary_call.h", "include/grpcpp/impl/client_unary_call.h",
@ -235,20 +239,26 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/impl/rpc_service_method.h", "include/grpcpp/impl/rpc_service_method.h",
"include/grpcpp/impl/serialization_traits.h", "include/grpcpp/impl/serialization_traits.h",
"include/grpcpp/impl/server_builder_option.h", "include/grpcpp/impl/server_builder_option.h",
"include/grpcpp/impl/server_builder_option_impl.h",
"include/grpcpp/impl/server_builder_plugin.h", "include/grpcpp/impl/server_builder_plugin.h",
"include/grpcpp/impl/server_initializer.h", "include/grpcpp/impl/server_initializer.h",
"include/grpcpp/impl/server_initializer_impl.h",
"include/grpcpp/impl/service_type.h", "include/grpcpp/impl/service_type.h",
"include/grpcpp/impl/sync_cxx11.h", "include/grpcpp/impl/sync_cxx11.h",
"include/grpcpp/impl/sync_no_cxx11.h", "include/grpcpp/impl/sync_no_cxx11.h",
"include/grpcpp/resource_quota.h", "include/grpcpp/resource_quota.h",
"include/grpcpp/resource_quota_impl.h",
"include/grpcpp/security/auth_context.h", "include/grpcpp/security/auth_context.h",
"include/grpcpp/security/auth_metadata_processor.h", "include/grpcpp/security/auth_metadata_processor.h",
"include/grpcpp/security/auth_metadata_processor_impl.h",
"include/grpcpp/security/credentials.h", "include/grpcpp/security/credentials.h",
"include/grpcpp/security/server_credentials.h", "include/grpcpp/security/server_credentials.h",
"include/grpcpp/security/server_credentials_impl.h",
"include/grpcpp/server.h", "include/grpcpp/server.h",
"include/grpcpp/server_builder.h", "include/grpcpp/server_builder.h",
"include/grpcpp/server_context.h", "include/grpcpp/server_context.h",
"include/grpcpp/server_posix.h", "include/grpcpp/server_posix.h",
"include/grpcpp/server_posix_impl.h",
"include/grpcpp/support/async_stream.h", "include/grpcpp/support/async_stream.h",
"include/grpcpp/support/async_unary_call.h", "include/grpcpp/support/async_unary_call.h",
"include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/byte_buffer.h",
@ -307,7 +317,6 @@ grpc_cc_library(
public_hdrs = GRPC_PUBLIC_HDRS + GRPC_SECURE_PUBLIC_HDRS, public_hdrs = GRPC_PUBLIC_HDRS + GRPC_SECURE_PUBLIC_HDRS,
standalone = True, standalone = True,
deps = [ deps = [
"grpc_cfstream",
"grpc_common", "grpc_common",
"grpc_lb_policy_grpclb_secure", "grpc_lb_policy_grpclb_secure",
"grpc_lb_policy_xds_secure", "grpc_lb_policy_xds_secure",
@ -361,7 +370,6 @@ grpc_cc_library(
"gpr", "gpr",
"grpc", "grpc",
"grpc++_base", "grpc++_base",
"grpc_cfstream",
"grpc++_codegen_base", "grpc++_codegen_base",
"grpc++_codegen_base_src", "grpc++_codegen_base_src",
"grpc++_codegen_proto", "grpc++_codegen_proto",
@ -395,6 +403,7 @@ grpc_cc_library(
hdrs = [ hdrs = [
"include/grpc++/support/error_details.h", "include/grpc++/support/error_details.h",
"include/grpcpp/support/error_details.h", "include/grpcpp/support/error_details.h",
"include/grpcpp/support/error_details_impl.h",
], ],
language = "c++", language = "c++",
standalone = True, standalone = True,
@ -578,8 +587,10 @@ grpc_cc_library(
"src/core/lib/gprpp/abstract.h", "src/core/lib/gprpp/abstract.h",
"src/core/lib/gprpp/fork.h", "src/core/lib/gprpp/fork.h",
"src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/manual_constructor.h",
"src/core/lib/gprpp/map.h",
"src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/memory.h",
"src/core/lib/gprpp/mutex_lock.h", "src/core/lib/gprpp/mutex_lock.h",
"src/core/lib/gprpp/pair.h",
"src/core/lib/gprpp/thd.h", "src/core/lib/gprpp/thd.h",
"src/core/lib/profiling/timers.h", "src/core/lib/profiling/timers.h",
], ],
@ -725,12 +736,15 @@ grpc_cc_library(
"src/core/lib/http/parser.cc", "src/core/lib/http/parser.cc",
"src/core/lib/iomgr/buffer_list.cc", "src/core/lib/iomgr/buffer_list.cc",
"src/core/lib/iomgr/call_combiner.cc", "src/core/lib/iomgr/call_combiner.cc",
"src/core/lib/iomgr/cfstream_handle.cc",
"src/core/lib/iomgr/combiner.cc", "src/core/lib/iomgr/combiner.cc",
"src/core/lib/iomgr/endpoint.cc", "src/core/lib/iomgr/endpoint.cc",
"src/core/lib/iomgr/endpoint_cfstream.cc",
"src/core/lib/iomgr/endpoint_pair_posix.cc", "src/core/lib/iomgr/endpoint_pair_posix.cc",
"src/core/lib/iomgr/endpoint_pair_uv.cc", "src/core/lib/iomgr/endpoint_pair_uv.cc",
"src/core/lib/iomgr/endpoint_pair_windows.cc", "src/core/lib/iomgr/endpoint_pair_windows.cc",
"src/core/lib/iomgr/error.cc", "src/core/lib/iomgr/error.cc",
"src/core/lib/iomgr/error_cfstream.cc",
"src/core/lib/iomgr/ev_epoll1_linux.cc", "src/core/lib/iomgr/ev_epoll1_linux.cc",
"src/core/lib/iomgr/ev_epollex_linux.cc", "src/core/lib/iomgr/ev_epollex_linux.cc",
"src/core/lib/iomgr/ev_poll_posix.cc", "src/core/lib/iomgr/ev_poll_posix.cc",
@ -751,6 +765,7 @@ grpc_cc_library(
"src/core/lib/iomgr/iomgr_custom.cc", "src/core/lib/iomgr/iomgr_custom.cc",
"src/core/lib/iomgr/iomgr_internal.cc", "src/core/lib/iomgr/iomgr_internal.cc",
"src/core/lib/iomgr/iomgr_posix.cc", "src/core/lib/iomgr/iomgr_posix.cc",
"src/core/lib/iomgr/iomgr_posix_cfstream.cc",
"src/core/lib/iomgr/iomgr_windows.cc", "src/core/lib/iomgr/iomgr_windows.cc",
"src/core/lib/iomgr/is_epollexclusive_available.cc", "src/core/lib/iomgr/is_epollexclusive_available.cc",
"src/core/lib/iomgr/load_file.cc", "src/core/lib/iomgr/load_file.cc",
@ -777,6 +792,7 @@ grpc_cc_library(
"src/core/lib/iomgr/socket_utils_windows.cc", "src/core/lib/iomgr/socket_utils_windows.cc",
"src/core/lib/iomgr/socket_windows.cc", "src/core/lib/iomgr/socket_windows.cc",
"src/core/lib/iomgr/tcp_client.cc", "src/core/lib/iomgr/tcp_client.cc",
"src/core/lib/iomgr/tcp_client_cfstream.cc",
"src/core/lib/iomgr/tcp_client_custom.cc", "src/core/lib/iomgr/tcp_client_custom.cc",
"src/core/lib/iomgr/tcp_client_posix.cc", "src/core/lib/iomgr/tcp_client_posix.cc",
"src/core/lib/iomgr/tcp_client_windows.cc", "src/core/lib/iomgr/tcp_client_windows.cc",
@ -876,12 +892,15 @@ grpc_cc_library(
"src/core/lib/iomgr/block_annotate.h", "src/core/lib/iomgr/block_annotate.h",
"src/core/lib/iomgr/buffer_list.h", "src/core/lib/iomgr/buffer_list.h",
"src/core/lib/iomgr/call_combiner.h", "src/core/lib/iomgr/call_combiner.h",
"src/core/lib/iomgr/cfstream_handle.h",
"src/core/lib/iomgr/closure.h", "src/core/lib/iomgr/closure.h",
"src/core/lib/iomgr/combiner.h", "src/core/lib/iomgr/combiner.h",
"src/core/lib/iomgr/dynamic_annotations.h", "src/core/lib/iomgr/dynamic_annotations.h",
"src/core/lib/iomgr/endpoint.h", "src/core/lib/iomgr/endpoint.h",
"src/core/lib/iomgr/endpoint_cfstream.h",
"src/core/lib/iomgr/endpoint_pair.h", "src/core/lib/iomgr/endpoint_pair.h",
"src/core/lib/iomgr/error.h", "src/core/lib/iomgr/error.h",
"src/core/lib/iomgr/error_cfstream.h",
"src/core/lib/iomgr/error_internal.h", "src/core/lib/iomgr/error_internal.h",
"src/core/lib/iomgr/ev_epoll1_linux.h", "src/core/lib/iomgr/ev_epoll1_linux.h",
"src/core/lib/iomgr/ev_epollex_linux.h", "src/core/lib/iomgr/ev_epollex_linux.h",
@ -1036,27 +1055,6 @@ grpc_cc_library(
], ],
) )
grpc_cc_library(
name = "grpc_cfstream",
srcs = [
"src/core/lib/iomgr/cfstream_handle.cc",
"src/core/lib/iomgr/endpoint_cfstream.cc",
"src/core/lib/iomgr/error_cfstream.cc",
"src/core/lib/iomgr/iomgr_posix_cfstream.cc",
"src/core/lib/iomgr/tcp_client_cfstream.cc",
],
hdrs = [
"src/core/lib/iomgr/cfstream_handle.h",
"src/core/lib/iomgr/endpoint_cfstream.h",
"src/core/lib/iomgr/error_cfstream.h",
],
use_cfstream = True,
deps = [
":gpr_base",
":grpc_base",
],
)
grpc_cc_library( grpc_cc_library(
name = "grpc_client_channel", name = "grpc_client_channel",
srcs = [ srcs = [
@ -1476,6 +1474,7 @@ grpc_cc_library(
language = "c++", language = "c++",
public_hdrs = [ public_hdrs = [
"include/grpcpp/ext/server_load_reporting.h", "include/grpcpp/ext/server_load_reporting.h",
"include/grpcpp/ext/server_load_reporting_impl.h",
], ],
deps = [ deps = [
"lb_server_load_reporting_filter", "lb_server_load_reporting_filter",
@ -2200,6 +2199,7 @@ grpc_cc_library(
public_hdrs = [ public_hdrs = [
"include/grpc++/ext/proto_server_reflection_plugin.h", "include/grpc++/ext/proto_server_reflection_plugin.h",
"include/grpcpp/ext/proto_server_reflection_plugin.h", "include/grpcpp/ext/proto_server_reflection_plugin.h",
"include/grpcpp/ext/proto_server_reflection_plugin_impl.h",
], ],
deps = [ deps = [
":grpc++", ":grpc++",
@ -2220,6 +2220,7 @@ grpc_cc_library(
language = "c++", language = "c++",
public_hdrs = [ public_hdrs = [
"include/grpcpp/ext/channelz_service_plugin.h", "include/grpcpp/ext/channelz_service_plugin.h",
"include/grpcpp/ext/channelz_service_plugin_impl.h",
], ],
deps = [ deps = [
":grpc++", ":grpc++",
@ -2284,6 +2285,7 @@ grpc_cc_library(
], ],
hdrs = [ hdrs = [
"include/grpcpp/opencensus.h", "include/grpcpp/opencensus.h",
"include/grpcpp/opencensus_impl.h",
"src/cpp/ext/filters/census/channel_filter.h", "src/cpp/ext/filters/census/channel_filter.h",
"src/cpp/ext/filters/census/client_filter.h", "src/cpp/ext/filters/census/client_filter.h",
"src/cpp/ext/filters/census/context.h", "src/cpp/ext/filters/census/context.h",
@ -2317,34 +2319,34 @@ grpc_cc_library(
name = "envoy_ads_upb", name = "envoy_ads_upb",
srcs = [ srcs = [
"src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c", "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c",
"src/core/ext/upb-generated/envoy/api/v2/cds.upb.c",
"src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c", "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c",
"src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c", "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c",
"src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c", "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c",
"src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c",
"src/core/ext/upb-generated/envoy/api/v2/cds.upb.c",
"src/core/ext/upb-generated/envoy/api/v2/eds.upb.c", "src/core/ext/upb-generated/envoy/api/v2/eds.upb.c",
"src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c",
"src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c", "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c",
], ],
hdrs = [ hdrs = [
"src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h", "src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/cds.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h", "src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h", "src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h", "src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/cds.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/eds.upb.h", "src/core/ext/upb-generated/envoy/api/v2/eds.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h",
"src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h", "src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h",
], ],
language = "c++",
external_deps = [ external_deps = [
"upb_lib", "upb_lib",
], ],
language = "c++",
deps = [ deps = [
":envoy_core_upb", ":envoy_core_upb",
":envoy_type_upb", ":envoy_type_upb",
":google_api_upb", ":google_api_upb",
":proto_gen_validate_upb", ":proto_gen_validate_upb",
] ],
) )
grpc_cc_library( grpc_cc_library(
@ -2365,15 +2367,16 @@ grpc_cc_library(
"src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h", "src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h",
"src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h", "src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h",
], ],
language = "c++",
external_deps = [ external_deps = [
"upb_lib", "upb_lib",
], ],
language = "c++",
tags = ["no_windows"],
deps = [ deps = [
":envoy_type_upb", ":envoy_type_upb",
":google_api_upb", ":google_api_upb",
":proto_gen_validate_upb" ":proto_gen_validate_upb",
] ],
) )
grpc_cc_library( grpc_cc_library(
@ -2386,14 +2389,15 @@ grpc_cc_library(
"src/core/ext/upb-generated/envoy/type/percent.upb.h", "src/core/ext/upb-generated/envoy/type/percent.upb.h",
"src/core/ext/upb-generated/envoy/type/range.upb.h", "src/core/ext/upb-generated/envoy/type/range.upb.h",
], ],
language = "c++",
external_deps = [ external_deps = [
"upb_lib", "upb_lib",
], ],
language = "c++",
tags = ["no_windows"],
deps = [ deps = [
":google_api_upb", ":google_api_upb",
":proto_gen_validate_upb" ":proto_gen_validate_upb",
] ],
) )
grpc_cc_library( grpc_cc_library(
@ -2406,13 +2410,14 @@ grpc_cc_library(
"src/core/ext/upb-generated/gogoproto/gogo.upb.h", "src/core/ext/upb-generated/gogoproto/gogo.upb.h",
"src/core/ext/upb-generated/validate/validate.upb.h", "src/core/ext/upb-generated/validate/validate.upb.h",
], ],
language = "c++",
external_deps = [ external_deps = [
"upb_lib", "upb_lib",
], ],
language = "c++",
tags = ["no_windows"],
deps = [ deps = [
":google_api_upb", ":google_api_upb",
] ],
) )
grpc_cc_library( grpc_cc_library(
@ -2441,10 +2446,11 @@ grpc_cc_library(
"src/core/ext/upb-generated/google/protobuf/wrappers.upb.h", "src/core/ext/upb-generated/google/protobuf/wrappers.upb.h",
"src/core/ext/upb-generated/google/rpc/status.upb.h", "src/core/ext/upb-generated/google/rpc/status.upb.h",
], ],
language = "c++",
external_deps = [ external_deps = [
"upb_lib", "upb_lib",
], ],
language = "c++",
tags = ["no_windows"],
) )
grpc_generate_one_off_targets() grpc_generate_one_off_targets()

@ -184,8 +184,10 @@ config("grpc_config") {
"src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/fork.cc",
"src/core/lib/gprpp/fork.h", "src/core/lib/gprpp/fork.h",
"src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/manual_constructor.h",
"src/core/lib/gprpp/map.h",
"src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/memory.h",
"src/core/lib/gprpp/mutex_lock.h", "src/core/lib/gprpp/mutex_lock.h",
"src/core/lib/gprpp/pair.h",
"src/core/lib/gprpp/thd.h", "src/core/lib/gprpp/thd.h",
"src/core/lib/gprpp/thd_posix.cc", "src/core/lib/gprpp/thd_posix.cc",
"src/core/lib/gprpp/thd_windows.cc", "src/core/lib/gprpp/thd_windows.cc",
@ -1004,12 +1006,16 @@ config("grpc_config") {
"include/grpcpp/client_context.h", "include/grpcpp/client_context.h",
"include/grpcpp/completion_queue.h", "include/grpcpp/completion_queue.h",
"include/grpcpp/create_channel.h", "include/grpcpp/create_channel.h",
"include/grpcpp/create_channel_impl.h",
"include/grpcpp/create_channel_posix.h", "include/grpcpp/create_channel_posix.h",
"include/grpcpp/create_channel_posix_impl.h",
"include/grpcpp/ext/health_check_service_server_builder_option.h", "include/grpcpp/ext/health_check_service_server_builder_option.h",
"include/grpcpp/generic/async_generic_service.h", "include/grpcpp/generic/async_generic_service.h",
"include/grpcpp/generic/generic_stub.h", "include/grpcpp/generic/generic_stub.h",
"include/grpcpp/generic/generic_stub_impl.h",
"include/grpcpp/grpcpp.h", "include/grpcpp/grpcpp.h",
"include/grpcpp/health_check_service_interface.h", "include/grpcpp/health_check_service_interface.h",
"include/grpcpp/health_check_service_interface_impl.h",
"include/grpcpp/impl/call.h", "include/grpcpp/impl/call.h",
"include/grpcpp/impl/channel_argument_option.h", "include/grpcpp/impl/channel_argument_option.h",
"include/grpcpp/impl/client_unary_call.h", "include/grpcpp/impl/client_unary_call.h",
@ -1066,18 +1072,24 @@ config("grpc_config") {
"include/grpcpp/impl/rpc_service_method.h", "include/grpcpp/impl/rpc_service_method.h",
"include/grpcpp/impl/serialization_traits.h", "include/grpcpp/impl/serialization_traits.h",
"include/grpcpp/impl/server_builder_option.h", "include/grpcpp/impl/server_builder_option.h",
"include/grpcpp/impl/server_builder_option_impl.h",
"include/grpcpp/impl/server_builder_plugin.h", "include/grpcpp/impl/server_builder_plugin.h",
"include/grpcpp/impl/server_initializer.h", "include/grpcpp/impl/server_initializer.h",
"include/grpcpp/impl/server_initializer_impl.h",
"include/grpcpp/impl/service_type.h", "include/grpcpp/impl/service_type.h",
"include/grpcpp/resource_quota.h", "include/grpcpp/resource_quota.h",
"include/grpcpp/resource_quota_impl.h",
"include/grpcpp/security/auth_context.h", "include/grpcpp/security/auth_context.h",
"include/grpcpp/security/auth_metadata_processor.h", "include/grpcpp/security/auth_metadata_processor.h",
"include/grpcpp/security/auth_metadata_processor_impl.h",
"include/grpcpp/security/credentials.h", "include/grpcpp/security/credentials.h",
"include/grpcpp/security/server_credentials.h", "include/grpcpp/security/server_credentials.h",
"include/grpcpp/security/server_credentials_impl.h",
"include/grpcpp/server.h", "include/grpcpp/server.h",
"include/grpcpp/server_builder.h", "include/grpcpp/server_builder.h",
"include/grpcpp/server_context.h", "include/grpcpp/server_context.h",
"include/grpcpp/server_posix.h", "include/grpcpp/server_posix.h",
"include/grpcpp/server_posix_impl.h",
"include/grpcpp/support/async_stream.h", "include/grpcpp/support/async_stream.h",
"include/grpcpp/support/async_unary_call.h", "include/grpcpp/support/async_unary_call.h",
"include/grpcpp/support/byte_buffer.h", "include/grpcpp/support/byte_buffer.h",
@ -1143,10 +1155,12 @@ config("grpc_config") {
"src/core/lib/gprpp/fork.h", "src/core/lib/gprpp/fork.h",
"src/core/lib/gprpp/inlined_vector.h", "src/core/lib/gprpp/inlined_vector.h",
"src/core/lib/gprpp/manual_constructor.h", "src/core/lib/gprpp/manual_constructor.h",
"src/core/lib/gprpp/map.h",
"src/core/lib/gprpp/memory.h", "src/core/lib/gprpp/memory.h",
"src/core/lib/gprpp/mutex_lock.h", "src/core/lib/gprpp/mutex_lock.h",
"src/core/lib/gprpp/optional.h", "src/core/lib/gprpp/optional.h",
"src/core/lib/gprpp/orphanable.h", "src/core/lib/gprpp/orphanable.h",
"src/core/lib/gprpp/pair.h",
"src/core/lib/gprpp/ref_counted.h", "src/core/lib/gprpp/ref_counted.h",
"src/core/lib/gprpp/ref_counted_ptr.h", "src/core/lib/gprpp/ref_counted_ptr.h",
"src/core/lib/gprpp/thd.h", "src/core/lib/gprpp/thd.h",

@ -24,7 +24,7 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
set(PACKAGE_NAME "grpc") set(PACKAGE_NAME "grpc")
set(PACKAGE_VERSION "1.20.0-dev") set(PACKAGE_VERSION "1.21.0-dev")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
@ -631,6 +631,7 @@ add_dependencies(buildtests_cxx generic_end2end_test)
add_dependencies(buildtests_cxx golden_file_test) add_dependencies(buildtests_cxx golden_file_test)
add_dependencies(buildtests_cxx grpc_alts_credentials_options_test) add_dependencies(buildtests_cxx grpc_alts_credentials_options_test)
add_dependencies(buildtests_cxx grpc_cli) add_dependencies(buildtests_cxx grpc_cli)
add_dependencies(buildtests_cxx grpc_core_map_test)
add_dependencies(buildtests_cxx grpc_linux_system_roots_test) add_dependencies(buildtests_cxx grpc_linux_system_roots_test)
add_dependencies(buildtests_cxx grpc_tool_test) add_dependencies(buildtests_cxx grpc_tool_test)
add_dependencies(buildtests_cxx grpclb_api_test) add_dependencies(buildtests_cxx grpclb_api_test)
@ -3000,12 +3001,16 @@ foreach(_hdr
include/grpcpp/client_context.h include/grpcpp/client_context.h
include/grpcpp/completion_queue.h include/grpcpp/completion_queue.h
include/grpcpp/create_channel.h include/grpcpp/create_channel.h
include/grpcpp/create_channel_impl.h
include/grpcpp/create_channel_posix.h include/grpcpp/create_channel_posix.h
include/grpcpp/create_channel_posix_impl.h
include/grpcpp/ext/health_check_service_server_builder_option.h include/grpcpp/ext/health_check_service_server_builder_option.h
include/grpcpp/generic/async_generic_service.h include/grpcpp/generic/async_generic_service.h
include/grpcpp/generic/generic_stub.h include/grpcpp/generic/generic_stub.h
include/grpcpp/generic/generic_stub_impl.h
include/grpcpp/grpcpp.h include/grpcpp/grpcpp.h
include/grpcpp/health_check_service_interface.h include/grpcpp/health_check_service_interface.h
include/grpcpp/health_check_service_interface_impl.h
include/grpcpp/impl/call.h include/grpcpp/impl/call.h
include/grpcpp/impl/channel_argument_option.h include/grpcpp/impl/channel_argument_option.h
include/grpcpp/impl/client_unary_call.h include/grpcpp/impl/client_unary_call.h
@ -3016,18 +3021,24 @@ foreach(_hdr
include/grpcpp/impl/rpc_service_method.h include/grpcpp/impl/rpc_service_method.h
include/grpcpp/impl/serialization_traits.h include/grpcpp/impl/serialization_traits.h
include/grpcpp/impl/server_builder_option.h include/grpcpp/impl/server_builder_option.h
include/grpcpp/impl/server_builder_option_impl.h
include/grpcpp/impl/server_builder_plugin.h include/grpcpp/impl/server_builder_plugin.h
include/grpcpp/impl/server_initializer.h include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/server_initializer_impl.h
include/grpcpp/impl/service_type.h include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h
include/grpcpp/security/auth_context.h include/grpcpp/security/auth_context.h
include/grpcpp/security/auth_metadata_processor.h include/grpcpp/security/auth_metadata_processor.h
include/grpcpp/security/auth_metadata_processor_impl.h
include/grpcpp/security/credentials.h include/grpcpp/security/credentials.h
include/grpcpp/security/server_credentials.h include/grpcpp/security/server_credentials.h
include/grpcpp/security/server_credentials_impl.h
include/grpcpp/server.h include/grpcpp/server.h
include/grpcpp/server_builder.h include/grpcpp/server_builder.h
include/grpcpp/server_context.h include/grpcpp/server_context.h
include/grpcpp/server_posix.h include/grpcpp/server_posix.h
include/grpcpp/server_posix_impl.h
include/grpcpp/support/async_stream.h include/grpcpp/support/async_stream.h
include/grpcpp/support/async_unary_call.h include/grpcpp/support/async_unary_call.h
include/grpcpp/support/byte_buffer.h include/grpcpp/support/byte_buffer.h
@ -3591,12 +3602,16 @@ foreach(_hdr
include/grpcpp/client_context.h include/grpcpp/client_context.h
include/grpcpp/completion_queue.h include/grpcpp/completion_queue.h
include/grpcpp/create_channel.h include/grpcpp/create_channel.h
include/grpcpp/create_channel_impl.h
include/grpcpp/create_channel_posix.h include/grpcpp/create_channel_posix.h
include/grpcpp/create_channel_posix_impl.h
include/grpcpp/ext/health_check_service_server_builder_option.h include/grpcpp/ext/health_check_service_server_builder_option.h
include/grpcpp/generic/async_generic_service.h include/grpcpp/generic/async_generic_service.h
include/grpcpp/generic/generic_stub.h include/grpcpp/generic/generic_stub.h
include/grpcpp/generic/generic_stub_impl.h
include/grpcpp/grpcpp.h include/grpcpp/grpcpp.h
include/grpcpp/health_check_service_interface.h include/grpcpp/health_check_service_interface.h
include/grpcpp/health_check_service_interface_impl.h
include/grpcpp/impl/call.h include/grpcpp/impl/call.h
include/grpcpp/impl/channel_argument_option.h include/grpcpp/impl/channel_argument_option.h
include/grpcpp/impl/client_unary_call.h include/grpcpp/impl/client_unary_call.h
@ -3607,18 +3622,24 @@ foreach(_hdr
include/grpcpp/impl/rpc_service_method.h include/grpcpp/impl/rpc_service_method.h
include/grpcpp/impl/serialization_traits.h include/grpcpp/impl/serialization_traits.h
include/grpcpp/impl/server_builder_option.h include/grpcpp/impl/server_builder_option.h
include/grpcpp/impl/server_builder_option_impl.h
include/grpcpp/impl/server_builder_plugin.h include/grpcpp/impl/server_builder_plugin.h
include/grpcpp/impl/server_initializer.h include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/server_initializer_impl.h
include/grpcpp/impl/service_type.h include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h
include/grpcpp/security/auth_context.h include/grpcpp/security/auth_context.h
include/grpcpp/security/auth_metadata_processor.h include/grpcpp/security/auth_metadata_processor.h
include/grpcpp/security/auth_metadata_processor_impl.h
include/grpcpp/security/credentials.h include/grpcpp/security/credentials.h
include/grpcpp/security/server_credentials.h include/grpcpp/security/server_credentials.h
include/grpcpp/security/server_credentials_impl.h
include/grpcpp/server.h include/grpcpp/server.h
include/grpcpp/server_builder.h include/grpcpp/server_builder.h
include/grpcpp/server_context.h include/grpcpp/server_context.h
include/grpcpp/server_posix.h include/grpcpp/server_posix.h
include/grpcpp/server_posix_impl.h
include/grpcpp/support/async_stream.h include/grpcpp/support/async_stream.h
include/grpcpp/support/async_unary_call.h include/grpcpp/support/async_unary_call.h
include/grpcpp/support/byte_buffer.h include/grpcpp/support/byte_buffer.h
@ -3826,6 +3847,7 @@ target_link_libraries(grpc++_error_details
foreach(_hdr foreach(_hdr
include/grpc++/support/error_details.h include/grpc++/support/error_details.h
include/grpcpp/support/error_details.h include/grpcpp/support/error_details.h
include/grpcpp/support/error_details_impl.h
) )
string(REPLACE "include/" "" _path ${_hdr}) string(REPLACE "include/" "" _path ${_hdr})
get_filename_component(_path ${_path} PATH) get_filename_component(_path ${_path} PATH)
@ -3959,6 +3981,7 @@ target_link_libraries(grpc++_reflection
foreach(_hdr foreach(_hdr
include/grpc++/ext/proto_server_reflection_plugin.h include/grpc++/ext/proto_server_reflection_plugin.h
include/grpcpp/ext/proto_server_reflection_plugin.h include/grpcpp/ext/proto_server_reflection_plugin.h
include/grpcpp/ext/proto_server_reflection_plugin_impl.h
) )
string(REPLACE "include/" "" _path ${_hdr}) string(REPLACE "include/" "" _path ${_hdr})
get_filename_component(_path ${_path} PATH) get_filename_component(_path ${_path} PATH)
@ -4554,12 +4577,16 @@ foreach(_hdr
include/grpcpp/client_context.h include/grpcpp/client_context.h
include/grpcpp/completion_queue.h include/grpcpp/completion_queue.h
include/grpcpp/create_channel.h include/grpcpp/create_channel.h
include/grpcpp/create_channel_impl.h
include/grpcpp/create_channel_posix.h include/grpcpp/create_channel_posix.h
include/grpcpp/create_channel_posix_impl.h
include/grpcpp/ext/health_check_service_server_builder_option.h include/grpcpp/ext/health_check_service_server_builder_option.h
include/grpcpp/generic/async_generic_service.h include/grpcpp/generic/async_generic_service.h
include/grpcpp/generic/generic_stub.h include/grpcpp/generic/generic_stub.h
include/grpcpp/generic/generic_stub_impl.h
include/grpcpp/grpcpp.h include/grpcpp/grpcpp.h
include/grpcpp/health_check_service_interface.h include/grpcpp/health_check_service_interface.h
include/grpcpp/health_check_service_interface_impl.h
include/grpcpp/impl/call.h include/grpcpp/impl/call.h
include/grpcpp/impl/channel_argument_option.h include/grpcpp/impl/channel_argument_option.h
include/grpcpp/impl/client_unary_call.h include/grpcpp/impl/client_unary_call.h
@ -4570,18 +4597,24 @@ foreach(_hdr
include/grpcpp/impl/rpc_service_method.h include/grpcpp/impl/rpc_service_method.h
include/grpcpp/impl/serialization_traits.h include/grpcpp/impl/serialization_traits.h
include/grpcpp/impl/server_builder_option.h include/grpcpp/impl/server_builder_option.h
include/grpcpp/impl/server_builder_option_impl.h
include/grpcpp/impl/server_builder_plugin.h include/grpcpp/impl/server_builder_plugin.h
include/grpcpp/impl/server_initializer.h include/grpcpp/impl/server_initializer.h
include/grpcpp/impl/server_initializer_impl.h
include/grpcpp/impl/service_type.h include/grpcpp/impl/service_type.h
include/grpcpp/resource_quota.h include/grpcpp/resource_quota.h
include/grpcpp/resource_quota_impl.h
include/grpcpp/security/auth_context.h include/grpcpp/security/auth_context.h
include/grpcpp/security/auth_metadata_processor.h include/grpcpp/security/auth_metadata_processor.h
include/grpcpp/security/auth_metadata_processor_impl.h
include/grpcpp/security/credentials.h include/grpcpp/security/credentials.h
include/grpcpp/security/server_credentials.h include/grpcpp/security/server_credentials.h
include/grpcpp/security/server_credentials_impl.h
include/grpcpp/server.h include/grpcpp/server.h
include/grpcpp/server_builder.h include/grpcpp/server_builder.h
include/grpcpp/server_context.h include/grpcpp/server_context.h
include/grpcpp/server_posix.h include/grpcpp/server_posix.h
include/grpcpp/server_posix_impl.h
include/grpcpp/support/async_stream.h include/grpcpp/support/async_stream.h
include/grpcpp/support/async_unary_call.h include/grpcpp/support/async_unary_call.h
include/grpcpp/support/byte_buffer.h include/grpcpp/support/byte_buffer.h
@ -4966,6 +4999,7 @@ target_link_libraries(grpcpp_channelz
foreach(_hdr foreach(_hdr
include/grpcpp/ext/channelz_service_plugin.h include/grpcpp/ext/channelz_service_plugin.h
include/grpcpp/ext/channelz_service_plugin_impl.h
) )
string(REPLACE "include/" "" _path ${_hdr}) string(REPLACE "include/" "" _path ${_hdr})
get_filename_component(_path ${_path} PATH) get_filename_component(_path ${_path} PATH)
@ -13456,6 +13490,45 @@ target_link_libraries(grpc_cli
) )
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(grpc_core_map_test
test/core/gprpp/map_test.cc
third_party/googletest/googletest/src/gtest-all.cc
third_party/googletest/googlemock/src/gmock-all.cc
)
target_include_directories(grpc_core_map_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
PRIVATE ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR}
PRIVATE ${_gRPC_NANOPB_INCLUDE_DIR}
PRIVATE third_party/googletest/googletest/include
PRIVATE third_party/googletest/googletest
PRIVATE third_party/googletest/googlemock/include
PRIVATE third_party/googletest/googlemock
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
target_link_libraries(grpc_core_map_test
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
grpc_test_util
grpc++
grpc
gpr
${_gRPC_GFLAGS_LIBRARIES}
)
endif (gRPC_BUILD_TESTS) endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_CODEGEN) if (gRPC_BUILD_CODEGEN)

@ -460,8 +460,8 @@ Q = @
endif endif
CORE_VERSION = 7.0.0 CORE_VERSION = 7.0.0
CPP_VERSION = 1.20.0-dev CPP_VERSION = 1.21.0-dev
CSHARP_VERSION = 1.20.0-dev CSHARP_VERSION = 1.21.0-dev
CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES))
CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS)
@ -1209,6 +1209,7 @@ generic_end2end_test: $(BINDIR)/$(CONFIG)/generic_end2end_test
golden_file_test: $(BINDIR)/$(CONFIG)/golden_file_test golden_file_test: $(BINDIR)/$(CONFIG)/golden_file_test
grpc_alts_credentials_options_test: $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test grpc_alts_credentials_options_test: $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test
grpc_cli: $(BINDIR)/$(CONFIG)/grpc_cli grpc_cli: $(BINDIR)/$(CONFIG)/grpc_cli
grpc_core_map_test: $(BINDIR)/$(CONFIG)/grpc_core_map_test
grpc_cpp_plugin: $(BINDIR)/$(CONFIG)/grpc_cpp_plugin grpc_cpp_plugin: $(BINDIR)/$(CONFIG)/grpc_cpp_plugin
grpc_csharp_plugin: $(BINDIR)/$(CONFIG)/grpc_csharp_plugin grpc_csharp_plugin: $(BINDIR)/$(CONFIG)/grpc_csharp_plugin
grpc_linux_system_roots_test: $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test grpc_linux_system_roots_test: $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test
@ -1681,6 +1682,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/golden_file_test \ $(BINDIR)/$(CONFIG)/golden_file_test \
$(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \
$(BINDIR)/$(CONFIG)/grpc_cli \ $(BINDIR)/$(CONFIG)/grpc_cli \
$(BINDIR)/$(CONFIG)/grpc_core_map_test \
$(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \ $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \
$(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpc_tool_test \
$(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \
@ -1823,6 +1825,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/golden_file_test \ $(BINDIR)/$(CONFIG)/golden_file_test \
$(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \ $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test \
$(BINDIR)/$(CONFIG)/grpc_cli \ $(BINDIR)/$(CONFIG)/grpc_cli \
$(BINDIR)/$(CONFIG)/grpc_core_map_test \
$(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \ $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test \
$(BINDIR)/$(CONFIG)/grpc_tool_test \ $(BINDIR)/$(CONFIG)/grpc_tool_test \
$(BINDIR)/$(CONFIG)/grpclb_api_test \ $(BINDIR)/$(CONFIG)/grpclb_api_test \
@ -2314,6 +2317,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/golden_file_test || ( echo test golden_file_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/golden_file_test || ( echo test golden_file_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_alts_credentials_options_test" $(E) "[RUN] Testing grpc_alts_credentials_options_test"
$(Q) $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test || ( echo test grpc_alts_credentials_options_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpc_alts_credentials_options_test || ( echo test grpc_alts_credentials_options_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_core_map_test"
$(Q) $(BINDIR)/$(CONFIG)/grpc_core_map_test || ( echo test grpc_core_map_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_linux_system_roots_test" $(E) "[RUN] Testing grpc_linux_system_roots_test"
$(Q) $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test || ( echo test grpc_linux_system_roots_test failed ; exit 1 ) $(Q) $(BINDIR)/$(CONFIG)/grpc_linux_system_roots_test || ( echo test grpc_linux_system_roots_test failed ; exit 1 )
$(E) "[RUN] Testing grpc_tool_test" $(E) "[RUN] Testing grpc_tool_test"
@ -5331,12 +5336,16 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/client_context.h \ include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \ include/grpcpp/completion_queue.h \
include/grpcpp/create_channel.h \ include/grpcpp/create_channel.h \
include/grpcpp/create_channel_impl.h \
include/grpcpp/create_channel_posix.h \ include/grpcpp/create_channel_posix.h \
include/grpcpp/create_channel_posix_impl.h \
include/grpcpp/ext/health_check_service_server_builder_option.h \ include/grpcpp/ext/health_check_service_server_builder_option.h \
include/grpcpp/generic/async_generic_service.h \ include/grpcpp/generic/async_generic_service.h \
include/grpcpp/generic/generic_stub.h \ include/grpcpp/generic/generic_stub.h \
include/grpcpp/generic/generic_stub_impl.h \
include/grpcpp/grpcpp.h \ include/grpcpp/grpcpp.h \
include/grpcpp/health_check_service_interface.h \ include/grpcpp/health_check_service_interface.h \
include/grpcpp/health_check_service_interface_impl.h \
include/grpcpp/impl/call.h \ include/grpcpp/impl/call.h \
include/grpcpp/impl/channel_argument_option.h \ include/grpcpp/impl/channel_argument_option.h \
include/grpcpp/impl/client_unary_call.h \ include/grpcpp/impl/client_unary_call.h \
@ -5347,18 +5356,24 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/rpc_service_method.h \ include/grpcpp/impl/rpc_service_method.h \
include/grpcpp/impl/serialization_traits.h \ include/grpcpp/impl/serialization_traits.h \
include/grpcpp/impl/server_builder_option.h \ include/grpcpp/impl/server_builder_option.h \
include/grpcpp/impl/server_builder_option_impl.h \
include/grpcpp/impl/server_builder_plugin.h \ include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/server_initializer_impl.h \
include/grpcpp/impl/service_type.h \ include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \ include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
include/grpcpp/security/auth_context.h \ include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \ include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/auth_metadata_processor_impl.h \
include/grpcpp/security/credentials.h \ include/grpcpp/security/credentials.h \
include/grpcpp/security/server_credentials.h \ include/grpcpp/security/server_credentials.h \
include/grpcpp/security/server_credentials_impl.h \
include/grpcpp/server.h \ include/grpcpp/server.h \
include/grpcpp/server_builder.h \ include/grpcpp/server_builder.h \
include/grpcpp/server_context.h \ include/grpcpp/server_context.h \
include/grpcpp/server_posix.h \ include/grpcpp/server_posix.h \
include/grpcpp/server_posix_impl.h \
include/grpcpp/support/async_stream.h \ include/grpcpp/support/async_stream.h \
include/grpcpp/support/async_unary_call.h \ include/grpcpp/support/async_unary_call.h \
include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/byte_buffer.h \
@ -5930,12 +5945,16 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/client_context.h \ include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \ include/grpcpp/completion_queue.h \
include/grpcpp/create_channel.h \ include/grpcpp/create_channel.h \
include/grpcpp/create_channel_impl.h \
include/grpcpp/create_channel_posix.h \ include/grpcpp/create_channel_posix.h \
include/grpcpp/create_channel_posix_impl.h \
include/grpcpp/ext/health_check_service_server_builder_option.h \ include/grpcpp/ext/health_check_service_server_builder_option.h \
include/grpcpp/generic/async_generic_service.h \ include/grpcpp/generic/async_generic_service.h \
include/grpcpp/generic/generic_stub.h \ include/grpcpp/generic/generic_stub.h \
include/grpcpp/generic/generic_stub_impl.h \
include/grpcpp/grpcpp.h \ include/grpcpp/grpcpp.h \
include/grpcpp/health_check_service_interface.h \ include/grpcpp/health_check_service_interface.h \
include/grpcpp/health_check_service_interface_impl.h \
include/grpcpp/impl/call.h \ include/grpcpp/impl/call.h \
include/grpcpp/impl/channel_argument_option.h \ include/grpcpp/impl/channel_argument_option.h \
include/grpcpp/impl/client_unary_call.h \ include/grpcpp/impl/client_unary_call.h \
@ -5946,18 +5965,24 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/rpc_service_method.h \ include/grpcpp/impl/rpc_service_method.h \
include/grpcpp/impl/serialization_traits.h \ include/grpcpp/impl/serialization_traits.h \
include/grpcpp/impl/server_builder_option.h \ include/grpcpp/impl/server_builder_option.h \
include/grpcpp/impl/server_builder_option_impl.h \
include/grpcpp/impl/server_builder_plugin.h \ include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/server_initializer_impl.h \
include/grpcpp/impl/service_type.h \ include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \ include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
include/grpcpp/security/auth_context.h \ include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \ include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/auth_metadata_processor_impl.h \
include/grpcpp/security/credentials.h \ include/grpcpp/security/credentials.h \
include/grpcpp/security/server_credentials.h \ include/grpcpp/security/server_credentials.h \
include/grpcpp/security/server_credentials_impl.h \
include/grpcpp/server.h \ include/grpcpp/server.h \
include/grpcpp/server_builder.h \ include/grpcpp/server_builder.h \
include/grpcpp/server_context.h \ include/grpcpp/server_context.h \
include/grpcpp/server_posix.h \ include/grpcpp/server_posix.h \
include/grpcpp/server_posix_impl.h \
include/grpcpp/support/async_stream.h \ include/grpcpp/support/async_stream.h \
include/grpcpp/support/async_unary_call.h \ include/grpcpp/support/async_unary_call.h \
include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/byte_buffer.h \
@ -6171,6 +6196,7 @@ LIBGRPC++_ERROR_DETAILS_SRC = \
PUBLIC_HEADERS_CXX += \ PUBLIC_HEADERS_CXX += \
include/grpc++/support/error_details.h \ include/grpc++/support/error_details.h \
include/grpcpp/support/error_details.h \ include/grpcpp/support/error_details.h \
include/grpcpp/support/error_details_impl.h \
LIBGRPC++_ERROR_DETAILS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_ERROR_DETAILS_SRC)))) LIBGRPC++_ERROR_DETAILS_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_ERROR_DETAILS_SRC))))
@ -6297,6 +6323,7 @@ LIBGRPC++_REFLECTION_SRC = \
PUBLIC_HEADERS_CXX += \ PUBLIC_HEADERS_CXX += \
include/grpc++/ext/proto_server_reflection_plugin.h \ include/grpc++/ext/proto_server_reflection_plugin.h \
include/grpcpp/ext/proto_server_reflection_plugin.h \ include/grpcpp/ext/proto_server_reflection_plugin.h \
include/grpcpp/ext/proto_server_reflection_plugin_impl.h \
LIBGRPC++_REFLECTION_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_REFLECTION_SRC)))) LIBGRPC++_REFLECTION_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_REFLECTION_SRC))))
@ -6842,12 +6869,16 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/client_context.h \ include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \ include/grpcpp/completion_queue.h \
include/grpcpp/create_channel.h \ include/grpcpp/create_channel.h \
include/grpcpp/create_channel_impl.h \
include/grpcpp/create_channel_posix.h \ include/grpcpp/create_channel_posix.h \
include/grpcpp/create_channel_posix_impl.h \
include/grpcpp/ext/health_check_service_server_builder_option.h \ include/grpcpp/ext/health_check_service_server_builder_option.h \
include/grpcpp/generic/async_generic_service.h \ include/grpcpp/generic/async_generic_service.h \
include/grpcpp/generic/generic_stub.h \ include/grpcpp/generic/generic_stub.h \
include/grpcpp/generic/generic_stub_impl.h \
include/grpcpp/grpcpp.h \ include/grpcpp/grpcpp.h \
include/grpcpp/health_check_service_interface.h \ include/grpcpp/health_check_service_interface.h \
include/grpcpp/health_check_service_interface_impl.h \
include/grpcpp/impl/call.h \ include/grpcpp/impl/call.h \
include/grpcpp/impl/channel_argument_option.h \ include/grpcpp/impl/channel_argument_option.h \
include/grpcpp/impl/client_unary_call.h \ include/grpcpp/impl/client_unary_call.h \
@ -6858,18 +6889,24 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/rpc_service_method.h \ include/grpcpp/impl/rpc_service_method.h \
include/grpcpp/impl/serialization_traits.h \ include/grpcpp/impl/serialization_traits.h \
include/grpcpp/impl/server_builder_option.h \ include/grpcpp/impl/server_builder_option.h \
include/grpcpp/impl/server_builder_option_impl.h \
include/grpcpp/impl/server_builder_plugin.h \ include/grpcpp/impl/server_builder_plugin.h \
include/grpcpp/impl/server_initializer.h \ include/grpcpp/impl/server_initializer.h \
include/grpcpp/impl/server_initializer_impl.h \
include/grpcpp/impl/service_type.h \ include/grpcpp/impl/service_type.h \
include/grpcpp/resource_quota.h \ include/grpcpp/resource_quota.h \
include/grpcpp/resource_quota_impl.h \
include/grpcpp/security/auth_context.h \ include/grpcpp/security/auth_context.h \
include/grpcpp/security/auth_metadata_processor.h \ include/grpcpp/security/auth_metadata_processor.h \
include/grpcpp/security/auth_metadata_processor_impl.h \
include/grpcpp/security/credentials.h \ include/grpcpp/security/credentials.h \
include/grpcpp/security/server_credentials.h \ include/grpcpp/security/server_credentials.h \
include/grpcpp/security/server_credentials_impl.h \
include/grpcpp/server.h \ include/grpcpp/server.h \
include/grpcpp/server_builder.h \ include/grpcpp/server_builder.h \
include/grpcpp/server_context.h \ include/grpcpp/server_context.h \
include/grpcpp/server_posix.h \ include/grpcpp/server_posix.h \
include/grpcpp/server_posix_impl.h \
include/grpcpp/support/async_stream.h \ include/grpcpp/support/async_stream.h \
include/grpcpp/support/async_unary_call.h \ include/grpcpp/support/async_unary_call.h \
include/grpcpp/support/byte_buffer.h \ include/grpcpp/support/byte_buffer.h \
@ -7223,6 +7260,7 @@ LIBGRPCPP_CHANNELZ_SRC = \
PUBLIC_HEADERS_CXX += \ PUBLIC_HEADERS_CXX += \
include/grpcpp/ext/channelz_service_plugin.h \ include/grpcpp/ext/channelz_service_plugin.h \
include/grpcpp/ext/channelz_service_plugin_impl.h \
LIBGRPCPP_CHANNELZ_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPCPP_CHANNELZ_SRC)))) LIBGRPCPP_CHANNELZ_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPCPP_CHANNELZ_SRC))))
@ -16426,6 +16464,49 @@ endif
endif endif
GRPC_CORE_MAP_TEST_SRC = \
test/core/gprpp/map_test.cc \
GRPC_CORE_MAP_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPC_CORE_MAP_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/grpc_core_map_test: openssl_dep_error
else
ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.5.0+.
$(BINDIR)/$(CONFIG)/grpc_core_map_test: protobuf_dep_error
else
$(BINDIR)/$(CONFIG)/grpc_core_map_test: $(PROTOBUF_DEP) $(GRPC_CORE_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LDXX) $(LDFLAGS) $(GRPC_CORE_MAP_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpc_core_map_test
endif
endif
$(OBJDIR)/$(CONFIG)/test/core/gprpp/map_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_grpc_core_map_test: $(GRPC_CORE_MAP_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(GRPC_CORE_MAP_TEST_OBJS:.o=.dep)
endif
endif
GRPC_CPP_PLUGIN_SRC = \ GRPC_CPP_PLUGIN_SRC = \
src/compiler/cpp_plugin.cc \ src/compiler/cpp_plugin.cc \

@ -17,20 +17,13 @@ register_toolchains(
"//third_party/toolchains:cc-toolchain-clang-x86_64-default", "//third_party/toolchains:cc-toolchain-clang-x86_64-default",
) )
http_archive( # TODO(https://github.com/grpc/grpc/issues/18331): Move off of this dependency.
name = "cython", git_repository(
build_file = "//third_party:cython.BUILD", name = "org_pubref_rules_protobuf",
sha256 = "d68138a2381afbdd0876c3cb2a22389043fa01c4badede1228ee073032b07a27", remote = "https://github.com/ghostwriternr/rules_protobuf",
strip_prefix = "cython-c2b80d87658a8525ce091cbe146cb7eaa29fed5c", tag = "v0.8.2.1-alpha",
urls = [
"https://github.com/cython/cython/archive/c2b80d87658a8525ce091cbe146cb7eaa29fed5c.tar.gz",
],
) )
load("//third_party/py:python_configure.bzl", "python_configure")
python_configure(name = "local_config_python")
git_repository( git_repository(
name = "io_bazel_rules_python", name = "io_bazel_rules_python",
commit = "8b5d0683a7d878b28fffe464779c8a53659fc645", commit = "8b5d0683a7d878b28fffe464779c8a53659fc645",
@ -39,24 +32,21 @@ git_repository(
load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories", "pip_import") load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories", "pip_import")
pip_repositories()
pip_import( pip_import(
name = "grpc_python_dependencies", name = "grpc_python_dependencies",
requirements = "//:requirements.bazel.txt", requirements = "//:requirements.bazel.txt",
) )
load("@grpc_python_dependencies//:requirements.bzl", "pip_install") http_archive(
name = "cython",
pip_install() build_file = "//third_party:cython.BUILD",
sha256 = "d68138a2381afbdd0876c3cb2a22389043fa01c4badede1228ee073032b07a27",
# NOTE(https://github.com/pubref/rules_protobuf/pull/196): Switch to upstream repo after this gets merged. strip_prefix = "cython-c2b80d87658a8525ce091cbe146cb7eaa29fed5c",
git_repository( urls = [
name = "org_pubref_rules_protobuf", "https://github.com/cython/cython/archive/c2b80d87658a8525ce091cbe146cb7eaa29fed5c.tar.gz",
remote = "https://github.com/ghostwriternr/rules_protobuf", ],
tag = "v0.8.2.1-alpha",
) )
load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_repositories") load("//bazel:grpc_python_deps.bzl", "grpc_python_deps")
py_proto_repositories() grpc_python_deps()

@ -80,7 +80,8 @@ def grpc_cc_library(
visibility = None, visibility = None,
alwayslink = 0, alwayslink = 0,
data = [], data = [],
use_cfstream = False): use_cfstream = False,
tags = []):
copts = [] copts = []
if use_cfstream: if use_cfstream:
copts = if_mac(["-DGRPC_CFSTREAM"]) copts = if_mac(["-DGRPC_CFSTREAM"])
@ -117,6 +118,7 @@ def grpc_cc_library(
], ],
alwayslink = alwayslink, alwayslink = alwayslink,
data = data, data = data,
tags = tags,
) )
def grpc_proto_plugin(name, srcs = [], deps = []): def grpc_proto_plugin(name, srcs = [], deps = []):
@ -149,7 +151,6 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
if language.upper() == "C": if language.upper() == "C":
copts = copts + if_not_windows(["-std=c99"]) copts = copts + if_not_windows(["-std=c99"])
args = { args = {
"name": name,
"srcs": srcs, "srcs": srcs,
"args": args, "args": args,
"data": data, "data": data,
@ -161,7 +162,17 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
"exec_compatible_with": exec_compatible_with, "exec_compatible_with": exec_compatible_with,
} }
if uses_polling: if uses_polling:
native.cc_test(testonly = True, tags = ["manual"], **args) # Only run targets with pollers for non-MSVC
# TODO(yfen): Enable MSVC for poller-enabled targets without pollers
native.cc_test(
name = name,
testonly = True,
tags = [
"manual",
"no_windows",
],
**args
)
for poller in POLLERS: for poller in POLLERS:
native.sh_test( native.sh_test(
name = name + "@poller=" + poller, name = name + "@poller=" + poller,
@ -175,13 +186,13 @@ def grpc_cc_test(name, srcs = [], deps = [], external_deps = [], args = [], data
poller, poller,
"$(location %s)" % name, "$(location %s)" % name,
] + args["args"], ] + args["args"],
tags = tags, tags = (tags + ["no_windows"]),
exec_compatible_with = exec_compatible_with, exec_compatible_with = exec_compatible_with,
) )
else: else:
native.cc_test(**args) native.cc_test(tags = tags, **args)
def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = []): def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], data = [], language = "C++", testonly = False, linkshared = False, linkopts = [], tags = []):
copts = [] copts = []
if language.upper() == "C": if language.upper() == "C":
copts = ["-std=c99"] copts = ["-std=c99"]
@ -195,6 +206,7 @@ def grpc_cc_binary(name, srcs = [], deps = [], external_deps = [], args = [], da
deps = deps + _get_external_deps(external_deps), deps = deps + _get_external_deps(external_deps),
copts = copts, copts = copts,
linkopts = if_not_windows(["-pthread"]) + linkopts, linkopts = if_not_windows(["-pthread"]) + linkopts,
tags = tags,
) )
def grpc_generate_one_off_targets(): def grpc_generate_one_off_targets():

@ -0,0 +1,16 @@
load("//third_party/py:python_configure.bzl", "python_configure")
load("@io_bazel_rules_python//python:pip.bzl", "pip_repositories")
load("@grpc_python_dependencies//:requirements.bzl", "pip_install")
load("@org_pubref_rules_protobuf//python:rules.bzl", "py_proto_repositories")
def grpc_python_deps():
# TODO(https://github.com/grpc/grpc/issues/18256): Remove conditional.
if hasattr(native, "http_archive"):
python_configure(name = "local_config_python")
pip_repositories()
pip_install()
py_proto_repositories()
else:
print("Building Python gRPC with bazel 23.0+ is disabled pending " +
"resolution of https://github.com/grpc/grpc/issues/18256.")

@ -13,8 +13,8 @@ settings:
'#09': Per-language overrides are possible with (eg) ruby_version tag here '#09': Per-language overrides are possible with (eg) ruby_version tag here
'#10': See the expand_version.py for all the quirks here '#10': See the expand_version.py for all the quirks here
core_version: 7.0.0 core_version: 7.0.0
g_stands_for: godric g_stands_for: gandalf
version: 1.20.0-dev version: 1.21.0-dev
filegroups: filegroups:
- name: alts_proto - name: alts_proto
headers: headers:
@ -194,8 +194,10 @@ filegroups:
- src/core/lib/gprpp/atomic.h - src/core/lib/gprpp/atomic.h
- src/core/lib/gprpp/fork.h - src/core/lib/gprpp/fork.h
- src/core/lib/gprpp/manual_constructor.h - src/core/lib/gprpp/manual_constructor.h
- src/core/lib/gprpp/map.h
- src/core/lib/gprpp/memory.h - src/core/lib/gprpp/memory.h
- src/core/lib/gprpp/mutex_lock.h - src/core/lib/gprpp/mutex_lock.h
- src/core/lib/gprpp/pair.h
- src/core/lib/gprpp/thd.h - src/core/lib/gprpp/thd.h
- src/core/lib/profiling/timers.h - src/core/lib/profiling/timers.h
uses: uses:
@ -1344,12 +1346,16 @@ filegroups:
- include/grpcpp/client_context.h - include/grpcpp/client_context.h
- include/grpcpp/completion_queue.h - include/grpcpp/completion_queue.h
- include/grpcpp/create_channel.h - include/grpcpp/create_channel.h
- include/grpcpp/create_channel_impl.h
- include/grpcpp/create_channel_posix.h - include/grpcpp/create_channel_posix.h
- include/grpcpp/create_channel_posix_impl.h
- include/grpcpp/ext/health_check_service_server_builder_option.h - include/grpcpp/ext/health_check_service_server_builder_option.h
- include/grpcpp/generic/async_generic_service.h - include/grpcpp/generic/async_generic_service.h
- include/grpcpp/generic/generic_stub.h - include/grpcpp/generic/generic_stub.h
- include/grpcpp/generic/generic_stub_impl.h
- include/grpcpp/grpcpp.h - include/grpcpp/grpcpp.h
- include/grpcpp/health_check_service_interface.h - include/grpcpp/health_check_service_interface.h
- include/grpcpp/health_check_service_interface_impl.h
- include/grpcpp/impl/call.h - include/grpcpp/impl/call.h
- include/grpcpp/impl/channel_argument_option.h - include/grpcpp/impl/channel_argument_option.h
- include/grpcpp/impl/client_unary_call.h - include/grpcpp/impl/client_unary_call.h
@ -1360,18 +1366,24 @@ filegroups:
- include/grpcpp/impl/rpc_service_method.h - include/grpcpp/impl/rpc_service_method.h
- include/grpcpp/impl/serialization_traits.h - include/grpcpp/impl/serialization_traits.h
- include/grpcpp/impl/server_builder_option.h - include/grpcpp/impl/server_builder_option.h
- include/grpcpp/impl/server_builder_option_impl.h
- include/grpcpp/impl/server_builder_plugin.h - include/grpcpp/impl/server_builder_plugin.h
- include/grpcpp/impl/server_initializer.h - include/grpcpp/impl/server_initializer.h
- include/grpcpp/impl/server_initializer_impl.h
- include/grpcpp/impl/service_type.h - include/grpcpp/impl/service_type.h
- include/grpcpp/resource_quota.h - include/grpcpp/resource_quota.h
- include/grpcpp/resource_quota_impl.h
- include/grpcpp/security/auth_context.h - include/grpcpp/security/auth_context.h
- include/grpcpp/security/auth_metadata_processor.h - include/grpcpp/security/auth_metadata_processor.h
- include/grpcpp/security/auth_metadata_processor_impl.h
- include/grpcpp/security/credentials.h - include/grpcpp/security/credentials.h
- include/grpcpp/security/server_credentials.h - include/grpcpp/security/server_credentials.h
- include/grpcpp/security/server_credentials_impl.h
- include/grpcpp/server.h - include/grpcpp/server.h
- include/grpcpp/server_builder.h - include/grpcpp/server_builder.h
- include/grpcpp/server_context.h - include/grpcpp/server_context.h
- include/grpcpp/server_posix.h - include/grpcpp/server_posix.h
- include/grpcpp/server_posix_impl.h
- include/grpcpp/support/async_stream.h - include/grpcpp/support/async_stream.h
- include/grpcpp/support/async_unary_call.h - include/grpcpp/support/async_unary_call.h
- include/grpcpp/support/byte_buffer.h - include/grpcpp/support/byte_buffer.h
@ -1714,6 +1726,7 @@ libs:
public_headers: public_headers:
- include/grpc++/support/error_details.h - include/grpc++/support/error_details.h
- include/grpcpp/support/error_details.h - include/grpcpp/support/error_details.h
- include/grpcpp/support/error_details_impl.h
src: src:
- src/proto/grpc/status/status.proto - src/proto/grpc/status/status.proto
- src/cpp/util/error_details.cc - src/cpp/util/error_details.cc
@ -1739,6 +1752,7 @@ libs:
public_headers: public_headers:
- include/grpc++/ext/proto_server_reflection_plugin.h - include/grpc++/ext/proto_server_reflection_plugin.h
- include/grpcpp/ext/proto_server_reflection_plugin.h - include/grpcpp/ext/proto_server_reflection_plugin.h
- include/grpcpp/ext/proto_server_reflection_plugin_impl.h
headers: headers:
- src/cpp/ext/proto_server_reflection.h - src/cpp/ext/proto_server_reflection.h
src: src:
@ -1917,6 +1931,7 @@ libs:
language: c++ language: c++
public_headers: public_headers:
- include/grpcpp/ext/channelz_service_plugin.h - include/grpcpp/ext/channelz_service_plugin.h
- include/grpcpp/ext/channelz_service_plugin_impl.h
headers: headers:
- src/cpp/server/channelz/channelz_service.h - src/cpp/server/channelz/channelz_service.h
src: src:
@ -4735,6 +4750,22 @@ targets:
- grpc - grpc
- gpr - gpr
- grpc++_test_config - grpc++_test_config
- name: grpc_core_map_test
gtest: true
build: test
language: c++
headers:
- test/core/gprpp/map_tester.h
src:
- test/core/gprpp/map_test.cc
deps:
- grpc_test_util
- grpc++
- grpc
- gpr
uses:
- grpc++_test
uses_polling: false
- name: grpc_cpp_plugin - name: grpc_cpp_plugin
build: protoc build: protoc
language: c++ language: c++

@ -61,6 +61,8 @@ the form shown above.
If **Timeout** is omitted a server should assume an infinite timeout. Client implementations are free to send a default minimum timeout based on their deployment requirements. If **Timeout** is omitted a server should assume an infinite timeout. Client implementations are free to send a default minimum timeout based on their deployment requirements.
If **Content-Type** does not begin with "application/grpc", gRPC servers SHOULD respond with HTTP status of 415 (Unsupported Media Type). This will prevent other HTTP/2 clients from interpreting a gRPC error response, which uses status 200 (OK), as successful.
**Custom-Metadata** is an arbitrary set of key-value pairs defined by the application layer. Header names starting with "grpc-" but not listed here are reserved for future GRPC use and should not be used by applications as **Custom-Metadata**. **Custom-Metadata** is an arbitrary set of key-value pairs defined by the application layer. Header names starting with "grpc-" but not listed here are reserved for future GRPC use and should not be used by applications as **Custom-Metadata**.
Note that HTTP2 does not allow arbitrary octet sequences for header values so binary header values must be encoded using Base64 as per https://tools.ietf.org/html/rfc4648#section-4. Implementations MUST accept padded and un-padded values and should emit un-padded values. Applications define binary headers by having their names end with "-bin". Runtime libraries use this suffix to detect binary headers and properly apply base64 encoding & decoding as headers are sent and received. Note that HTTP2 does not allow arbitrary octet sequences for header values so binary header values must be encoded using Base64 as per https://tools.ietf.org/html/rfc4648#section-4. Implementations MUST accept padded and un-padded values and should emit un-padded values. Applications define binary headers by having their names end with "-bin". Runtime libraries use this suffix to detect binary headers and properly apply base64 encoding & decoding as headers are sent and received.
@ -255,5 +257,3 @@ to be used.
* **Service-Name** → ?( {_proto package name_} "." ) {_service name_} * **Service-Name** → ?( {_proto package name_} "." ) {_service name_}
* **Message-Type** → {_fully qualified proto message name_} * **Message-Type** → {_fully qualified proto message name_}
* **Content-Type** → "application/grpc+proto" * **Content-Type** → "application/grpc+proto"

@ -19,4 +19,5 @@
- 1.17 'g' stands for ['gizmo'](https://github.com/grpc/grpc/tree/v1.17.x) - 1.17 'g' stands for ['gizmo'](https://github.com/grpc/grpc/tree/v1.17.x)
- 1.18 'g' stands for ['goose'](https://github.com/grpc/grpc/tree/v1.18.x) - 1.18 'g' stands for ['goose'](https://github.com/grpc/grpc/tree/v1.18.x)
- 1.19 'g' stands for ['gold'](https://github.com/grpc/grpc/tree/v1.19.x) - 1.19 'g' stands for ['gold'](https://github.com/grpc/grpc/tree/v1.19.x)
- 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/master) - 1.20 'g' stands for ['godric'](https://github.com/grpc/grpc/tree/v1.20.x)
- 1.21 'g' stands for ['gandalf'](https://github.com/grpc/grpc/tree/master)

@ -56,56 +56,110 @@ cc_binary(
name = "greeter_client", name = "greeter_client",
srcs = ["cpp/helloworld/greeter_client.cc"], srcs = ["cpp/helloworld/greeter_client.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":helloworld", "//:grpc++"], deps = [
":helloworld",
"//:grpc++",
],
)
cc_binary(
name = "greeter_async_client",
srcs = ["cpp/helloworld/greeter_async_client.cc"],
defines = ["BAZEL_BUILD"],
deps = [
":helloworld",
"//:grpc++",
],
)
cc_binary(
name = "greeter_async_client2",
srcs = ["cpp/helloworld/greeter_async_client2.cc"],
defines = ["BAZEL_BUILD"],
deps = [
":helloworld",
"//:grpc++",
],
) )
cc_binary( cc_binary(
name = "greeter_server", name = "greeter_server",
srcs = ["cpp/helloworld/greeter_server.cc"], srcs = ["cpp/helloworld/greeter_server.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":helloworld", "//:grpc++"], deps = [
":helloworld",
"//:grpc++",
],
)
cc_binary(
name = "greeter_async_server",
srcs = ["cpp/helloworld/greeter_async_server.cc"],
defines = ["BAZEL_BUILD"],
deps = [
":helloworld",
"//:grpc++",
],
) )
cc_binary( cc_binary(
name = "metadata_client", name = "metadata_client",
srcs = ["cpp/metadata/greeter_client.cc"], srcs = ["cpp/metadata/greeter_client.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":helloworld", "//:grpc++"], deps = [
":helloworld",
"//:grpc++",
],
) )
cc_binary( cc_binary(
name = "metadata_server", name = "metadata_server",
srcs = ["cpp/metadata/greeter_server.cc"], srcs = ["cpp/metadata/greeter_server.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":helloworld", "//:grpc++"], deps = [
":helloworld",
"//:grpc++",
],
) )
cc_binary( cc_binary(
name = "lb_client", name = "lb_client",
srcs = ["cpp/load_balancing/greeter_client.cc"], srcs = ["cpp/load_balancing/greeter_client.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":helloworld", "//:grpc++"], deps = [
":helloworld",
"//:grpc++",
],
) )
cc_binary( cc_binary(
name = "lb_server", name = "lb_server",
srcs = ["cpp/load_balancing/greeter_server.cc"], srcs = ["cpp/load_balancing/greeter_server.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":helloworld", "//:grpc++"], deps = [
":helloworld",
"//:grpc++",
],
) )
cc_binary( cc_binary(
name = "compression_client", name = "compression_client",
srcs = ["cpp/compression/greeter_client.cc"], srcs = ["cpp/compression/greeter_client.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":helloworld", "//:grpc++"], deps = [
":helloworld",
"//:grpc++",
],
) )
cc_binary( cc_binary(
name = "compression_server", name = "compression_server",
srcs = ["cpp/compression/greeter_server.cc"], srcs = ["cpp/compression/greeter_server.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":helloworld", "//:grpc++"], deps = [
":helloworld",
"//:grpc++",
],
) )
cc_binary( cc_binary(
@ -113,12 +167,48 @@ cc_binary(
srcs = ["cpp/keyvaluestore/caching_interceptor.h", srcs = ["cpp/keyvaluestore/caching_interceptor.h",
"cpp/keyvaluestore/client.cc"], "cpp/keyvaluestore/client.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":keyvaluestore", "//:grpc++"], deps = [
":keyvaluestore",
"//:grpc++",
],
) )
cc_binary( cc_binary(
name = "keyvaluestore_server", name = "keyvaluestore_server",
srcs = ["cpp/keyvaluestore/server.cc"], srcs = ["cpp/keyvaluestore/server.cc"],
defines = ["BAZEL_BUILD"], defines = ["BAZEL_BUILD"],
deps = [":keyvaluestore", "//:grpc++"], deps = [
) ":keyvaluestore",
"//:grpc++",
],
)
cc_binary(
name = "route_guide_client",
srcs = [
"cpp/route_guide/helper.cc",
"cpp/route_guide/helper.h",
"cpp/route_guide/route_guide_client.cc",
],
data = ["cpp/route_guide/route_guide_db.json"],
defines = ["BAZEL_BUILD"],
deps = [
":route_guide",
"//:grpc++",
],
)
cc_binary(
name = "route_guide_server",
srcs = [
"cpp/route_guide/helper.cc",
"cpp/route_guide/helper.h",
"cpp/route_guide/route_guide_server.cc",
],
data = ["cpp/route_guide/route_guide_db.json"],
defines = ["BAZEL_BUILD"],
deps = [
":route_guide",
"//:grpc++",
],
)

@ -23,7 +23,11 @@
#include <grpcpp/grpcpp.h> #include <grpcpp/grpcpp.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h" #include "helloworld.grpc.pb.h"
#endif
using grpc::Channel; using grpc::Channel;
using grpc::ClientAsyncResponseReader; using grpc::ClientAsyncResponseReader;

@ -24,7 +24,11 @@
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <thread> #include <thread>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h" #include "helloworld.grpc.pb.h"
#endif
using grpc::Channel; using grpc::Channel;
using grpc::ClientAsyncResponseReader; using grpc::ClientAsyncResponseReader;

@ -24,7 +24,11 @@
#include <grpcpp/grpcpp.h> #include <grpcpp/grpcpp.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h" #include "helloworld.grpc.pb.h"
#endif
using grpc::Server; using grpc::Server;
using grpc::ServerAsyncResponseWriter; using grpc::ServerAsyncResponseWriter;

@ -23,7 +23,11 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <vector> #include <vector>
#ifdef BAZEL_BUILD
#include "examples/protos/route_guide.grpc.pb.h"
#else
#include "route_guide.grpc.pb.h" #include "route_guide.grpc.pb.h"
#endif
namespace routeguide { namespace routeguide {
@ -35,13 +39,16 @@ std::string GetDbFileContent(int argc, char** argv) {
size_t start_position = argv_1.find(arg_str); size_t start_position = argv_1.find(arg_str);
if (start_position != std::string::npos) { if (start_position != std::string::npos) {
start_position += arg_str.size(); start_position += arg_str.size();
if (argv_1[start_position] == ' ' || if (argv_1[start_position] == ' ' || argv_1[start_position] == '=') {
argv_1[start_position] == '=') {
db_path = argv_1.substr(start_position + 1); db_path = argv_1.substr(start_position + 1);
} }
} }
} else { } else {
#ifdef BAZEL_BUILD
db_path = "cpp/route_guide/route_guide_db.json";
#else
db_path = "route_guide_db.json"; db_path = "route_guide_db.json";
#endif
} }
std::ifstream db_file(db_path); std::ifstream db_file(db_path);
if (!db_file.is_open()) { if (!db_file.is_open()) {
@ -60,17 +67,13 @@ class Parser {
public: public:
explicit Parser(const std::string& db) : db_(db) { explicit Parser(const std::string& db) : db_(db) {
// Remove all spaces. // Remove all spaces.
db_.erase( db_.erase(std::remove_if(db_.begin(), db_.end(), isspace), db_.end());
std::remove_if(db_.begin(), db_.end(), isspace),
db_.end());
if (!Match("[")) { if (!Match("[")) {
SetFailedAndReturnFalse(); SetFailedAndReturnFalse();
} }
} }
bool Finished() { bool Finished() { return current_ >= db_.size(); }
return current_ >= db_.size();
}
bool TryParseOne(Feature* feature) { bool TryParseOne(Feature* feature) {
if (failed_ || Finished() || !Match("{")) { if (failed_ || Finished() || !Match("{")) {
@ -96,7 +99,7 @@ class Parser {
if (current_ == db_.size()) { if (current_ == db_.size()) {
return SetFailedAndReturnFalse(); return SetFailedAndReturnFalse();
} }
feature->set_name(db_.substr(name_start, current_-name_start-1)); feature->set_name(db_.substr(name_start, current_ - name_start - 1));
if (!Match("},")) { if (!Match("},")) {
if (db_[current_ - 1] == ']' && current_ == db_.size()) { if (db_[current_ - 1] == ']' && current_ == db_.size()) {
return true; return true;
@ -107,7 +110,6 @@ class Parser {
} }
private: private:
bool SetFailedAndReturnFalse() { bool SetFailedAndReturnFalse() {
failed_ = true; failed_ = true;
return false; return false;
@ -121,7 +123,8 @@ class Parser {
void ReadLong(long* l) { void ReadLong(long* l) {
size_t start = current_; size_t start = current_;
while (current_ != db_.size() && db_[current_] != ',' && db_[current_] != '}') { while (current_ != db_.size() && db_[current_] != ',' &&
db_[current_] != '}') {
current_++; current_++;
} }
// It will throw an exception if fails. // It will throw an exception if fails.
@ -154,10 +157,8 @@ void ParseDb(const std::string& db, std::vector<Feature>* feature_list) {
break; break;
} }
} }
std::cout << "DB parsed, loaded " << feature_list->size() std::cout << "DB parsed, loaded " << feature_list->size() << " features."
<< " features." << std::endl; << std::endl;
} }
} // namespace routeguide } // namespace routeguide

@ -29,7 +29,11 @@
#include <grpcpp/create_channel.h> #include <grpcpp/create_channel.h>
#include <grpcpp/security/credentials.h> #include <grpcpp/security/credentials.h>
#include "helper.h" #include "helper.h"
#ifdef BAZEL_BUILD
#include "examples/protos/route_guide.grpc.pb.h"
#else
#include "route_guide.grpc.pb.h" #include "route_guide.grpc.pb.h"
#endif
using grpc::Channel; using grpc::Channel;
using grpc::ClientContext; using grpc::ClientContext;

@ -29,7 +29,11 @@
#include <grpcpp/server_context.h> #include <grpcpp/server_context.h>
#include <grpcpp/security/server_credentials.h> #include <grpcpp/security/server_credentials.h>
#include "helper.h" #include "helper.h"
#ifdef BAZEL_BUILD
#include "examples/protos/route_guide.grpc.pb.h"
#else
#include "route_guide.grpc.pb.h" #include "route_guide.grpc.pb.h"
#endif
using grpc::Server; using grpc::Server;
using grpc::ServerBuilder; using grpc::ServerBuilder;
@ -147,24 +151,25 @@ class RouteGuideImpl final : public RouteGuide::Service {
Status RouteChat(ServerContext* context, Status RouteChat(ServerContext* context,
ServerReaderWriter<RouteNote, RouteNote>* stream) override { ServerReaderWriter<RouteNote, RouteNote>* stream) override {
std::vector<RouteNote> received_notes;
RouteNote note; RouteNote note;
while (stream->Read(&note)) { while (stream->Read(&note)) {
for (const RouteNote& n : received_notes) { std::unique_lock<std::mutex> lock(mu_);
for (const RouteNote& n : received_notes_) {
if (n.location().latitude() == note.location().latitude() && if (n.location().latitude() == note.location().latitude() &&
n.location().longitude() == note.location().longitude()) { n.location().longitude() == note.location().longitude()) {
stream->Write(n); stream->Write(n);
} }
} }
received_notes.push_back(note); received_notes_.push_back(note);
} }
return Status::OK; return Status::OK;
} }
private: private:
std::vector<Feature> feature_list_; std::vector<Feature> feature_list_;
std::mutex mu_;
std::vector<RouteNote> received_notes_;
}; };
void RunServer(const std::string& db_path) { void RunServer(const std::string& db_path) {

@ -23,7 +23,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC-C++' s.name = 'gRPC-C++'
# TODO (mxyan): use version that match gRPC version when pod is stabilized # TODO (mxyan): use version that match gRPC version when pod is stabilized
# version = '1.20.0-dev' # version = '1.21.0-dev'
version = '0.0.8-dev' version = '0.0.8-dev'
s.version = version s.version = version
s.summary = 'gRPC C++ library' s.summary = 'gRPC C++ library'
@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.license = 'Apache License, Version 2.0' s.license = 'Apache License, Version 2.0'
s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' } s.authors = { 'The gRPC contributors' => 'grpc-packages@google.com' }
grpc_version = '1.20.0-dev' grpc_version = '1.21.0-dev'
s.source = { s.source = {
:git => 'https://github.com/grpc/grpc.git', :git => 'https://github.com/grpc/grpc.git',
@ -85,12 +85,16 @@ Pod::Spec.new do |s|
'include/grpcpp/client_context.h', 'include/grpcpp/client_context.h',
'include/grpcpp/completion_queue.h', 'include/grpcpp/completion_queue.h',
'include/grpcpp/create_channel.h', 'include/grpcpp/create_channel.h',
'include/grpcpp/create_channel_impl.h',
'include/grpcpp/create_channel_posix.h', 'include/grpcpp/create_channel_posix.h',
'include/grpcpp/create_channel_posix_impl.h',
'include/grpcpp/ext/health_check_service_server_builder_option.h', 'include/grpcpp/ext/health_check_service_server_builder_option.h',
'include/grpcpp/generic/async_generic_service.h', 'include/grpcpp/generic/async_generic_service.h',
'include/grpcpp/generic/generic_stub.h', 'include/grpcpp/generic/generic_stub.h',
'include/grpcpp/generic/generic_stub_impl.h',
'include/grpcpp/grpcpp.h', 'include/grpcpp/grpcpp.h',
'include/grpcpp/health_check_service_interface.h', 'include/grpcpp/health_check_service_interface.h',
'include/grpcpp/health_check_service_interface_impl.h',
'include/grpcpp/impl/call.h', 'include/grpcpp/impl/call.h',
'include/grpcpp/impl/channel_argument_option.h', 'include/grpcpp/impl/channel_argument_option.h',
'include/grpcpp/impl/client_unary_call.h', 'include/grpcpp/impl/client_unary_call.h',
@ -101,18 +105,24 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/rpc_service_method.h', 'include/grpcpp/impl/rpc_service_method.h',
'include/grpcpp/impl/serialization_traits.h', 'include/grpcpp/impl/serialization_traits.h',
'include/grpcpp/impl/server_builder_option.h', 'include/grpcpp/impl/server_builder_option.h',
'include/grpcpp/impl/server_builder_option_impl.h',
'include/grpcpp/impl/server_builder_plugin.h', 'include/grpcpp/impl/server_builder_plugin.h',
'include/grpcpp/impl/server_initializer.h', 'include/grpcpp/impl/server_initializer.h',
'include/grpcpp/impl/server_initializer_impl.h',
'include/grpcpp/impl/service_type.h', 'include/grpcpp/impl/service_type.h',
'include/grpcpp/resource_quota.h', 'include/grpcpp/resource_quota.h',
'include/grpcpp/resource_quota_impl.h',
'include/grpcpp/security/auth_context.h', 'include/grpcpp/security/auth_context.h',
'include/grpcpp/security/auth_metadata_processor.h', 'include/grpcpp/security/auth_metadata_processor.h',
'include/grpcpp/security/auth_metadata_processor_impl.h',
'include/grpcpp/security/credentials.h', 'include/grpcpp/security/credentials.h',
'include/grpcpp/security/server_credentials.h', 'include/grpcpp/security/server_credentials.h',
'include/grpcpp/security/server_credentials_impl.h',
'include/grpcpp/server.h', 'include/grpcpp/server.h',
'include/grpcpp/server_builder.h', 'include/grpcpp/server_builder.h',
'include/grpcpp/server_context.h', 'include/grpcpp/server_context.h',
'include/grpcpp/server_posix.h', 'include/grpcpp/server_posix.h',
'include/grpcpp/server_posix_impl.h',
'include/grpcpp/support/async_stream.h', 'include/grpcpp/support/async_stream.h',
'include/grpcpp/support/async_unary_call.h', 'include/grpcpp/support/async_unary_call.h',
'include/grpcpp/support/byte_buffer.h', 'include/grpcpp/support/byte_buffer.h',
@ -253,8 +263,10 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/atomic.h',
'src/core/lib/gprpp/fork.h', 'src/core/lib/gprpp/fork.h',
'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/manual_constructor.h',
'src/core/lib/gprpp/map.h',
'src/core/lib/gprpp/memory.h', 'src/core/lib/gprpp/memory.h',
'src/core/lib/gprpp/mutex_lock.h', 'src/core/lib/gprpp/mutex_lock.h',
'src/core/lib/gprpp/pair.h',
'src/core/lib/gprpp/thd.h', 'src/core/lib/gprpp/thd.h',
'src/core/lib/profiling/timers.h', 'src/core/lib/profiling/timers.h',
'src/core/ext/transport/chttp2/transport/bin_decoder.h', 'src/core/ext/transport/chttp2/transport/bin_decoder.h',
@ -568,8 +580,10 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/atomic.h',
'src/core/lib/gprpp/fork.h', 'src/core/lib/gprpp/fork.h',
'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/manual_constructor.h',
'src/core/lib/gprpp/map.h',
'src/core/lib/gprpp/memory.h', 'src/core/lib/gprpp/memory.h',
'src/core/lib/gprpp/mutex_lock.h', 'src/core/lib/gprpp/mutex_lock.h',
'src/core/lib/gprpp/pair.h',
'src/core/lib/gprpp/thd.h', 'src/core/lib/gprpp/thd.h',
'src/core/lib/profiling/timers.h', 'src/core/lib/profiling/timers.h',
'src/core/lib/avl/avl.h', 'src/core/lib/avl/avl.h',

@ -22,7 +22,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC-Core' s.name = 'gRPC-Core'
version = '1.20.0-dev' version = '1.21.0-dev'
s.version = version s.version = version
s.summary = 'Core cross-platform gRPC library, written in C' s.summary = 'Core cross-platform gRPC library, written in C'
s.homepage = 'https://grpc.io' s.homepage = 'https://grpc.io'
@ -208,8 +208,10 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/atomic.h',
'src/core/lib/gprpp/fork.h', 'src/core/lib/gprpp/fork.h',
'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/manual_constructor.h',
'src/core/lib/gprpp/map.h',
'src/core/lib/gprpp/memory.h', 'src/core/lib/gprpp/memory.h',
'src/core/lib/gprpp/mutex_lock.h', 'src/core/lib/gprpp/mutex_lock.h',
'src/core/lib/gprpp/pair.h',
'src/core/lib/gprpp/thd.h', 'src/core/lib/gprpp/thd.h',
'src/core/lib/profiling/timers.h', 'src/core/lib/profiling/timers.h',
'src/core/lib/gpr/alloc.cc', 'src/core/lib/gpr/alloc.cc',
@ -855,7 +857,15 @@ Pod::Spec.new do |s|
'src/core/ext/filters/http/client_authority_filter.cc', 'src/core/ext/filters/http/client_authority_filter.cc',
'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc',
'src/core/ext/filters/workarounds/workaround_utils.cc', 'src/core/ext/filters/workarounds/workaround_utils.cc',
'src/core/plugin_registry/grpc_plugin_registry.cc' 'src/core/plugin_registry/grpc_plugin_registry.cc',
'src/core/lib/iomgr/cfstream_handle.cc',
'src/core/lib/iomgr/endpoint_cfstream.cc',
'src/core/lib/iomgr/error_cfstream.cc',
'src/core/lib/iomgr/iomgr_posix_cfstream.cc',
'src/core/lib/iomgr/tcp_client_cfstream.cc',
'src/core/lib/iomgr/cfstream_handle.h',
'src/core/lib/iomgr/endpoint_cfstream.h',
'src/core/lib/iomgr/error_cfstream.h'
ss.private_header_files = 'src/core/lib/gpr/alloc.h', ss.private_header_files = 'src/core/lib/gpr/alloc.h',
'src/core/lib/gpr/arena.h', 'src/core/lib/gpr/arena.h',
@ -877,8 +887,10 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/atomic.h', 'src/core/lib/gprpp/atomic.h',
'src/core/lib/gprpp/fork.h', 'src/core/lib/gprpp/fork.h',
'src/core/lib/gprpp/manual_constructor.h', 'src/core/lib/gprpp/manual_constructor.h',
'src/core/lib/gprpp/map.h',
'src/core/lib/gprpp/memory.h', 'src/core/lib/gprpp/memory.h',
'src/core/lib/gprpp/mutex_lock.h', 'src/core/lib/gprpp/mutex_lock.h',
'src/core/lib/gprpp/pair.h',
'src/core/lib/gprpp/thd.h', 'src/core/lib/gprpp/thd.h',
'src/core/lib/profiling/timers.h', 'src/core/lib/profiling/timers.h',
'src/core/ext/transport/chttp2/transport/bin_decoder.h', 'src/core/ext/transport/chttp2/transport/bin_decoder.h',
@ -1160,26 +1172,15 @@ Pod::Spec.new do |s|
'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h',
'src/core/ext/filters/http/client_authority_filter.h', 'src/core/ext/filters/http/client_authority_filter.h',
'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h', 'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h',
'src/core/ext/filters/workarounds/workaround_utils.h' 'src/core/ext/filters/workarounds/workaround_utils.h',
'src/core/lib/iomgr/cfstream_handle.h',
'src/core/lib/iomgr/endpoint_cfstream.h',
'src/core/lib/iomgr/error_cfstream.h'
end end
# CFStream is now default. Leaving this subspec only for compatibility purpose.
s.subspec 'CFStream-Implementation' do |ss| s.subspec 'CFStream-Implementation' do |ss|
ss.header_mappings_dir = '.'
ss.dependency "#{s.name}/Implementation", version ss.dependency "#{s.name}/Implementation", version
ss.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1'
}
ss.source_files = 'src/core/lib/iomgr/cfstream_handle.cc',
'src/core/lib/iomgr/endpoint_cfstream.cc',
'src/core/lib/iomgr/error_cfstream.cc',
'src/core/lib/iomgr/iomgr_posix_cfstream.cc',
'src/core/lib/iomgr/tcp_client_cfstream.cc',
'src/core/lib/iomgr/cfstream_handle.h',
'src/core/lib/iomgr/endpoint_cfstream.h',
'src/core/lib/iomgr/error_cfstream.h'
ss.private_header_files = 'src/core/lib/iomgr/cfstream_handle.h',
'src/core/lib/iomgr/endpoint_cfstream.h',
'src/core/lib/iomgr/error_cfstream.h'
end end
s.subspec 'Cronet-Interface' do |ss| s.subspec 'Cronet-Interface' do |ss|

@ -21,7 +21,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC-ProtoRPC' s.name = 'gRPC-ProtoRPC'
version = '1.20.0-dev' version = '1.21.0-dev'
s.version = version s.version = version
s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.summary = 'RPC library for Protocol Buffers, based on gRPC'
s.homepage = 'https://grpc.io' s.homepage = 'https://grpc.io'
@ -53,12 +53,10 @@ Pod::Spec.new do |s|
ss.source_files = "#{src_dir}/*.{h,m}" ss.source_files = "#{src_dir}/*.{h,m}"
end end
# CFStream is now default. Leaving this subspec only for compatibility purpose.
s.subspec 'CFStream' do |ss| s.subspec 'CFStream' do |ss|
ss.dependency 'gRPC/CFStream', version
ss.dependency "#{s.name}/Main", version ss.dependency "#{s.name}/Main", version
ss.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1'
}
end end
s.pod_target_xcconfig = { s.pod_target_xcconfig = {

@ -21,7 +21,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC-RxLibrary' s.name = 'gRPC-RxLibrary'
version = '1.20.0-dev' version = '1.21.0-dev'
s.version = version s.version = version
s.summary = 'Reactive Extensions library for iOS/OSX.' s.summary = 'Reactive Extensions library for iOS/OSX.'
s.homepage = 'https://grpc.io' s.homepage = 'https://grpc.io'

@ -20,7 +20,7 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'gRPC' s.name = 'gRPC'
version = '1.20.0-dev' version = '1.21.0-dev'
s.version = version s.version = version
s.summary = 'gRPC client library for iOS/OSX' s.summary = 'gRPC client library for iOS/OSX'
s.homepage = 'https://grpc.io' s.homepage = 'https://grpc.io'
@ -64,14 +64,9 @@ Pod::Spec.new do |s|
ss.dependency 'gRPC-Core', version ss.dependency 'gRPC-Core', version
end end
# This subspec is mutually exclusive with the `Main` subspec # CFStream is now default. Leaving this subspec only for compatibility purpose.
s.subspec 'CFStream' do |ss| s.subspec 'CFStream' do |ss|
ss.dependency 'gRPC-Core/CFStream-Implementation', version
ss.dependency "#{s.name}/Main", version ss.dependency "#{s.name}/Main", version
ss.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => 'GRPC_CFSTREAM=1'
}
end end
s.subspec 'GID' do |ss| s.subspec 'GID' do |ss|

@ -30,7 +30,7 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.add_dependency 'google-protobuf', '~> 3.7' s.add_dependency 'google-protobuf', '~> 3.7'
s.add_dependency 'googleapis-common-protos-types', '~> 1.0.0' s.add_dependency 'googleapis-common-protos-types', '~> 1.0'
s.add_development_dependency 'bundler', '~> 1.9' s.add_development_dependency 'bundler', '~> 1.9'
s.add_development_dependency 'facter', '~> 2.4' s.add_development_dependency 'facter', '~> 2.4'
@ -102,8 +102,10 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gprpp/atomic.h ) s.files += %w( src/core/lib/gprpp/atomic.h )
s.files += %w( src/core/lib/gprpp/fork.h ) s.files += %w( src/core/lib/gprpp/fork.h )
s.files += %w( src/core/lib/gprpp/manual_constructor.h ) s.files += %w( src/core/lib/gprpp/manual_constructor.h )
s.files += %w( src/core/lib/gprpp/map.h )
s.files += %w( src/core/lib/gprpp/memory.h ) s.files += %w( src/core/lib/gprpp/memory.h )
s.files += %w( src/core/lib/gprpp/mutex_lock.h ) s.files += %w( src/core/lib/gprpp/mutex_lock.h )
s.files += %w( src/core/lib/gprpp/pair.h )
s.files += %w( src/core/lib/gprpp/thd.h ) s.files += %w( src/core/lib/gprpp/thd.h )
s.files += %w( src/core/lib/profiling/timers.h ) s.files += %w( src/core/lib/profiling/timers.h )
s.files += %w( src/core/lib/gpr/alloc.cc ) s.files += %w( src/core/lib/gpr/alloc.cc )

@ -193,6 +193,7 @@
#define GPR_PLATFORM_STRING "ios" #define GPR_PLATFORM_STRING "ios"
#define GPR_CPU_IPHONE 1 #define GPR_CPU_IPHONE 1
#define GPR_PTHREAD_TLS 1 #define GPR_PTHREAD_TLS 1
#define GRPC_CFSTREAM 1
/* the c-ares resolver isnt safe to enable on iOS */ /* the c-ares resolver isnt safe to enable on iOS */
#define GRPC_ARES 0 #define GRPC_ARES 0
#else /* TARGET_OS_IPHONE */ #else /* TARGET_OS_IPHONE */
@ -235,7 +236,6 @@
#define GPR_POSIX_SYNC 1 #define GPR_POSIX_SYNC 1
#define GPR_POSIX_TIME 1 #define GPR_POSIX_TIME 1
#define GPR_GETPID_IN_UNISTD_H 1 #define GPR_GETPID_IN_UNISTD_H 1
/* TODO(mxyan): Remove when CFStream becomes default */
#ifndef GRPC_CFSTREAM #ifndef GRPC_CFSTREAM
#define GPR_SUPPORT_CHANNELS_FROM_FD 1 #define GPR_SUPPORT_CHANNELS_FROM_FD 1
#endif #endif

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,60 +19,36 @@
#ifndef GRPCPP_CREATE_CHANNEL_H #ifndef GRPCPP_CREATE_CHANNEL_H
#define GRPCPP_CREATE_CHANNEL_H #define GRPCPP_CREATE_CHANNEL_H
#include <memory> #include <grpcpp/create_channel_impl.h>
#include <grpcpp/channel.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/config.h>
namespace grpc { namespace grpc {
/// Create a new \a Channel pointing to \a target. static inline std::shared_ptr<Channel> CreateChannel(
///
/// \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.
std::shared_ptr<Channel> CreateChannel(
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds); const std::shared_ptr<ChannelCredentials>& creds) {
return ::grpc_impl::CreateChannel(target, creds);
}
/// Create a new \em custom \a Channel pointing to \a target. static inline std::shared_ptr<Channel> CreateCustomChannel(
///
/// \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> CreateCustomChannel(
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args); const ChannelArguments& args) {
return ::grpc_impl::CreateCustomChannel(target, creds, args);
}
namespace experimental { namespace experimental {
/// Create a new \em custom \a Channel pointing to \a target with \a
/// interceptors being invoked per call. static inline std::shared_ptr<Channel> CreateCustomChannelWithInterceptors(
///
/// \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 grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args, const ChannelArguments& args,
std::vector< std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
interceptor_creators); interceptor_creators) {
return ::grpc_impl::experimental::CreateCustomChannelWithInterceptors(
target, creds, args, std::move(interceptor_creators));
}
} // namespace experimental } // namespace experimental
} // namespace grpc } // namespace grpc

@ -0,0 +1,79 @@
/*
*
* Copyright 2015 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_CREATE_CHANNEL_IMPL_H
#define GRPCPP_CREATE_CHANNEL_IMPL_H
#include <memory>
#include <grpcpp/channel.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/security/credentials.h>
#include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/config.h>
namespace grpc_impl {
/// Create a new \a Channel pointing to \a target.
///
/// \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.
std::shared_ptr<grpc::Channel> CreateChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds);
/// Create a new \em custom \a Channel pointing to \a target.
///
/// \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<grpc::Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::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<grpc::Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args,
std::vector<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
} // namespace experimental
} // namespace grpc_impl
#endif // GRPCPP_CREATE_CHANNEL_IMPL_H

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2016 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,46 +19,34 @@
#ifndef GRPCPP_CREATE_CHANNEL_POSIX_H #ifndef GRPCPP_CREATE_CHANNEL_POSIX_H
#define GRPCPP_CREATE_CHANNEL_POSIX_H #define GRPCPP_CREATE_CHANNEL_POSIX_H
#include <memory> #include <grpcpp/create_channel_posix_impl.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/channel.h>
#include <grpcpp/support/channel_arguments.h>
namespace grpc { namespace grpc {
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD #ifdef GPR_SUPPORT_CHANNELS_FROM_FD
/// Create a new \a Channel communicating over the given file descriptor. static inline std::shared_ptr<Channel> CreateInsecureChannelFromFd(
/// const grpc::string& target, int fd) {
/// \param target The name of the target. return ::grpc_impl::CreateInsecureChannelFromFd(target, fd);
/// \param fd The file descriptor representing a socket. }
std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target,
int fd);
/// Create a new \a Channel communicating over given file descriptor with custom static inline std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
/// channel arguments. const grpc::string& target, int fd, const ChannelArguments& args) {
/// return ::grpc_impl::CreateCustomInsecureChannelFromFd(target, fd, args);
/// \param target The name of the target. }
/// \param fd The file descriptor representing a socket.
/// \param args Options for channel creation.
std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd(
const grpc::string& target, int fd, const ChannelArguments& args);
namespace experimental { namespace experimental {
/// Create a new \a Channel communicating over given file descriptor with custom static inline std::shared_ptr<Channel>
/// channel arguments. CreateCustomInsecureChannelWithInterceptorsFromFd(
///
/// \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, const grpc::string& target, int fd, const ChannelArguments& args,
std::unique_ptr<std::vector< std::unique_ptr<std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>> std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators); interceptor_creators) {
return ::grpc_impl::experimental::
CreateCustomInsecureChannelWithInterceptorsFromFd(
target, fd, args, std::move(interceptor_creators));
}
} // namespace experimental } // namespace experimental

@ -0,0 +1,70 @@
/*
*
* Copyright 2016 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_CREATE_CHANNEL_POSIX_IMPL_H
#define GRPCPP_CREATE_CHANNEL_POSIX_IMPL_H
#include <memory>
#include <grpc/support/port_platform.h>
#include <grpcpp/channel.h>
#include <grpcpp/support/channel_arguments.h>
namespace grpc_impl {
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD
/// Create a new \a Channel communicating over the given file descriptor.
///
/// \param target The name of the target.
/// \param fd The file descriptor representing a socket.
std::shared_ptr<grpc::Channel> CreateInsecureChannelFromFd(
const grpc::string& target, int fd);
/// 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.
std::shared_ptr<grpc::Channel> CreateCustomInsecureChannelFromFd(
const grpc::string& target, int fd, const grpc::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<grpc::Channel>
CreateCustomInsecureChannelWithInterceptorsFromFd(
const grpc::string& target, int fd, const grpc::ChannelArguments& args,
std::unique_ptr<std::vector<
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>>
interceptor_creators);
} // namespace experimental
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc_impl
#endif // GRPCPP_CREATE_CHANNEL_POSIX_IMPL_H

@ -19,20 +19,15 @@
#ifndef GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_H #ifndef GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_H
#define GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_H #define GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_H
#include <grpc/support/port_platform.h> #include <grpcpp/ext/channelz_service_plugin_impl.h>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/impl/server_initializer.h>
#include <grpcpp/support/config.h>
namespace grpc { namespace grpc {
namespace channelz { namespace channelz {
namespace experimental { namespace experimental {
/// Add channelz server plugin to \a ServerBuilder. This function should static inline void InitChannelzService() {
/// be called at static initialization time. This service is experimental ::grpc_impl::channelz::experimental::InitChannelzService();
/// for now. Track progress in https://github.com/grpc/grpc/issues/15988. }
void InitChannelzService();
} // namespace experimental } // namespace experimental
} // namespace channelz } // namespace channelz

@ -0,0 +1,41 @@
/*
*
* 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_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H
#define GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H
#include <grpc/support/port_platform.h>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/impl/server_initializer.h>
#include <grpcpp/support/config.h>
namespace grpc_impl {
namespace channelz {
namespace experimental {
/// Add channelz server plugin to \a ServerBuilder. This function should
/// be called at static initialization time. This service is experimental
/// for now. Track progress in https://github.com/grpc/grpc/issues/15988.
void InitChannelzService();
} // namespace experimental
} // namespace channelz
} // namespace grpc_impl
#endif // GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,34 +19,17 @@
#ifndef GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H #ifndef GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H
#define GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H #define GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H
#include <grpcpp/impl/server_builder_plugin.h> #include <grpcpp/ext/proto_server_reflection_plugin_impl.h>
#include <grpcpp/support/config.h>
namespace grpc {
class ServerInitializer;
class ProtoServerReflection;
} // namespace grpc
namespace grpc { namespace grpc {
namespace reflection { namespace reflection {
class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin { typedef ::grpc_impl::reflection::ProtoServerReflectionPlugin
public: ProtoServerReflectionPlugin;
ProtoServerReflectionPlugin();
::grpc::string name() override;
void InitServer(::grpc::ServerInitializer* si) override;
void Finish(::grpc::ServerInitializer* si) override;
void ChangeArguments(const ::grpc::string& name, void* value) override;
bool has_async_methods() const override;
bool has_sync_methods() const override;
private:
std::shared_ptr<grpc::ProtoServerReflection> reflection_service_;
};
/// Add proto reflection plugin to \a ServerBuilder. static inline void InitProtoReflectionServerBuilderPlugin() {
/// This function should be called at the static initialization time. ::grpc_impl::reflection::InitProtoReflectionServerBuilderPlugin();
void InitProtoReflectionServerBuilderPlugin(); }
} // namespace reflection } // namespace reflection
} // namespace grpc } // namespace grpc

@ -0,0 +1,55 @@
/*
*
* Copyright 2015 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_EXT_PROTO_SERVER_REFLECTION_PLUGIN_IMPL_H
#define GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_IMPL_H
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/support/config.h>
namespace grpc {
class ProtoServerReflection;
} // namespace grpc
namespace grpc_impl {
class ServerInitializer;
namespace reflection {
class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin {
public:
ProtoServerReflectionPlugin();
::grpc::string name() override;
void InitServer(::grpc_impl::ServerInitializer* si) override;
void Finish(::grpc_impl::ServerInitializer* si) override;
void ChangeArguments(const ::grpc::string& name, void* value) override;
bool has_async_methods() const override;
bool has_sync_methods() const override;
private:
std::shared_ptr<grpc::ProtoServerReflection> reflection_service_;
};
/// Add proto reflection plugin to \a ServerBuilder.
/// This function should be called at the static initialization time.
void InitProtoReflectionServerBuilderPlugin();
} // namespace reflection
} // namespace grpc_impl
#endif // GRPCPP_EXT_PROTO_SERVER_REFLECTION_PLUGIN_IMPL_H

@ -19,32 +19,22 @@
#ifndef GRPCPP_EXT_SERVER_LOAD_REPORTING_H #ifndef GRPCPP_EXT_SERVER_LOAD_REPORTING_H
#define GRPCPP_EXT_SERVER_LOAD_REPORTING_H #define GRPCPP_EXT_SERVER_LOAD_REPORTING_H
#include <grpc/support/port_platform.h> #include <grpcpp/ext/server_load_reporting_impl.h>
#include <grpc/load_reporting.h>
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/server_context.h>
#include <grpcpp/impl/server_builder_option.h>
namespace grpc { namespace grpc {
namespace load_reporter { namespace load_reporter {
namespace experimental { namespace experimental {
// The ServerBuilderOption to enable server-side load reporting feature. To typedef ::grpc_impl::load_reporter::experimental::
// enable the feature, please make sure the binary builds with the LoadReportingServiceServerBuilderOption
// grpcpp_server_load_reporting library and set this option in the LoadReportingServiceServerBuilderOption;
// ServerBuilder.
class LoadReportingServiceServerBuilderOption : public ServerBuilderOption {
public:
void UpdateArguments(::grpc::ChannelArguments* args) override;
void UpdatePlugins(std::vector<std::unique_ptr<::grpc::ServerBuilderPlugin>>*
plugins) override;
};
// Adds the load reporting cost with \a cost_name and \a cost_value in the static inline void AddLoadReportingCost(grpc::ServerContext* ctx,
// trailing metadata of the server context. const grpc::string& cost_name,
void AddLoadReportingCost(grpc::ServerContext* ctx, double cost_value) {
const grpc::string& cost_name, double cost_value); ::grpc_impl::load_reporter::experimental::AddLoadReportingCost(ctx, cost_name,
cost_value);
}
} // namespace experimental } // namespace experimental
} // namespace load_reporter } // namespace load_reporter

@ -0,0 +1,54 @@
/*
*
* 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_EXT_SERVER_LOAD_REPORTING_IMPL_H
#define GRPCPP_EXT_SERVER_LOAD_REPORTING_IMPL_H
#include <grpc/support/port_platform.h>
#include <grpc/load_reporting.h>
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/server_context.h>
#include <grpcpp/impl/server_builder_option.h>
namespace grpc_impl {
namespace load_reporter {
namespace experimental {
// The ServerBuilderOption to enable server-side load reporting feature. To
// enable the feature, please make sure the binary builds with the
// grpcpp_server_load_reporting library and set this option in the
// ServerBuilder.
class LoadReportingServiceServerBuilderOption
: public grpc::ServerBuilderOption {
public:
void UpdateArguments(::grpc::ChannelArguments* args) override;
void UpdatePlugins(std::vector<std::unique_ptr<::grpc::ServerBuilderPlugin>>*
plugins) override;
};
// Adds the load reporting cost with \a cost_name and \a cost_value in the
// trailing metadata of the server context.
void AddLoadReportingCost(grpc::ServerContext* ctx,
const grpc::string& cost_name, double cost_value);
} // namespace experimental
} // namespace load_reporter
} // namespace grpc_impl
#endif // GRPCPP_EXT_SERVER_LOAD_REPORTING_IMPL_H

@ -19,85 +19,11 @@
#ifndef GRPCPP_GENERIC_GENERIC_STUB_H #ifndef GRPCPP_GENERIC_GENERIC_STUB_H
#define GRPCPP_GENERIC_GENERIC_STUB_H #define GRPCPP_GENERIC_GENERIC_STUB_H
#include <functional> #include <grpcpp/generic/generic_stub_impl.h>
#include <grpcpp/support/async_stream.h>
#include <grpcpp/support/async_unary_call.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/client_callback.h>
#include <grpcpp/support/status.h>
namespace grpc { namespace grpc {
class CompletionQueue; typedef ::grpc_impl::GenericStub GenericStub;
typedef ClientAsyncReaderWriter<ByteBuffer, ByteBuffer>
GenericClientAsyncReaderWriter;
typedef ClientAsyncResponseReader<ByteBuffer> GenericClientAsyncResponseReader;
/// Generic stubs provide a type-unsafe interface to call gRPC methods
/// by name.
class GenericStub final {
public:
explicit GenericStub(std::shared_ptr<ChannelInterface> channel)
: channel_(channel) {}
/// Setup a call to a named method \a method using \a context, but don't
/// start it. Let it be started explicitly with StartCall and a tag.
/// The return value only indicates whether or not registration of the call
/// succeeded (i.e. the call won't proceed if the return value is nullptr).
std::unique_ptr<GenericClientAsyncReaderWriter> PrepareCall(
ClientContext* context, const grpc::string& method, CompletionQueue* cq);
/// Setup a unary call to a named method \a method using \a context, and don't
/// start it. Let it be started explicitly with StartCall.
/// The return value only indicates whether or not registration of the call
/// succeeded (i.e. the call won't proceed if the return value is nullptr).
std::unique_ptr<GenericClientAsyncResponseReader> PrepareUnaryCall(
ClientContext* context, const grpc::string& method,
const ByteBuffer& request, CompletionQueue* cq);
/// DEPRECATED for multi-threaded use
/// Begin a call to a named method \a method using \a context.
/// A tag \a tag will be delivered to \a cq when the call has been started
/// (i.e, initial metadata has been sent).
/// The return value only indicates whether or not registration of the call
/// succeeded (i.e. the call won't proceed if the return value is nullptr).
std::unique_ptr<GenericClientAsyncReaderWriter> Call(
ClientContext* context, const grpc::string& method, CompletionQueue* cq,
void* tag);
/// NOTE: class experimental_type is not part of the public API of this class
/// TODO(vjpai): Move these contents to the public API of GenericStub when
/// they are no longer experimental
class experimental_type {
public:
explicit experimental_type(GenericStub* stub) : stub_(stub) {}
/// Setup and start a unary call to a named method \a method using
/// \a context and specifying the \a request and \a response buffers.
void UnaryCall(ClientContext* context, const grpc::string& method,
const ByteBuffer* request, ByteBuffer* response,
std::function<void(Status)> on_completion);
/// Setup a call to a named method \a method using \a context and tied to
/// \a reactor . Like any other bidi streaming RPC, it will not be activated
/// until StartCall is invoked on its reactor.
void PrepareBidiStreamingCall(
ClientContext* context, const grpc::string& method,
experimental::ClientBidiReactor<ByteBuffer, ByteBuffer>* reactor);
private:
GenericStub* stub_;
};
/// 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); }
private:
std::shared_ptr<ChannelInterface> channel_;
};
} // namespace grpc } // namespace grpc

@ -0,0 +1,108 @@
/*
*
* Copyright 2015 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_GENERIC_GENERIC_STUB_IMPL_H
#define GRPCPP_GENERIC_GENERIC_STUB_IMPL_H
#include <functional>
#include <grpcpp/support/async_stream.h>
#include <grpcpp/support/async_unary_call.h>
#include <grpcpp/support/byte_buffer.h>
#include <grpcpp/support/client_callback.h>
#include <grpcpp/support/status.h>
namespace grpc {
class CompletionQueue;
typedef ClientAsyncReaderWriter<ByteBuffer, ByteBuffer>
GenericClientAsyncReaderWriter;
typedef ClientAsyncResponseReader<ByteBuffer> GenericClientAsyncResponseReader;
} // namespace grpc
namespace grpc_impl {
/// Generic stubs provide a type-unsafe interface to call gRPC methods
/// by name.
class GenericStub final {
public:
explicit GenericStub(std::shared_ptr<grpc::ChannelInterface> channel)
: channel_(channel) {}
/// Setup a call to a named method \a method using \a context, but don't
/// start it. Let it be started explicitly with StartCall and a tag.
/// The return value only indicates whether or not registration of the call
/// succeeded (i.e. the call won't proceed if the return value is nullptr).
std::unique_ptr<grpc::GenericClientAsyncReaderWriter> PrepareCall(
grpc::ClientContext* context, const grpc::string& method,
grpc::CompletionQueue* cq);
/// Setup a unary call to a named method \a method using \a context, and don't
/// start it. Let it be started explicitly with StartCall.
/// The return value only indicates whether or not registration of the call
/// succeeded (i.e. the call won't proceed if the return value is nullptr).
std::unique_ptr<grpc::GenericClientAsyncResponseReader> PrepareUnaryCall(
grpc::ClientContext* context, const grpc::string& method,
const grpc::ByteBuffer& request, grpc::CompletionQueue* cq);
/// DEPRECATED for multi-threaded use
/// Begin a call to a named method \a method using \a context.
/// A tag \a tag will be delivered to \a cq when the call has been started
/// (i.e, initial metadata has been sent).
/// The return value only indicates whether or not registration of the call
/// succeeded (i.e. the call won't proceed if the return value is nullptr).
std::unique_ptr<grpc::GenericClientAsyncReaderWriter> Call(
grpc::ClientContext* context, const grpc::string& method,
grpc::CompletionQueue* cq, void* tag);
/// NOTE: class experimental_type is not part of the public API of this class
/// TODO(vjpai): Move these contents to the public API of GenericStub when
/// they are no longer experimental
class experimental_type {
public:
explicit experimental_type(GenericStub* stub) : stub_(stub) {}
/// Setup and start a unary call to a named method \a method using
/// \a context and specifying the \a request and \a response buffers.
void UnaryCall(grpc::ClientContext* context, const grpc::string& method,
const grpc::ByteBuffer* request, grpc::ByteBuffer* response,
std::function<void(grpc::Status)> on_completion);
/// Setup a call to a named method \a method using \a context and tied to
/// \a reactor . Like any other bidi streaming RPC, it will not be activated
/// until StartCall is invoked on its reactor.
void PrepareBidiStreamingCall(
grpc::ClientContext* context, const grpc::string& method,
grpc::experimental::ClientBidiReactor<grpc::ByteBuffer,
grpc::ByteBuffer>* reactor);
private:
GenericStub* stub_;
};
/// 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); }
private:
std::shared_ptr<grpc::ChannelInterface> channel_;
};
} // namespace grpc_impl
#endif // GRPCPP_GENERIC_GENERIC_STUB_IMPL_H

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2016 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,39 +19,22 @@
#ifndef GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_H #ifndef GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_H
#define GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_H #define GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_H
#include <grpcpp/support/config.h> #include <grpcpp/health_check_service_interface_impl.h>
namespace grpc { namespace grpc {
const char kHealthCheckServiceInterfaceArg[] = const char kHealthCheckServiceInterfaceArg[] =
"grpc.health_check_service_interface"; "grpc.health_check_service_interface";
/// The gRPC server uses this interface to expose the health checking service typedef ::grpc_impl::HealthCheckServiceInterface HealthCheckServiceInterface;
/// without depending on protobuf.
class HealthCheckServiceInterface { static inline void EnableDefaultHealthCheckService(bool enable) {
public: ::grpc_impl::EnableDefaultHealthCheckService(enable);
virtual ~HealthCheckServiceInterface() {} }
/// Set or change the serving status of the given \a service_name. static inline bool DefaultHealthCheckServiceEnabled() {
virtual void SetServingStatus(const grpc::string& service_name, return ::grpc_impl::DefaultHealthCheckServiceEnabled();
bool serving) = 0; }
/// Apply to all registered service names.
virtual void SetServingStatus(bool serving) = 0;
/// Set all registered service names to not serving and prevent future
/// state changes.
virtual void Shutdown() {}
};
/// Enable/disable the default health checking service. This applies to all C++
/// servers created afterwards. For each server, user can override the default
/// with a HealthCheckServiceServerBuilderOption.
/// NOT thread safe.
void EnableDefaultHealthCheckService(bool enable);
/// Returns whether the default health checking service is enabled.
/// NOT thread safe.
bool DefaultHealthCheckServiceEnabled();
} // namespace grpc } // namespace grpc

@ -0,0 +1,55 @@
/*
*
* Copyright 2016 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_HEALTH_CHECK_SERVICE_INTERFACE_IMPL_H
#define GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_IMPL_H
#include <grpcpp/support/config.h>
namespace grpc_impl {
/// The gRPC server uses this interface to expose the health checking service
/// without depending on protobuf.
class HealthCheckServiceInterface {
public:
virtual ~HealthCheckServiceInterface() {}
/// Set or change the serving status of the given \a service_name.
virtual void SetServingStatus(const grpc::string& service_name,
bool serving) = 0;
/// Apply to all registered service names.
virtual void SetServingStatus(bool serving) = 0;
/// Set all registered service names to not serving and prevent future
/// state changes.
virtual void Shutdown() {}
};
/// Enable/disable the default health checking service. This applies to all C++
/// servers created afterwards. For each server, user can override the default
/// with a HealthCheckServiceServerBuilderOption.
/// NOT thread safe.
void EnableDefaultHealthCheckService(bool enable);
/// Returns whether the default health checking service is enabled.
/// NOT thread safe.
bool DefaultHealthCheckServiceEnabled();
} // namespace grpc_impl
#endif // GRPCPP_HEALTH_CHECK_SERVICE_INTERFACE_IMPL_H

@ -28,6 +28,10 @@
#include <grpcpp/impl/codegen/rpc_service_method.h> #include <grpcpp/impl/codegen/rpc_service_method.h>
#include <grpcpp/impl/codegen/server_context.h> #include <grpcpp/impl/codegen/server_context.h>
namespace grpc_impl {
class ServerCredentials;
}
namespace grpc { namespace grpc {
class AsyncGenericService; class AsyncGenericService;
@ -35,7 +39,6 @@ class Channel;
class GenericServerContext; class GenericServerContext;
class ServerCompletionQueue; class ServerCompletionQueue;
class ServerContext; class ServerContext;
class ServerCredentials;
class Service; class Service;
extern CoreCodegenInterface* g_core_codegen_interface; extern CoreCodegenInterface* g_core_codegen_interface;
@ -150,7 +153,7 @@ class ServerInterface : public internal::CallHook {
/// ///
/// \warning It's an error to call this method on an already started server. /// \warning It's an error to call this method on an already started server.
virtual int AddListeningPort(const grpc::string& addr, virtual int AddListeningPort(const grpc::string& addr,
ServerCredentials* creds) = 0; grpc_impl::ServerCredentials* creds) = 0;
/// Start the server. /// Start the server.
/// ///

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,24 +19,11 @@
#ifndef GRPCPP_IMPL_SERVER_BUILDER_OPTION_H #ifndef GRPCPP_IMPL_SERVER_BUILDER_OPTION_H
#define GRPCPP_IMPL_SERVER_BUILDER_OPTION_H #define GRPCPP_IMPL_SERVER_BUILDER_OPTION_H
#include <map> #include <grpcpp/impl/server_builder_option_impl.h>
#include <memory>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/support/channel_arguments.h>
namespace grpc { namespace grpc {
/// Interface to pass an option to a \a ServerBuilder. typedef ::grpc_impl::ServerBuilderOption ServerBuilderOption;
class ServerBuilderOption {
public:
virtual ~ServerBuilderOption() {}
/// Alter the \a ChannelArguments used to create the gRPC server.
virtual void UpdateArguments(ChannelArguments* args) = 0;
/// Alter the ServerBuilderPlugin map that will be added into ServerBuilder.
virtual void UpdatePlugins(
std::vector<std::unique_ptr<ServerBuilderPlugin>>* plugins) = 0;
};
} // namespace grpc } // namespace grpc

@ -0,0 +1,43 @@
/*
*
* Copyright 2015 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_SERVER_BUILDER_OPTION_IMPL_H
#define GRPCPP_IMPL_SERVER_BUILDER_OPTION_IMPL_H
#include <map>
#include <memory>
#include <grpcpp/impl/server_builder_plugin.h>
#include <grpcpp/support/channel_arguments.h>
namespace grpc_impl {
/// Interface to pass an option to a \a ServerBuilder.
class ServerBuilderOption {
public:
virtual ~ServerBuilderOption() {}
/// Alter the \a ChannelArguments used to create the gRPC server.
virtual void UpdateArguments(grpc::ChannelArguments* args) = 0;
/// Alter the ServerBuilderPlugin map that will be added into ServerBuilder.
virtual void UpdatePlugins(
std::vector<std::unique_ptr<grpc::ServerBuilderPlugin>>* plugins) = 0;
};
} // namespace grpc_impl
#endif // GRPCPP_IMPL_SERVER_BUILDER_OPTION_IMPL_H

@ -23,10 +23,13 @@
#include <grpcpp/support/config.h> #include <grpcpp/support/config.h>
namespace grpc_impl {
class ServerInitializer;
}
namespace grpc { namespace grpc {
class ServerBuilder; class ServerBuilder;
class ServerInitializer;
class ChannelArguments; class ChannelArguments;
/// This interface is meant for internal usage only. Implementations of this /// This interface is meant for internal usage only. Implementations of this
@ -44,10 +47,10 @@ class ServerBuilderPlugin {
/// InitServer will be called in ServerBuilder::BuildAndStart(), after the /// InitServer will be called in ServerBuilder::BuildAndStart(), after the
/// Server instance is created. /// Server instance is created.
virtual void InitServer(ServerInitializer* si) = 0; virtual void InitServer(grpc_impl::ServerInitializer* si) = 0;
/// Finish will be called at the end of ServerBuilder::BuildAndStart(). /// Finish will be called at the end of ServerBuilder::BuildAndStart().
virtual void Finish(ServerInitializer* si) = 0; virtual void Finish(grpc_impl::ServerInitializer* si) = 0;
/// ChangeArguments is an interface that can be used in /// ChangeArguments is an interface that can be used in
/// ServerBuilderOption::UpdatePlugins /// ServerBuilderOption::UpdatePlugins

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2016 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,36 +19,11 @@
#ifndef GRPCPP_IMPL_SERVER_INITIALIZER_H #ifndef GRPCPP_IMPL_SERVER_INITIALIZER_H
#define GRPCPP_IMPL_SERVER_INITIALIZER_H #define GRPCPP_IMPL_SERVER_INITIALIZER_H
#include <memory> #include <grpcpp/impl/server_initializer_impl.h>
#include <vector>
#include <grpcpp/server.h>
namespace grpc { namespace grpc {
class Server; typedef ::grpc_impl::ServerInitializer ServerInitializer;
class Service;
class ServerInitializer {
public:
ServerInitializer(Server* server) : server_(server) {}
bool RegisterService(std::shared_ptr<Service> service) {
if (!server_->RegisterService(nullptr, service.get())) {
return false;
}
default_services_.push_back(service);
return true;
}
const std::vector<grpc::string>* GetServiceList() {
return &server_->services_;
}
private:
Server* server_;
std::vector<std::shared_ptr<Service> > default_services_;
};
} // namespace grpc } // namespace grpc

@ -0,0 +1,57 @@
/*
*
* Copyright 2016 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_SERVER_INITIALIZER_IMPL_H
#define GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H
#include <memory>
#include <vector>
#include <grpcpp/server.h>
namespace grpc {
class Server;
class Service;
} // namespace grpc
namespace grpc_impl {
class ServerInitializer {
public:
ServerInitializer(grpc::Server* server) : server_(server) {}
bool RegisterService(std::shared_ptr<grpc::Service> service) {
if (!server_->RegisterService(nullptr, service.get())) {
return false;
}
default_services_.push_back(service);
return true;
}
const std::vector<grpc::string>* GetServiceList() {
return &server_->services_;
}
private:
grpc::Server* server_;
std::vector<std::shared_ptr<grpc::Service> > default_services_;
};
} // namespace grpc_impl
#endif // GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H

@ -19,29 +19,20 @@
#ifndef GRPCPP_OPENCENSUS_H #ifndef GRPCPP_OPENCENSUS_H
#define GRPCPP_OPENCENSUS_H #define GRPCPP_OPENCENSUS_H
#include "opencensus/trace/span.h" #include "grpcpp/opencensus_impl.h"
namespace grpc { namespace grpc {
// These symbols in this file will not be included in the binary unless
// grpc_opencensus_plugin build target was added as a dependency. At the moment
// it is only setup to be built with Bazel.
// Registers the OpenCensus plugin with gRPC, so that it will be used for future static inline void RegisterOpenCensusPlugin() {
// RPCs. This must be called before any views are created. ::grpc_impl::RegisterOpenCensusPlugin();
void RegisterOpenCensusPlugin(); }
static inline void RegisterOpenCensusViewsForExport() {
// RPC stats definitions, defined by ::grpc_impl::RegisterOpenCensusViewsForExport();
// https://github.com/census-instrumentation/opencensus-specs/blob/master/stats/gRPC.md }
static inline ::opencensus::trace::Span GetSpanFromServerContext(
// Registers the cumulative gRPC views so that they will be exported by any ServerContext* context) {
// registered stats exporter. For on-task stats, construct a View using the return ::grpc_impl::GetSpanFromServerContext(context);
// ViewDescriptors below. }
void RegisterOpenCensusViewsForExport();
class ServerContext;
// Returns the tracing Span for the current RPC.
::opencensus::trace::Span GetSpanFromServerContext(ServerContext* context);
} // namespace grpc } // namespace grpc

@ -0,0 +1,51 @@
/*
*
* Copyright 2019 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_OPENCENSUS_IMPL_H
#define GRPCPP_OPENCENSUS_IMPL_H
#include "opencensus/trace/span.h"
namespace grpc {
class ServerContext;
}
namespace grpc_impl {
// These symbols in this file will not be included in the binary unless
// grpc_opencensus_plugin build target was added as a dependency. At the moment
// it is only setup to be built with Bazel.
// Registers the OpenCensus plugin with gRPC, so that it will be used for future
// RPCs. This must be called before any views are created.
void RegisterOpenCensusPlugin();
// RPC stats definitions, defined by
// https://github.com/census-instrumentation/opencensus-specs/blob/master/stats/gRPC.md
// Registers the cumulative gRPC views so that they will be exported by any
// registered stats exporter. For on-task stats, construct a View using the
// ViewDescriptors below.
void RegisterOpenCensusViewsForExport();
// Returns the tracing Span for the current RPC.
::opencensus::trace::Span GetSpanFromServerContext(
grpc::ServerContext* context);
} // namespace grpc_impl
#endif // GRPCPP_OPENCENSUS_IMPL_H

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2016 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,50 +19,11 @@
#ifndef GRPCPP_RESOURCE_QUOTA_H #ifndef GRPCPP_RESOURCE_QUOTA_H
#define GRPCPP_RESOURCE_QUOTA_H #define GRPCPP_RESOURCE_QUOTA_H
struct grpc_resource_quota; #include <grpcpp/resource_quota_impl.h>
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/grpc_library.h>
namespace grpc { namespace grpc {
/// ResourceQuota represents a bound on memory and thread usage by the gRPC typedef ::grpc_impl::ResourceQuota ResourceQuota;
/// library. A ResourceQuota can be attached to a server (via \a ServerBuilder),
/// or a client channel (via \a ChannelArguments).
/// gRPC will attempt to keep memory and threads used by all attached entities
/// below the ResourceQuota bound.
class ResourceQuota final : private GrpcLibraryCodegen {
public:
/// \param name - a unique name for this ResourceQuota.
explicit ResourceQuota(const grpc::string& name);
ResourceQuota();
~ResourceQuota();
/// Resize this \a ResourceQuota to a new size. If \a new_size is smaller
/// than the current size of the pool, memory usage will be monotonically
/// decreased until it falls under \a new_size.
/// No time bound is given for this to occur however.
ResourceQuota& Resize(size_t new_size);
/// Set the max number of threads that can be allocated from this
/// ResourceQuota object.
///
/// If the new_max_threads value is smaller than the current value, no new
/// threads are allocated until the number of active threads fall below
/// new_max_threads. There is no time bound on when this may happen i.e none
/// of the current threads are forcefully destroyed and all threads run their
/// normal course.
ResourceQuota& SetMaxThreads(int new_max_threads);
grpc_resource_quota* c_resource_quota() const { return impl_; }
private:
ResourceQuota(const ResourceQuota& rhs);
ResourceQuota& operator=(const ResourceQuota& rhs);
grpc_resource_quota* const impl_;
};
} // namespace grpc } // namespace grpc
#endif // GRPCPP_RESOURCE_QUOTA_H #endif // GRPCPP_RESOURCE_QUOTA_H

@ -0,0 +1,68 @@
/*
*
* Copyright 2016 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_RESOURCE_QUOTA_IMPL_H
#define GRPCPP_RESOURCE_QUOTA_IMPL_H
struct grpc_resource_quota;
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/grpc_library.h>
namespace grpc_impl {
/// ResourceQuota represents a bound on memory and thread usage by the gRPC
/// library. A ResourceQuota can be attached to a server (via \a ServerBuilder),
/// or a client channel (via \a ChannelArguments).
/// gRPC will attempt to keep memory and threads used by all attached entities
/// below the ResourceQuota bound.
class ResourceQuota final : private ::grpc::GrpcLibraryCodegen {
public:
/// \param name - a unique name for this ResourceQuota.
explicit ResourceQuota(const grpc::string& name);
ResourceQuota();
~ResourceQuota();
/// Resize this \a ResourceQuota to a new size. If \a new_size is smaller
/// than the current size of the pool, memory usage will be monotonically
/// decreased until it falls under \a new_size.
/// No time bound is given for this to occur however.
ResourceQuota& Resize(size_t new_size);
/// Set the max number of threads that can be allocated from this
/// ResourceQuota object.
///
/// If the new_max_threads value is smaller than the current value, no new
/// threads are allocated until the number of active threads fall below
/// new_max_threads. There is no time bound on when this may happen i.e none
/// of the current threads are forcefully destroyed and all threads run their
/// normal course.
ResourceQuota& SetMaxThreads(int new_max_threads);
grpc_resource_quota* c_resource_quota() const { return impl_; }
private:
ResourceQuota(const ResourceQuota& rhs);
ResourceQuota& operator=(const ResourceQuota& rhs);
grpc_resource_quota* const impl_;
};
} // namespace grpc_impl
#endif // GRPCPP_RESOURCE_QUOTA_IMPL_H

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,42 +19,11 @@
#ifndef GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H #ifndef GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H
#define GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H #define GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_H
#include <map> #include <grpcpp/security/auth_metadata_processor_impl.h>
#include <grpcpp/security/auth_context.h>
#include <grpcpp/support/status.h>
#include <grpcpp/support/string_ref.h>
namespace grpc { namespace grpc {
/// Interface allowing custom server-side authorization based on credentials typedef ::grpc_impl::AuthMetadataProcessor AuthMetadataProcessor;
/// encoded in metadata. Objects of this type can be passed to
/// \a ServerCredentials::SetAuthMetadataProcessor().
class AuthMetadataProcessor {
public:
typedef std::multimap<grpc::string_ref, grpc::string_ref> InputMetadata;
typedef std::multimap<grpc::string, grpc::string> OutputMetadata;
virtual ~AuthMetadataProcessor() {}
/// If this method returns true, the \a Process function will be scheduled in
/// a different thread from the one processing the call.
virtual bool IsBlocking() const { return true; }
/// context is read/write: it contains the properties of the channel peer and
/// it is the job of the Process method to augment it with properties derived
/// from the passed-in auth_metadata.
/// consumed_auth_metadata needs to be filled with metadata that has been
/// consumed by the processor and will be removed from the call.
/// response_metadata is the metadata that will be sent as part of the
/// response.
/// If the return value is not Status::OK, the rpc call will be aborted with
/// the error code and error message sent back to the client.
virtual Status Process(const InputMetadata& auth_metadata,
AuthContext* context,
OutputMetadata* consumed_auth_metadata,
OutputMetadata* response_metadata) = 0;
};
} // namespace grpc } // namespace grpc

@ -0,0 +1,61 @@
/*
*
* Copyright 2015 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_SECURITY_AUTH_METADATA_PROCESSOR_IMPL_H
#define GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_IMPL_H
#include <map>
#include <grpcpp/security/auth_context.h>
#include <grpcpp/support/status.h>
#include <grpcpp/support/string_ref.h>
namespace grpc_impl {
/// Interface allowing custom server-side authorization based on credentials
/// encoded in metadata. Objects of this type can be passed to
/// \a ServerCredentials::SetAuthMetadataProcessor().
class AuthMetadataProcessor {
public:
typedef std::multimap<grpc::string_ref, grpc::string_ref> InputMetadata;
typedef std::multimap<grpc::string, grpc::string> OutputMetadata;
virtual ~AuthMetadataProcessor() {}
/// If this method returns true, the \a Process function will be scheduled in
/// a different thread from the one processing the call.
virtual bool IsBlocking() const { return true; }
/// context is read/write: it contains the properties of the channel peer and
/// it is the job of the Process method to augment it with properties derived
/// from the passed-in auth_metadata.
/// consumed_auth_metadata needs to be filled with metadata that has been
/// consumed by the processor and will be removed from the call.
/// response_metadata is the metadata that will be sent as part of the
/// response.
/// If the return value is not Status::OK, the rpc call will be aborted with
/// the error code and error message sent back to the client.
virtual grpc::Status Process(const InputMetadata& auth_metadata,
grpc::AuthContext* context,
OutputMetadata* consumed_auth_metadata,
OutputMetadata* response_metadata) = 0;
};
} // namespace grpc_impl
#endif // GRPCPP_SECURITY_AUTH_METADATA_PROCESSOR_IMPL_H

@ -33,23 +33,31 @@
struct grpc_call; struct grpc_call;
namespace grpc { namespace grpc {
class ChannelArguments;
class Channel;
class SecureChannelCredentials;
class CallCredentials;
class SecureCallCredentials;
class CallCredentials;
class ChannelArguments;
class ChannelCredentials; class ChannelCredentials;
} // namespace grpc
namespace grpc_impl {
std::shared_ptr<grpc::Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<grpc::ChannelCredentials>& creds,
const grpc::ChannelArguments& args);
namespace experimental { namespace experimental {
std::shared_ptr<Channel> CreateCustomChannelWithInterceptors( std::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<grpc::ChannelCredentials>& creds,
const ChannelArguments& args, const grpc::ChannelArguments& args,
std::vector< std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators); interceptor_creators);
} // namespace experimental } // namespace experimental
} // namespace grpc_impl
namespace grpc {
class Channel;
class SecureChannelCredentials;
class SecureCallCredentials;
/// 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.
@ -70,18 +78,18 @@ class ChannelCredentials : private GrpcLibraryCodegen {
virtual SecureChannelCredentials* AsSecureCredentials() = 0; virtual SecureChannelCredentials* AsSecureCredentials() = 0;
private: private:
friend std::shared_ptr<Channel> CreateCustomChannel( friend std::shared_ptr<Channel> grpc_impl::CreateCustomChannel(
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args); const grpc::ChannelArguments& args);
friend std::shared_ptr<Channel> friend std::shared_ptr<Channel>
experimental::CreateCustomChannelWithInterceptors( grpc_impl::experimental::CreateCustomChannelWithInterceptors(
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args, const grpc::ChannelArguments& args,
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators); interceptor_creators);
virtual std::shared_ptr<Channel> CreateChannel( virtual std::shared_ptr<Channel> CreateChannel(

@ -1,6 +1,6 @@
/* /*
* *
* Copyright 2015 gRPC authors. * Copyright 2019 gRPC authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,39 +19,11 @@
#ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_H #ifndef GRPCPP_SECURITY_SERVER_CREDENTIALS_H
#define GRPCPP_SECURITY_SERVER_CREDENTIALS_H #define GRPCPP_SECURITY_SERVER_CREDENTIALS_H
#include <memory> #include <grpcpp/security/server_credentials_impl.h>
#include <vector>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/security/auth_metadata_processor.h>
#include <grpcpp/support/config.h>
struct grpc_server;
namespace grpc { namespace grpc {
class Server;
/// Wrapper around \a grpc_server_credentials, a way to authenticate a server.
class ServerCredentials {
public:
virtual ~ServerCredentials();
/// This method is not thread-safe and has to be called before the server is
/// started. The last call to this function wins.
virtual void SetAuthMetadataProcessor(
const std::shared_ptr<AuthMetadataProcessor>& processor) = 0;
private: typedef ::grpc_impl::ServerCredentials ServerCredentials;
friend class ::grpc::Server;
/// Tries to bind \a server to the given \a addr (eg, localhost:1234,
/// 192.168.1.1:31416, [::1]:27182, etc.)
///
/// \return bound port number on sucess, 0 on failure.
// TODO(dgq): the "port" part seems to be a misnomer.
virtual int AddPortToServer(const grpc::string& addr,
grpc_server* server) = 0;
};
/// Options to create ServerCredentials with SSL /// Options to create ServerCredentials with SSL
struct SslServerCredentialsOptions { struct SslServerCredentialsOptions {
@ -79,27 +51,29 @@ struct SslServerCredentialsOptions {
grpc_ssl_client_certificate_request_type client_certificate_request; grpc_ssl_client_certificate_request_type client_certificate_request;
}; };
/// Builds SSL ServerCredentials given SSL specific options static inline std::shared_ptr<ServerCredentials> SslServerCredentials(
std::shared_ptr<ServerCredentials> SslServerCredentials( const SslServerCredentialsOptions& options) {
const SslServerCredentialsOptions& options); return ::grpc_impl::SslServerCredentials(options);
}
/// Builds insecure server credentials. static inline std::shared_ptr<ServerCredentials> InsecureServerCredentials() {
std::shared_ptr<ServerCredentials> InsecureServerCredentials(); return ::grpc_impl::InsecureServerCredentials();
}
namespace experimental { namespace experimental {
/// Options to create ServerCredentials with ALTS typedef ::grpc_impl::experimental::AltsServerCredentialsOptions
struct AltsServerCredentialsOptions { AltsServerCredentialsOptions;
/// Add fields if needed.
};
/// Builds ALTS ServerCredentials given ALTS specific options static inline std::shared_ptr<ServerCredentials> AltsServerCredentials(
std::shared_ptr<ServerCredentials> AltsServerCredentials( const AltsServerCredentialsOptions& options) {
const AltsServerCredentialsOptions& options); return ::grpc_impl::experimental::AltsServerCredentials(options);
}
/// Builds Local ServerCredentials. static inline std::shared_ptr<ServerCredentials> LocalServerCredentials(
std::shared_ptr<ServerCredentials> LocalServerCredentials( grpc_local_connect_type type) {
grpc_local_connect_type type); return ::grpc_impl::experimental::LocalServerCredentials(type);
}
} // namespace experimental } // namespace experimental
} // namespace grpc } // namespace grpc

@ -0,0 +1,85 @@
/*
*
* Copyright 2015 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_SECURITY_SERVER_CREDENTIALS_IMPL_H
#define GRPCPP_SECURITY_SERVER_CREDENTIALS_IMPL_H
#include <memory>
#include <vector>
#include <grpc/grpc_security_constants.h>
#include <grpcpp/security/auth_metadata_processor.h>
#include <grpcpp/support/config.h>
struct grpc_server;
namespace grpc {
class Server;
struct SslServerCredentialsOptions;
} // namespace grpc
namespace grpc_impl {
/// Wrapper around \a grpc_server_credentials, a way to authenticate a server.
class ServerCredentials {
public:
virtual ~ServerCredentials();
/// This method is not thread-safe and has to be called before the server is
/// started. The last call to this function wins.
virtual void SetAuthMetadataProcessor(
const std::shared_ptr<grpc::AuthMetadataProcessor>& processor) = 0;
private:
friend class ::grpc::Server;
/// Tries to bind \a server to the given \a addr (eg, localhost:1234,
/// 192.168.1.1:31416, [::1]:27182, etc.)
///
/// \return bound port number on success, 0 on failure.
// TODO(dgq): the "port" part seems to be a misnomer.
virtual int AddPortToServer(const grpc::string& addr,
grpc_server* server) = 0;
};
/// Builds SSL ServerCredentials given SSL specific options
std::shared_ptr<ServerCredentials> SslServerCredentials(
const grpc::SslServerCredentialsOptions& options);
/// Builds insecure server credentials.
std::shared_ptr<ServerCredentials> InsecureServerCredentials();
namespace experimental {
/// Options to create ServerCredentials with ALTS
struct AltsServerCredentialsOptions {
/// Add fields if needed.
};
/// Builds ALTS ServerCredentials given ALTS specific options
std::shared_ptr<ServerCredentials> AltsServerCredentials(
const AltsServerCredentialsOptions& options);
/// Builds Local ServerCredentials.
std::shared_ptr<ServerCredentials> LocalServerCredentials(
grpc_local_connect_type type);
} // namespace experimental
} // namespace grpc_impl
#endif // GRPCPP_SECURITY_SERVER_CREDENTIALS_IMPL_H

@ -28,6 +28,7 @@
#include <grpc/compression.h> #include <grpc/compression.h>
#include <grpc/support/atm.h> #include <grpc/support/atm.h>
#include <grpcpp/completion_queue.h> #include <grpcpp/completion_queue.h>
#include <grpcpp/health_check_service_interface.h>
#include <grpcpp/impl/call.h> #include <grpcpp/impl/call.h>
#include <grpcpp/impl/codegen/client_interceptor.h> #include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/impl/codegen/grpc_library.h> #include <grpcpp/impl/codegen/grpc_library.h>
@ -40,12 +41,14 @@
struct grpc_server; struct grpc_server;
namespace grpc_impl {
class ServerInitializer;
}
namespace grpc { namespace grpc {
class AsyncGenericService; class AsyncGenericService;
class HealthCheckServiceInterface;
class ServerContext; class ServerContext;
class ServerInitializer;
/// Represents a gRPC server. /// Represents a gRPC server.
/// ///
@ -199,7 +202,7 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
friend class AsyncGenericService; friend class AsyncGenericService;
friend class ServerBuilder; friend class ServerBuilder;
friend class ServerInitializer; friend class grpc_impl::ServerInitializer;
class SyncRequest; class SyncRequest;
class CallbackRequestBase; class CallbackRequestBase;
@ -257,7 +260,7 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
CompletionQueue* CallbackCQ() override; CompletionQueue* CallbackCQ() override;
ServerInitializer* initializer(); grpc_impl::ServerInitializer* initializer();
// A vector of interceptor factory objects. // A vector of interceptor factory objects.
// This should be destroyed after health_check_service_ and this requirement // This should be destroyed after health_check_service_ and this requirement
@ -321,7 +324,7 @@ class Server : public ServerInterface, private GrpcLibraryCodegen {
// Pointer to the wrapped grpc_server. // Pointer to the wrapped grpc_server.
grpc_server* server_; grpc_server* server_;
std::unique_ptr<ServerInitializer> server_initializer_; std::unique_ptr<grpc_impl::ServerInitializer> server_initializer_;
std::unique_ptr<HealthCheckServiceInterface> health_check_service_; std::unique_ptr<HealthCheckServiceInterface> health_check_service_;
bool health_check_service_disabled_; bool health_check_service_disabled_;

@ -35,14 +35,18 @@
struct grpc_resource_quota; struct grpc_resource_quota;
namespace grpc_impl {
class ServerCredentials;
class ResourceQuota;
} // namespace grpc_impl
namespace grpc { namespace grpc {
class AsyncGenericService; class AsyncGenericService;
class ResourceQuota;
class CompletionQueue; class CompletionQueue;
class Server; class Server;
class ServerCompletionQueue; class ServerCompletionQueue;
class ServerCredentials;
class Service; class Service;
namespace testing { namespace testing {
@ -93,9 +97,10 @@ class ServerBuilder {
/// number bound to the \a grpc::Server for the corresponding endpoint after /// number bound to the \a grpc::Server for the corresponding endpoint after
/// it is successfully bound by BuildAndStart(), 0 otherwise. AddListeningPort /// it is successfully bound by BuildAndStart(), 0 otherwise. AddListeningPort
/// does not modify this pointer. /// does not modify this pointer.
ServerBuilder& AddListeningPort(const grpc::string& addr_uri, ServerBuilder& AddListeningPort(
std::shared_ptr<ServerCredentials> creds, const grpc::string& addr_uri,
int* selected_port = nullptr); std::shared_ptr<grpc_impl::ServerCredentials> creds,
int* selected_port = nullptr);
/// Add a completion queue for handling asynchronous services. /// Add a completion queue for handling asynchronous services.
/// ///
@ -186,7 +191,8 @@ class ServerBuilder {
grpc_compression_algorithm algorithm); grpc_compression_algorithm algorithm);
/// Set the attached buffer pool for this server /// Set the attached buffer pool for this server
ServerBuilder& SetResourceQuota(const ResourceQuota& resource_quota); ServerBuilder& SetResourceQuota(
const ::grpc_impl::ResourceQuota& resource_quota);
ServerBuilder& SetOption(std::unique_ptr<ServerBuilderOption> option); ServerBuilder& SetOption(std::unique_ptr<ServerBuilderOption> option);
@ -251,7 +257,7 @@ class ServerBuilder {
/// Experimental, to be deprecated /// Experimental, to be deprecated
struct Port { struct Port {
grpc::string addr; grpc::string addr;
std::shared_ptr<ServerCredentials> creds; std::shared_ptr<grpc_impl::ServerCredentials> creds;
int* selected_port; int* selected_port;
}; };
@ -319,7 +325,7 @@ class ServerBuilder {
/// List of completion queues added via \a AddCompletionQueue method. /// List of completion queues added via \a AddCompletionQueue method.
std::vector<ServerCompletionQueue*> cqs_; std::vector<ServerCompletionQueue*> cqs_;
std::shared_ptr<ServerCredentials> creds_; std::shared_ptr<grpc_impl::ServerCredentials> creds_;
std::vector<std::unique_ptr<ServerBuilderPlugin>> plugins_; std::vector<std::unique_ptr<ServerBuilderPlugin>> plugins_;
grpc_resource_quota* resource_quota_; grpc_resource_quota* resource_quota_;
AsyncGenericService* generic_service_{nullptr}; AsyncGenericService* generic_service_{nullptr};

@ -19,21 +19,15 @@
#ifndef GRPCPP_SERVER_POSIX_H #ifndef GRPCPP_SERVER_POSIX_H
#define GRPCPP_SERVER_POSIX_H #define GRPCPP_SERVER_POSIX_H
#include <memory> #include <grpcpp/server_posix_impl.h>
#include <grpc/support/port_platform.h>
#include <grpcpp/server.h>
namespace grpc { namespace grpc {
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD #ifdef GPR_SUPPORT_CHANNELS_FROM_FD
/// Add a new client to a \a Server communicating over the given static inline void AddInsecureChannelFromFd(Server* server, int fd) {
/// file descriptor. ::grpc_impl::AddInsecureChannelFromFd(server, fd);
/// }
/// \param server The server to add the client to.
/// \param fd The file descriptor representing a socket.
void AddInsecureChannelFromFd(Server* server, int fd);
#endif // GPR_SUPPORT_CHANNELS_FROM_FD #endif // GPR_SUPPORT_CHANNELS_FROM_FD

@ -0,0 +1,42 @@
/*
*
* Copyright 2016 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_SERVER_POSIX_IMPL_H
#define GRPCPP_SERVER_POSIX_IMPL_H
#include <memory>
#include <grpc/support/port_platform.h>
#include <grpcpp/server.h>
namespace grpc_impl {
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD
/// Add a new client to a \a Server communicating over the given
/// file descriptor.
///
/// \param server The server to add the client to.
/// \param fd The file descriptor representing a socket.
void AddInsecureChannelFromFd(grpc::Server* server, int fd);
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc
#endif // GRPCPP_SERVER_POSIX_IMPL_H

@ -26,13 +26,16 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpcpp/support/config.h> #include <grpcpp/support/config.h>
namespace grpc_impl {
class ResourceQuota;
}
namespace grpc { namespace grpc {
namespace testing { namespace testing {
class ChannelArgumentsTest; class ChannelArgumentsTest;
} // namespace testing } // namespace testing
class ResourceQuota;
/// Options for channel creation. The user can use generic setters to pass /// Options for channel creation. The user can use generic setters to pass
/// key value pairs down to C channel creation code. For gRPC related options, /// key value pairs down to C channel creation code. For gRPC related options,
/// concrete setters are provided. /// concrete setters are provided.
@ -83,7 +86,7 @@ class ChannelArguments {
void SetUserAgentPrefix(const grpc::string& user_agent_prefix); void SetUserAgentPrefix(const grpc::string& user_agent_prefix);
/// Set the buffer pool to be attached to the constructed channel. /// Set the buffer pool to be attached to the constructed channel.
void SetResourceQuota(const ResourceQuota& resource_quota); void SetResourceQuota(const ::grpc_impl::ResourceQuota& resource_quota);
/// Set the max receive and send message sizes. /// Set the max receive and send message sizes.
void SetMaxReceiveMessageSize(int size); void SetMaxReceiveMessageSize(int size);

@ -19,7 +19,7 @@
#ifndef GRPCPP_SUPPORT_ERROR_DETAILS_H #ifndef GRPCPP_SUPPORT_ERROR_DETAILS_H
#define GRPCPP_SUPPORT_ERROR_DETAILS_H #define GRPCPP_SUPPORT_ERROR_DETAILS_H
#include <grpcpp/support/status.h> #include <grpcpp/support/error_details_impl.h>
namespace google { namespace google {
namespace rpc { namespace rpc {
@ -29,17 +29,15 @@ class Status;
namespace grpc { namespace grpc {
/// Map a \a grpc::Status to a \a google::rpc::Status. static inline Status ExtractErrorDetails(const Status& from,
/// The given \a to object will be cleared. ::google::rpc::Status* to) {
/// On success, returns status with OK. return ::grpc_impl::ExtractErrorDetails(from, to);
/// Returns status with \a INVALID_ARGUMENT, if failed to deserialize. }
/// Returns status with \a FAILED_PRECONDITION, if \a to is nullptr.
Status ExtractErrorDetails(const Status& from, ::google::rpc::Status* to); static inline Status SetErrorDetails(const ::google::rpc::Status& from,
Status* to) {
/// Map \a google::rpc::Status to a \a grpc::Status. return ::grpc_impl::SetErrorDetails(from, to);
/// Returns OK on success. }
/// Returns status with \a FAILED_PRECONDITION if \a to is nullptr.
Status SetErrorDetails(const ::google::rpc::Status& from, Status* to);
} // namespace grpc } // namespace grpc

@ -0,0 +1,48 @@
/*
*
* Copyright 2017 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_SUPPORT_ERROR_DETAILS_IMPL_H
#define GRPCPP_SUPPORT_ERROR_DETAILS_IMPL_H
#include <grpcpp/support/status.h>
namespace google {
namespace rpc {
class Status;
} // namespace rpc
} // namespace google
namespace grpc_impl {
/// Map a \a grpc::Status to a \a google::rpc::Status.
/// The given \a to object will be cleared.
/// On success, returns status with OK.
/// Returns status with \a INVALID_ARGUMENT, if failed to deserialize.
/// Returns status with \a FAILED_PRECONDITION, if \a to is nullptr.
grpc::Status ExtractErrorDetails(const grpc::Status& from,
::google::rpc::Status* to);
/// Map \a google::rpc::Status to a \a grpc::Status.
/// Returns OK on success.
/// Returns status with \a FAILED_PRECONDITION if \a to is nullptr.
grpc::Status SetErrorDetails(const ::google::rpc::Status& from,
grpc::Status* to);
} // namespace grpc_impl
#endif // GRPCPP_SUPPORT_ERROR_DETAILS_IMPL_H

@ -13,8 +13,8 @@
<date>2018-01-19</date> <date>2018-01-19</date>
<time>16:06:07</time> <time>16:06:07</time>
<version> <version>
<release>1.20.0dev</release> <release>1.21.0dev</release>
<api>1.20.0dev</api> <api>1.21.0dev</api>
</version> </version>
<stability> <stability>
<release>beta</release> <release>beta</release>
@ -107,8 +107,10 @@
<file baseinstalldir="/" name="src/core/lib/gprpp/atomic.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/atomic.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/fork.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/fork.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/manual_constructor.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/manual_constructor.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/map.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/memory.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/memory.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/mutex_lock.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/mutex_lock.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/pair.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gprpp/thd.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/gprpp/thd.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/profiling/timers.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/alloc.cc" role="src" /> <file baseinstalldir="/" name="src/core/lib/gpr/alloc.cc" role="src" />

@ -382,6 +382,10 @@ void GenerateServerClass(Printer* out, const ServiceDescriptor* service) {
"/// <summary>Base class for server-side implementations of " "/// <summary>Base class for server-side implementations of "
"$servicename$</summary>\n", "$servicename$</summary>\n",
"servicename", GetServiceClassName(service)); "servicename", GetServiceClassName(service));
out->Print(
"[grpc::BindServiceMethod(typeof($classname$), "
"\"BindService\")]\n",
"classname", GetServiceClassName(service));
out->Print("public abstract partial class $name$\n", "name", out->Print("public abstract partial class $name$\n", "name",
GetServerClassName(service)); GetServerClassName(service));
out->Print("{\n"); out->Print("{\n");

@ -70,6 +70,10 @@ static void PrintAllComments(const DescriptorType* desc, Printer* printer) {
} }
printer->Print("\n"); printer->Print("\n");
} }
printer->Print(" *\n");
printer->Print(
" * This method belongs to a set of APIs that have been deprecated. Using"
" the v2 API is recommended.\n");
printer->Print(" */\n"); printer->Print(" */\n");
} }
@ -278,6 +282,13 @@ void PrintMethodImplementations(Printer* printer,
map< ::grpc::string, ::grpc::string> vars = { map< ::grpc::string, ::grpc::string> vars = {
{"service_class", ServiceClassName(service)}}; {"service_class", ServiceClassName(service)}};
printer.Print(vars,
"/**\n"
" * The methods in this protocol belong to a set of old APIs "
"that have been deprecated. They do not\n"
" * recognize call options provided in the initializer. Using "
"the v2 protocol is recommended.\n"
" */\n");
printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n"); printer.Print(vars, "@protocol $service_class$ <NSObject>\n\n");
for (int i = 0; i < service->method_count(); i++) { for (int i = 0; i < service->method_count(); i++) {
PrintMethodDeclarations(&printer, service->method(i)); PrintMethodDeclarations(&printer, service->method(i));
@ -329,10 +340,13 @@ void PrintMethodImplementations(Printer* printer,
"callOptions:(GRPCCallOptions " "callOptions:(GRPCCallOptions "
"*_Nullable)callOptions" "*_Nullable)callOptions"
" NS_DESIGNATED_INITIALIZER;\n"); " NS_DESIGNATED_INITIALIZER;\n");
printer.Print("- (instancetype)initWithHost:(NSString *)host;\n");
printer.Print( printer.Print(
"+ (instancetype)serviceWithHost:(NSString *)host " "+ (instancetype)serviceWithHost:(NSString *)host "
"callOptions:(GRPCCallOptions *_Nullable)callOptions;\n"); "callOptions:(GRPCCallOptions *_Nullable)callOptions;\n");
printer.Print(
"// The following methods belong to a set of old APIs that have been "
"deprecated.\n");
printer.Print("- (instancetype)initWithHost:(NSString *)host;\n");
printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n"); printer.Print("+ (instancetype)serviceWithHost:(NSString *)host;\n");
printer.Print("@end\n"); printer.Print("@end\n");

@ -51,6 +51,7 @@
#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/inlined_vector.h" #include "src/core/lib/gprpp/inlined_vector.h"
#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/mutex_lock.h"
#include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/combiner.h"
#include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/iomgr/polling_entity.h"
@ -91,7 +92,55 @@ grpc_core::TraceFlag grpc_client_channel_routing_trace(
* CHANNEL-WIDE FUNCTIONS * CHANNEL-WIDE FUNCTIONS
*/ */
struct external_connectivity_watcher; // Forward declaration.
typedef struct client_channel_channel_data channel_data;
namespace grpc_core {
namespace {
class ExternalConnectivityWatcher {
public:
class WatcherList {
public:
WatcherList() { gpr_mu_init(&mu_); }
~WatcherList() { gpr_mu_destroy(&mu_); }
int size() const;
ExternalConnectivityWatcher* Lookup(grpc_closure* on_complete) const;
void Add(ExternalConnectivityWatcher* watcher);
void Remove(const ExternalConnectivityWatcher* watcher);
private:
// head_ is guarded by a mutex, since the size() method needs to
// iterate over the list, and it's called from the C-core API
// function grpc_channel_num_external_connectivity_watchers(), which
// is synchronous and therefore cannot run in the combiner.
mutable gpr_mu mu_;
ExternalConnectivityWatcher* head_ = nullptr;
};
ExternalConnectivityWatcher(channel_data* chand, grpc_polling_entity pollent,
grpc_connectivity_state* state,
grpc_closure* on_complete,
grpc_closure* watcher_timer_init);
~ExternalConnectivityWatcher();
private:
static void OnWatchCompleteLocked(void* arg, grpc_error* error);
static void WatchConnectivityStateLocked(void* arg, grpc_error* ignored);
channel_data* chand_;
grpc_polling_entity pollent_;
grpc_connectivity_state* state_;
grpc_closure* on_complete_;
grpc_closure* watcher_timer_init_;
grpc_closure my_closure_;
ExternalConnectivityWatcher* next_ = nullptr;
};
} // namespace
} // namespace grpc_core
struct QueuedPick { struct QueuedPick {
LoadBalancingPolicy::PickArgs pick; LoadBalancingPolicy::PickArgs pick;
@ -99,7 +148,7 @@ struct QueuedPick {
QueuedPick* next = nullptr; QueuedPick* next = nullptr;
}; };
typedef struct client_channel_channel_data { struct client_channel_channel_data {
// //
// Fields set at construction and never modified. // Fields set at construction and never modified.
// //
@ -136,17 +185,16 @@ typedef struct client_channel_channel_data {
// //
grpc_core::Atomic<grpc_error*> disconnect_error; grpc_core::Atomic<grpc_error*> disconnect_error;
// external_connectivity_watcher_list head is guarded by its own mutex, since
// counts need to be grabbed immediately without polling on a CQ.
gpr_mu external_connectivity_watcher_list_mu;
struct external_connectivity_watcher* external_connectivity_watcher_list_head;
// The following properties are guarded by a mutex since APIs require them // The following properties are guarded by a mutex since APIs require them
// to be instantaneously available. // to be instantaneously available.
gpr_mu info_mu; gpr_mu info_mu;
grpc_core::UniquePtr<char> info_lb_policy_name; grpc_core::UniquePtr<char> info_lb_policy_name;
grpc_core::UniquePtr<char> info_service_config_json; grpc_core::UniquePtr<char> info_service_config_json;
} channel_data;
grpc_core::ManualConstructor<
grpc_core::ExternalConnectivityWatcher::WatcherList>
external_connectivity_watcher_list;
};
// Forward declarations. // Forward declarations.
static void start_pick_locked(void* arg, grpc_error* ignored); static void start_pick_locked(void* arg, grpc_error* ignored);
@ -262,6 +310,123 @@ class ServiceConfigSetter {
grpc_closure closure_; grpc_closure closure_;
}; };
//
// ExternalConnectivityWatcher::WatcherList
//
int ExternalConnectivityWatcher::WatcherList::size() const {
MutexLock lock(&mu_);
int count = 0;
for (ExternalConnectivityWatcher* w = head_; w != nullptr; w = w->next_) {
++count;
}
return count;
}
ExternalConnectivityWatcher* ExternalConnectivityWatcher::WatcherList::Lookup(
grpc_closure* on_complete) const {
MutexLock lock(&mu_);
ExternalConnectivityWatcher* w = head_;
while (w != nullptr && w->on_complete_ != on_complete) {
w = w->next_;
}
return w;
}
void ExternalConnectivityWatcher::WatcherList::Add(
ExternalConnectivityWatcher* watcher) {
GPR_ASSERT(Lookup(watcher->on_complete_) == nullptr);
MutexLock lock(&mu_);
GPR_ASSERT(watcher->next_ == nullptr);
watcher->next_ = head_;
head_ = watcher;
}
void ExternalConnectivityWatcher::WatcherList::Remove(
const ExternalConnectivityWatcher* watcher) {
MutexLock lock(&mu_);
if (watcher == head_) {
head_ = watcher->next_;
return;
}
for (ExternalConnectivityWatcher* w = head_; w != nullptr; w = w->next_) {
if (w->next_ == watcher) {
w->next_ = w->next_->next_;
return;
}
}
GPR_UNREACHABLE_CODE(return );
}
//
// ExternalConnectivityWatcher
//
ExternalConnectivityWatcher::ExternalConnectivityWatcher(
channel_data* chand, grpc_polling_entity pollent,
grpc_connectivity_state* state, grpc_closure* on_complete,
grpc_closure* watcher_timer_init)
: chand_(chand),
pollent_(pollent),
state_(state),
on_complete_(on_complete),
watcher_timer_init_(watcher_timer_init) {
grpc_polling_entity_add_to_pollset_set(&pollent_, chand_->interested_parties);
GRPC_CHANNEL_STACK_REF(chand_->owning_stack, "ExternalConnectivityWatcher");
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(&my_closure_, WatchConnectivityStateLocked, this,
grpc_combiner_scheduler(chand_->combiner)),
GRPC_ERROR_NONE);
}
ExternalConnectivityWatcher::~ExternalConnectivityWatcher() {
grpc_polling_entity_del_from_pollset_set(&pollent_,
chand_->interested_parties);
GRPC_CHANNEL_STACK_UNREF(chand_->owning_stack, "ExternalConnectivityWatcher");
}
void ExternalConnectivityWatcher::OnWatchCompleteLocked(void* arg,
grpc_error* error) {
ExternalConnectivityWatcher* self =
static_cast<ExternalConnectivityWatcher*>(arg);
grpc_closure* on_complete = self->on_complete_;
self->chand_->external_connectivity_watcher_list->Remove(self);
Delete(self);
GRPC_CLOSURE_SCHED(on_complete, GRPC_ERROR_REF(error));
}
void ExternalConnectivityWatcher::WatchConnectivityStateLocked(
void* arg, grpc_error* ignored) {
ExternalConnectivityWatcher* self =
static_cast<ExternalConnectivityWatcher*>(arg);
if (self->state_ == nullptr) {
// Handle cancellation.
GPR_ASSERT(self->watcher_timer_init_ == nullptr);
ExternalConnectivityWatcher* found =
self->chand_->external_connectivity_watcher_list->Lookup(
self->on_complete_);
if (found != nullptr) {
grpc_connectivity_state_notify_on_state_change(
&found->chand_->state_tracker, nullptr, &found->my_closure_);
}
Delete(self);
return;
}
// New watcher.
self->chand_->external_connectivity_watcher_list->Add(self);
// This assumes that the closure is scheduled on the ExecCtx scheduler
// and that GRPC_CLOSURE_RUN would run the closure immediately.
GRPC_CLOSURE_RUN(self->watcher_timer_init_, GRPC_ERROR_NONE);
GRPC_CLOSURE_INIT(&self->my_closure_, OnWatchCompleteLocked, self,
grpc_combiner_scheduler(self->chand_->combiner));
grpc_connectivity_state_notify_on_state_change(
&self->chand_->state_tracker, self->state_, &self->my_closure_);
}
//
// ClientChannelControlHelper
//
class ClientChannelControlHelper class ClientChannelControlHelper
: public LoadBalancingPolicy::ChannelControlHelper { : public LoadBalancingPolicy::ChannelControlHelper {
public: public:
@ -478,12 +643,7 @@ static grpc_error* cc_init_channel_elem(grpc_channel_element* elem,
chand->disconnect_error.Store(GRPC_ERROR_NONE, chand->disconnect_error.Store(GRPC_ERROR_NONE,
grpc_core::MemoryOrder::RELAXED); grpc_core::MemoryOrder::RELAXED);
gpr_mu_init(&chand->info_mu); gpr_mu_init(&chand->info_mu);
gpr_mu_init(&chand->external_connectivity_watcher_list_mu); chand->external_connectivity_watcher_list.Init();
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
chand->external_connectivity_watcher_list_head = nullptr;
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
chand->owning_stack = args->channel_stack; chand->owning_stack = args->channel_stack;
chand->deadline_checking_enabled = chand->deadline_checking_enabled =
grpc_deadline_checking_enabled(args->channel_args); grpc_deadline_checking_enabled(args->channel_args);
@ -593,7 +753,7 @@ static void cc_destroy_channel_elem(grpc_channel_element* elem) {
chand->disconnect_error.Load(grpc_core::MemoryOrder::RELAXED)); chand->disconnect_error.Load(grpc_core::MemoryOrder::RELAXED));
grpc_connectivity_state_destroy(&chand->state_tracker); grpc_connectivity_state_destroy(&chand->state_tracker);
gpr_mu_destroy(&chand->info_mu); gpr_mu_destroy(&chand->info_mu);
gpr_mu_destroy(&chand->external_connectivity_watcher_list_mu); chand->external_connectivity_watcher_list.Destroy();
} }
/************************************************************************* /*************************************************************************
@ -2957,6 +3117,10 @@ const grpc_channel_filter grpc_client_channel_filter = {
"client-channel", "client-channel",
}; };
//
// functions exported to the rest of core
//
void grpc_client_channel_set_channelz_node( void grpc_client_channel_set_channelz_node(
grpc_channel_element* elem, grpc_core::channelz::ClientChannelNode* node) { grpc_channel_element* elem, grpc_core::channelz::ClientChannelNode* node) {
channel_data* chand = static_cast<channel_data*>(elem->channel_data); channel_data* chand = static_cast<channel_data*>(elem->channel_data);
@ -2996,120 +3160,10 @@ grpc_connectivity_state grpc_client_channel_check_connectivity_state(
return out; return out;
} }
typedef struct external_connectivity_watcher {
channel_data* chand;
grpc_polling_entity pollent;
grpc_closure* on_complete;
grpc_closure* watcher_timer_init;
grpc_connectivity_state* state;
grpc_closure my_closure;
struct external_connectivity_watcher* next;
} external_connectivity_watcher;
static external_connectivity_watcher* lookup_external_connectivity_watcher(
channel_data* chand, grpc_closure* on_complete) {
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
while (w != nullptr && w->on_complete != on_complete) {
w = w->next;
}
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
return w;
}
static void external_connectivity_watcher_list_append(
channel_data* chand, external_connectivity_watcher* w) {
GPR_ASSERT(!lookup_external_connectivity_watcher(chand, w->on_complete));
gpr_mu_lock(&w->chand->external_connectivity_watcher_list_mu);
GPR_ASSERT(!w->next);
w->next = chand->external_connectivity_watcher_list_head;
chand->external_connectivity_watcher_list_head = w;
gpr_mu_unlock(&w->chand->external_connectivity_watcher_list_mu);
}
static void external_connectivity_watcher_list_remove(
channel_data* chand, external_connectivity_watcher* to_remove) {
GPR_ASSERT(
lookup_external_connectivity_watcher(chand, to_remove->on_complete));
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
if (to_remove == chand->external_connectivity_watcher_list_head) {
chand->external_connectivity_watcher_list_head = to_remove->next;
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
return;
}
external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
while (w != nullptr) {
if (w->next == to_remove) {
w->next = w->next->next;
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
return;
}
w = w->next;
}
GPR_UNREACHABLE_CODE(return );
}
int grpc_client_channel_num_external_connectivity_watchers( int grpc_client_channel_num_external_connectivity_watchers(
grpc_channel_element* elem) { grpc_channel_element* elem) {
channel_data* chand = static_cast<channel_data*>(elem->channel_data); channel_data* chand = static_cast<channel_data*>(elem->channel_data);
int count = 0; return chand->external_connectivity_watcher_list->size();
gpr_mu_lock(&chand->external_connectivity_watcher_list_mu);
external_connectivity_watcher* w =
chand->external_connectivity_watcher_list_head;
while (w != nullptr) {
count++;
w = w->next;
}
gpr_mu_unlock(&chand->external_connectivity_watcher_list_mu);
return count;
}
static void on_external_watch_complete_locked(void* arg, grpc_error* error) {
external_connectivity_watcher* w =
static_cast<external_connectivity_watcher*>(arg);
grpc_closure* follow_up = w->on_complete;
grpc_polling_entity_del_from_pollset_set(&w->pollent,
w->chand->interested_parties);
GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack,
"external_connectivity_watcher");
external_connectivity_watcher_list_remove(w->chand, w);
gpr_free(w);
GRPC_CLOSURE_SCHED(follow_up, GRPC_ERROR_REF(error));
}
static void watch_connectivity_state_locked(void* arg,
grpc_error* error_ignored) {
external_connectivity_watcher* w =
static_cast<external_connectivity_watcher*>(arg);
external_connectivity_watcher* found = nullptr;
if (w->state != nullptr) {
external_connectivity_watcher_list_append(w->chand, w);
// An assumption is being made that the closure is scheduled on the exec ctx
// scheduler and that GRPC_CLOSURE_RUN would run the closure immediately.
GRPC_CLOSURE_RUN(w->watcher_timer_init, GRPC_ERROR_NONE);
GRPC_CLOSURE_INIT(&w->my_closure, on_external_watch_complete_locked, w,
grpc_combiner_scheduler(w->chand->combiner));
grpc_connectivity_state_notify_on_state_change(&w->chand->state_tracker,
w->state, &w->my_closure);
} else {
GPR_ASSERT(w->watcher_timer_init == nullptr);
found = lookup_external_connectivity_watcher(w->chand, w->on_complete);
if (found) {
GPR_ASSERT(found->on_complete == w->on_complete);
grpc_connectivity_state_notify_on_state_change(
&found->chand->state_tracker, nullptr, &found->my_closure);
}
grpc_polling_entity_del_from_pollset_set(&w->pollent,
w->chand->interested_parties);
GRPC_CHANNEL_STACK_UNREF(w->chand->owning_stack,
"external_connectivity_watcher");
gpr_free(w);
}
} }
void grpc_client_channel_watch_connectivity_state( void grpc_client_channel_watch_connectivity_state(
@ -3117,21 +3171,8 @@ void grpc_client_channel_watch_connectivity_state(
grpc_connectivity_state* state, grpc_closure* closure, grpc_connectivity_state* state, grpc_closure* closure,
grpc_closure* watcher_timer_init) { grpc_closure* watcher_timer_init) {
channel_data* chand = static_cast<channel_data*>(elem->channel_data); channel_data* chand = static_cast<channel_data*>(elem->channel_data);
external_connectivity_watcher* w = grpc_core::New<grpc_core::ExternalConnectivityWatcher>(
static_cast<external_connectivity_watcher*>(gpr_zalloc(sizeof(*w))); chand, pollent, state, closure, watcher_timer_init);
w->chand = chand;
w->pollent = pollent;
w->on_complete = closure;
w->state = state;
w->watcher_timer_init = watcher_timer_init;
grpc_polling_entity_add_to_pollset_set(&w->pollent,
chand->interested_parties);
GRPC_CHANNEL_STACK_REF(w->chand->owning_stack,
"external_connectivity_watcher");
GRPC_CLOSURE_SCHED(
GRPC_CLOSURE_INIT(&w->my_closure, watch_connectivity_state_locked, w,
grpc_combiner_scheduler(chand->combiner)),
GRPC_ERROR_NONE);
} }
grpc_core::RefCountedPtr<grpc_core::SubchannelCall> grpc_core::RefCountedPtr<grpc_core::SubchannelCall>

@ -287,7 +287,6 @@ HealthCheckClient::CallState::CallState(
->GetInitialCallSizeEstimate(0))), ->GetInitialCallSizeEstimate(0))),
payload_(context_) { payload_(context_) {
grpc_call_combiner_init(&call_combiner_); grpc_call_combiner_init(&call_combiner_);
gpr_atm_rel_store(&seen_response_, static_cast<gpr_atm>(0));
} }
HealthCheckClient::CallState::~CallState() { HealthCheckClient::CallState::~CallState() {
@ -295,9 +294,6 @@ HealthCheckClient::CallState::~CallState() {
gpr_log(GPR_INFO, "HealthCheckClient %p: destroying CallState %p", gpr_log(GPR_INFO, "HealthCheckClient %p: destroying CallState %p",
health_check_client_.get(), this); health_check_client_.get(), this);
} }
// The subchannel call is in the arena, so reset the pointer before we destroy
// the arena.
call_.reset();
for (size_t i = 0; i < GRPC_CONTEXT_COUNT; i++) { for (size_t i = 0; i < GRPC_CONTEXT_COUNT; i++) {
if (context_[i].destroy != nullptr) { if (context_[i].destroy != nullptr) {
context_[i].destroy(context_[i].value); context_[i].destroy(context_[i].value);
@ -349,7 +345,6 @@ void HealthCheckClient::CallState::StartCall() {
return; return;
} }
// Initialize payload and batch. // Initialize payload and batch.
memset(&batch_, 0, sizeof(batch_));
payload_.context = context_; payload_.context = context_;
batch_.payload = &payload_; batch_.payload = &payload_;
// on_complete callback takes ref, handled manually. // on_complete callback takes ref, handled manually.
@ -401,8 +396,6 @@ void HealthCheckClient::CallState::StartCall() {
// Start batch. // Start batch.
StartBatch(&batch_); StartBatch(&batch_);
// Initialize recv_trailing_metadata batch. // Initialize recv_trailing_metadata batch.
memset(&recv_trailing_metadata_batch_, 0,
sizeof(recv_trailing_metadata_batch_));
recv_trailing_metadata_batch_.payload = &payload_; recv_trailing_metadata_batch_.payload = &payload_;
// Add recv_trailing_metadata op. // Add recv_trailing_metadata op.
grpc_metadata_batch_init(&recv_trailing_metadata_); grpc_metadata_batch_init(&recv_trailing_metadata_);
@ -439,12 +432,22 @@ void HealthCheckClient::CallState::StartBatch(
GRPC_ERROR_NONE, "start_subchannel_batch"); GRPC_ERROR_NONE, "start_subchannel_batch");
} }
void HealthCheckClient::CallState::AfterCallStackDestruction(
void* arg, grpc_error* error) {
HealthCheckClient::CallState* self =
static_cast<HealthCheckClient::CallState*>(arg);
self->Unref(DEBUG_LOCATION, "cancel");
}
void HealthCheckClient::CallState::OnCancelComplete(void* arg, void HealthCheckClient::CallState::OnCancelComplete(void* arg,
grpc_error* error) { grpc_error* error) {
HealthCheckClient::CallState* self = HealthCheckClient::CallState* self =
static_cast<HealthCheckClient::CallState*>(arg); static_cast<HealthCheckClient::CallState*>(arg);
GRPC_CALL_COMBINER_STOP(&self->call_combiner_, "health_cancel"); GRPC_CALL_COMBINER_STOP(&self->call_combiner_, "health_cancel");
self->Unref(DEBUG_LOCATION, "cancel"); GRPC_CLOSURE_INIT(&self->after_call_stack_destruction_,
AfterCallStackDestruction, self, grpc_schedule_on_exec_ctx);
self->call_->SetAfterCallStackDestroy(&self->after_call_stack_destruction_);
self->call_.reset();
} }
void HealthCheckClient::CallState::StartCancel(void* arg, grpc_error* error) { void HealthCheckClient::CallState::StartCancel(void* arg, grpc_error* error) {
@ -458,7 +461,9 @@ void HealthCheckClient::CallState::StartCancel(void* arg, grpc_error* error) {
} }
void HealthCheckClient::CallState::Cancel() { void HealthCheckClient::CallState::Cancel() {
if (call_ != nullptr) { bool expected = false;
if (cancelled_.CompareExchangeStrong(&expected, true, MemoryOrder::ACQ_REL,
MemoryOrder::ACQUIRE)) {
Ref(DEBUG_LOCATION, "cancel").release(); Ref(DEBUG_LOCATION, "cancel").release();
GRPC_CALL_COMBINER_START( GRPC_CALL_COMBINER_START(
&call_combiner_, &call_combiner_,
@ -501,13 +506,12 @@ void HealthCheckClient::CallState::DoneReadingRecvMessage(grpc_error* error) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("backend unhealthy"); error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("backend unhealthy");
} }
health_check_client_->SetHealthStatus(state, error); health_check_client_->SetHealthStatus(state, error);
gpr_atm_rel_store(&seen_response_, static_cast<gpr_atm>(1)); seen_response_.Store(true, MemoryOrder::RELEASE);
grpc_slice_buffer_destroy_internal(&recv_message_buffer_); grpc_slice_buffer_destroy_internal(&recv_message_buffer_);
// Start another recv_message batch. // Start another recv_message batch.
// This re-uses the ref we're holding. // This re-uses the ref we're holding.
// Note: Can't just reuse batch_ here, since we don't know that all // Note: Can't just reuse batch_ here, since we don't know that all
// callbacks from the original batch have completed yet. // callbacks from the original batch have completed yet.
memset(&recv_message_batch_, 0, sizeof(recv_message_batch_));
recv_message_batch_.payload = &payload_; recv_message_batch_.payload = &payload_;
payload_.recv_message.recv_message = &recv_message_; payload_.recv_message.recv_message = &recv_message_;
payload_.recv_message.recv_message_ready = GRPC_CLOSURE_INIT( payload_.recv_message.recv_message_ready = GRPC_CLOSURE_INIT(
@ -635,7 +639,7 @@ void HealthCheckClient::CallState::CallEnded(bool retry) {
health_check_client_->call_state_.reset(); health_check_client_->call_state_.reset();
if (retry) { if (retry) {
GPR_ASSERT(!health_check_client_->shutting_down_); GPR_ASSERT(!health_check_client_->shutting_down_);
if (static_cast<bool>(gpr_atm_acq_load(&seen_response_))) { if (seen_response_.Load(MemoryOrder::ACQUIRE)) {
// If the call fails after we've gotten a successful response, reset // If the call fails after we've gotten a successful response, reset
// the backoff and restart the call immediately. // the backoff and restart the call immediately.
health_check_client_->retry_backoff_.Reset(); health_check_client_->retry_backoff_.Reset();

@ -22,13 +22,13 @@
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/atm.h>
#include <grpc/support/sync.h> #include <grpc/support/sync.h>
#include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/client_channel_channelz.h"
#include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/ext/filters/client_channel/subchannel.h"
#include "src/core/lib/backoff/backoff.h" #include "src/core/lib/backoff/backoff.h"
#include "src/core/lib/gpr/arena.h" #include "src/core/lib/gpr/arena.h"
#include "src/core/lib/gprpp/atomic.h"
#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/iomgr/call_combiner.h" #include "src/core/lib/iomgr/call_combiner.h"
@ -91,6 +91,8 @@ class HealthCheckClient : public InternallyRefCounted<HealthCheckClient> {
grpc_error* PullSliceFromRecvMessage(); grpc_error* PullSliceFromRecvMessage();
void DoneReadingRecvMessage(grpc_error* error); void DoneReadingRecvMessage(grpc_error* error);
static void AfterCallStackDestruction(void* arg, grpc_error* error);
RefCountedPtr<HealthCheckClient> health_check_client_; RefCountedPtr<HealthCheckClient> health_check_client_;
grpc_polling_entity pollent_; grpc_polling_entity pollent_;
@ -126,12 +128,18 @@ class HealthCheckClient : public InternallyRefCounted<HealthCheckClient> {
OrphanablePtr<ByteStream> recv_message_; OrphanablePtr<ByteStream> recv_message_;
grpc_closure recv_message_ready_; grpc_closure recv_message_ready_;
grpc_slice_buffer recv_message_buffer_; grpc_slice_buffer recv_message_buffer_;
gpr_atm seen_response_; Atomic<bool> seen_response_{false};
// recv_trailing_metadata // recv_trailing_metadata
grpc_metadata_batch recv_trailing_metadata_; grpc_metadata_batch recv_trailing_metadata_;
grpc_transport_stream_stats collect_stats_; grpc_transport_stream_stats collect_stats_;
grpc_closure recv_trailing_metadata_ready_; grpc_closure recv_trailing_metadata_ready_;
// True if the cancel_stream batch has been started.
Atomic<bool> cancelled_{false};
// Closure for call stack destruction.
grpc_closure after_call_stack_destruction_;
}; };
void StartCall(); void StartCall();

@ -558,7 +558,7 @@ GrpcLb::PickResult GrpcLb::Picker::Pick(PickArgs* pick, grpc_error** error) {
// subchannel call (and therefore no client_load_reporting filter) // subchannel call (and therefore no client_load_reporting filter)
// for dropped calls. // for dropped calls.
if (client_stats_ != nullptr) { if (client_stats_ != nullptr) {
client_stats_->AddCallDroppedLocked(drop_token); client_stats_->AddCallDropped(drop_token);
} }
return PICK_COMPLETE; return PICK_COMPLETE;
} }
@ -917,7 +917,7 @@ void GrpcLb::BalancerCallState::SendClientLoadReportLocked() {
// Construct message payload. // Construct message payload.
GPR_ASSERT(send_message_payload_ == nullptr); GPR_ASSERT(send_message_payload_ == nullptr);
grpc_grpclb_request* request = grpc_grpclb_request* request =
grpc_grpclb_load_report_request_create_locked(client_stats_.get()); grpc_grpclb_load_report_request_create(client_stats_.get());
// Skip client load report if the counters were all zero in the last // Skip client load report if the counters were all zero in the last
// report and they are still zero in this one. // report and they are still zero in this one.
if (LoadReportCountersAreZero(request)) { if (LoadReportCountersAreZero(request)) {

@ -25,6 +25,8 @@
#include <grpc/support/atm.h> #include <grpc/support/atm.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include "src/core/lib/gprpp/mutex_lock.h"
namespace grpc_core { namespace grpc_core {
void GrpcLbClientStats::AddCallStarted() { void GrpcLbClientStats::AddCallStarted() {
@ -43,11 +45,12 @@ void GrpcLbClientStats::AddCallFinished(
} }
} }
void GrpcLbClientStats::AddCallDroppedLocked(const char* token) { void GrpcLbClientStats::AddCallDropped(const char* token) {
// Increment num_calls_started and num_calls_finished. // Increment num_calls_started and num_calls_finished.
gpr_atm_full_fetch_add(&num_calls_started_, (gpr_atm)1); gpr_atm_full_fetch_add(&num_calls_started_, (gpr_atm)1);
gpr_atm_full_fetch_add(&num_calls_finished_, (gpr_atm)1); gpr_atm_full_fetch_add(&num_calls_finished_, (gpr_atm)1);
// Record the drop. // Record the drop.
MutexLock lock(&drop_count_mu_);
if (drop_token_counts_ == nullptr) { if (drop_token_counts_ == nullptr) {
drop_token_counts_.reset(New<DroppedCallCounts>()); drop_token_counts_.reset(New<DroppedCallCounts>());
} }
@ -69,7 +72,7 @@ void AtomicGetAndResetCounter(int64_t* value, gpr_atm* counter) {
} // namespace } // namespace
void GrpcLbClientStats::GetLocked( void GrpcLbClientStats::Get(
int64_t* num_calls_started, int64_t* num_calls_finished, int64_t* num_calls_started, int64_t* num_calls_finished,
int64_t* num_calls_finished_with_client_failed_to_send, int64_t* num_calls_finished_with_client_failed_to_send,
int64_t* num_calls_finished_known_received, int64_t* num_calls_finished_known_received,
@ -80,6 +83,7 @@ void GrpcLbClientStats::GetLocked(
&num_calls_finished_with_client_failed_to_send_); &num_calls_finished_with_client_failed_to_send_);
AtomicGetAndResetCounter(num_calls_finished_known_received, AtomicGetAndResetCounter(num_calls_finished_known_received,
&num_calls_finished_known_received_); &num_calls_finished_known_received_);
MutexLock lock(&drop_count_mu_);
*drop_token_counts = std::move(drop_token_counts_); *drop_token_counts = std::move(drop_token_counts_);
} }

@ -41,20 +41,19 @@ class GrpcLbClientStats : public RefCounted<GrpcLbClientStats> {
typedef InlinedVector<DropTokenCount, 10> DroppedCallCounts; typedef InlinedVector<DropTokenCount, 10> DroppedCallCounts;
GrpcLbClientStats() {} GrpcLbClientStats() { gpr_mu_init(&drop_count_mu_); }
~GrpcLbClientStats() { gpr_mu_destroy(&drop_count_mu_); }
void AddCallStarted(); void AddCallStarted();
void AddCallFinished(bool finished_with_client_failed_to_send, void AddCallFinished(bool finished_with_client_failed_to_send,
bool finished_known_received); bool finished_known_received);
// This method is not thread-safe; caller must synchronize. void AddCallDropped(const char* token);
void AddCallDroppedLocked(const char* token);
// This method is not thread-safe; caller must synchronize. void Get(int64_t* num_calls_started, int64_t* num_calls_finished,
void GetLocked(int64_t* num_calls_started, int64_t* num_calls_finished, int64_t* num_calls_finished_with_client_failed_to_send,
int64_t* num_calls_finished_with_client_failed_to_send, int64_t* num_calls_finished_known_received,
int64_t* num_calls_finished_known_received, UniquePtr<DroppedCallCounts>* drop_token_counts);
UniquePtr<DroppedCallCounts>* drop_token_counts);
// A destruction function to use as the user_data key when attaching // A destruction function to use as the user_data key when attaching
// client stats to a grpc_mdelem. // client stats to a grpc_mdelem.
@ -63,13 +62,12 @@ class GrpcLbClientStats : public RefCounted<GrpcLbClientStats> {
} }
private: private:
// This field must only be accessed via *_locked() methods.
UniquePtr<DroppedCallCounts> drop_token_counts_;
// These fields may be accessed from multiple threads at a time.
gpr_atm num_calls_started_ = 0; gpr_atm num_calls_started_ = 0;
gpr_atm num_calls_finished_ = 0; gpr_atm num_calls_finished_ = 0;
gpr_atm num_calls_finished_with_client_failed_to_send_ = 0; gpr_atm num_calls_finished_with_client_failed_to_send_ = 0;
gpr_atm num_calls_finished_known_received_ = 0; gpr_atm num_calls_finished_known_received_ = 0;
gpr_mu drop_count_mu_; // Guards drop_token_counts_.
UniquePtr<DroppedCallCounts> drop_token_counts_;
}; };
} // namespace grpc_core } // namespace grpc_core

@ -107,7 +107,7 @@ static bool encode_drops(pb_ostream_t* stream, const pb_field_t* field,
return true; return true;
} }
grpc_grpclb_request* grpc_grpclb_load_report_request_create_locked( grpc_grpclb_request* grpc_grpclb_load_report_request_create(
grpc_core::GrpcLbClientStats* client_stats) { grpc_core::GrpcLbClientStats* client_stats) {
grpc_grpclb_request* req = static_cast<grpc_grpclb_request*>( grpc_grpclb_request* req = static_cast<grpc_grpclb_request*>(
gpr_zalloc(sizeof(grpc_grpclb_request))); gpr_zalloc(sizeof(grpc_grpclb_request)));
@ -122,7 +122,7 @@ grpc_grpclb_request* grpc_grpclb_load_report_request_create_locked(
req->client_stats.calls_finished_with_drop.funcs.encode = encode_drops; req->client_stats.calls_finished_with_drop.funcs.encode = encode_drops;
grpc_core::UniquePtr<grpc_core::GrpcLbClientStats::DroppedCallCounts> grpc_core::UniquePtr<grpc_core::GrpcLbClientStats::DroppedCallCounts>
drop_counts; drop_counts;
client_stats->GetLocked( client_stats->Get(
&req->client_stats.num_calls_started, &req->client_stats.num_calls_started,
&req->client_stats.num_calls_finished, &req->client_stats.num_calls_finished,
&req->client_stats.num_calls_finished_with_client_failed_to_send, &req->client_stats.num_calls_finished_with_client_failed_to_send,

@ -43,7 +43,7 @@ typedef struct {
/** Create a request for a gRPC LB service under \a lb_service_name */ /** Create a request for a gRPC LB service under \a lb_service_name */
grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name); grpc_grpclb_request* grpc_grpclb_request_create(const char* lb_service_name);
grpc_grpclb_request* grpc_grpclb_load_report_request_create_locked( grpc_grpclb_request* grpc_grpclb_load_report_request_create(
grpc_core::GrpcLbClientStats* client_stats); grpc_core::GrpcLbClientStats* client_stats);
/** Protocol Buffers v3-encode \a request */ /** Protocol Buffers v3-encode \a request */

@ -186,10 +186,17 @@ void PickFirst::ShutdownLocked() {
} }
void PickFirst::ExitIdleLocked() { void PickFirst::ExitIdleLocked() {
if (shutdown_) return;
if (idle_) { if (idle_) {
idle_ = false; idle_ = false;
if (subchannel_list_ != nullptr && if (subchannel_list_ == nullptr ||
subchannel_list_->num_subchannels() > 0) { subchannel_list_->num_subchannels() == 0) {
grpc_error* error =
GRPC_ERROR_CREATE_FROM_STATIC_STRING("No addresses to connect to");
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error),
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error)));
} else {
subchannel_list_->subchannel(0) subchannel_list_->subchannel(0)
->CheckConnectivityStateAndStartWatchingLocked(); ->CheckConnectivityStateAndStartWatchingLocked();
} }
@ -253,13 +260,19 @@ void PickFirst::UpdateLocked(UpdateArgs args) {
grpc_channel_args_destroy(new_args); grpc_channel_args_destroy(new_args);
if (subchannel_list->num_subchannels() == 0) { if (subchannel_list->num_subchannels() == 0) {
// Empty update or no valid subchannels. Unsubscribe from all current // Empty update or no valid subchannels. Unsubscribe from all current
// subchannels and put the channel in TRANSIENT_FAILURE. // subchannels.
subchannel_list_ = std::move(subchannel_list); // Empty list. subchannel_list_ = std::move(subchannel_list); // Empty list.
selected_ = nullptr; selected_ = nullptr;
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"); // If not idle, put the channel in TRANSIENT_FAILURE.
channel_control_helper()->UpdateState( // (If we are idle, then this will happen in ExitIdleLocked() if we
GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error), // haven't gotten a non-empty update by the time the application tries
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error))); // to start a new call.)
if (!idle_) {
grpc_error* error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update");
channel_control_helper()->UpdateState(
GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error),
UniquePtr<SubchannelPicker>(New<TransientFailurePicker>(error)));
}
return; return;
} }
// If one of the subchannels in the new list is already in state // If one of the subchannels in the new list is already in state

@ -68,7 +68,9 @@
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "include/grpc/support/alloc.h"
#include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/client_channel/lb_policy.h"
#include "src/core/ext/filters/client_channel/lb_policy/xds/xds.h" #include "src/core/ext/filters/client_channel/lb_policy/xds/xds.h"
#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h" #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h"
#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h" #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h"
@ -85,6 +87,7 @@
#include "src/core/lib/gpr/host_port.h" #include "src/core/lib/gpr/host_port.h"
#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/manual_constructor.h"
#include "src/core/lib/gprpp/map.h"
#include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/mutex_lock.h" #include "src/core/lib/gprpp/mutex_lock.h"
#include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/orphanable.h"
@ -114,6 +117,7 @@ TraceFlag grpc_lb_xds_trace(false, "xds");
namespace { namespace {
constexpr char kXds[] = "xds_experimental"; constexpr char kXds[] = "xds_experimental";
constexpr char kDefaultLocalityName[] = "xds_default_locality";
class XdsLb : public LoadBalancingPolicy { class XdsLb : public LoadBalancingPolicy {
public: public:
@ -128,6 +132,9 @@ class XdsLb : public LoadBalancingPolicy {
channelz::ChildRefsList* child_channels) override; channelz::ChildRefsList* child_channels) override;
private: private:
struct LocalityServerlistEntry;
using LocalityList = InlinedVector<UniquePtr<LocalityServerlistEntry>, 1>;
/// Contains a channel to the LB server and all the data related to the /// Contains a channel to the LB server and all the data related to the
/// channel. /// channel.
class BalancerChannelState class BalancerChannelState
@ -266,25 +273,88 @@ class XdsLb : public LoadBalancingPolicy {
RefCountedPtr<XdsLbClientStats> client_stats_; RefCountedPtr<XdsLbClientStats> client_stats_;
}; };
class Helper : public ChannelControlHelper { class LocalityMap {
public: public:
explicit Helper(RefCountedPtr<XdsLb> parent) : parent_(std::move(parent)) {} class LocalityEntry : public InternallyRefCounted<LocalityEntry> {
public:
explicit LocalityEntry(RefCountedPtr<XdsLb> parent)
: parent_(std::move(parent)) {
gpr_mu_init(&child_policy_mu_);
}
~LocalityEntry() { gpr_mu_destroy(&child_policy_mu_); }
void UpdateLocked(xds_grpclb_serverlist* serverlist,
LoadBalancingPolicy::Config* child_policy_config,
const grpc_channel_args* args);
void ShutdownLocked();
void ResetBackoffLocked();
void FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels,
channelz::ChildRefsList* child_channels);
void Orphan() override;
private:
class Helper : public ChannelControlHelper {
public:
explicit Helper(RefCountedPtr<LocalityEntry> entry)
: entry_(std::move(entry)) {}
Subchannel* CreateSubchannel(const grpc_channel_args& args) override;
grpc_channel* CreateChannel(const char* target,
const grpc_channel_args& args) override;
void UpdateState(grpc_connectivity_state state, grpc_error* state_error,
UniquePtr<SubchannelPicker> picker) override;
void RequestReresolution() override;
void set_child(LoadBalancingPolicy* child) { child_ = child; }
private:
bool CalledByPendingChild() const;
bool CalledByCurrentChild() const;
RefCountedPtr<LocalityEntry> entry_;
LoadBalancingPolicy* child_ = nullptr;
};
// Methods for dealing with the child policy.
OrphanablePtr<LoadBalancingPolicy> CreateChildPolicyLocked(
const char* name, const grpc_channel_args* args);
grpc_channel_args* CreateChildPolicyArgsLocked(
const grpc_channel_args* args);
OrphanablePtr<LoadBalancingPolicy> child_policy_;
OrphanablePtr<LoadBalancingPolicy> pending_child_policy_;
// Lock held when modifying the value of child_policy_ or
// pending_child_policy_.
gpr_mu child_policy_mu_;
RefCountedPtr<XdsLb> parent_;
};
Subchannel* CreateSubchannel(const grpc_channel_args& args) override; LocalityMap() { gpr_mu_init(&child_refs_mu_); }
grpc_channel* CreateChannel(const char* target, ~LocalityMap() { gpr_mu_destroy(&child_refs_mu_); }
const grpc_channel_args& args) override;
void UpdateState(grpc_connectivity_state state, grpc_error* state_error,
UniquePtr<SubchannelPicker> picker) override;
void RequestReresolution() override;
void set_child(LoadBalancingPolicy* child) { child_ = child; } void UpdateLocked(const LocalityList& locality_list,
LoadBalancingPolicy::Config* child_policy_config,
const grpc_channel_args* args, XdsLb* parent);
void ShutdownLocked();
void ResetBackoffLocked();
void FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels,
channelz::ChildRefsList* child_channels);
private: private:
bool CalledByPendingChild() const; void PruneLocalities(const LocalityList& locality_list);
bool CalledByCurrentChild() const; Map<UniquePtr<char>, OrphanablePtr<LocalityEntry>, StringLess> map_;
// Lock held while filling child refs for all localities
// inside the map
gpr_mu child_refs_mu_;
};
RefCountedPtr<XdsLb> parent_; struct LocalityServerlistEntry {
LoadBalancingPolicy* child_ = nullptr; ~LocalityServerlistEntry() {
gpr_free(locality_name);
xds_grpclb_destroy_serverlist(serverlist);
}
char* locality_name;
// The deserialized response from the balancer. May be nullptr until one
// such response has arrived.
xds_grpclb_serverlist* serverlist;
}; };
~XdsLb(); ~XdsLb();
@ -309,12 +379,6 @@ class XdsLb : public LoadBalancingPolicy {
// Callback to enter fallback mode. // Callback to enter fallback mode.
static void OnFallbackTimerLocked(void* arg, grpc_error* error); static void OnFallbackTimerLocked(void* arg, grpc_error* error);
// Methods for dealing with the child policy.
void CreateOrUpdateChildPolicyLocked();
grpc_channel_args* CreateChildPolicyArgsLocked();
OrphanablePtr<LoadBalancingPolicy> CreateChildPolicyLocked(
const char* name, const grpc_channel_args* args);
// Who the client is trying to communicate with. // Who the client is trying to communicate with.
const char* server_name_ = nullptr; const char* server_name_ = nullptr;
@ -338,10 +402,6 @@ class XdsLb : public LoadBalancingPolicy {
// Timeout in milliseconds for the LB call. 0 means no deadline. // Timeout in milliseconds for the LB call. 0 means no deadline.
int lb_call_timeout_ms_ = 0; int lb_call_timeout_ms_ = 0;
// The deserialized response from the balancer. May be nullptr until one
// such response has arrived.
xds_grpclb_serverlist* serverlist_ = nullptr;
// Timeout in milliseconds for before using fallback backend addresses. // Timeout in milliseconds for before using fallback backend addresses.
// 0 means not using fallback. // 0 means not using fallback.
RefCountedPtr<Config> fallback_policy_config_; RefCountedPtr<Config> fallback_policy_config_;
@ -355,11 +415,12 @@ class XdsLb : public LoadBalancingPolicy {
// The policy to use for the backends. // The policy to use for the backends.
RefCountedPtr<Config> child_policy_config_; RefCountedPtr<Config> child_policy_config_;
OrphanablePtr<LoadBalancingPolicy> child_policy_; // Map of policies to use in the backend
OrphanablePtr<LoadBalancingPolicy> pending_child_policy_; LocalityMap locality_map_;
// Lock held when modifying the value of child_policy_ or LocalityList locality_serverlist_;
// pending_child_policy_. // TODO(mhaidry) : Add a pending locality map that may be swapped with the
gpr_mu child_policy_mu_; // the current one when new localities in the pending map are ready
// to accept connections
}; };
// //
@ -378,105 +439,6 @@ XdsLb::PickResult XdsLb::Picker::Pick(PickArgs* pick, grpc_error** error) {
return result; return result;
} }
//
// XdsLb::Helper
//
bool XdsLb::Helper::CalledByPendingChild() const {
GPR_ASSERT(child_ != nullptr);
return child_ == parent_->pending_child_policy_.get();
}
bool XdsLb::Helper::CalledByCurrentChild() const {
GPR_ASSERT(child_ != nullptr);
return child_ == parent_->child_policy_.get();
}
Subchannel* XdsLb::Helper::CreateSubchannel(const grpc_channel_args& args) {
if (parent_->shutting_down_ ||
(!CalledByPendingChild() && !CalledByCurrentChild())) {
return nullptr;
}
return parent_->channel_control_helper()->CreateSubchannel(args);
}
grpc_channel* XdsLb::Helper::CreateChannel(const char* target,
const grpc_channel_args& args) {
if (parent_->shutting_down_ ||
(!CalledByPendingChild() && !CalledByCurrentChild())) {
return nullptr;
}
return parent_->channel_control_helper()->CreateChannel(target, args);
}
void XdsLb::Helper::UpdateState(grpc_connectivity_state state,
grpc_error* state_error,
UniquePtr<SubchannelPicker> picker) {
if (parent_->shutting_down_) {
GRPC_ERROR_UNREF(state_error);
return;
}
// If this request is from the pending child policy, ignore it until
// it reports READY, at which point we swap it into place.
if (CalledByPendingChild()) {
if (grpc_lb_xds_trace.enabled()) {
gpr_log(GPR_INFO,
"[xdslb %p helper %p] pending child policy %p reports state=%s",
parent_.get(), this, parent_->pending_child_policy_.get(),
grpc_connectivity_state_name(state));
}
if (state != GRPC_CHANNEL_READY) {
GRPC_ERROR_UNREF(state_error);
return;
}
grpc_pollset_set_del_pollset_set(
parent_->child_policy_->interested_parties(),
parent_->interested_parties());
MutexLock lock(&parent_->child_policy_mu_);
parent_->child_policy_ = std::move(parent_->pending_child_policy_);
} else if (!CalledByCurrentChild()) {
// This request is from an outdated child, so ignore it.
GRPC_ERROR_UNREF(state_error);
return;
}
// TODO(juanlishen): When in fallback mode, pass the child picker
// through without wrapping it. (Or maybe use a different helper for
// the fallback policy?)
GPR_ASSERT(parent_->lb_chand_ != nullptr);
RefCountedPtr<XdsLbClientStats> client_stats =
parent_->lb_chand_->lb_calld() == nullptr
? nullptr
: parent_->lb_chand_->lb_calld()->client_stats();
parent_->channel_control_helper()->UpdateState(
state, state_error,
UniquePtr<SubchannelPicker>(
New<Picker>(std::move(picker), std::move(client_stats))));
}
void XdsLb::Helper::RequestReresolution() {
if (parent_->shutting_down_) return;
// If there is a pending child policy, ignore re-resolution requests
// from the current child policy (or any outdated child).
if (parent_->pending_child_policy_ != nullptr && !CalledByPendingChild()) {
return;
}
if (grpc_lb_xds_trace.enabled()) {
gpr_log(GPR_INFO,
"[xdslb %p] Re-resolution requested from the internal RR policy "
"(%p).",
parent_.get(), parent_->child_policy_.get());
}
GPR_ASSERT(parent_->lb_chand_ != nullptr);
// If we are talking to a balancer, we expect to get updated addresses
// from the balancer, so we can ignore the re-resolution request from
// the child policy. Otherwise, pass the re-resolution request up to the
// channel.
if (parent_->lb_chand_->lb_calld() == nullptr ||
!parent_->lb_chand_->lb_calld()->seen_initial_response()) {
parent_->channel_control_helper()->RequestReresolution();
}
}
// //
// serverlist parsing code // serverlist parsing code
// //
@ -951,7 +913,9 @@ void XdsLb::BalancerChannelState::BalancerCallState::
self.release(); self.release();
lb_calld->ScheduleNextClientLoadReportLocked(); lb_calld->ScheduleNextClientLoadReportLocked();
} }
if (xds_grpclb_serverlist_equals(xdslb_policy->serverlist_, serverlist)) { if (!xdslb_policy->locality_serverlist_.empty() &&
xds_grpclb_serverlist_equals(
xdslb_policy->locality_serverlist_[0]->serverlist, serverlist)) {
if (grpc_lb_xds_trace.enabled()) { if (grpc_lb_xds_trace.enabled()) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[xdslb %p] Incoming server list identical to current, " "[xdslb %p] Incoming server list identical to current, "
@ -960,21 +924,31 @@ void XdsLb::BalancerChannelState::BalancerCallState::
} }
xds_grpclb_destroy_serverlist(serverlist); xds_grpclb_destroy_serverlist(serverlist);
} else { /* new serverlist */ } else { /* new serverlist */
if (xdslb_policy->serverlist_ != nullptr) { if (!xdslb_policy->locality_serverlist_.empty()) {
/* dispose of the old serverlist */ /* dispose of the old serverlist */
xds_grpclb_destroy_serverlist(xdslb_policy->serverlist_); xds_grpclb_destroy_serverlist(
xdslb_policy->locality_serverlist_[0]->serverlist);
} else { } else {
/* or dispose of the fallback */ /* or dispose of the fallback */
xdslb_policy->fallback_backend_addresses_.reset(); xdslb_policy->fallback_backend_addresses_.reset();
if (xdslb_policy->fallback_timer_callback_pending_) { if (xdslb_policy->fallback_timer_callback_pending_) {
grpc_timer_cancel(&xdslb_policy->lb_fallback_timer_); grpc_timer_cancel(&xdslb_policy->lb_fallback_timer_);
} }
/* Initialize locality serverlist, currently the list only handles
* one child */
xdslb_policy->locality_serverlist_.emplace_back(
MakeUnique<LocalityServerlistEntry>());
xdslb_policy->locality_serverlist_[0]->locality_name =
static_cast<char*>(gpr_strdup(kDefaultLocalityName));
} }
// and update the copy in the XdsLb instance. This // and update the copy in the XdsLb instance. This
// serverlist instance will be destroyed either upon the next // serverlist instance will be destroyed either upon the next
// update or when the XdsLb instance is destroyed. // update or when the XdsLb instance is destroyed.
xdslb_policy->serverlist_ = serverlist; xdslb_policy->locality_serverlist_[0]->serverlist = serverlist;
xdslb_policy->CreateOrUpdateChildPolicyLocked(); xdslb_policy->locality_map_.UpdateLocked(
xdslb_policy->locality_serverlist_,
xdslb_policy->child_policy_config_.get(), xdslb_policy->args_,
xdslb_policy);
} }
} else { } else {
if (grpc_lb_xds_trace.enabled()) { if (grpc_lb_xds_trace.enabled()) {
@ -1112,9 +1086,11 @@ grpc_channel_args* BuildBalancerChannelArgs(const grpc_channel_args* args) {
// ctor and dtor // ctor and dtor
// //
XdsLb::XdsLb(Args args) : LoadBalancingPolicy(std::move(args)) { XdsLb::XdsLb(Args args)
: LoadBalancingPolicy(std::move(args)),
locality_map_(),
locality_serverlist_() {
gpr_mu_init(&lb_chand_mu_); gpr_mu_init(&lb_chand_mu_);
gpr_mu_init(&child_policy_mu_);
// Record server name. // Record server name.
const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI); const grpc_arg* arg = grpc_channel_args_find(args.args, GRPC_ARG_SERVER_URI);
const char* server_uri = grpc_channel_arg_get_string(arg); const char* server_uri = grpc_channel_arg_get_string(arg);
@ -1141,10 +1117,7 @@ XdsLb::~XdsLb() {
gpr_mu_destroy(&lb_chand_mu_); gpr_mu_destroy(&lb_chand_mu_);
gpr_free((void*)server_name_); gpr_free((void*)server_name_);
grpc_channel_args_destroy(args_); grpc_channel_args_destroy(args_);
if (serverlist_ != nullptr) { locality_serverlist_.clear();
xds_grpclb_destroy_serverlist(serverlist_);
}
gpr_mu_destroy(&child_policy_mu_);
} }
void XdsLb::ShutdownLocked() { void XdsLb::ShutdownLocked() {
@ -1152,19 +1125,7 @@ void XdsLb::ShutdownLocked() {
if (fallback_timer_callback_pending_) { if (fallback_timer_callback_pending_) {
grpc_timer_cancel(&lb_fallback_timer_); grpc_timer_cancel(&lb_fallback_timer_);
} }
if (child_policy_ != nullptr) { locality_map_.ShutdownLocked();
grpc_pollset_set_del_pollset_set(child_policy_->interested_parties(),
interested_parties());
}
if (pending_child_policy_ != nullptr) {
grpc_pollset_set_del_pollset_set(
pending_child_policy_->interested_parties(), interested_parties());
}
{
MutexLock lock(&child_policy_mu_);
child_policy_.reset();
pending_child_policy_.reset();
}
// We destroy the LB channel here instead of in our destructor because // We destroy the LB channel here instead of in our destructor because
// destroying the channel triggers a last callback to // destroying the channel triggers a last callback to
// OnBalancerChannelConnectivityChangedLocked(), and we need to be // OnBalancerChannelConnectivityChangedLocked(), and we need to be
@ -1187,30 +1148,13 @@ void XdsLb::ResetBackoffLocked() {
if (pending_lb_chand_ != nullptr) { if (pending_lb_chand_ != nullptr) {
grpc_channel_reset_connect_backoff(pending_lb_chand_->channel()); grpc_channel_reset_connect_backoff(pending_lb_chand_->channel());
} }
if (child_policy_ != nullptr) { locality_map_.ResetBackoffLocked();
child_policy_->ResetBackoffLocked();
}
if (pending_child_policy_ != nullptr) {
pending_child_policy_->ResetBackoffLocked();
}
} }
void XdsLb::FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels, void XdsLb::FillChildRefsForChannelz(channelz::ChildRefsList* child_subchannels,
channelz::ChildRefsList* child_channels) { channelz::ChildRefsList* child_channels) {
{ // Delegate to the child_policy_ to fill the children subchannels.
// Delegate to the child_policy_ to fill the children subchannels. locality_map_.FillChildRefsForChannelz(child_subchannels, child_channels);
// This must be done holding child_policy_mu_, since this method does not
// run in the combiner.
MutexLock lock(&child_policy_mu_);
if (child_policy_ != nullptr) {
child_policy_->FillChildRefsForChannelz(child_subchannels,
child_channels);
}
if (pending_child_policy_ != nullptr) {
pending_child_policy_->FillChildRefsForChannelz(child_subchannels,
child_channels);
}
}
MutexLock lock(&lb_chand_mu_); MutexLock lock(&lb_chand_mu_);
if (lb_chand_ != nullptr) { if (lb_chand_ != nullptr) {
grpc_core::channelz::ChannelNode* channel_node = grpc_core::channelz::ChannelNode* channel_node =
@ -1314,10 +1258,11 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
// have been created from a serverlist. // have been created from a serverlist.
// TODO(vpowar): Handle the fallback_address changes when we add support for // TODO(vpowar): Handle the fallback_address changes when we add support for
// fallback in xDS. // fallback in xDS.
if (child_policy_ != nullptr) CreateOrUpdateChildPolicyLocked(); locality_map_.UpdateLocked(locality_serverlist_, child_policy_config_.get(),
args_, this);
// If this is the initial update, start the fallback timer. // If this is the initial update, start the fallback timer.
if (is_initial_update) { if (is_initial_update) {
if (lb_fallback_timeout_ms_ > 0 && serverlist_ == nullptr && if (lb_fallback_timeout_ms_ > 0 && locality_serverlist_.empty() &&
!fallback_timer_callback_pending_) { !fallback_timer_callback_pending_) {
grpc_millis deadline = ExecCtx::Get()->Now() + lb_fallback_timeout_ms_; grpc_millis deadline = ExecCtx::Get()->Now() + lb_fallback_timeout_ms_;
Ref(DEBUG_LOCATION, "on_fallback_timer").release(); // Held by closure Ref(DEBUG_LOCATION, "on_fallback_timer").release(); // Held by closure
@ -1341,8 +1286,8 @@ void XdsLb::OnFallbackTimerLocked(void* arg, grpc_error* error) {
xdslb_policy->fallback_timer_callback_pending_ = false; xdslb_policy->fallback_timer_callback_pending_ = false;
// If we receive a serverlist after the timer fires but before this callback // If we receive a serverlist after the timer fires but before this callback
// actually runs, don't fall back. // actually runs, don't fall back.
if (xdslb_policy->serverlist_ == nullptr && !xdslb_policy->shutting_down_ && if (xdslb_policy->locality_serverlist_.empty() &&
error == GRPC_ERROR_NONE) { !xdslb_policy->shutting_down_ && error == GRPC_ERROR_NONE) {
if (grpc_lb_xds_trace.enabled()) { if (grpc_lb_xds_trace.enabled()) {
gpr_log(GPR_INFO, gpr_log(GPR_INFO,
"[xdslb %p] Fallback timer fired. Not using fallback backends", "[xdslb %p] Fallback timer fired. Not using fallback backends",
@ -1352,11 +1297,70 @@ void XdsLb::OnFallbackTimerLocked(void* arg, grpc_error* error) {
xdslb_policy->Unref(DEBUG_LOCATION, "on_fallback_timer"); xdslb_policy->Unref(DEBUG_LOCATION, "on_fallback_timer");
} }
// void XdsLb::LocalityMap::PruneLocalities(const LocalityList& locality_list) {
// code for interacting with the child policy for (auto iter = map_.begin(); iter != map_.end();) {
// bool found = false;
for (size_t i = 0; i < locality_list.size(); i++) {
if (!gpr_stricmp(locality_list[i]->locality_name, iter->first.get())) {
found = true;
}
}
if (!found) { // Remove entries not present in the locality list
MutexLock lock(&child_refs_mu_);
iter = map_.erase(iter);
} else
iter++;
}
}
void XdsLb::LocalityMap::UpdateLocked(
const LocalityList& locality_serverlist,
LoadBalancingPolicy::Config* child_policy_config,
const grpc_channel_args* args, XdsLb* parent) {
if (parent->shutting_down_) return;
for (size_t i = 0; i < locality_serverlist.size(); i++) {
UniquePtr<char> locality_name(
gpr_strdup(locality_serverlist[i]->locality_name));
auto iter = map_.find(locality_name);
if (iter == map_.end()) {
OrphanablePtr<LocalityEntry> new_entry =
MakeOrphanable<LocalityEntry>(parent->Ref());
MutexLock lock(&child_refs_mu_);
iter = map_.emplace(std::move(locality_name), std::move(new_entry)).first;
}
// Don't create new child policies if not directed to
xds_grpclb_serverlist* serverlist =
parent->locality_serverlist_[i]->serverlist;
iter->second->UpdateLocked(serverlist, child_policy_config, args);
}
PruneLocalities(locality_serverlist);
}
void grpc_core::XdsLb::LocalityMap::ShutdownLocked() {
MutexLock lock(&child_refs_mu_);
map_.clear();
}
void grpc_core::XdsLb::LocalityMap::ResetBackoffLocked() {
for (auto iter = map_.begin(); iter != map_.end(); iter++) {
iter->second->ResetBackoffLocked();
}
}
void grpc_core::XdsLb::LocalityMap::FillChildRefsForChannelz(
channelz::ChildRefsList* child_subchannels,
channelz::ChildRefsList* child_channels) {
MutexLock lock(&child_refs_mu_);
for (auto iter = map_.begin(); iter != map_.end(); iter++) {
iter->second->FillChildRefsForChannelz(child_subchannels, child_channels);
}
}
grpc_channel_args* XdsLb::CreateChildPolicyArgsLocked() { // Locality Entry child policy methods
grpc_channel_args*
XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyArgsLocked(
const grpc_channel_args* args_in) {
const grpc_arg args_to_add[] = { const grpc_arg args_to_add[] = {
// A channel arg indicating if the target is a backend inferred from a // A channel arg indicating if the target is a backend inferred from a
// grpclb load balancer. // grpclb load balancer.
@ -1368,15 +1372,16 @@ grpc_channel_args* XdsLb::CreateChildPolicyArgsLocked() {
grpc_channel_arg_integer_create( grpc_channel_arg_integer_create(
const_cast<char*>(GRPC_ARG_INHIBIT_HEALTH_CHECKING), 1), const_cast<char*>(GRPC_ARG_INHIBIT_HEALTH_CHECKING), 1),
}; };
return grpc_channel_args_copy_and_add(args_, args_to_add, return grpc_channel_args_copy_and_add(args_in, args_to_add,
GPR_ARRAY_SIZE(args_to_add)); GPR_ARRAY_SIZE(args_to_add));
} }
OrphanablePtr<LoadBalancingPolicy> XdsLb::CreateChildPolicyLocked( OrphanablePtr<LoadBalancingPolicy>
XdsLb::LocalityMap::LocalityEntry::CreateChildPolicyLocked(
const char* name, const grpc_channel_args* args) { const char* name, const grpc_channel_args* args) {
Helper* helper = New<Helper>(Ref()); Helper* helper = New<Helper>(this->Ref());
LoadBalancingPolicy::Args lb_policy_args; LoadBalancingPolicy::Args lb_policy_args;
lb_policy_args.combiner = combiner(); lb_policy_args.combiner = parent_->combiner();
lb_policy_args.args = args; lb_policy_args.args = args;
lb_policy_args.channel_control_helper = lb_policy_args.channel_control_helper =
UniquePtr<ChannelControlHelper>(helper); UniquePtr<ChannelControlHelper>(helper);
@ -1397,22 +1402,27 @@ OrphanablePtr<LoadBalancingPolicy> XdsLb::CreateChildPolicyLocked(
// child policy. This will make the child policy progress upon activity on xDS // child policy. This will make the child policy progress upon activity on xDS
// LB, which in turn is tied to the application's call. // LB, which in turn is tied to the application's call.
grpc_pollset_set_add_pollset_set(lb_policy->interested_parties(), grpc_pollset_set_add_pollset_set(lb_policy->interested_parties(),
interested_parties()); parent_->interested_parties());
return lb_policy; return lb_policy;
} }
void XdsLb::CreateOrUpdateChildPolicyLocked() { void XdsLb::LocalityMap::LocalityEntry::UpdateLocked(
if (shutting_down_) return; xds_grpclb_serverlist* serverlist,
LoadBalancingPolicy::Config* child_policy_config,
const grpc_channel_args* args_in) {
if (parent_->shutting_down_) return;
// This should never be invoked if we do not have serverlist_, as fallback // This should never be invoked if we do not have serverlist_, as fallback
// mode is disabled for xDS plugin. // mode is disabled for xDS plugin.
// TODO(juanlishen): Change this as part of implementing fallback mode. // TODO(juanlishen): Change this as part of implementing fallback mode.
GPR_ASSERT(serverlist_ != nullptr); GPR_ASSERT(serverlist != nullptr);
GPR_ASSERT(serverlist_->num_servers > 0); GPR_ASSERT(serverlist->num_servers > 0);
// Construct update args. // Construct update args.
UpdateArgs update_args; UpdateArgs update_args;
update_args.addresses = ProcessServerlist(serverlist_); update_args.addresses = ProcessServerlist(serverlist);
update_args.config = child_policy_config_; update_args.config =
update_args.args = CreateChildPolicyArgsLocked(); child_policy_config == nullptr ? nullptr : child_policy_config->Ref();
update_args.args = CreateChildPolicyArgsLocked(args_in);
// If the child policy name changes, we need to create a new child // If the child policy name changes, we need to create a new child
// policy. When this happens, we leave child_policy_ as-is and store // policy. When this happens, we leave child_policy_ as-is and store
// the new child policy in pending_child_policy_. Once the new child // the new child policy in pending_child_policy_. Once the new child
@ -1464,9 +1474,9 @@ void XdsLb::CreateOrUpdateChildPolicyLocked() {
// when the new child transitions into state READY. // when the new child transitions into state READY.
// TODO(juanlishen): If the child policy is not configured via service config, // TODO(juanlishen): If the child policy is not configured via service config,
// use whatever algorithm is specified by the balancer. // use whatever algorithm is specified by the balancer.
const char* child_policy_name = child_policy_config_ == nullptr const char* child_policy_name = child_policy_config == nullptr
? "round_robin" ? "round_robin"
: child_policy_config_->name(); : child_policy_config->name();
const bool create_policy = const bool create_policy =
// case 1 // case 1
child_policy_ == nullptr || child_policy_ == nullptr ||
@ -1512,6 +1522,145 @@ void XdsLb::CreateOrUpdateChildPolicyLocked() {
policy_to_update->UpdateLocked(std::move(update_args)); policy_to_update->UpdateLocked(std::move(update_args));
} }
void XdsLb::LocalityMap::LocalityEntry::ShutdownLocked() {
// Remove the child policy's interested_parties pollset_set from the
// xDS policy.
grpc_pollset_set_del_pollset_set(child_policy_->interested_parties(),
parent_->interested_parties());
if (pending_child_policy_ != nullptr) {
grpc_pollset_set_del_pollset_set(
pending_child_policy_->interested_parties(),
parent_->interested_parties());
}
{
MutexLock lock(&child_policy_mu_);
child_policy_.reset();
pending_child_policy_.reset();
}
}
void XdsLb::LocalityMap::LocalityEntry::ResetBackoffLocked() {
child_policy_->ResetBackoffLocked();
if (pending_child_policy_ != nullptr) {
pending_child_policy_->ResetBackoffLocked();
}
}
void XdsLb::LocalityMap::LocalityEntry::FillChildRefsForChannelz(
channelz::ChildRefsList* child_subchannels,
channelz::ChildRefsList* child_channels) {
MutexLock lock(&child_policy_mu_);
child_policy_->FillChildRefsForChannelz(child_subchannels, child_channels);
if (pending_child_policy_ != nullptr) {
pending_child_policy_->FillChildRefsForChannelz(child_subchannels,
child_channels);
}
}
void XdsLb::LocalityMap::LocalityEntry::Orphan() {
ShutdownLocked();
Unref();
}
//
// LocalityEntry::Helper implementation
//
bool XdsLb::LocalityMap::LocalityEntry::Helper::CalledByPendingChild() const {
GPR_ASSERT(child_ != nullptr);
return child_ == entry_->pending_child_policy_.get();
}
bool XdsLb::LocalityMap::LocalityEntry::Helper::CalledByCurrentChild() const {
GPR_ASSERT(child_ != nullptr);
return child_ == entry_->child_policy_.get();
}
Subchannel* XdsLb::LocalityMap::LocalityEntry::Helper::CreateSubchannel(
const grpc_channel_args& args) {
if (entry_->parent_->shutting_down_ ||
(!CalledByPendingChild() && !CalledByCurrentChild())) {
return nullptr;
}
return entry_->parent_->channel_control_helper()->CreateSubchannel(args);
}
grpc_channel* XdsLb::LocalityMap::LocalityEntry::Helper::CreateChannel(
const char* target, const grpc_channel_args& args) {
if (entry_->parent_->shutting_down_ ||
(!CalledByPendingChild() && !CalledByCurrentChild())) {
return nullptr;
}
return entry_->parent_->channel_control_helper()->CreateChannel(target, args);
}
void XdsLb::LocalityMap::LocalityEntry::Helper::UpdateState(
grpc_connectivity_state state, grpc_error* state_error,
UniquePtr<SubchannelPicker> picker) {
if (entry_->parent_->shutting_down_) {
GRPC_ERROR_UNREF(state_error);
return;
}
// If this request is from the pending child policy, ignore it until
// it reports READY, at which point we swap it into place.
if (CalledByPendingChild()) {
if (grpc_lb_xds_trace.enabled()) {
gpr_log(GPR_INFO,
"[xdslb %p helper %p] pending child policy %p reports state=%s",
entry_->parent_.get(), this, entry_->pending_child_policy_.get(),
grpc_connectivity_state_name(state));
}
if (state != GRPC_CHANNEL_READY) {
GRPC_ERROR_UNREF(state_error);
return;
}
grpc_pollset_set_del_pollset_set(
entry_->child_policy_->interested_parties(),
entry_->parent_->interested_parties());
MutexLock lock(&entry_->child_policy_mu_);
entry_->child_policy_ = std::move(entry_->pending_child_policy_);
} else if (!CalledByCurrentChild()) {
// This request is from an outdated child, so ignore it.
GRPC_ERROR_UNREF(state_error);
return;
}
// TODO(juanlishen): When in fallback mode, pass the child picker
// through without wrapping it. (Or maybe use a different helper for
// the fallback policy?)
GPR_ASSERT(entry_->parent_->lb_chand_ != nullptr);
RefCountedPtr<XdsLbClientStats> client_stats =
entry_->parent_->lb_chand_->lb_calld() == nullptr
? nullptr
: entry_->parent_->lb_chand_->lb_calld()->client_stats();
entry_->parent_->channel_control_helper()->UpdateState(
state, state_error,
UniquePtr<SubchannelPicker>(
New<Picker>(std::move(picker), std::move(client_stats))));
}
void XdsLb::LocalityMap::LocalityEntry::Helper::RequestReresolution() {
if (entry_->parent_->shutting_down_) return;
// If there is a pending child policy, ignore re-resolution requests
// from the current child policy (or any outdated child).
if (entry_->pending_child_policy_ != nullptr && !CalledByPendingChild()) {
return;
}
if (grpc_lb_xds_trace.enabled()) {
gpr_log(GPR_INFO,
"[xdslb %p] Re-resolution requested from the internal RR policy "
"(%p).",
entry_->parent_.get(), entry_->child_policy_.get());
}
GPR_ASSERT(entry_->parent_->lb_chand_ != nullptr);
// If we are talking to a balancer, we expect to get updated addresses
// from the balancer, so we can ignore the re-resolution request from
// the child policy. Otherwise, pass the re-resolution request up to the
// channel.
if (entry_->parent_->lb_chand_->lb_calld() == nullptr ||
!entry_->parent_->lb_chand_->lb_calld()->seen_initial_response()) {
entry_->parent_->channel_control_helper()->RequestReresolution();
}
}
// //
// factory // factory
// //

@ -645,17 +645,22 @@ void grpc_chttp2_stream_unref(grpc_chttp2_stream* s) {
} }
#endif #endif
grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t, grpc_chttp2_stream::Reffer::Reffer(grpc_chttp2_stream* s) {
grpc_stream_refcount* refcount,
const void* server_data,
gpr_arena* arena)
: t(t), refcount(refcount), metadata_buffer{{arena}, {arena}} {
/* We reserve one 'active stream' that's dropped when the stream is /* We reserve one 'active stream' that's dropped when the stream is
read-closed. The others are for Chttp2IncomingByteStreams that are read-closed. The others are for Chttp2IncomingByteStreams that are
actively reading */ actively reading */
GRPC_CHTTP2_STREAM_REF(this, "chttp2"); GRPC_CHTTP2_STREAM_REF(s, "chttp2");
GRPC_CHTTP2_REF_TRANSPORT(t, "stream"); GRPC_CHTTP2_REF_TRANSPORT(s->t, "stream");
}
grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t,
grpc_stream_refcount* refcount,
const void* server_data,
gpr_arena* arena)
: t(t),
refcount(refcount),
reffer(this),
metadata_buffer{{arena}, {arena}} {
if (server_data) { if (server_data) {
id = static_cast<uint32_t>((uintptr_t)server_data); id = static_cast<uint32_t>((uintptr_t)server_data);
*t->accepting_stream = this; *t->accepting_stream = this;
@ -2598,6 +2603,9 @@ static void start_bdp_ping_locked(void* tp, grpc_error* error) {
gpr_log(GPR_INFO, "%s: Start BDP ping err=%s", t->peer_string, gpr_log(GPR_INFO, "%s: Start BDP ping err=%s", t->peer_string,
grpc_error_string(error)); grpc_error_string(error));
} }
if (error != GRPC_ERROR_NONE || t->closed_with_error != GRPC_ERROR_NONE) {
return;
}
/* Reset the keepalive ping timer */ /* Reset the keepalive ping timer */
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) { if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING) {
grpc_timer_cancel(&t->keepalive_ping_timer); grpc_timer_cancel(&t->keepalive_ping_timer);
@ -2611,7 +2619,7 @@ static void finish_bdp_ping_locked(void* tp, grpc_error* error) {
gpr_log(GPR_INFO, "%s: Complete BDP ping err=%s", t->peer_string, gpr_log(GPR_INFO, "%s: Complete BDP ping err=%s", t->peer_string,
grpc_error_string(error)); grpc_error_string(error));
} }
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE || t->closed_with_error != GRPC_ERROR_NONE) {
GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping"); GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
return; return;
} }

@ -510,6 +510,12 @@ struct grpc_chttp2_stream {
void* context; void* context;
grpc_chttp2_transport* t; grpc_chttp2_transport* t;
grpc_stream_refcount* refcount; grpc_stream_refcount* refcount;
// Reffer is a 0-len structure, simply reffing `t` and `refcount` in its ctor
// before initializing the rest of the stream, to avoid cache misses. This
// field MUST be right after `t` and `refcount`.
struct Reffer {
explicit Reffer(grpc_chttp2_stream* s);
} reffer;
grpc_closure destroy_stream; grpc_closure destroy_stream;
grpc_closure* destroy_stream_arg; grpc_closure* destroy_stream_arg;

@ -108,6 +108,9 @@ static gpr_timespec now_impl(gpr_clock_type clock) {
now.clock_type = clock; now.clock_type = clock;
switch (clock) { switch (clock) {
case GPR_CLOCK_REALTIME: case GPR_CLOCK_REALTIME:
// gettimeofday(...) function may return with a value whose tv_usec is
// greater than 1e6 on iOS The case is resolved with the guard at end of
// this function.
gettimeofday(&now_tv, nullptr); gettimeofday(&now_tv, nullptr);
now.tv_sec = now_tv.tv_sec; now.tv_sec = now_tv.tv_sec;
now.tv_nsec = now_tv.tv_usec * 1000; now.tv_nsec = now_tv.tv_usec * 1000;
@ -124,6 +127,16 @@ static gpr_timespec now_impl(gpr_clock_type clock) {
abort(); abort();
} }
// Guard the tv_nsec field in valid range for all clock types
while (GPR_UNLIKELY(now.tv_nsec >= 1e9)) {
now.tv_sec++;
now.tv_nsec -= 1e9;
}
while (GPR_UNLIKELY(now.tv_nsec < 0)) {
now.tv_sec--;
now.tv_nsec += 1e9;
}
return now; return now;
} }
#endif #endif

@ -0,0 +1,419 @@
/*
*
* Copyright 2017 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 GRPC_CORE_LIB_GPRPP_MAP_H
#define GRPC_CORE_LIB_GPRPP_MAP_H
#include <grpc/support/port_platform.h>
#include <string.h>
#include <functional>
#include <iterator>
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/pair.h"
namespace grpc_core {
struct StringLess {
bool operator()(const char* a, const char* b) const {
return strcmp(a, b) < 0;
}
bool operator()(const UniquePtr<char>& k1, const UniquePtr<char>& k2) {
return strcmp(k1.get(), k2.get()) < 0;
}
};
namespace testing {
class MapTest;
}
// Alternative map implementation for grpc_core
template <class Key, class T, class Compare = std::less<Key>>
class Map {
public:
typedef Key key_type;
typedef T mapped_type;
typedef Pair<key_type, mapped_type> value_type;
typedef Compare key_compare;
class iterator;
~Map() { clear(); }
T& operator[](key_type&& key);
T& operator[](const key_type& key);
iterator find(const key_type& k);
size_t erase(const key_type& key);
// Removes the current entry and points to the next one
iterator erase(iterator iter);
size_t size() { return size_; }
template <class... Args>
Pair<iterator, bool> emplace(Args&&... args);
Pair<iterator, bool> insert(value_type&& pair) {
return emplace(std::move(pair));
}
Pair<iterator, bool> insert(const value_type& pair) { return emplace(pair); }
bool empty() const { return root_ == nullptr; }
void clear() {
auto iter = begin();
while (!empty()) {
iter = erase(iter);
}
}
iterator begin() {
Entry* curr = GetMinEntry(root_);
return iterator(this, curr);
}
iterator end() { return iterator(this, nullptr); }
private:
friend class testing::MapTest;
struct Entry {
explicit Entry(value_type&& pair) : pair(std::move(pair)) {}
value_type pair;
Entry* left = nullptr;
Entry* right = nullptr;
int32_t height = 1;
};
static int32_t EntryHeight(const Entry* e) {
return e == nullptr ? 0 : e->height;
}
static Entry* GetMinEntry(Entry* e);
Entry* InOrderSuccessor(const Entry* e) const;
static Entry* RotateLeft(Entry* e);
static Entry* RotateRight(Entry* e);
static Entry* RebalanceTreeAfterInsertion(Entry* root, const key_type& k);
static Entry* RebalanceTreeAfterDeletion(Entry* root);
// Returns a pair with the first value being an iterator pointing to the
// inserted entry and the second value being the new root of the subtree
// after a rebalance
Pair<iterator, Entry*> InsertRecursive(Entry* root, value_type&& p);
static Entry* RemoveRecursive(Entry* root, const key_type& k);
// Return 0 if lhs = rhs
// 1 if lhs > rhs
// -1 if lhs < rhs
static int CompareKeys(const Key& lhs, const Key& rhs);
Entry* root_ = nullptr;
size_t size_ = 0;
};
template <class Key, class T, class Compare>
class Map<Key, T, Compare>::iterator
: public std::iterator<std::input_iterator_tag, Pair<Key, T>, int32_t,
Pair<Key, T>*, Pair<Key, T>&> {
public:
iterator(const iterator& iter) : curr_(iter.curr_), map_(iter.map_) {}
bool operator==(const iterator& rhs) const { return (curr_ == rhs.curr_); }
bool operator!=(const iterator& rhs) const { return (curr_ != rhs.curr_); }
iterator& operator++() {
curr_ = map_->InOrderSuccessor(curr_);
return *this;
}
iterator operator++(int) {
Entry* prev = curr_;
curr_ = map_->InOrderSuccessor(curr_);
return iterator(map_, prev);
}
iterator& operator=(const iterator& other) {
if (this != &other) {
this->curr_ = other.curr_;
this->map_ = other.map_;
}
return *this;
}
// operator*()
value_type& operator*() { return curr_->pair; }
const value_type& operator*() const { return curr_->pair; }
// operator->()
value_type* operator->() { return &curr_->pair; }
value_type const* operator->() const { return &curr_->pair; }
private:
friend class Map<key_type, mapped_type, key_compare>;
using GrpcMap = typename ::grpc_core::Map<Key, T, Compare>;
iterator(GrpcMap* map, Entry* curr) : curr_(curr), map_(map) {}
Entry* curr_;
GrpcMap* map_;
};
template <class Key, class T, class Compare>
T& Map<Key, T, Compare>::operator[](key_type&& key) {
auto iter = find(key);
if (iter == end()) {
return emplace(std::move(key), T()).first->second;
}
return iter->second;
}
template <class Key, class T, class Compare>
T& Map<Key, T, Compare>::operator[](const key_type& key) {
auto iter = find(key);
if (iter == end()) {
return emplace(key, T()).first->second;
}
return iter->second;
}
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::iterator Map<Key, T, Compare>::find(
const key_type& k) {
Entry* iter = root_;
while (iter != nullptr) {
int comp = CompareKeys(iter->pair.first, k);
if (comp == 0) {
return iterator(this, iter);
} else if (comp < 0) {
iter = iter->right;
} else {
iter = iter->left;
}
}
return end();
}
template <class Key, class T, class Compare>
template <class... Args>
typename ::grpc_core::Pair<typename Map<Key, T, Compare>::iterator, bool>
Map<Key, T, Compare>::emplace(Args&&... args) {
Pair<key_type, mapped_type> pair(std::forward<Args>(args)...);
iterator ret = find(pair.first);
bool insertion = false;
if (ret == end()) {
Pair<iterator, Entry*> p = InsertRecursive(root_, std::move(pair));
root_ = p.second;
ret = p.first;
insertion = true;
size_++;
}
return MakePair(ret, insertion);
}
template <class Key, class T, class Compare>
size_t Map<Key, T, Compare>::erase(const key_type& key) {
iterator it = find(key);
if (it == end()) return 0;
erase(it);
return 1;
}
// TODO(mhaidry): Modify erase to use the iterator location
// to create an efficient erase method
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::iterator Map<Key, T, Compare>::erase(
iterator iter) {
if (iter == end()) return iter;
key_type& del_key = iter->first;
iter++;
root_ = RemoveRecursive(root_, del_key);
size_--;
return iter;
}
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::Entry* Map<Key, T, Compare>::InOrderSuccessor(
const Entry* e) const {
if (e->right != nullptr) {
return GetMinEntry(e->right);
}
Entry* successor = nullptr;
Entry* iter = root_;
while (iter != nullptr) {
int comp = CompareKeys(iter->pair.first, e->pair.first);
if (comp > 0) {
successor = iter;
iter = iter->left;
} else if (comp < 0) {
iter = iter->right;
} else
break;
}
return successor;
}
// Returns a pair with the first value being an iterator pointing to the
// inserted entry and the second value being the new root of the subtree
// after a rebalance
template <class Key, class T, class Compare>
typename ::grpc_core::Pair<typename Map<Key, T, Compare>::iterator,
typename Map<Key, T, Compare>::Entry*>
Map<Key, T, Compare>::InsertRecursive(Entry* root, value_type&& p) {
if (root == nullptr) {
Entry* e = New<Entry>(std::move(p));
return MakePair(iterator(this, e), e);
}
int comp = CompareKeys(root->pair.first, p.first);
if (comp > 0) {
Pair<iterator, Entry*> ret = InsertRecursive(root->left, std::move(p));
root->left = ret.second;
ret.second = RebalanceTreeAfterInsertion(root, ret.first->first);
return ret;
} else if (comp < 0) {
Pair<iterator, Entry*> ret = InsertRecursive(root->right, std::move(p));
root->right = ret.second;
ret.second = RebalanceTreeAfterInsertion(root, ret.first->first);
return ret;
} else {
root->pair = std::move(p);
return MakePair(iterator(this, root), root);
}
}
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::Entry* Map<Key, T, Compare>::GetMinEntry(
Entry* e) {
if (e != nullptr) {
while (e->left != nullptr) {
e = e->left;
}
}
return e;
}
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::Entry* Map<Key, T, Compare>::RotateLeft(
Entry* e) {
Entry* rightChild = e->right;
Entry* rightLeftChild = rightChild->left;
rightChild->left = e;
e->right = rightLeftChild;
e->height = 1 + GPR_MAX(EntryHeight(e->left), EntryHeight(e->right));
rightChild->height = 1 + GPR_MAX(EntryHeight(rightChild->left),
EntryHeight(rightChild->right));
return rightChild;
}
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::Entry* Map<Key, T, Compare>::RotateRight(
Entry* e) {
Entry* leftChild = e->left;
Entry* leftRightChild = leftChild->right;
leftChild->right = e;
e->left = leftRightChild;
e->height = 1 + GPR_MAX(EntryHeight(e->left), EntryHeight(e->right));
leftChild->height =
1 + GPR_MAX(EntryHeight(leftChild->left), EntryHeight(leftChild->right));
return leftChild;
}
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::Entry*
Map<Key, T, Compare>::RebalanceTreeAfterInsertion(Entry* root,
const key_type& k) {
root->height = 1 + GPR_MAX(EntryHeight(root->left), EntryHeight(root->right));
int32_t heightDifference = EntryHeight(root->left) - EntryHeight(root->right);
if (heightDifference > 1 && CompareKeys(root->left->pair.first, k) > 0) {
return RotateRight(root);
}
if (heightDifference < -1 && CompareKeys(root->right->pair.first, k) < 0) {
return RotateLeft(root);
}
if (heightDifference > 1 && CompareKeys(root->left->pair.first, k) < 0) {
root->left = RotateLeft(root->left);
return RotateRight(root);
}
if (heightDifference < -1 && CompareKeys(root->right->pair.first, k) > 0) {
root->right = RotateRight(root->right);
return RotateLeft(root);
}
return root;
}
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::Entry*
Map<Key, T, Compare>::RebalanceTreeAfterDeletion(Entry* root) {
root->height = 1 + GPR_MAX(EntryHeight(root->left), EntryHeight(root->right));
int32_t heightDifference = EntryHeight(root->left) - EntryHeight(root->right);
if (heightDifference > 1) {
int leftHeightDifference =
EntryHeight(root->left->left) - EntryHeight(root->left->right);
if (leftHeightDifference < 0) {
root->left = RotateLeft(root->left);
}
return RotateRight(root);
}
if (heightDifference < -1) {
int rightHeightDifference =
EntryHeight(root->right->left) - EntryHeight(root->right->right);
if (rightHeightDifference > 0) {
root->right = RotateRight(root->right);
}
return RotateLeft(root);
}
return root;
}
template <class Key, class T, class Compare>
typename Map<Key, T, Compare>::Entry* Map<Key, T, Compare>::RemoveRecursive(
Entry* root, const key_type& k) {
if (root == nullptr) return root;
int comp = CompareKeys(root->pair.first, k);
if (comp > 0) {
root->left = RemoveRecursive(root->left, k);
} else if (comp < 0) {
root->right = RemoveRecursive(root->right, k);
} else {
Entry* ret;
if (root->left == nullptr) {
ret = root->right;
Delete(root);
return ret;
} else if (root->right == nullptr) {
ret = root->left;
Delete(root);
return ret;
} else {
ret = root->right;
while (ret->left != nullptr) {
ret = ret->left;
}
root->pair.swap(ret->pair);
root->right = RemoveRecursive(root->right, ret->pair.first);
}
}
return RebalanceTreeAfterDeletion(root);
}
template <class Key, class T, class Compare>
int Map<Key, T, Compare>::CompareKeys(const key_type& lhs,
const key_type& rhs) {
key_compare compare;
bool left_comparison = compare(lhs, rhs);
bool right_comparison = compare(rhs, lhs);
// Both values are equal
if (!left_comparison && !right_comparison) {
return 0;
}
return left_comparison ? -1 : 1;
}
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_GPRPP_MAP_H */

@ -0,0 +1,38 @@
/*
*
* Copyright 2017 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 GRPC_CORE_LIB_GPRPP_PAIR_H
#define GRPC_CORE_LIB_GPRPP_PAIR_H
#include <grpc/support/port_platform.h>
#include <utility>
namespace grpc_core {
template <class T1, class T2>
using Pair = std::pair<T1, T2>;
template <class T1, class T2>
inline Pair<typename std::decay<T1>::type, typename std::decay<T2>::type>
MakePair(T1&& u, T2&& v) {
typedef typename std::decay<T1>::type V1;
typedef typename std::decay<T2>::type V2;
return Pair<V1, V2>(std::forward<T1>(u), std::forward<T2>(v));
}
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_GPRPP_PAIR_H */

@ -192,4 +192,11 @@ void CFStreamHandle::Unref(const char* file, int line, const char* reason) {
} }
} }
#else
/* Creating a dummy function so that the grpc_cfstream library will be
* non-empty.
*/
void CFStreamDummy() {}
#endif #endif

@ -172,7 +172,6 @@ static int is_metadata_server_reachable() {
detector.pollent = grpc_polling_entity_create_from_pollset(pollset); detector.pollent = grpc_polling_entity_create_from_pollset(pollset);
detector.is_done = 0; detector.is_done = 0;
detector.success = 0; detector.success = 0;
memset(&detector.response, 0, sizeof(detector.response));
memset(&request, 0, sizeof(grpc_httpcli_request)); memset(&request, 0, sizeof(grpc_httpcli_request));
request.host = (char*)GRPC_COMPUTE_ENGINE_DETECTION_HOST; request.host = (char*)GRPC_COMPUTE_ENGINE_DETECTION_HOST;
request.http.path = (char*)"/"; request.http.path = (char*)"/";

@ -624,9 +624,8 @@ static int verify_jwt_signature(EVP_PKEY* key, const char* alg,
gpr_log(GPR_ERROR, "EVP_DigestVerifyUpdate failed."); gpr_log(GPR_ERROR, "EVP_DigestVerifyUpdate failed.");
goto end; goto end;
} }
if (EVP_DigestVerifyFinal( if (EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(signature),
md_ctx, const_cast<uint8_t*>(GRPC_SLICE_START_PTR(signature)), GRPC_SLICE_LENGTH(signature)) != 1) {
GRPC_SLICE_LENGTH(signature)) != 1) {
gpr_log(GPR_ERROR, "JWT signature verification failed."); gpr_log(GPR_ERROR, "JWT signature verification failed.");
goto end; goto end;
} }

@ -44,24 +44,15 @@ namespace {
grpc_error* ssl_check_peer( grpc_error* ssl_check_peer(
const char* peer_name, const tsi_peer* peer, const char* peer_name, const tsi_peer* peer,
grpc_core::RefCountedPtr<grpc_auth_context>* auth_context) { grpc_core::RefCountedPtr<grpc_auth_context>* auth_context) {
#if TSI_OPENSSL_ALPN_SUPPORT grpc_error* error = grpc_ssl_check_alpn(peer);
/* Check the ALPN if ALPN is supported. */ if (error != GRPC_ERROR_NONE) {
const tsi_peer_property* p = return error;
tsi_peer_get_property_by_name(peer, TSI_SSL_ALPN_SELECTED_PROTOCOL);
if (p == nullptr) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Cannot check peer: missing selected ALPN property.");
}
if (!grpc_chttp2_is_alpn_version_supported(p->value.data, p->value.length)) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Cannot check peer: invalid ALPN value.");
} }
#endif /* TSI_OPENSSL_ALPN_SUPPORT */
/* Check the peer name if specified. */ /* Check the peer name if specified. */
if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) { if (peer_name != nullptr && !grpc_ssl_host_matches_name(peer, peer_name)) {
char* msg; char* msg;
gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name); gpr_asprintf(&msg, "Peer name %s is not in peer certificate", peer_name);
grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg); error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
gpr_free(msg); gpr_free(msg);
return error; return error;
} }

@ -73,6 +73,7 @@ static void do_basic_init(void) {
g_shutting_down = false; g_shutting_down = false;
grpc_register_built_in_plugins(); grpc_register_built_in_plugins();
grpc_cq_global_init(); grpc_cq_global_init();
gpr_time_init();
g_initializations = 0; g_initializations = 0;
} }
@ -132,7 +133,6 @@ void grpc_init(void) {
} }
grpc_core::Fork::GlobalInit(); grpc_core::Fork::GlobalInit();
grpc_fork_handlers_auto_register(); grpc_fork_handlers_auto_register();
gpr_time_init();
gpr_arena_init(); gpr_arena_init();
grpc_stats_init(); grpc_stats_init();
grpc_slice_intern_init(); grpc_slice_intern_init();

@ -25,4 +25,4 @@
const char* grpc_version_string(void) { return "7.0.0"; } const char* grpc_version_string(void) { return "7.0.0"; }
const char* grpc_g_stands_for(void) { return "godric"; } const char* grpc_g_stands_for(void) { return "gandalf"; }

@ -29,6 +29,7 @@
#include "src/core/lib/gpr/alloc.h" #include "src/core/lib/gpr/alloc.h"
#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_internal.h"
@ -243,25 +244,26 @@ void grpc_transport_stream_op_batch_finish_with_failure(
GRPC_ERROR_UNREF(error); GRPC_ERROR_UNREF(error);
} }
typedef struct { struct made_transport_op {
grpc_closure outer_on_complete; grpc_closure outer_on_complete;
grpc_closure* inner_on_complete; grpc_closure* inner_on_complete = nullptr;
grpc_transport_op op; grpc_transport_op op;
} made_transport_op; made_transport_op() {
memset(&outer_on_complete, 0, sizeof(outer_on_complete));
}
};
static void destroy_made_transport_op(void* arg, grpc_error* error) { static void destroy_made_transport_op(void* arg, grpc_error* error) {
made_transport_op* op = static_cast<made_transport_op*>(arg); made_transport_op* op = static_cast<made_transport_op*>(arg);
GRPC_CLOSURE_SCHED(op->inner_on_complete, GRPC_ERROR_REF(error)); GRPC_CLOSURE_SCHED(op->inner_on_complete, GRPC_ERROR_REF(error));
gpr_free(op); grpc_core::Delete<made_transport_op>(op);
} }
grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) { grpc_transport_op* grpc_make_transport_op(grpc_closure* on_complete) {
made_transport_op* op = made_transport_op* op = grpc_core::New<made_transport_op>();
static_cast<made_transport_op*>(gpr_malloc(sizeof(*op)));
GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op, GRPC_CLOSURE_INIT(&op->outer_on_complete, destroy_made_transport_op, op,
grpc_schedule_on_exec_ctx); grpc_schedule_on_exec_ctx);
op->inner_on_complete = on_complete; op->inner_on_complete = on_complete;
memset(&op->op, 0, sizeof(op->op));
op->op.on_consumed = &op->outer_on_complete; op->op.on_consumed = &op->outer_on_complete;
return &op->op; return &op->op;
} }

@ -273,40 +273,40 @@ struct grpc_transport_stream_op_batch_payload {
/** Transport op: a set of operations to perform on a transport as a whole */ /** Transport op: a set of operations to perform on a transport as a whole */
typedef struct grpc_transport_op { typedef struct grpc_transport_op {
/** Called when processing of this op is done. */ /** Called when processing of this op is done. */
grpc_closure* on_consumed; grpc_closure* on_consumed = nullptr;
/** connectivity monitoring - set connectivity_state to NULL to unsubscribe */ /** connectivity monitoring - set connectivity_state to NULL to unsubscribe */
grpc_closure* on_connectivity_state_change; grpc_closure* on_connectivity_state_change = nullptr;
grpc_connectivity_state* connectivity_state; grpc_connectivity_state* connectivity_state = nullptr;
/** should the transport be disconnected /** should the transport be disconnected
* Error contract: the transport that gets this op must cause * Error contract: the transport that gets this op must cause
* disconnect_with_error to be unref'ed after processing it */ * disconnect_with_error to be unref'ed after processing it */
grpc_error* disconnect_with_error; grpc_error* disconnect_with_error = nullptr;
/** what should the goaway contain? /** what should the goaway contain?
* Error contract: the transport that gets this op must cause * Error contract: the transport that gets this op must cause
* goaway_error to be unref'ed after processing it */ * goaway_error to be unref'ed after processing it */
grpc_error* goaway_error; grpc_error* goaway_error = nullptr;
/** set the callback for accepting new streams; /** set the callback for accepting new streams;
this is a permanent callback, unlike the other one-shot closures. this is a permanent callback, unlike the other one-shot closures.
If true, the callback is set to set_accept_stream_fn, with its If true, the callback is set to set_accept_stream_fn, with its
user_data argument set to set_accept_stream_user_data */ user_data argument set to set_accept_stream_user_data */
bool set_accept_stream; bool set_accept_stream = false;
void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport, void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport,
const void* server_data); const void* server_data) = nullptr;
void* set_accept_stream_user_data; void* set_accept_stream_user_data = nullptr;
/** add this transport to a pollset */ /** add this transport to a pollset */
grpc_pollset* bind_pollset; grpc_pollset* bind_pollset = nullptr;
/** add this transport to a pollset_set */ /** add this transport to a pollset_set */
grpc_pollset_set* bind_pollset_set; grpc_pollset_set* bind_pollset_set = nullptr;
/** send a ping, if either on_initiate or on_ack is not NULL */ /** send a ping, if either on_initiate or on_ack is not NULL */
struct { struct {
/** Ping may be delayed by the transport, on_initiate callback will be /** Ping may be delayed by the transport, on_initiate callback will be
called when the ping is actually being sent. */ called when the ping is actually being sent. */
grpc_closure* on_initiate; grpc_closure* on_initiate = nullptr;
/** Called when the ping ack is received */ /** Called when the ping ack is received */
grpc_closure* on_ack; grpc_closure* on_ack = nullptr;
} send_ping; } send_ping;
// If true, will reset the channel's connection backoff. // If true, will reset the channel's connection backoff.
bool reset_connect_backoff; bool reset_connect_backoff = false;
/*************************************************************************** /***************************************************************************
* remaining fields are initialized and used at the discretion of the * remaining fields are initialized and used at the discretion of the

@ -18,8 +18,6 @@
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <chrono>
#include <condition_variable>
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
@ -41,12 +39,7 @@
#include <grpcpp/support/channel_arguments.h> #include <grpcpp/support/channel_arguments.h>
#include <grpcpp/support/config.h> #include <grpcpp/support/config.h>
#include <grpcpp/support/status.h> #include <grpcpp/support/status.h>
#include <grpcpp/support/time.h>
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/gprpp/thd.h"
#include "src/core/lib/profiling/timers.h"
#include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/surface/completion_queue.h"
namespace grpc { namespace grpc {

@ -19,34 +19,38 @@
#include <memory> #include <memory>
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <grpcpp/create_channel.h> #include <grpcpp/create_channel_impl.h>
#include <grpcpp/impl/grpc_library.h> #include <grpcpp/impl/grpc_library.h>
#include <grpcpp/support/channel_arguments.h> #include <grpcpp/support/channel_arguments.h>
#include "src/cpp/client/create_channel_internal.h" #include "src/cpp/client/create_channel_internal.h"
namespace grpc { namespace grpc {
class ChannelArguments;
std::shared_ptr<Channel> CreateChannel( class ChannelArguments;
}
namespace grpc_impl {
std::shared_ptr<grpc::Channel> CreateChannel(
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds) { const std::shared_ptr<grpc::ChannelCredentials>& creds) {
return CreateCustomChannel(target, creds, ChannelArguments()); return CreateCustomChannel(target, creds, grpc::ChannelArguments());
} }
std::shared_ptr<Channel> CreateCustomChannel( std::shared_ptr<grpc::Channel> CreateCustomChannel(
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<grpc::ChannelCredentials>& creds,
const ChannelArguments& args) { const grpc::ChannelArguments& args) {
GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds. grpc::GrpcLibraryCodegen
init_lib; // We need to call init in case of a bad creds.
return creds ? creds->CreateChannel(target, args) return creds ? creds->CreateChannel(target, args)
: CreateChannelInternal( : grpc::CreateChannelInternal(
"", "",
grpc_lame_client_channel_create( grpc_lame_client_channel_create(
nullptr, GRPC_STATUS_INVALID_ARGUMENT, nullptr, GRPC_STATUS_INVALID_ARGUMENT,
"Invalid credentials."), "Invalid credentials."),
std::vector<std::unique_ptr< std::vector<std::unique_ptr<
experimental::ClientInterceptorFactoryInterface>>()); grpc::experimental::
ClientInterceptorFactoryInterface>>());
} }
namespace experimental { namespace experimental {
@ -61,23 +65,24 @@ namespace experimental {
/// hold an object or is invalid, a lame channel (one on which all operations /// hold an object or is invalid, a lame channel (one on which all operations
/// fail) is returned. /// fail) is returned.
/// \param args Options for channel creation. /// \param args Options for channel creation.
std::shared_ptr<Channel> CreateCustomChannelWithInterceptors( std::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors(
const grpc::string& target, const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds, const std::shared_ptr<grpc::ChannelCredentials>& creds,
const ChannelArguments& args, const grpc::ChannelArguments& args,
std::vector< std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) { interceptor_creators) {
return creds ? creds->CreateChannelWithInterceptors( return creds ? creds->CreateChannelWithInterceptors(
target, args, std::move(interceptor_creators)) target, args, std::move(interceptor_creators))
: CreateChannelInternal( : grpc::CreateChannelInternal(
"", "",
grpc_lame_client_channel_create( grpc_lame_client_channel_create(
nullptr, GRPC_STATUS_INVALID_ARGUMENT, nullptr, GRPC_STATUS_INVALID_ARGUMENT,
"Invalid credentials."), "Invalid credentials."),
std::vector<std::unique_ptr< std::vector<std::unique_ptr<
experimental::ClientInterceptorFactoryInterface>>()); grpc::experimental::
ClientInterceptorFactoryInterface>>());
} }
} // namespace experimental } // namespace experimental
} // namespace grpc } // namespace grpc_impl

@ -24,45 +24,46 @@
#include "src/cpp/client/create_channel_internal.h" #include "src/cpp/client/create_channel_internal.h"
namespace grpc { namespace grpc_impl {
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD #ifdef GPR_SUPPORT_CHANNELS_FROM_FD
std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target, std::shared_ptr<grpc::Channel> CreateInsecureChannelFromFd(
int fd) { const grpc::string& target, int fd) {
internal::GrpcLibrary init_lib; grpc::internal::GrpcLibrary init_lib;
init_lib.init(); init_lib.init();
return CreateChannelInternal( return grpc::CreateChannelInternal(
"", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr), "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr),
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); grpc::experimental::ClientInterceptorFactoryInterface>>());
} }
std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd( std::shared_ptr<grpc::Channel> CreateCustomInsecureChannelFromFd(
const grpc::string& target, int fd, const ChannelArguments& args) { const grpc::string& target, int fd, const grpc::ChannelArguments& args) {
internal::GrpcLibrary init_lib; grpc::internal::GrpcLibrary init_lib;
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( return grpc::CreateChannelInternal(
"", "",
grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args), grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args),
std::vector< std::vector<std::unique_ptr<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>()); grpc::experimental::ClientInterceptorFactoryInterface>>());
} }
namespace experimental { namespace experimental {
std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd( std::shared_ptr<grpc::Channel>
const grpc::string& target, int fd, const ChannelArguments& args, CreateCustomInsecureChannelWithInterceptorsFromFd(
const grpc::string& target, int fd, const grpc::ChannelArguments& args,
std::vector< std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>> std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators) { interceptor_creators) {
internal::GrpcLibrary init_lib; grpc::internal::GrpcLibrary init_lib;
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( return grpc::CreateChannelInternal(
"", "",
grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args), grpc_insecure_channel_create_from_fd(target.c_str(), fd, &channel_args),
std::move(interceptor_creators)); std::move(interceptor_creators));
@ -72,4 +73,4 @@ std::shared_ptr<Channel> CreateCustomInsecureChannelWithInterceptorsFromFd(
#endif // GPR_SUPPORT_CHANNELS_FROM_FD #endif // GPR_SUPPORT_CHANNELS_FROM_FD
} // namespace grpc } // namespace grpc_impl

@ -22,63 +22,75 @@
#include <grpcpp/impl/rpc_method.h> #include <grpcpp/impl/rpc_method.h>
#include <grpcpp/support/client_callback.h> #include <grpcpp/support/client_callback.h>
namespace grpc { namespace grpc_impl {
namespace { namespace {
std::unique_ptr<GenericClientAsyncReaderWriter> CallInternal( std::unique_ptr<grpc::GenericClientAsyncReaderWriter> CallInternal(
ChannelInterface* channel, ClientContext* context, grpc::ChannelInterface* channel, grpc::ClientContext* context,
const grpc::string& method, CompletionQueue* cq, bool start, void* tag) { const grpc::string& method, grpc::CompletionQueue* cq, bool start,
return std::unique_ptr<GenericClientAsyncReaderWriter>( void* tag) {
internal::ClientAsyncReaderWriterFactory<ByteBuffer, ByteBuffer>::Create( return std::unique_ptr<grpc::GenericClientAsyncReaderWriter>(
channel, cq, grpc::internal::ClientAsyncReaderWriterFactory<grpc::ByteBuffer,
internal::RpcMethod(method.c_str(), grpc::ByteBuffer>::
internal::RpcMethod::BIDI_STREAMING), Create(channel, cq,
context, start, tag)); grpc::internal::RpcMethod(
method.c_str(), grpc::internal::RpcMethod::BIDI_STREAMING),
context, start, tag));
} }
} // namespace } // namespace
// begin a call to a named method // begin a call to a named method
std::unique_ptr<GenericClientAsyncReaderWriter> GenericStub::Call( std::unique_ptr<grpc::GenericClientAsyncReaderWriter> GenericStub::Call(
ClientContext* context, const grpc::string& method, CompletionQueue* cq, grpc::ClientContext* context, const grpc::string& method,
void* tag) { grpc::CompletionQueue* cq, void* tag) {
return CallInternal(channel_.get(), context, method, cq, true, tag); return CallInternal(channel_.get(), context, method, cq, true, tag);
} }
// setup a call to a named method // setup a call to a named method
std::unique_ptr<GenericClientAsyncReaderWriter> GenericStub::PrepareCall( std::unique_ptr<grpc::GenericClientAsyncReaderWriter> GenericStub::PrepareCall(
ClientContext* context, const grpc::string& method, CompletionQueue* cq) { grpc::ClientContext* context, const grpc::string& method,
grpc::CompletionQueue* cq) {
return CallInternal(channel_.get(), context, method, cq, false, nullptr); return CallInternal(channel_.get(), context, method, cq, false, nullptr);
} }
// setup a unary call to a named method // setup a unary call to a named method
std::unique_ptr<GenericClientAsyncResponseReader> GenericStub::PrepareUnaryCall( std::unique_ptr<grpc::GenericClientAsyncResponseReader>
ClientContext* context, const grpc::string& method, GenericStub::PrepareUnaryCall(grpc::ClientContext* context,
const ByteBuffer& request, CompletionQueue* cq) { const grpc::string& method,
return std::unique_ptr<GenericClientAsyncResponseReader>( const grpc::ByteBuffer& request,
internal::ClientAsyncResponseReaderFactory<ByteBuffer>::Create( grpc::CompletionQueue* cq) {
channel_.get(), cq, return std::unique_ptr<grpc::GenericClientAsyncResponseReader>(
internal::RpcMethod(method.c_str(), internal::RpcMethod::NORMAL_RPC), grpc::internal::ClientAsyncResponseReaderFactory<
context, request, false)); grpc::ByteBuffer>::Create(channel_.get(), cq,
grpc::internal::RpcMethod(
method.c_str(),
grpc::internal::RpcMethod::NORMAL_RPC),
context, request, false));
} }
void GenericStub::experimental_type::UnaryCall( void GenericStub::experimental_type::UnaryCall(
ClientContext* context, const grpc::string& method, grpc::ClientContext* context, const grpc::string& method,
const ByteBuffer* request, ByteBuffer* response, const grpc::ByteBuffer* request, grpc::ByteBuffer* response,
std::function<void(Status)> on_completion) { std::function<void(grpc::Status)> on_completion) {
internal::CallbackUnaryCall( grpc::internal::CallbackUnaryCall(
stub_->channel_.get(), stub_->channel_.get(),
internal::RpcMethod(method.c_str(), internal::RpcMethod::NORMAL_RPC), grpc::internal::RpcMethod(method.c_str(),
grpc::internal::RpcMethod::NORMAL_RPC),
context, request, response, std::move(on_completion)); context, request, response, std::move(on_completion));
} }
void GenericStub::experimental_type::PrepareBidiStreamingCall( void GenericStub::experimental_type::PrepareBidiStreamingCall(
ClientContext* context, const grpc::string& method, grpc::ClientContext* context, const grpc::string& method,
experimental::ClientBidiReactor<ByteBuffer, ByteBuffer>* reactor) { grpc::experimental::ClientBidiReactor<grpc::ByteBuffer, grpc::ByteBuffer>*
internal::ClientCallbackReaderWriterFactory<ByteBuffer, ByteBuffer>::Create( reactor) {
stub_->channel_.get(), grpc::internal::ClientCallbackReaderWriterFactory<
internal::RpcMethod(method.c_str(), internal::RpcMethod::BIDI_STREAMING), grpc::ByteBuffer,
context, reactor); grpc::ByteBuffer>::Create(stub_->channel_.get(),
grpc::internal::RpcMethod(
method.c_str(),
grpc::internal::RpcMethod::BIDI_STREAMING),
context, reactor);
} }
} // namespace grpc } // namespace grpc_impl

@ -143,7 +143,7 @@ void ChannelArguments::SetUserAgentPrefix(
} }
void ChannelArguments::SetResourceQuota( void ChannelArguments::SetResourceQuota(
const grpc::ResourceQuota& resource_quota) { const grpc_impl::ResourceQuota& resource_quota) {
SetPointerWithVtable(GRPC_ARG_RESOURCE_QUOTA, SetPointerWithVtable(GRPC_ARG_RESOURCE_QUOTA,
resource_quota.c_resource_quota(), resource_quota.c_resource_quota(),
grpc_resource_quota_arg_vtable()); grpc_resource_quota_arg_vtable());

@ -19,7 +19,7 @@
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpcpp/resource_quota.h> #include <grpcpp/resource_quota.h>
namespace grpc { namespace grpc_impl {
ResourceQuota::ResourceQuota() : impl_(grpc_resource_quota_create(nullptr)) {} ResourceQuota::ResourceQuota() : impl_(grpc_resource_quota_create(nullptr)) {}
@ -37,4 +37,4 @@ ResourceQuota& ResourceQuota::SetMaxThreads(int new_max_threads) {
grpc_resource_quota_set_max_threads(impl_, new_max_threads); grpc_resource_quota_set_max_threads(impl_, new_max_threads);
return *this; return *this;
} }
} // namespace grpc } // namespace grpc_impl

@ -22,5 +22,5 @@
#include <grpcpp/grpcpp.h> #include <grpcpp/grpcpp.h>
namespace grpc { namespace grpc {
grpc::string Version() { return "1.20.0-dev"; } grpc::string Version() { return "1.21.0-dev"; }
} // namespace grpc } // namespace grpc

@ -30,35 +30,6 @@
namespace grpc { namespace grpc {
void RegisterOpenCensusPlugin() {
RegisterChannelFilter<CensusChannelData, CensusClientCallData>(
"opencensus_client", GRPC_CLIENT_CHANNEL, INT_MAX /* priority */,
nullptr /* condition function */);
RegisterChannelFilter<CensusChannelData, CensusServerCallData>(
"opencensus_server", GRPC_SERVER_CHANNEL, INT_MAX /* priority */,
nullptr /* condition function */);
// Access measures to ensure they are initialized. Otherwise, creating a view
// before the first RPC would cause an error.
RpcClientSentBytesPerRpc();
RpcClientReceivedBytesPerRpc();
RpcClientRoundtripLatency();
RpcClientServerLatency();
RpcClientSentMessagesPerRpc();
RpcClientReceivedMessagesPerRpc();
RpcServerSentBytesPerRpc();
RpcServerReceivedBytesPerRpc();
RpcServerServerLatency();
RpcServerSentMessagesPerRpc();
RpcServerReceivedMessagesPerRpc();
}
::opencensus::trace::Span GetSpanFromServerContext(ServerContext* context) {
return reinterpret_cast<const CensusContext*>(context->census_context())
->Span();
}
// These measure definitions should be kept in sync across opencensus // These measure definitions should be kept in sync across opencensus
// implementations--see // implementations--see
// https://github.com/census-instrumentation/opencensus-java/blob/master/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java. // https://github.com/census-instrumentation/opencensus-java/blob/master/contrib/grpc_metrics/src/main/java/io/opencensus/contrib/grpc/metrics/RpcMeasureConstants.java.
@ -126,5 +97,39 @@ ABSL_CONST_INIT const absl::string_view
ABSL_CONST_INIT const absl::string_view kRpcServerServerLatencyMeasureName = ABSL_CONST_INIT const absl::string_view kRpcServerServerLatencyMeasureName =
"grpc.io/server/server_latency"; "grpc.io/server/server_latency";
} // namespace grpc } // namespace grpc
namespace grpc_impl {
void RegisterOpenCensusPlugin() {
grpc::RegisterChannelFilter<grpc::CensusChannelData,
grpc::CensusClientCallData>(
"opencensus_client", GRPC_CLIENT_CHANNEL, INT_MAX /* priority */,
nullptr /* condition function */);
grpc::RegisterChannelFilter<grpc::CensusChannelData,
grpc::CensusServerCallData>(
"opencensus_server", GRPC_SERVER_CHANNEL, INT_MAX /* priority */,
nullptr /* condition function */);
// Access measures to ensure they are initialized. Otherwise, creating a view
// before the first RPC would cause an error.
grpc::RpcClientSentBytesPerRpc();
grpc::RpcClientReceivedBytesPerRpc();
grpc::RpcClientRoundtripLatency();
grpc::RpcClientServerLatency();
grpc::RpcClientSentMessagesPerRpc();
grpc::RpcClientReceivedMessagesPerRpc();
grpc::RpcServerSentBytesPerRpc();
grpc::RpcServerReceivedBytesPerRpc();
grpc::RpcServerServerLatency();
grpc::RpcServerSentMessagesPerRpc();
grpc::RpcServerReceivedMessagesPerRpc();
}
::opencensus::trace::Span GetSpanFromServerContext(
grpc::ServerContext* context) {
return reinterpret_cast<const grpc::CensusContext*>(context->census_context())
->Span();
}
} // namespace grpc_impl

@ -26,7 +26,6 @@
#include "opencensus/stats/stats.h" #include "opencensus/stats/stats.h"
namespace grpc { namespace grpc {
class ServerContext; class ServerContext;
// The tag keys set when recording RPC stats. // The tag keys set when recording RPC stats.

@ -25,6 +25,23 @@
#include "opencensus/stats/internal/set_aggregation_window.h" #include "opencensus/stats/internal/set_aggregation_window.h"
#include "opencensus/stats/stats.h" #include "opencensus/stats/stats.h"
namespace grpc_impl {
void RegisterOpenCensusViewsForExport() {
grpc::ClientSentMessagesPerRpcCumulative().RegisterForExport();
grpc::ClientSentBytesPerRpcCumulative().RegisterForExport();
grpc::ClientReceivedMessagesPerRpcCumulative().RegisterForExport();
grpc::ClientReceivedBytesPerRpcCumulative().RegisterForExport();
grpc::ClientRoundtripLatencyCumulative().RegisterForExport();
grpc::ClientServerLatencyCumulative().RegisterForExport();
grpc::ServerSentMessagesPerRpcCumulative().RegisterForExport();
grpc::ServerSentBytesPerRpcCumulative().RegisterForExport();
grpc::ServerReceivedMessagesPerRpcCumulative().RegisterForExport();
grpc::ServerReceivedBytesPerRpcCumulative().RegisterForExport();
grpc::ServerServerLatencyCumulative().RegisterForExport();
}
} // namespace grpc_impl
namespace grpc { namespace grpc {
using ::opencensus::stats::Aggregation; using ::opencensus::stats::Aggregation;
@ -71,21 +88,6 @@ ViewDescriptor HourDescriptor() {
} // namespace } // namespace
void RegisterOpenCensusViewsForExport() {
ClientSentMessagesPerRpcCumulative().RegisterForExport();
ClientSentBytesPerRpcCumulative().RegisterForExport();
ClientReceivedMessagesPerRpcCumulative().RegisterForExport();
ClientReceivedBytesPerRpcCumulative().RegisterForExport();
ClientRoundtripLatencyCumulative().RegisterForExport();
ClientServerLatencyCumulative().RegisterForExport();
ServerSentMessagesPerRpcCumulative().RegisterForExport();
ServerSentBytesPerRpcCumulative().RegisterForExport();
ServerReceivedMessagesPerRpcCumulative().RegisterForExport();
ServerReceivedBytesPerRpcCumulative().RegisterForExport();
ServerServerLatencyCumulative().RegisterForExport();
}
// client cumulative // client cumulative
const ViewDescriptor& ClientSentBytesPerRpcCumulative() { const ViewDescriptor& ClientSentBytesPerRpcCumulative() {
const static ViewDescriptor descriptor = const static ViewDescriptor descriptor =

@ -23,7 +23,7 @@
#include "src/cpp/ext/proto_server_reflection.h" #include "src/cpp/ext/proto_server_reflection.h"
namespace grpc { namespace grpc_impl {
namespace reflection { namespace reflection {
ProtoServerReflectionPlugin::ProtoServerReflectionPlugin() ProtoServerReflectionPlugin::ProtoServerReflectionPlugin()
@ -79,4 +79,4 @@ struct StaticProtoReflectionPluginInitializer {
} static_proto_reflection_plugin_initializer; } static_proto_reflection_plugin_initializer;
} // namespace reflection } // namespace reflection
} // namespace grpc } // namespace grpc_impl

@ -24,6 +24,12 @@
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
namespace grpc { namespace grpc {
grpc::protobuf::util::Status ParseJson(const char* json_str,
grpc::protobuf::Message* message) {
grpc::protobuf::json::JsonParseOptions options;
options.case_insensitive_enum_parsing = true;
return grpc::protobuf::json::JsonStringToMessage(json_str, message, options);
}
Status ChannelzService::GetTopChannels( Status ChannelzService::GetTopChannels(
ServerContext* unused, const channelz::v1::GetTopChannelsRequest* request, ServerContext* unused, const channelz::v1::GetTopChannelsRequest* request,
@ -33,8 +39,7 @@ Status ChannelzService::GetTopChannels(
return Status(StatusCode::INTERNAL, return Status(StatusCode::INTERNAL,
"grpc_channelz_get_top_channels returned null"); "grpc_channelz_get_top_channels returned null");
} }
grpc::protobuf::util::Status s = grpc::protobuf::util::Status s = ParseJson(json_str, response);
grpc::protobuf::json::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (!s.ok()) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(StatusCode::INTERNAL, s.ToString());
@ -50,8 +55,7 @@ Status ChannelzService::GetServers(
return Status(StatusCode::INTERNAL, return Status(StatusCode::INTERNAL,
"grpc_channelz_get_servers returned null"); "grpc_channelz_get_servers returned null");
} }
grpc::protobuf::util::Status s = grpc::protobuf::util::Status s = ParseJson(json_str, response);
grpc::protobuf::json::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (!s.ok()) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(StatusCode::INTERNAL, s.ToString());
@ -67,8 +71,7 @@ Status ChannelzService::GetServer(ServerContext* unused,
return Status(StatusCode::INTERNAL, return Status(StatusCode::INTERNAL,
"grpc_channelz_get_server returned null"); "grpc_channelz_get_server returned null");
} }
grpc::protobuf::util::Status s = grpc::protobuf::util::Status s = ParseJson(json_str, response);
grpc::protobuf::json::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (!s.ok()) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(StatusCode::INTERNAL, s.ToString());
@ -85,8 +88,7 @@ Status ChannelzService::GetServerSockets(
return Status(StatusCode::INTERNAL, return Status(StatusCode::INTERNAL,
"grpc_channelz_get_server_sockets returned null"); "grpc_channelz_get_server_sockets returned null");
} }
grpc::protobuf::util::Status s = grpc::protobuf::util::Status s = ParseJson(json_str, response);
grpc::protobuf::json::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (!s.ok()) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(StatusCode::INTERNAL, s.ToString());
@ -101,8 +103,7 @@ Status ChannelzService::GetChannel(
if (json_str == nullptr) { if (json_str == nullptr) {
return Status(StatusCode::NOT_FOUND, "No object found for that ChannelId"); return Status(StatusCode::NOT_FOUND, "No object found for that ChannelId");
} }
grpc::protobuf::util::Status s = grpc::protobuf::util::Status s = ParseJson(json_str, response);
grpc::protobuf::json::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (!s.ok()) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(StatusCode::INTERNAL, s.ToString());
@ -118,8 +119,7 @@ Status ChannelzService::GetSubchannel(
return Status(StatusCode::NOT_FOUND, return Status(StatusCode::NOT_FOUND,
"No object found for that SubchannelId"); "No object found for that SubchannelId");
} }
grpc::protobuf::util::Status s = grpc::protobuf::util::Status s = ParseJson(json_str, response);
grpc::protobuf::json::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (!s.ok()) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(StatusCode::INTERNAL, s.ToString());
@ -134,8 +134,7 @@ Status ChannelzService::GetSocket(ServerContext* unused,
if (json_str == nullptr) { if (json_str == nullptr) {
return Status(StatusCode::NOT_FOUND, "No object found for that SocketId"); return Status(StatusCode::NOT_FOUND, "No object found for that SocketId");
} }
grpc::protobuf::util::Status s = grpc::protobuf::util::Status s = ParseJson(json_str, response);
grpc::protobuf::json::JsonStringToMessage(json_str, response);
gpr_free(json_str); gpr_free(json_str);
if (!s.ok()) { if (!s.ok()) {
return Status(StatusCode::INTERNAL, s.ToString()); return Status(StatusCode::INTERNAL, s.ToString());

@ -67,13 +67,21 @@ CreateChannelzServicePlugin() {
new ChannelzServicePlugin()); new ChannelzServicePlugin());
} }
} // namespace experimental
} // namespace channelz
} // namespace grpc
namespace grpc_impl {
namespace channelz {
namespace experimental {
void InitChannelzService() { void InitChannelzService() {
static bool already_here = false; static bool already_here = false;
if (already_here) return; if (already_here) return;
already_here = true; already_here = true;
::grpc::ServerBuilder::InternalAddPluginFactory(&CreateChannelzServicePlugin); ::grpc::ServerBuilder::InternalAddPluginFactory(
&grpc::channelz::experimental::CreateChannelzServicePlugin);
} }
} // namespace experimental } // namespace experimental
} // namespace channelz } // namespace channelz
} // namespace grpc } // namespace grpc_impl

@ -16,9 +16,9 @@
* *
*/ */
#include <grpcpp/health_check_service_interface.h> #include <grpcpp/health_check_service_interface_impl.h>
namespace grpc { namespace grpc_impl {
namespace { namespace {
bool g_grpc_default_health_check_service_enabled = false; bool g_grpc_default_health_check_service_enabled = false;
} // namespace } // namespace
@ -31,4 +31,4 @@ void EnableDefaultHealthCheckService(bool enable) {
g_grpc_default_health_check_service_enabled = enable; g_grpc_default_health_check_service_enabled = enable;
} }
} // namespace grpc } // namespace grpc_impl

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

Loading…
Cancel
Save