Merge github.com:grpc/grpc into grand-unified-closures
This commit is contained in:
commit
106df11093
|
|
@ -99,3 +99,6 @@ artifacts/
|
|||
|
||||
# Git generated files for conflicting
|
||||
*.orig
|
||||
|
||||
# IDE specific folder for JetBrains IDEs
|
||||
.idea/
|
||||
|
|
|
|||
48
.travis.yml
48
.travis.yml
|
|
@ -8,33 +8,37 @@ env:
|
|||
- TEST=objc
|
||||
- JOBS=1
|
||||
matrix:
|
||||
- SCHEME="RxLibraryUnitTests" WORKSPACE="Tests.xcworkspace"
|
||||
TEST_PATH="src/objective-c/tests" BUILD_ONLY="false"
|
||||
- SCHEME="RxLibraryUnitTests"
|
||||
WORKSPACE="Tests.xcworkspace" TEST_PATH="src/objective-c/tests" BUILD_ONLY="false"
|
||||
INTEROP_SERVER="false"
|
||||
- SCHEME="InteropTestsLocalSSL" WORKSPACE="Tests.xcworkspace"
|
||||
TEST_PATH="src/objective-c/tests" BUILD_ONLY="false" INTEROP_SERVER="true"
|
||||
- SCHEME="InteropTestsLocalCleartext" WORKSPACE="Tests.xcworkspace"
|
||||
TEST_PATH="src/objective-c/tests" BUILD_ONLY="false"
|
||||
- SCHEME="InteropTestsLocalSSL"
|
||||
WORKSPACE="Tests.xcworkspace" TEST_PATH="src/objective-c/tests" BUILD_ONLY="false"
|
||||
INTEROP_SERVER="true"
|
||||
- SCHEME="InteropTestsLocalCleartext"
|
||||
WORKSPACE="Tests.xcworkspace" TEST_PATH="src/objective-c/tests" BUILD_ONLY="false"
|
||||
INTEROP_SERVER="true"
|
||||
# TODO(jcanizales): Make tests an app project (instead of library), so the following will work.
|
||||
# - SCHEME="InteropTestsRemote" WORKSPACE="Tests.xcworkspace"
|
||||
# TEST_PATH="src/objective-c/tests" BUILD_ONLY="false"
|
||||
# - SCHEME="InteropTestsRemote"
|
||||
# WORKSPACE="Tests.xcworkspace" TEST_PATH="src/objective-c/tests" BUILD_ONLY="false"
|
||||
# INTEROP_SERVER="true"
|
||||
- SCHEME="HelloWorld" WORKSPACE="HelloWorld.xcworkspace"
|
||||
TEST_PATH="examples/objective-c/helloworld" BUILD_ONLY="true"
|
||||
INTEROP_SERVER="false"
|
||||
- SCHEME="RouteGuideClient" WORKSPACE="RouteGuideClient.xcworkspace"
|
||||
TEST_PATH="examples/objective-c/route_guide" BUILD_ONLY="true"
|
||||
INTEROP_SERVER="false"
|
||||
- SCHEME="AuthSample" WORKSPACE="AuthSample.xcworkspace"
|
||||
TEST_PATH="examples/objective-c/auth_sample" BUILD_ONLY="true"
|
||||
INTEROP_SERVER="false"
|
||||
- SCHEME="Sample" WORKSPACE="Sample.xcworkspace"
|
||||
TEST_PATH="src/objective-c/examples/Sample" BUILD_ONLY="true"
|
||||
INTEROP_SERVER="false"
|
||||
- SCHEME="SwiftSample" WORKSPACE="SwiftSample.xcworkspace"
|
||||
TEST_PATH="src/objective-c/examples/SwiftSample" BUILD_ONLY="true"
|
||||
- SCHEME="HelloWorld"
|
||||
WORKSPACE="HelloWorld.xcworkspace" TEST_PATH="examples/objective-c/helloworld"
|
||||
BUILD_ONLY="true" INTEROP_SERVER="false"
|
||||
- SCHEME="RouteGuideClient"
|
||||
WORKSPACE="RouteGuideClient.xcworkspace" TEST_PATH="examples/objective-c/route_guide"
|
||||
BUILD_ONLY="true" INTEROP_SERVER="false"
|
||||
- SCHEME="AuthSample"
|
||||
WORKSPACE="AuthSample.xcworkspace" TEST_PATH="examples/objective-c/auth_sample"
|
||||
BUILD_ONLY="true" INTEROP_SERVER="false"
|
||||
- SCHEME="Sample"
|
||||
WORKSPACE="Sample.xcworkspace" TEST_PATH="src/objective-c/examples/Sample" BUILD_ONLY="true"
|
||||
INTEROP_SERVER="false"
|
||||
- SCHEME="Sample"
|
||||
WORKSPACE="Sample.xcworkspace" TEST_PATH="src/objective-c/examples/Sample" BUILD_ONLY="true"
|
||||
INTEROP_SERVER="false" FRAMEWORKS="YES"
|
||||
- SCHEME="SwiftSample"
|
||||
WORKSPACE="SwiftSample.xcworkspace" TEST_PATH="src/objective-c/examples/SwiftSample"
|
||||
BUILD_ONLY="true" INTEROP_SERVER="false"
|
||||
before_install:
|
||||
# Until Travis upgrades from Cocoapods 0.39, we need to do it here.
|
||||
- pod --version
|
||||
|
|
|
|||
42
BUILD
42
BUILD
|
|
@ -167,6 +167,7 @@ cc_library(
|
|||
"src/core/lib/channel/compress_filter.h",
|
||||
"src/core/lib/channel/connected_channel.h",
|
||||
"src/core/lib/channel/context.h",
|
||||
"src/core/lib/channel/handshaker.h",
|
||||
"src/core/lib/channel/http_client_filter.h",
|
||||
"src/core/lib/channel/http_server_filter.h",
|
||||
"src/core/lib/compression/algorithm_metadata.h",
|
||||
|
|
@ -238,6 +239,7 @@ cc_library(
|
|||
"src/core/lib/transport/metadata.h",
|
||||
"src/core/lib/transport/metadata_batch.h",
|
||||
"src/core/lib/transport/static_metadata.h",
|
||||
"src/core/lib/transport/timeout_encoding.h",
|
||||
"src/core/lib/transport/transport.h",
|
||||
"src/core/lib/transport/transport_impl.h",
|
||||
"src/core/ext/transport/chttp2/transport/bin_decoder.h",
|
||||
|
|
@ -259,7 +261,6 @@ cc_library(
|
|||
"src/core/ext/transport/chttp2/transport/internal.h",
|
||||
"src/core/ext/transport/chttp2/transport/status_conversion.h",
|
||||
"src/core/ext/transport/chttp2/transport/stream_map.h",
|
||||
"src/core/ext/transport/chttp2/transport/timeout_encoding.h",
|
||||
"src/core/ext/transport/chttp2/transport/varint.h",
|
||||
"src/core/ext/transport/chttp2/alpn/alpn.h",
|
||||
"src/core/lib/security/context/security_context.h",
|
||||
|
|
@ -302,16 +303,19 @@ cc_library(
|
|||
"src/core/ext/client_config/subchannel_call_holder.h",
|
||||
"src/core/ext/client_config/subchannel_index.h",
|
||||
"src/core/ext/client_config/uri_parser.h",
|
||||
"src/core/ext/lb_policy/grpclb/grpclb.h",
|
||||
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
|
||||
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
|
||||
"src/core/ext/load_reporting/load_reporting.h",
|
||||
"src/core/ext/load_reporting/load_reporting_filter.h",
|
||||
"src/core/ext/census/aggregation.h",
|
||||
"src/core/ext/census/base_resources.h",
|
||||
"src/core/ext/census/census_interface.h",
|
||||
"src/core/ext/census/census_rpc_stats.h",
|
||||
"src/core/ext/census/gen/census.pb.h",
|
||||
"src/core/ext/census/grpc_filter.h",
|
||||
"src/core/ext/census/mlog.h",
|
||||
"src/core/ext/census/resource.h",
|
||||
"src/core/ext/census/rpc_metric_id.h",
|
||||
"src/core/lib/surface/init.c",
|
||||
"src/core/lib/channel/channel_args.c",
|
||||
|
|
@ -319,6 +323,7 @@ cc_library(
|
|||
"src/core/lib/channel/channel_stack_builder.c",
|
||||
"src/core/lib/channel/compress_filter.c",
|
||||
"src/core/lib/channel/connected_channel.c",
|
||||
"src/core/lib/channel/handshaker.c",
|
||||
"src/core/lib/channel/http_client_filter.c",
|
||||
"src/core/lib/channel/http_server_filter.c",
|
||||
"src/core/lib/compression/compression.c",
|
||||
|
|
@ -400,6 +405,7 @@ cc_library(
|
|||
"src/core/lib/transport/metadata.c",
|
||||
"src/core/lib/transport/metadata_batch.c",
|
||||
"src/core/lib/transport/static_metadata.c",
|
||||
"src/core/lib/transport/timeout_encoding.c",
|
||||
"src/core/lib/transport/transport.c",
|
||||
"src/core/lib/transport/transport_op_string.c",
|
||||
"src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c",
|
||||
|
|
@ -422,7 +428,6 @@ cc_library(
|
|||
"src/core/ext/transport/chttp2/transport/status_conversion.c",
|
||||
"src/core/ext/transport/chttp2/transport/stream_lists.c",
|
||||
"src/core/ext/transport/chttp2/transport/stream_map.c",
|
||||
"src/core/ext/transport/chttp2/transport/timeout_encoding.c",
|
||||
"src/core/ext/transport/chttp2/transport/varint.c",
|
||||
"src/core/ext/transport/chttp2/transport/writing.c",
|
||||
"src/core/ext/transport/chttp2/alpn/alpn.c",
|
||||
|
|
@ -478,6 +483,7 @@ cc_library(
|
|||
"src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c",
|
||||
"src/core/ext/transport/chttp2/client/insecure/channel_create.c",
|
||||
"src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c",
|
||||
"src/core/ext/lb_policy/grpclb/grpclb.c",
|
||||
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
|
||||
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
|
||||
"src/core/ext/lb_policy/pick_first/pick_first.c",
|
||||
|
|
@ -486,6 +492,7 @@ cc_library(
|
|||
"src/core/ext/resolver/sockaddr/sockaddr_resolver.c",
|
||||
"src/core/ext/load_reporting/load_reporting.c",
|
||||
"src/core/ext/load_reporting/load_reporting_filter.c",
|
||||
"src/core/ext/census/base_resources.c",
|
||||
"src/core/ext/census/context.c",
|
||||
"src/core/ext/census/gen/census.pb.c",
|
||||
"src/core/ext/census/grpc_context.c",
|
||||
|
|
@ -495,6 +502,7 @@ cc_library(
|
|||
"src/core/ext/census/mlog.c",
|
||||
"src/core/ext/census/operation.c",
|
||||
"src/core/ext/census/placeholders.c",
|
||||
"src/core/ext/census/resource.c",
|
||||
"src/core/ext/census/tracing.c",
|
||||
"src/core/plugin_registry/grpc_plugin_registry.c",
|
||||
],
|
||||
|
|
@ -556,6 +564,7 @@ cc_library(
|
|||
"src/core/lib/channel/compress_filter.h",
|
||||
"src/core/lib/channel/connected_channel.h",
|
||||
"src/core/lib/channel/context.h",
|
||||
"src/core/lib/channel/handshaker.h",
|
||||
"src/core/lib/channel/http_client_filter.h",
|
||||
"src/core/lib/channel/http_server_filter.h",
|
||||
"src/core/lib/compression/algorithm_metadata.h",
|
||||
|
|
@ -627,6 +636,7 @@ cc_library(
|
|||
"src/core/lib/transport/metadata.h",
|
||||
"src/core/lib/transport/metadata_batch.h",
|
||||
"src/core/lib/transport/static_metadata.h",
|
||||
"src/core/lib/transport/timeout_encoding.h",
|
||||
"src/core/lib/transport/transport.h",
|
||||
"src/core/lib/transport/transport_impl.h",
|
||||
"third_party/objective_c/Cronet/cronet_c_for_grpc.h",
|
||||
|
|
@ -649,7 +659,6 @@ cc_library(
|
|||
"src/core/ext/transport/chttp2/transport/internal.h",
|
||||
"src/core/ext/transport/chttp2/transport/status_conversion.h",
|
||||
"src/core/ext/transport/chttp2/transport/stream_map.h",
|
||||
"src/core/ext/transport/chttp2/transport/timeout_encoding.h",
|
||||
"src/core/ext/transport/chttp2/transport/varint.h",
|
||||
"src/core/ext/transport/chttp2/alpn/alpn.h",
|
||||
"src/core/ext/client_config/client_channel.h",
|
||||
|
|
@ -698,6 +707,7 @@ cc_library(
|
|||
"src/core/lib/channel/channel_stack_builder.c",
|
||||
"src/core/lib/channel/compress_filter.c",
|
||||
"src/core/lib/channel/connected_channel.c",
|
||||
"src/core/lib/channel/handshaker.c",
|
||||
"src/core/lib/channel/http_client_filter.c",
|
||||
"src/core/lib/channel/http_server_filter.c",
|
||||
"src/core/lib/compression/compression.c",
|
||||
|
|
@ -779,6 +789,7 @@ cc_library(
|
|||
"src/core/lib/transport/metadata.c",
|
||||
"src/core/lib/transport/metadata_batch.c",
|
||||
"src/core/lib/transport/static_metadata.c",
|
||||
"src/core/lib/transport/timeout_encoding.c",
|
||||
"src/core/lib/transport/transport.c",
|
||||
"src/core/lib/transport/transport_op_string.c",
|
||||
"src/core/ext/transport/cronet/client/secure/cronet_channel_create.c",
|
||||
|
|
@ -804,7 +815,6 @@ cc_library(
|
|||
"src/core/ext/transport/chttp2/transport/status_conversion.c",
|
||||
"src/core/ext/transport/chttp2/transport/stream_lists.c",
|
||||
"src/core/ext/transport/chttp2/transport/stream_map.c",
|
||||
"src/core/ext/transport/chttp2/transport/timeout_encoding.c",
|
||||
"src/core/ext/transport/chttp2/transport/varint.c",
|
||||
"src/core/ext/transport/chttp2/transport/writing.c",
|
||||
"src/core/ext/transport/chttp2/alpn/alpn.c",
|
||||
|
|
@ -910,6 +920,7 @@ cc_library(
|
|||
"src/core/lib/channel/compress_filter.h",
|
||||
"src/core/lib/channel/connected_channel.h",
|
||||
"src/core/lib/channel/context.h",
|
||||
"src/core/lib/channel/handshaker.h",
|
||||
"src/core/lib/channel/http_client_filter.h",
|
||||
"src/core/lib/channel/http_server_filter.h",
|
||||
"src/core/lib/compression/algorithm_metadata.h",
|
||||
|
|
@ -981,6 +992,7 @@ cc_library(
|
|||
"src/core/lib/transport/metadata.h",
|
||||
"src/core/lib/transport/metadata_batch.h",
|
||||
"src/core/lib/transport/static_metadata.h",
|
||||
"src/core/lib/transport/timeout_encoding.h",
|
||||
"src/core/lib/transport/transport.h",
|
||||
"src/core/lib/transport/transport_impl.h",
|
||||
"src/core/ext/transport/chttp2/transport/bin_decoder.h",
|
||||
|
|
@ -1002,7 +1014,6 @@ cc_library(
|
|||
"src/core/ext/transport/chttp2/transport/internal.h",
|
||||
"src/core/ext/transport/chttp2/transport/status_conversion.h",
|
||||
"src/core/ext/transport/chttp2/transport/stream_map.h",
|
||||
"src/core/ext/transport/chttp2/transport/timeout_encoding.h",
|
||||
"src/core/ext/transport/chttp2/transport/varint.h",
|
||||
"src/core/ext/transport/chttp2/alpn/alpn.h",
|
||||
"src/core/ext/client_config/client_channel.h",
|
||||
|
|
@ -1023,14 +1034,17 @@ cc_library(
|
|||
"src/core/ext/client_config/uri_parser.h",
|
||||
"src/core/ext/load_reporting/load_reporting.h",
|
||||
"src/core/ext/load_reporting/load_reporting_filter.h",
|
||||
"src/core/ext/lb_policy/grpclb/grpclb.h",
|
||||
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
|
||||
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
|
||||
"src/core/ext/census/aggregation.h",
|
||||
"src/core/ext/census/base_resources.h",
|
||||
"src/core/ext/census/census_interface.h",
|
||||
"src/core/ext/census/census_rpc_stats.h",
|
||||
"src/core/ext/census/gen/census.pb.h",
|
||||
"src/core/ext/census/grpc_filter.h",
|
||||
"src/core/ext/census/mlog.h",
|
||||
"src/core/ext/census/resource.h",
|
||||
"src/core/ext/census/rpc_metric_id.h",
|
||||
"src/core/lib/surface/init.c",
|
||||
"src/core/lib/surface/init_unsecure.c",
|
||||
|
|
@ -1039,6 +1053,7 @@ cc_library(
|
|||
"src/core/lib/channel/channel_stack_builder.c",
|
||||
"src/core/lib/channel/compress_filter.c",
|
||||
"src/core/lib/channel/connected_channel.c",
|
||||
"src/core/lib/channel/handshaker.c",
|
||||
"src/core/lib/channel/http_client_filter.c",
|
||||
"src/core/lib/channel/http_server_filter.c",
|
||||
"src/core/lib/compression/compression.c",
|
||||
|
|
@ -1120,6 +1135,7 @@ cc_library(
|
|||
"src/core/lib/transport/metadata.c",
|
||||
"src/core/lib/transport/metadata_batch.c",
|
||||
"src/core/lib/transport/static_metadata.c",
|
||||
"src/core/lib/transport/timeout_encoding.c",
|
||||
"src/core/lib/transport/transport.c",
|
||||
"src/core/lib/transport/transport_op_string.c",
|
||||
"src/core/ext/transport/chttp2/server/insecure/server_chttp2.c",
|
||||
|
|
@ -1143,7 +1159,6 @@ cc_library(
|
|||
"src/core/ext/transport/chttp2/transport/status_conversion.c",
|
||||
"src/core/ext/transport/chttp2/transport/stream_lists.c",
|
||||
"src/core/ext/transport/chttp2/transport/stream_map.c",
|
||||
"src/core/ext/transport/chttp2/transport/timeout_encoding.c",
|
||||
"src/core/ext/transport/chttp2/transport/varint.c",
|
||||
"src/core/ext/transport/chttp2/transport/writing.c",
|
||||
"src/core/ext/transport/chttp2/alpn/alpn.c",
|
||||
|
|
@ -1172,10 +1187,12 @@ cc_library(
|
|||
"src/core/ext/resolver/sockaddr/sockaddr_resolver.c",
|
||||
"src/core/ext/load_reporting/load_reporting.c",
|
||||
"src/core/ext/load_reporting/load_reporting_filter.c",
|
||||
"src/core/ext/lb_policy/grpclb/grpclb.c",
|
||||
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
|
||||
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
|
||||
"src/core/ext/lb_policy/pick_first/pick_first.c",
|
||||
"src/core/ext/lb_policy/round_robin/round_robin.c",
|
||||
"src/core/ext/census/base_resources.c",
|
||||
"src/core/ext/census/context.c",
|
||||
"src/core/ext/census/gen/census.pb.c",
|
||||
"src/core/ext/census/grpc_context.c",
|
||||
|
|
@ -1185,6 +1202,7 @@ cc_library(
|
|||
"src/core/ext/census/mlog.c",
|
||||
"src/core/ext/census/operation.c",
|
||||
"src/core/ext/census/placeholders.c",
|
||||
"src/core/ext/census/resource.c",
|
||||
"src/core/ext/census/tracing.c",
|
||||
"src/core/plugin_registry/grpc_unsecure_plugin_registry.c",
|
||||
],
|
||||
|
|
@ -1801,6 +1819,7 @@ objc_library(
|
|||
"src/core/lib/channel/channel_stack_builder.c",
|
||||
"src/core/lib/channel/compress_filter.c",
|
||||
"src/core/lib/channel/connected_channel.c",
|
||||
"src/core/lib/channel/handshaker.c",
|
||||
"src/core/lib/channel/http_client_filter.c",
|
||||
"src/core/lib/channel/http_server_filter.c",
|
||||
"src/core/lib/compression/compression.c",
|
||||
|
|
@ -1882,6 +1901,7 @@ objc_library(
|
|||
"src/core/lib/transport/metadata.c",
|
||||
"src/core/lib/transport/metadata_batch.c",
|
||||
"src/core/lib/transport/static_metadata.c",
|
||||
"src/core/lib/transport/timeout_encoding.c",
|
||||
"src/core/lib/transport/transport.c",
|
||||
"src/core/lib/transport/transport_op_string.c",
|
||||
"src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c",
|
||||
|
|
@ -1904,7 +1924,6 @@ objc_library(
|
|||
"src/core/ext/transport/chttp2/transport/status_conversion.c",
|
||||
"src/core/ext/transport/chttp2/transport/stream_lists.c",
|
||||
"src/core/ext/transport/chttp2/transport/stream_map.c",
|
||||
"src/core/ext/transport/chttp2/transport/timeout_encoding.c",
|
||||
"src/core/ext/transport/chttp2/transport/varint.c",
|
||||
"src/core/ext/transport/chttp2/transport/writing.c",
|
||||
"src/core/ext/transport/chttp2/alpn/alpn.c",
|
||||
|
|
@ -1960,6 +1979,7 @@ objc_library(
|
|||
"src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c",
|
||||
"src/core/ext/transport/chttp2/client/insecure/channel_create.c",
|
||||
"src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c",
|
||||
"src/core/ext/lb_policy/grpclb/grpclb.c",
|
||||
"src/core/ext/lb_policy/grpclb/load_balancer_api.c",
|
||||
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c",
|
||||
"src/core/ext/lb_policy/pick_first/pick_first.c",
|
||||
|
|
@ -1968,6 +1988,7 @@ objc_library(
|
|||
"src/core/ext/resolver/sockaddr/sockaddr_resolver.c",
|
||||
"src/core/ext/load_reporting/load_reporting.c",
|
||||
"src/core/ext/load_reporting/load_reporting_filter.c",
|
||||
"src/core/ext/census/base_resources.c",
|
||||
"src/core/ext/census/context.c",
|
||||
"src/core/ext/census/gen/census.pb.c",
|
||||
"src/core/ext/census/grpc_context.c",
|
||||
|
|
@ -1977,6 +1998,7 @@ objc_library(
|
|||
"src/core/ext/census/mlog.c",
|
||||
"src/core/ext/census/operation.c",
|
||||
"src/core/ext/census/placeholders.c",
|
||||
"src/core/ext/census/resource.c",
|
||||
"src/core/ext/census/tracing.c",
|
||||
"src/core/plugin_registry/grpc_plugin_registry.c",
|
||||
],
|
||||
|
|
@ -2017,6 +2039,7 @@ objc_library(
|
|||
"src/core/lib/channel/compress_filter.h",
|
||||
"src/core/lib/channel/connected_channel.h",
|
||||
"src/core/lib/channel/context.h",
|
||||
"src/core/lib/channel/handshaker.h",
|
||||
"src/core/lib/channel/http_client_filter.h",
|
||||
"src/core/lib/channel/http_server_filter.h",
|
||||
"src/core/lib/compression/algorithm_metadata.h",
|
||||
|
|
@ -2088,6 +2111,7 @@ objc_library(
|
|||
"src/core/lib/transport/metadata.h",
|
||||
"src/core/lib/transport/metadata_batch.h",
|
||||
"src/core/lib/transport/static_metadata.h",
|
||||
"src/core/lib/transport/timeout_encoding.h",
|
||||
"src/core/lib/transport/transport.h",
|
||||
"src/core/lib/transport/transport_impl.h",
|
||||
"src/core/ext/transport/chttp2/transport/bin_decoder.h",
|
||||
|
|
@ -2109,7 +2133,6 @@ objc_library(
|
|||
"src/core/ext/transport/chttp2/transport/internal.h",
|
||||
"src/core/ext/transport/chttp2/transport/status_conversion.h",
|
||||
"src/core/ext/transport/chttp2/transport/stream_map.h",
|
||||
"src/core/ext/transport/chttp2/transport/timeout_encoding.h",
|
||||
"src/core/ext/transport/chttp2/transport/varint.h",
|
||||
"src/core/ext/transport/chttp2/alpn/alpn.h",
|
||||
"src/core/lib/security/context/security_context.h",
|
||||
|
|
@ -2152,16 +2175,19 @@ objc_library(
|
|||
"src/core/ext/client_config/subchannel_call_holder.h",
|
||||
"src/core/ext/client_config/subchannel_index.h",
|
||||
"src/core/ext/client_config/uri_parser.h",
|
||||
"src/core/ext/lb_policy/grpclb/grpclb.h",
|
||||
"src/core/ext/lb_policy/grpclb/load_balancer_api.h",
|
||||
"src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h",
|
||||
"src/core/ext/load_reporting/load_reporting.h",
|
||||
"src/core/ext/load_reporting/load_reporting_filter.h",
|
||||
"src/core/ext/census/aggregation.h",
|
||||
"src/core/ext/census/base_resources.h",
|
||||
"src/core/ext/census/census_interface.h",
|
||||
"src/core/ext/census/census_rpc_stats.h",
|
||||
"src/core/ext/census/gen/census.pb.h",
|
||||
"src/core/ext/census/grpc_filter.h",
|
||||
"src/core/ext/census/mlog.h",
|
||||
"src/core/ext/census/resource.h",
|
||||
"src/core/ext/census/rpc_metric_id.h",
|
||||
],
|
||||
includes = [
|
||||
|
|
|
|||
799
CMakeLists.txt
799
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
52
INSTALL.md
52
INSTALL.md
|
|
@ -55,3 +55,55 @@ gRPC C Core library.
|
|||
$ make
|
||||
$ [sudo] make install
|
||||
```
|
||||
|
||||
##Windows
|
||||
|
||||
There are several ways to build under Windows, of varying complexity depending
|
||||
on experience with the tools involved.
|
||||
|
||||
<!--
|
||||
###Visual Studio
|
||||
|
||||
Versions 2013 and 2015 are both supported. You can use [their respective
|
||||
community
|
||||
editions](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx).
|
||||
|
||||
Building the C Core:
|
||||
- Open [grpc.sln](https://github.com/grpc/grpc/blob/master/vsprojects/grpc.sln).
|
||||
- Select your build target.
|
||||
- Build the `grpc` project.
|
||||
|
||||
Building the C++ runtime:
|
||||
- You need [CMake](https://cmake.org/) on your path to build protobuf (see below
|
||||
for building using solely CMake).
|
||||
- Run `vsprojects/build_protos.bat` (needs `cmake.exe` in your path).
|
||||
- Open [buildtests_cxx.sln]()
|
||||
- Select your build target.
|
||||
- build the `grpc++` project.
|
||||
-->
|
||||
|
||||
###msys2
|
||||
|
||||
This approach requires having [msys2](https://msys2.github.io/) installed.
|
||||
|
||||
- The Makefile (and source code) should support msys2's mingw32 and mingw64
|
||||
compilers. Building with msys2's native compiler is also possible, but
|
||||
difficult.
|
||||
- The Makefile is expecting the Windows versions of OpenSSL (see
|
||||
https://slproweb.com/products/Win32OpenSSL.html). It's also possible to build
|
||||
the Windows version of OpenSSL from scratch. The output should be `libeay32`
|
||||
and `ssleay32`.
|
||||
- If you are not installing the above files under msys2's path, you may specify
|
||||
it, for instance, in the following way:
|
||||
```CPPFLAGS=”-I/c/OpenSSL-Win32/include” LDFLAGS=”-L/c/OpenSSL-Win32/lib” make static_c```
|
||||
- [protobuf3](https://github.com/google/protobuf/blob/master/src/README.md#c-installation---windows)
|
||||
must be installed on the msys2 path.
|
||||
|
||||
###Cmake (experimental)
|
||||
|
||||
- Install [CMake](https://cmake.org/download/).
|
||||
- Run it over [grpc's
|
||||
CMakeLists.txt](https://github.com/grpc/grpc/blob/master/CMakeLists.txt) to
|
||||
generate "projects" for your compiler.
|
||||
- Build with your compiler of choice. The generated build files should have the
|
||||
protobuf3 dependency baked in.
|
||||
|
|
|
|||
339
Makefile
339
Makefile
|
|
@ -748,8 +748,8 @@ endif
|
|||
endif
|
||||
else
|
||||
PC_LIBS_GRPCXX = -lprotobuf
|
||||
PROTOC_PLUGINS = $(PROTOC_PLUGINS_ALL)
|
||||
endif
|
||||
PROTOC_PLUGINS = $(PROTOC_PLUGINS_ALL)
|
||||
else
|
||||
ifeq ($(HAS_EMBEDDED_PROTOBUF),true)
|
||||
PROTOBUF_DEP = $(LIBDIR)/$(CONFIG)/protobuf/libprotobuf.a
|
||||
|
|
@ -915,6 +915,7 @@ bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test
|
|||
bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test
|
||||
bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test
|
||||
census_context_test: $(BINDIR)/$(CONFIG)/census_context_test
|
||||
census_resource_test: $(BINDIR)/$(CONFIG)/census_resource_test
|
||||
channel_create_test: $(BINDIR)/$(CONFIG)/channel_create_test
|
||||
chttp2_hpack_encoder_test: $(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test
|
||||
chttp2_status_conversion_test: $(BINDIR)/$(CONFIG)/chttp2_status_conversion_test
|
||||
|
|
@ -1050,6 +1051,7 @@ grpc_objective_c_plugin: $(BINDIR)/$(CONFIG)/grpc_objective_c_plugin
|
|||
grpc_python_plugin: $(BINDIR)/$(CONFIG)/grpc_python_plugin
|
||||
grpc_ruby_plugin: $(BINDIR)/$(CONFIG)/grpc_ruby_plugin
|
||||
grpclb_api_test: $(BINDIR)/$(CONFIG)/grpclb_api_test
|
||||
grpclb_test: $(BINDIR)/$(CONFIG)/grpclb_test
|
||||
hybrid_end2end_test: $(BINDIR)/$(CONFIG)/hybrid_end2end_test
|
||||
interop_client: $(BINDIR)/$(CONFIG)/interop_client
|
||||
interop_server: $(BINDIR)/$(CONFIG)/interop_server
|
||||
|
|
@ -1134,7 +1136,7 @@ h2_fd_test: $(BINDIR)/$(CONFIG)/h2_fd_test
|
|||
h2_full_test: $(BINDIR)/$(CONFIG)/h2_full_test
|
||||
h2_full+pipe_test: $(BINDIR)/$(CONFIG)/h2_full+pipe_test
|
||||
h2_full+trace_test: $(BINDIR)/$(CONFIG)/h2_full+trace_test
|
||||
h2_loadreporting_test: $(BINDIR)/$(CONFIG)/h2_loadreporting_test
|
||||
h2_load_reporting_test: $(BINDIR)/$(CONFIG)/h2_load_reporting_test
|
||||
h2_oauth2_test: $(BINDIR)/$(CONFIG)/h2_oauth2_test
|
||||
h2_proxy_test: $(BINDIR)/$(CONFIG)/h2_proxy_test
|
||||
h2_sockpair_test: $(BINDIR)/$(CONFIG)/h2_sockpair_test
|
||||
|
|
@ -1150,7 +1152,7 @@ h2_fd_nosec_test: $(BINDIR)/$(CONFIG)/h2_fd_nosec_test
|
|||
h2_full_nosec_test: $(BINDIR)/$(CONFIG)/h2_full_nosec_test
|
||||
h2_full+pipe_nosec_test: $(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test
|
||||
h2_full+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test
|
||||
h2_loadreporting_nosec_test: $(BINDIR)/$(CONFIG)/h2_loadreporting_nosec_test
|
||||
h2_load_reporting_nosec_test: $(BINDIR)/$(CONFIG)/h2_load_reporting_nosec_test
|
||||
h2_proxy_nosec_test: $(BINDIR)/$(CONFIG)/h2_proxy_nosec_test
|
||||
h2_sockpair_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test
|
||||
h2_sockpair+trace_nosec_test: $(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test
|
||||
|
|
@ -1218,9 +1220,9 @@ pc_cxx: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++.pc
|
|||
pc_cxx_unsecure: $(LIBDIR)/$(CONFIG)/pkgconfig/grpc++_unsecure.pc
|
||||
|
||||
ifeq ($(EMBED_OPENSSL),true)
|
||||
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x509_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a
|
||||
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libboringssl_test_util.a $(LIBDIR)/$(CONFIG)/libboringssl_aes_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_asn1_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_base64_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bio_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bn_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_bytestring_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_aead_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cipher_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_cmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ed25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x25519_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_dh_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_digest_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ec_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ecdsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_err_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_extra_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_evp_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pbkdf_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_hmac_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs12_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_pkcs8_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_poly1305_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_rsa_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_x509_test_lib.a $(LIBDIR)/$(CONFIG)/libboringssl_ssl_test_lib.a
|
||||
else
|
||||
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a
|
||||
privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_cli_libs.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a
|
||||
endif
|
||||
|
||||
|
||||
|
|
@ -1235,6 +1237,7 @@ buildtests_c: privatelibs_c \
|
|||
$(BINDIR)/$(CONFIG)/bin_decoder_test \
|
||||
$(BINDIR)/$(CONFIG)/bin_encoder_test \
|
||||
$(BINDIR)/$(CONFIG)/census_context_test \
|
||||
$(BINDIR)/$(CONFIG)/census_resource_test \
|
||||
$(BINDIR)/$(CONFIG)/channel_create_test \
|
||||
$(BINDIR)/$(CONFIG)/chttp2_hpack_encoder_test \
|
||||
$(BINDIR)/$(CONFIG)/chttp2_status_conversion_test \
|
||||
|
|
@ -1352,7 +1355,7 @@ buildtests_c: privatelibs_c \
|
|||
$(BINDIR)/$(CONFIG)/h2_full_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_full+pipe_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_full+trace_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_loadreporting_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_load_reporting_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_oauth2_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_proxy_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_sockpair_test \
|
||||
|
|
@ -1368,7 +1371,7 @@ buildtests_c: privatelibs_c \
|
|||
$(BINDIR)/$(CONFIG)/h2_full_nosec_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_full+pipe_nosec_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_full+trace_nosec_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_loadreporting_nosec_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_load_reporting_nosec_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_proxy_nosec_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_sockpair_nosec_test \
|
||||
$(BINDIR)/$(CONFIG)/h2_sockpair+trace_nosec_test \
|
||||
|
|
@ -1407,6 +1410,7 @@ buildtests_cxx: privatelibs_cxx \
|
|||
$(BINDIR)/$(CONFIG)/golden_file_test \
|
||||
$(BINDIR)/$(CONFIG)/grpc_cli \
|
||||
$(BINDIR)/$(CONFIG)/grpclb_api_test \
|
||||
$(BINDIR)/$(CONFIG)/grpclb_test \
|
||||
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \
|
||||
$(BINDIR)/$(CONFIG)/interop_client \
|
||||
$(BINDIR)/$(CONFIG)/interop_server \
|
||||
|
|
@ -1491,6 +1495,7 @@ buildtests_cxx: privatelibs_cxx \
|
|||
$(BINDIR)/$(CONFIG)/golden_file_test \
|
||||
$(BINDIR)/$(CONFIG)/grpc_cli \
|
||||
$(BINDIR)/$(CONFIG)/grpclb_api_test \
|
||||
$(BINDIR)/$(CONFIG)/grpclb_test \
|
||||
$(BINDIR)/$(CONFIG)/hybrid_end2end_test \
|
||||
$(BINDIR)/$(CONFIG)/interop_client \
|
||||
$(BINDIR)/$(CONFIG)/interop_server \
|
||||
|
|
@ -1540,6 +1545,8 @@ test_c: buildtests_c
|
|||
$(Q) $(BINDIR)/$(CONFIG)/bin_encoder_test || ( echo test bin_encoder_test failed ; exit 1 )
|
||||
$(E) "[RUN] Testing census_context_test"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/census_context_test || ( echo test census_context_test failed ; exit 1 )
|
||||
$(E) "[RUN] Testing census_resource_test"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/census_resource_test || ( echo test census_resource_test failed ; exit 1 )
|
||||
$(E) "[RUN] Testing channel_create_test"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/channel_create_test || ( echo test channel_create_test failed ; exit 1 )
|
||||
$(E) "[RUN] Testing chttp2_hpack_encoder_test"
|
||||
|
|
@ -1782,6 +1789,8 @@ test_cxx: buildtests_cxx
|
|||
$(Q) $(BINDIR)/$(CONFIG)/golden_file_test || ( echo test golden_file_test failed ; exit 1 )
|
||||
$(E) "[RUN] Testing grpclb_api_test"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/grpclb_api_test || ( echo test grpclb_api_test failed ; exit 1 )
|
||||
$(E) "[RUN] Testing grpclb_test"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/grpclb_test || ( echo test grpclb_test failed ; exit 1 )
|
||||
$(E) "[RUN] Testing hybrid_end2end_test"
|
||||
$(Q) $(BINDIR)/$(CONFIG)/hybrid_end2end_test || ( echo test hybrid_end2end_test failed ; exit 1 )
|
||||
$(E) "[RUN] Testing interop_test"
|
||||
|
|
@ -1929,6 +1938,21 @@ $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc: src/proto/grpc/lb/v1/lo
|
|||
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin $<
|
||||
endif
|
||||
|
||||
ifeq ($(NO_PROTOC),true)
|
||||
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc: protoc_dep_error
|
||||
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc: protoc_dep_error
|
||||
else
|
||||
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc: src/proto/grpc/reflection/v1alpha/reflection.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
|
||||
$(E) "[PROTOC] Generating protobuf CC file from $<"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --cpp_out=$(GENDIR) $<
|
||||
|
||||
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc: src/proto/grpc/reflection/v1alpha/reflection.proto $(PROTOBUF_DEP) $(PROTOC_PLUGINS)
|
||||
$(E) "[GRPC] Generating gRPC's protobuf service CC file from $<"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) $(PROTOC) -Ithird_party/protobuf/src -I. --grpc_out=$(GENDIR) --plugin=protoc-gen-grpc=$(PROTOC_PLUGINS_DIR)/grpc_cpp_plugin $<
|
||||
endif
|
||||
|
||||
ifeq ($(NO_PROTOC),true)
|
||||
$(GENDIR)/src/proto/grpc/testing/compiler_test.pb.cc: protoc_dep_error
|
||||
$(GENDIR)/src/proto/grpc/testing/compiler_test.grpc.pb.cc: protoc_dep_error
|
||||
|
|
@ -2516,6 +2540,7 @@ LIBGRPC_SRC = \
|
|||
src/core/lib/channel/channel_stack_builder.c \
|
||||
src/core/lib/channel/compress_filter.c \
|
||||
src/core/lib/channel/connected_channel.c \
|
||||
src/core/lib/channel/handshaker.c \
|
||||
src/core/lib/channel/http_client_filter.c \
|
||||
src/core/lib/channel/http_server_filter.c \
|
||||
src/core/lib/compression/compression.c \
|
||||
|
|
@ -2597,6 +2622,7 @@ LIBGRPC_SRC = \
|
|||
src/core/lib/transport/metadata.c \
|
||||
src/core/lib/transport/metadata_batch.c \
|
||||
src/core/lib/transport/static_metadata.c \
|
||||
src/core/lib/transport/timeout_encoding.c \
|
||||
src/core/lib/transport/transport.c \
|
||||
src/core/lib/transport/transport_op_string.c \
|
||||
src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c \
|
||||
|
|
@ -2619,7 +2645,6 @@ LIBGRPC_SRC = \
|
|||
src/core/ext/transport/chttp2/transport/status_conversion.c \
|
||||
src/core/ext/transport/chttp2/transport/stream_lists.c \
|
||||
src/core/ext/transport/chttp2/transport/stream_map.c \
|
||||
src/core/ext/transport/chttp2/transport/timeout_encoding.c \
|
||||
src/core/ext/transport/chttp2/transport/varint.c \
|
||||
src/core/ext/transport/chttp2/transport/writing.c \
|
||||
src/core/ext/transport/chttp2/alpn/alpn.c \
|
||||
|
|
@ -2675,6 +2700,7 @@ LIBGRPC_SRC = \
|
|||
src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
|
||||
src/core/ext/transport/chttp2/client/insecure/channel_create.c \
|
||||
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
|
||||
src/core/ext/lb_policy/grpclb/grpclb.c \
|
||||
src/core/ext/lb_policy/grpclb/load_balancer_api.c \
|
||||
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
|
||||
third_party/nanopb/pb_common.c \
|
||||
|
|
@ -2686,6 +2712,7 @@ LIBGRPC_SRC = \
|
|||
src/core/ext/resolver/sockaddr/sockaddr_resolver.c \
|
||||
src/core/ext/load_reporting/load_reporting.c \
|
||||
src/core/ext/load_reporting/load_reporting_filter.c \
|
||||
src/core/ext/census/base_resources.c \
|
||||
src/core/ext/census/context.c \
|
||||
src/core/ext/census/gen/census.pb.c \
|
||||
src/core/ext/census/grpc_context.c \
|
||||
|
|
@ -2695,6 +2722,7 @@ LIBGRPC_SRC = \
|
|||
src/core/ext/census/mlog.c \
|
||||
src/core/ext/census/operation.c \
|
||||
src/core/ext/census/placeholders.c \
|
||||
src/core/ext/census/resource.c \
|
||||
src/core/ext/census/tracing.c \
|
||||
src/core/plugin_registry/grpc_plugin_registry.c \
|
||||
|
||||
|
|
@ -2789,6 +2817,7 @@ LIBGRPC_CRONET_SRC = \
|
|||
src/core/lib/channel/channel_stack_builder.c \
|
||||
src/core/lib/channel/compress_filter.c \
|
||||
src/core/lib/channel/connected_channel.c \
|
||||
src/core/lib/channel/handshaker.c \
|
||||
src/core/lib/channel/http_client_filter.c \
|
||||
src/core/lib/channel/http_server_filter.c \
|
||||
src/core/lib/compression/compression.c \
|
||||
|
|
@ -2870,6 +2899,7 @@ LIBGRPC_CRONET_SRC = \
|
|||
src/core/lib/transport/metadata.c \
|
||||
src/core/lib/transport/metadata_batch.c \
|
||||
src/core/lib/transport/static_metadata.c \
|
||||
src/core/lib/transport/timeout_encoding.c \
|
||||
src/core/lib/transport/transport.c \
|
||||
src/core/lib/transport/transport_op_string.c \
|
||||
src/core/ext/transport/cronet/client/secure/cronet_channel_create.c \
|
||||
|
|
@ -2895,7 +2925,6 @@ LIBGRPC_CRONET_SRC = \
|
|||
src/core/ext/transport/chttp2/transport/status_conversion.c \
|
||||
src/core/ext/transport/chttp2/transport/stream_lists.c \
|
||||
src/core/ext/transport/chttp2/transport/stream_map.c \
|
||||
src/core/ext/transport/chttp2/transport/timeout_encoding.c \
|
||||
src/core/ext/transport/chttp2/transport/varint.c \
|
||||
src/core/ext/transport/chttp2/transport/writing.c \
|
||||
src/core/ext/transport/chttp2/alpn/alpn.c \
|
||||
|
|
@ -3050,8 +3079,124 @@ LIBGRPC_TEST_UTIL_SRC = \
|
|||
test/core/util/port_server_client.c \
|
||||
test/core/util/port_windows.c \
|
||||
test/core/util/slice_splitter.c \
|
||||
src/core/lib/channel/channel_args.c \
|
||||
src/core/lib/channel/channel_stack.c \
|
||||
src/core/lib/channel/channel_stack_builder.c \
|
||||
src/core/lib/channel/compress_filter.c \
|
||||
src/core/lib/channel/connected_channel.c \
|
||||
src/core/lib/channel/handshaker.c \
|
||||
src/core/lib/channel/http_client_filter.c \
|
||||
src/core/lib/channel/http_server_filter.c \
|
||||
src/core/lib/compression/compression.c \
|
||||
src/core/lib/compression/message_compress.c \
|
||||
src/core/lib/debug/trace.c \
|
||||
src/core/lib/http/format_request.c \
|
||||
src/core/lib/http/httpcli.c \
|
||||
src/core/lib/http/parser.c \
|
||||
src/core/lib/iomgr/closure.c \
|
||||
src/core/lib/iomgr/endpoint.c \
|
||||
src/core/lib/iomgr/endpoint_pair_posix.c \
|
||||
src/core/lib/iomgr/endpoint_pair_windows.c \
|
||||
src/core/lib/iomgr/error.c \
|
||||
src/core/lib/iomgr/ev_epoll_linux.c \
|
||||
src/core/lib/iomgr/ev_poll_and_epoll_posix.c \
|
||||
src/core/lib/iomgr/ev_poll_posix.c \
|
||||
src/core/lib/iomgr/ev_posix.c \
|
||||
src/core/lib/iomgr/exec_ctx.c \
|
||||
src/core/lib/iomgr/executor.c \
|
||||
src/core/lib/iomgr/iocp_windows.c \
|
||||
src/core/lib/iomgr/iomgr.c \
|
||||
src/core/lib/iomgr/iomgr_posix.c \
|
||||
src/core/lib/iomgr/iomgr_windows.c \
|
||||
src/core/lib/iomgr/load_file.c \
|
||||
src/core/lib/iomgr/network_status_tracker.c \
|
||||
src/core/lib/iomgr/polling_entity.c \
|
||||
src/core/lib/iomgr/pollset_set_windows.c \
|
||||
src/core/lib/iomgr/pollset_windows.c \
|
||||
src/core/lib/iomgr/resolve_address_posix.c \
|
||||
src/core/lib/iomgr/resolve_address_windows.c \
|
||||
src/core/lib/iomgr/sockaddr_utils.c \
|
||||
src/core/lib/iomgr/socket_utils_common_posix.c \
|
||||
src/core/lib/iomgr/socket_utils_linux.c \
|
||||
src/core/lib/iomgr/socket_utils_posix.c \
|
||||
src/core/lib/iomgr/socket_windows.c \
|
||||
src/core/lib/iomgr/tcp_client_posix.c \
|
||||
src/core/lib/iomgr/tcp_client_windows.c \
|
||||
src/core/lib/iomgr/tcp_posix.c \
|
||||
src/core/lib/iomgr/tcp_server_posix.c \
|
||||
src/core/lib/iomgr/tcp_server_windows.c \
|
||||
src/core/lib/iomgr/tcp_windows.c \
|
||||
src/core/lib/iomgr/time_averaged_stats.c \
|
||||
src/core/lib/iomgr/timer.c \
|
||||
src/core/lib/iomgr/timer_heap.c \
|
||||
src/core/lib/iomgr/udp_server.c \
|
||||
src/core/lib/iomgr/unix_sockets_posix.c \
|
||||
src/core/lib/iomgr/unix_sockets_posix_noop.c \
|
||||
src/core/lib/iomgr/wakeup_fd_eventfd.c \
|
||||
src/core/lib/iomgr/wakeup_fd_nospecial.c \
|
||||
src/core/lib/iomgr/wakeup_fd_pipe.c \
|
||||
src/core/lib/iomgr/wakeup_fd_posix.c \
|
||||
src/core/lib/iomgr/workqueue_posix.c \
|
||||
src/core/lib/iomgr/workqueue_windows.c \
|
||||
src/core/lib/json/json.c \
|
||||
src/core/lib/json/json_reader.c \
|
||||
src/core/lib/json/json_string.c \
|
||||
src/core/lib/json/json_writer.c \
|
||||
src/core/lib/surface/alarm.c \
|
||||
src/core/lib/surface/api_trace.c \
|
||||
src/core/lib/surface/byte_buffer.c \
|
||||
src/core/lib/surface/byte_buffer_reader.c \
|
||||
src/core/lib/surface/call.c \
|
||||
src/core/lib/surface/call_details.c \
|
||||
src/core/lib/surface/call_log_batch.c \
|
||||
src/core/lib/surface/channel.c \
|
||||
src/core/lib/surface/channel_init.c \
|
||||
src/core/lib/surface/channel_ping.c \
|
||||
src/core/lib/surface/channel_stack_type.c \
|
||||
src/core/lib/surface/completion_queue.c \
|
||||
src/core/lib/surface/event_string.c \
|
||||
src/core/lib/surface/lame_client.c \
|
||||
src/core/lib/surface/metadata_array.c \
|
||||
src/core/lib/surface/server.c \
|
||||
src/core/lib/surface/validate_metadata.c \
|
||||
src/core/lib/surface/version.c \
|
||||
src/core/lib/transport/byte_stream.c \
|
||||
src/core/lib/transport/connectivity_state.c \
|
||||
src/core/lib/transport/metadata.c \
|
||||
src/core/lib/transport/metadata_batch.c \
|
||||
src/core/lib/transport/static_metadata.c \
|
||||
src/core/lib/transport/timeout_encoding.c \
|
||||
src/core/lib/transport/transport.c \
|
||||
src/core/lib/transport/transport_op_string.c \
|
||||
|
||||
PUBLIC_HEADERS_C += \
|
||||
include/grpc/byte_buffer.h \
|
||||
include/grpc/byte_buffer_reader.h \
|
||||
include/grpc/compression.h \
|
||||
include/grpc/grpc.h \
|
||||
include/grpc/grpc_posix.h \
|
||||
include/grpc/status.h \
|
||||
include/grpc/impl/codegen/byte_buffer.h \
|
||||
include/grpc/impl/codegen/byte_buffer_reader.h \
|
||||
include/grpc/impl/codegen/compression_types.h \
|
||||
include/grpc/impl/codegen/connectivity_state.h \
|
||||
include/grpc/impl/codegen/grpc_types.h \
|
||||
include/grpc/impl/codegen/propagation_bits.h \
|
||||
include/grpc/impl/codegen/status.h \
|
||||
include/grpc/impl/codegen/alloc.h \
|
||||
include/grpc/impl/codegen/atm.h \
|
||||
include/grpc/impl/codegen/atm_gcc_atomic.h \
|
||||
include/grpc/impl/codegen/atm_gcc_sync.h \
|
||||
include/grpc/impl/codegen/atm_windows.h \
|
||||
include/grpc/impl/codegen/log.h \
|
||||
include/grpc/impl/codegen/port_platform.h \
|
||||
include/grpc/impl/codegen/slice.h \
|
||||
include/grpc/impl/codegen/slice_buffer.h \
|
||||
include/grpc/impl/codegen/sync.h \
|
||||
include/grpc/impl/codegen/sync_generic.h \
|
||||
include/grpc/impl/codegen/sync_posix.h \
|
||||
include/grpc/impl/codegen/sync_windows.h \
|
||||
include/grpc/impl/codegen/time.h \
|
||||
|
||||
LIBGRPC_TEST_UTIL_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC_TEST_UTIL_SRC))))
|
||||
|
||||
|
|
@ -3131,6 +3276,7 @@ LIBGRPC_UNSECURE_SRC = \
|
|||
src/core/lib/channel/channel_stack_builder.c \
|
||||
src/core/lib/channel/compress_filter.c \
|
||||
src/core/lib/channel/connected_channel.c \
|
||||
src/core/lib/channel/handshaker.c \
|
||||
src/core/lib/channel/http_client_filter.c \
|
||||
src/core/lib/channel/http_server_filter.c \
|
||||
src/core/lib/compression/compression.c \
|
||||
|
|
@ -3212,6 +3358,7 @@ LIBGRPC_UNSECURE_SRC = \
|
|||
src/core/lib/transport/metadata.c \
|
||||
src/core/lib/transport/metadata_batch.c \
|
||||
src/core/lib/transport/static_metadata.c \
|
||||
src/core/lib/transport/timeout_encoding.c \
|
||||
src/core/lib/transport/transport.c \
|
||||
src/core/lib/transport/transport_op_string.c \
|
||||
src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \
|
||||
|
|
@ -3235,7 +3382,6 @@ LIBGRPC_UNSECURE_SRC = \
|
|||
src/core/ext/transport/chttp2/transport/status_conversion.c \
|
||||
src/core/ext/transport/chttp2/transport/stream_lists.c \
|
||||
src/core/ext/transport/chttp2/transport/stream_map.c \
|
||||
src/core/ext/transport/chttp2/transport/timeout_encoding.c \
|
||||
src/core/ext/transport/chttp2/transport/varint.c \
|
||||
src/core/ext/transport/chttp2/transport/writing.c \
|
||||
src/core/ext/transport/chttp2/alpn/alpn.c \
|
||||
|
|
@ -3264,6 +3410,7 @@ LIBGRPC_UNSECURE_SRC = \
|
|||
src/core/ext/resolver/sockaddr/sockaddr_resolver.c \
|
||||
src/core/ext/load_reporting/load_reporting.c \
|
||||
src/core/ext/load_reporting/load_reporting_filter.c \
|
||||
src/core/ext/lb_policy/grpclb/grpclb.c \
|
||||
src/core/ext/lb_policy/grpclb/load_balancer_api.c \
|
||||
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
|
||||
third_party/nanopb/pb_common.c \
|
||||
|
|
@ -3271,6 +3418,7 @@ LIBGRPC_UNSECURE_SRC = \
|
|||
third_party/nanopb/pb_encode.c \
|
||||
src/core/ext/lb_policy/pick_first/pick_first.c \
|
||||
src/core/ext/lb_policy/round_robin/round_robin.c \
|
||||
src/core/ext/census/base_resources.c \
|
||||
src/core/ext/census/context.c \
|
||||
src/core/ext/census/gen/census.pb.c \
|
||||
src/core/ext/census/grpc_context.c \
|
||||
|
|
@ -3280,6 +3428,7 @@ LIBGRPC_UNSECURE_SRC = \
|
|||
src/core/ext/census/mlog.c \
|
||||
src/core/ext/census/operation.c \
|
||||
src/core/ext/census/placeholders.c \
|
||||
src/core/ext/census/resource.c \
|
||||
src/core/ext/census/tracing.c \
|
||||
src/core/plugin_registry/grpc_unsecure_plugin_registry.c \
|
||||
|
||||
|
|
@ -3753,6 +3902,55 @@ endif
|
|||
endif
|
||||
|
||||
|
||||
LIBGRPC++_REFLECTION_CODEGEN_SRC = \
|
||||
$(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.pb.cc $(GENDIR)/src/proto/grpc/reflection/v1alpha/reflection.grpc.pb.cc \
|
||||
|
||||
PUBLIC_HEADERS_CXX += \
|
||||
|
||||
LIBGRPC++_REFLECTION_CODEGEN_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_REFLECTION_CODEGEN_SRC))))
|
||||
|
||||
|
||||
ifeq ($(NO_SECURE),true)
|
||||
|
||||
# You can't build secure libraries if you don't have OpenSSL.
|
||||
|
||||
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a: openssl_dep_error
|
||||
|
||||
|
||||
else
|
||||
|
||||
ifeq ($(NO_PROTOBUF),true)
|
||||
|
||||
# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay.
|
||||
|
||||
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a: protobuf_dep_error
|
||||
|
||||
|
||||
else
|
||||
|
||||
$(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_REFLECTION_CODEGEN_OBJS)
|
||||
$(E) "[AR] Creating $@"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a
|
||||
$(Q) $(AR) $(AROPTS) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a $(LIBGRPC++_REFLECTION_CODEGEN_OBJS)
|
||||
ifeq ($(SYSTEM),Darwin)
|
||||
$(Q) ranlib -no_warning_for_no_symbols $(LIBDIR)/$(CONFIG)/libgrpc++_reflection_codegen.a
|
||||
endif
|
||||
|
||||
|
||||
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
ifneq ($(NO_SECURE),true)
|
||||
ifneq ($(NO_DEPS),true)
|
||||
-include $(LIBGRPC++_REFLECTION_CODEGEN_OBJS:.o=.dep)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
LIBGRPC++_TEST_CONFIG_SRC = \
|
||||
test/cpp/util/test_config.cc \
|
||||
|
||||
|
|
@ -6341,6 +6539,7 @@ LIBEND2END_TESTS_SRC = \
|
|||
test/core/end2end/tests/default_host.c \
|
||||
test/core/end2end/tests/disappearing_server.c \
|
||||
test/core/end2end/tests/empty_batch.c \
|
||||
test/core/end2end/tests/filter_call_init_fails.c \
|
||||
test/core/end2end/tests/filter_causes_close.c \
|
||||
test/core/end2end/tests/graceful_server_shutdown.c \
|
||||
test/core/end2end/tests/high_initial_seqno.c \
|
||||
|
|
@ -6348,6 +6547,7 @@ LIBEND2END_TESTS_SRC = \
|
|||
test/core/end2end/tests/idempotent_request.c \
|
||||
test/core/end2end/tests/invoke_large_request.c \
|
||||
test/core/end2end/tests/large_metadata.c \
|
||||
test/core/end2end/tests/load_reporting_hook.c \
|
||||
test/core/end2end/tests/max_concurrent_streams.c \
|
||||
test/core/end2end/tests/max_message_length.c \
|
||||
test/core/end2end/tests/negative_deadline.c \
|
||||
|
|
@ -6419,6 +6619,7 @@ LIBEND2END_NOSEC_TESTS_SRC = \
|
|||
test/core/end2end/tests/default_host.c \
|
||||
test/core/end2end/tests/disappearing_server.c \
|
||||
test/core/end2end/tests/empty_batch.c \
|
||||
test/core/end2end/tests/filter_call_init_fails.c \
|
||||
test/core/end2end/tests/filter_causes_close.c \
|
||||
test/core/end2end/tests/graceful_server_shutdown.c \
|
||||
test/core/end2end/tests/high_initial_seqno.c \
|
||||
|
|
@ -6426,6 +6627,7 @@ LIBEND2END_NOSEC_TESTS_SRC = \
|
|||
test/core/end2end/tests/idempotent_request.c \
|
||||
test/core/end2end/tests/invoke_large_request.c \
|
||||
test/core/end2end/tests/large_metadata.c \
|
||||
test/core/end2end/tests/load_reporting_hook.c \
|
||||
test/core/end2end/tests/max_concurrent_streams.c \
|
||||
test/core/end2end/tests/max_message_length.c \
|
||||
test/core/end2end/tests/negative_deadline.c \
|
||||
|
|
@ -6760,6 +6962,38 @@ endif
|
|||
endif
|
||||
|
||||
|
||||
CENSUS_RESOURCE_TEST_SRC = \
|
||||
test/core/census/resource_test.c \
|
||||
|
||||
CENSUS_RESOURCE_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(CENSUS_RESOURCE_TEST_SRC))))
|
||||
ifeq ($(NO_SECURE),true)
|
||||
|
||||
# You can't build secure targets if you don't have OpenSSL.
|
||||
|
||||
$(BINDIR)/$(CONFIG)/census_resource_test: openssl_dep_error
|
||||
|
||||
else
|
||||
|
||||
|
||||
|
||||
$(BINDIR)/$(CONFIG)/census_resource_test: $(CENSUS_RESOURCE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
$(E) "[LD] Linking $@"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) $(LD) $(LDFLAGS) $(CENSUS_RESOURCE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/census_resource_test
|
||||
|
||||
endif
|
||||
|
||||
$(OBJDIR)/$(CONFIG)/test/core/census/resource_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
|
||||
deps_census_resource_test: $(CENSUS_RESOURCE_TEST_OBJS:.o=.dep)
|
||||
|
||||
ifneq ($(NO_SECURE),true)
|
||||
ifneq ($(NO_DEPS),true)
|
||||
-include $(CENSUS_RESOURCE_TEST_OBJS:.o=.dep)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
CHANNEL_CREATE_TEST_SRC = \
|
||||
test/core/surface/channel_create_test.c \
|
||||
|
||||
|
|
@ -9993,7 +10227,7 @@ endif
|
|||
|
||||
|
||||
TIMEOUT_ENCODING_TEST_SRC = \
|
||||
test/core/transport/chttp2/timeout_encoding_test.c \
|
||||
test/core/transport/timeout_encoding_test.c \
|
||||
|
||||
TIMEOUT_ENCODING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(TIMEOUT_ENCODING_TEST_SRC))))
|
||||
ifeq ($(NO_SECURE),true)
|
||||
|
|
@ -10013,7 +10247,7 @@ $(BINDIR)/$(CONFIG)/timeout_encoding_test: $(TIMEOUT_ENCODING_TEST_OBJS) $(LIBDI
|
|||
|
||||
endif
|
||||
|
||||
$(OBJDIR)/$(CONFIG)/test/core/transport/chttp2/timeout_encoding_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
$(OBJDIR)/$(CONFIG)/test/core/transport/timeout_encoding_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
|
||||
deps_timeout_encoding_test: $(TIMEOUT_ENCODING_TEST_OBJS:.o=.dep)
|
||||
|
||||
|
|
@ -11327,6 +11561,53 @@ endif
|
|||
$(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_api_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
|
||||
|
||||
|
||||
GRPCLB_TEST_SRC = \
|
||||
$(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc \
|
||||
test/cpp/grpclb/grpclb_test.cc \
|
||||
|
||||
GRPCLB_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GRPCLB_TEST_SRC))))
|
||||
ifeq ($(NO_SECURE),true)
|
||||
|
||||
# You can't build secure targets if you don't have OpenSSL.
|
||||
|
||||
$(BINDIR)/$(CONFIG)/grpclb_test: openssl_dep_error
|
||||
|
||||
else
|
||||
|
||||
|
||||
|
||||
|
||||
ifeq ($(NO_PROTOBUF),true)
|
||||
|
||||
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
|
||||
|
||||
$(BINDIR)/$(CONFIG)/grpclb_test: protobuf_dep_error
|
||||
|
||||
else
|
||||
|
||||
$(BINDIR)/$(CONFIG)/grpclb_test: $(PROTOBUF_DEP) $(GRPCLB_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a
|
||||
$(E) "[LD] Linking $@"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) $(LDXX) $(LDFLAGS) $(GRPCLB_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/grpclb_test
|
||||
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
$(OBJDIR)/$(CONFIG)/src/proto/grpc/lb/v1/load_balancer.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a
|
||||
|
||||
$(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_test.o: $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a
|
||||
|
||||
deps_grpclb_test: $(GRPCLB_TEST_OBJS:.o=.dep)
|
||||
|
||||
ifneq ($(NO_SECURE),true)
|
||||
ifneq ($(NO_DEPS),true)
|
||||
-include $(GRPCLB_TEST_OBJS:.o=.dep)
|
||||
endif
|
||||
endif
|
||||
$(OBJDIR)/$(CONFIG)/test/cpp/grpclb/grpclb_test.o: $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.pb.cc $(GENDIR)/src/proto/grpc/lb/v1/load_balancer.grpc.pb.cc
|
||||
|
||||
|
||||
HYBRID_END2END_TEST_SRC = \
|
||||
test/cpp/end2end/hybrid_end2end_test.cc \
|
||||
|
||||
|
|
@ -14001,34 +14282,34 @@ endif
|
|||
endif
|
||||
|
||||
|
||||
H2_LOADREPORTING_TEST_SRC = \
|
||||
test/core/end2end/fixtures/h2_loadreporting.c \
|
||||
H2_LOAD_REPORTING_TEST_SRC = \
|
||||
test/core/end2end/fixtures/h2_load_reporting.c \
|
||||
|
||||
H2_LOADREPORTING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_LOADREPORTING_TEST_SRC))))
|
||||
H2_LOAD_REPORTING_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_LOAD_REPORTING_TEST_SRC))))
|
||||
ifeq ($(NO_SECURE),true)
|
||||
|
||||
# You can't build secure targets if you don't have OpenSSL.
|
||||
|
||||
$(BINDIR)/$(CONFIG)/h2_loadreporting_test: openssl_dep_error
|
||||
$(BINDIR)/$(CONFIG)/h2_load_reporting_test: openssl_dep_error
|
||||
|
||||
else
|
||||
|
||||
|
||||
|
||||
$(BINDIR)/$(CONFIG)/h2_loadreporting_test: $(H2_LOADREPORTING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
$(BINDIR)/$(CONFIG)/h2_load_reporting_test: $(H2_LOAD_REPORTING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
$(E) "[LD] Linking $@"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) $(LD) $(LDFLAGS) $(H2_LOADREPORTING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_loadreporting_test
|
||||
$(Q) $(LD) $(LDFLAGS) $(H2_LOAD_REPORTING_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/h2_load_reporting_test
|
||||
|
||||
endif
|
||||
|
||||
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_loadreporting.o: $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_load_reporting.o: $(LIBDIR)/$(CONFIG)/libend2end_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
|
||||
deps_h2_loadreporting_test: $(H2_LOADREPORTING_TEST_OBJS:.o=.dep)
|
||||
deps_h2_load_reporting_test: $(H2_LOAD_REPORTING_TEST_OBJS:.o=.dep)
|
||||
|
||||
ifneq ($(NO_SECURE),true)
|
||||
ifneq ($(NO_DEPS),true)
|
||||
-include $(H2_LOADREPORTING_TEST_OBJS:.o=.dep)
|
||||
-include $(H2_LOAD_REPORTING_TEST_OBJS:.o=.dep)
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
@ -14441,23 +14722,23 @@ ifneq ($(NO_DEPS),true)
|
|||
endif
|
||||
|
||||
|
||||
H2_LOADREPORTING_NOSEC_TEST_SRC = \
|
||||
test/core/end2end/fixtures/h2_loadreporting.c \
|
||||
H2_LOAD_REPORTING_NOSEC_TEST_SRC = \
|
||||
test/core/end2end/fixtures/h2_load_reporting.c \
|
||||
|
||||
H2_LOADREPORTING_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_LOADREPORTING_NOSEC_TEST_SRC))))
|
||||
H2_LOAD_REPORTING_NOSEC_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(H2_LOAD_REPORTING_NOSEC_TEST_SRC))))
|
||||
|
||||
|
||||
$(BINDIR)/$(CONFIG)/h2_loadreporting_nosec_test: $(H2_LOADREPORTING_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
$(BINDIR)/$(CONFIG)/h2_load_reporting_nosec_test: $(H2_LOAD_REPORTING_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
$(E) "[LD] Linking $@"
|
||||
$(Q) mkdir -p `dirname $@`
|
||||
$(Q) $(LD) $(LDFLAGS) $(H2_LOADREPORTING_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_loadreporting_nosec_test
|
||||
$(Q) $(LD) $(LDFLAGS) $(H2_LOAD_REPORTING_NOSEC_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) -o $(BINDIR)/$(CONFIG)/h2_load_reporting_nosec_test
|
||||
|
||||
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_loadreporting.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
$(OBJDIR)/$(CONFIG)/test/core/end2end/fixtures/h2_load_reporting.o: $(LIBDIR)/$(CONFIG)/libend2end_nosec_tests.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libgrpc_unsecure.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
|
||||
|
||||
deps_h2_loadreporting_nosec_test: $(H2_LOADREPORTING_NOSEC_TEST_OBJS:.o=.dep)
|
||||
deps_h2_load_reporting_nosec_test: $(H2_LOAD_REPORTING_NOSEC_TEST_OBJS:.o=.dep)
|
||||
|
||||
ifneq ($(NO_DEPS),true)
|
||||
-include $(H2_LOADREPORTING_NOSEC_TEST_OBJS:.o=.dep)
|
||||
-include $(H2_LOAD_REPORTING_NOSEC_TEST_OBJS:.o=.dep)
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ graft include/grpc
|
|||
graft third_party/boringssl
|
||||
graft third_party/nanopb
|
||||
graft third_party/zlib
|
||||
include src/python/grpcio/build.py
|
||||
include src/python/grpcio/_unixccompiler_patch.py
|
||||
include src/python/grpcio/commands.py
|
||||
include src/python/grpcio/grpc_version.py
|
||||
include src/python/grpcio/grpc_core_dependencies.py
|
||||
|
|
|
|||
2
Rakefile
2
Rakefile
|
|
@ -83,7 +83,7 @@ task 'dlls' do
|
|||
env += 'EMBED_ZLIB=true '
|
||||
env += 'BUILDDIR=/tmp '
|
||||
env += "V=#{verbose} "
|
||||
out = '/tmp/libs/opt/grpc-0.dll'
|
||||
out = '/tmp/libs/opt/grpc-1.dll'
|
||||
|
||||
w64 = { cross: 'x86_64-w64-mingw32', out: 'grpc_c.64.ruby' }
|
||||
w32 = { cross: 'i686-w64-mingw32', out: 'grpc_c.32.ruby' }
|
||||
|
|
|
|||
|
|
@ -569,6 +569,7 @@
|
|||
'src/core/lib/channel/channel_stack_builder.c',
|
||||
'src/core/lib/channel/compress_filter.c',
|
||||
'src/core/lib/channel/connected_channel.c',
|
||||
'src/core/lib/channel/handshaker.c',
|
||||
'src/core/lib/channel/http_client_filter.c',
|
||||
'src/core/lib/channel/http_server_filter.c',
|
||||
'src/core/lib/compression/compression.c',
|
||||
|
|
@ -650,6 +651,7 @@
|
|||
'src/core/lib/transport/metadata.c',
|
||||
'src/core/lib/transport/metadata_batch.c',
|
||||
'src/core/lib/transport/static_metadata.c',
|
||||
'src/core/lib/transport/timeout_encoding.c',
|
||||
'src/core/lib/transport/transport.c',
|
||||
'src/core/lib/transport/transport_op_string.c',
|
||||
'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
|
||||
|
|
@ -672,7 +674,6 @@
|
|||
'src/core/ext/transport/chttp2/transport/status_conversion.c',
|
||||
'src/core/ext/transport/chttp2/transport/stream_lists.c',
|
||||
'src/core/ext/transport/chttp2/transport/stream_map.c',
|
||||
'src/core/ext/transport/chttp2/transport/timeout_encoding.c',
|
||||
'src/core/ext/transport/chttp2/transport/varint.c',
|
||||
'src/core/ext/transport/chttp2/transport/writing.c',
|
||||
'src/core/ext/transport/chttp2/alpn/alpn.c',
|
||||
|
|
@ -728,6 +729,7 @@
|
|||
'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
|
||||
'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
|
||||
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
|
||||
'src/core/ext/lb_policy/grpclb/grpclb.c',
|
||||
'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
|
||||
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
|
||||
'third_party/nanopb/pb_common.c',
|
||||
|
|
@ -739,6 +741,7 @@
|
|||
'src/core/ext/resolver/sockaddr/sockaddr_resolver.c',
|
||||
'src/core/ext/load_reporting/load_reporting.c',
|
||||
'src/core/ext/load_reporting/load_reporting_filter.c',
|
||||
'src/core/ext/census/base_resources.c',
|
||||
'src/core/ext/census/context.c',
|
||||
'src/core/ext/census/gen/census.pb.c',
|
||||
'src/core/ext/census/grpc_context.c',
|
||||
|
|
@ -748,6 +751,7 @@
|
|||
'src/core/ext/census/mlog.c',
|
||||
'src/core/ext/census/operation.c',
|
||||
'src/core/ext/census/placeholders.c',
|
||||
'src/core/ext/census/resource.c',
|
||||
'src/core/ext/census/tracing.c',
|
||||
'src/core/plugin_registry/grpc_plugin_registry.c',
|
||||
],
|
||||
|
|
|
|||
64
build.yaml
64
build.yaml
|
|
@ -14,13 +14,16 @@ filegroups:
|
|||
- include/grpc/census.h
|
||||
headers:
|
||||
- src/core/ext/census/aggregation.h
|
||||
- src/core/ext/census/base_resources.h
|
||||
- src/core/ext/census/census_interface.h
|
||||
- src/core/ext/census/census_rpc_stats.h
|
||||
- src/core/ext/census/gen/census.pb.h
|
||||
- src/core/ext/census/grpc_filter.h
|
||||
- src/core/ext/census/mlog.h
|
||||
- src/core/ext/census/resource.h
|
||||
- src/core/ext/census/rpc_metric_id.h
|
||||
src:
|
||||
- src/core/ext/census/base_resources.c
|
||||
- src/core/ext/census/context.c
|
||||
- src/core/ext/census/gen/census.pb.c
|
||||
- src/core/ext/census/grpc_context.c
|
||||
|
|
@ -30,6 +33,7 @@ filegroups:
|
|||
- src/core/ext/census/mlog.c
|
||||
- src/core/ext/census/operation.c
|
||||
- src/core/ext/census/placeholders.c
|
||||
- src/core/ext/census/resource.c
|
||||
- src/core/ext/census/tracing.c
|
||||
plugin: census_grpc_plugin
|
||||
uses:
|
||||
|
|
@ -158,6 +162,7 @@ filegroups:
|
|||
- src/core/lib/channel/compress_filter.h
|
||||
- src/core/lib/channel/connected_channel.h
|
||||
- src/core/lib/channel/context.h
|
||||
- src/core/lib/channel/handshaker.h
|
||||
- src/core/lib/channel/http_client_filter.h
|
||||
- src/core/lib/channel/http_server_filter.h
|
||||
- src/core/lib/compression/algorithm_metadata.h
|
||||
|
|
@ -229,6 +234,7 @@ filegroups:
|
|||
- src/core/lib/transport/metadata.h
|
||||
- src/core/lib/transport/metadata_batch.h
|
||||
- src/core/lib/transport/static_metadata.h
|
||||
- src/core/lib/transport/timeout_encoding.h
|
||||
- src/core/lib/transport/transport.h
|
||||
- src/core/lib/transport/transport_impl.h
|
||||
src:
|
||||
|
|
@ -237,6 +243,7 @@ filegroups:
|
|||
- src/core/lib/channel/channel_stack_builder.c
|
||||
- src/core/lib/channel/compress_filter.c
|
||||
- src/core/lib/channel/connected_channel.c
|
||||
- src/core/lib/channel/handshaker.c
|
||||
- src/core/lib/channel/http_client_filter.c
|
||||
- src/core/lib/channel/http_server_filter.c
|
||||
- src/core/lib/compression/compression.c
|
||||
|
|
@ -318,6 +325,7 @@ filegroups:
|
|||
- src/core/lib/transport/metadata.c
|
||||
- src/core/lib/transport/metadata_batch.c
|
||||
- src/core/lib/transport/static_metadata.c
|
||||
- src/core/lib/transport/timeout_encoding.c
|
||||
- src/core/lib/transport/transport.c
|
||||
- src/core/lib/transport/transport_op_string.c
|
||||
deps:
|
||||
|
|
@ -378,11 +386,14 @@ filegroups:
|
|||
- gpr_codegen
|
||||
- name: grpc_lb_policy_grpclb
|
||||
headers:
|
||||
- src/core/ext/lb_policy/grpclb/grpclb.h
|
||||
- src/core/ext/lb_policy/grpclb/load_balancer_api.h
|
||||
- src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h
|
||||
src:
|
||||
- src/core/ext/lb_policy/grpclb/grpclb.c
|
||||
- src/core/ext/lb_policy/grpclb/load_balancer_api.c
|
||||
- src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c
|
||||
plugin: grpc_lb_policy_grpclb
|
||||
uses:
|
||||
- grpc_base
|
||||
- grpc_client_config
|
||||
|
|
@ -531,7 +542,6 @@ filegroups:
|
|||
- src/core/ext/transport/chttp2/transport/internal.h
|
||||
- src/core/ext/transport/chttp2/transport/status_conversion.h
|
||||
- src/core/ext/transport/chttp2/transport/stream_map.h
|
||||
- src/core/ext/transport/chttp2/transport/timeout_encoding.h
|
||||
- src/core/ext/transport/chttp2/transport/varint.h
|
||||
src:
|
||||
- src/core/ext/transport/chttp2/transport/bin_decoder.c
|
||||
|
|
@ -553,7 +563,6 @@ filegroups:
|
|||
- src/core/ext/transport/chttp2/transport/status_conversion.c
|
||||
- src/core/ext/transport/chttp2/transport/stream_lists.c
|
||||
- src/core/ext/transport/chttp2/transport/stream_map.c
|
||||
- src/core/ext/transport/chttp2/transport/timeout_encoding.c
|
||||
- src/core/ext/transport/chttp2/transport/varint.c
|
||||
- src/core/ext/transport/chttp2/transport/writing.c
|
||||
plugin: grpc_chttp2_plugin
|
||||
|
|
@ -772,6 +781,16 @@ filegroups:
|
|||
language: c++
|
||||
public_headers:
|
||||
- include/grpc++/impl/codegen/config_protobuf.h
|
||||
- name: grpc++_reflection_proto
|
||||
language: c++
|
||||
public_headers:
|
||||
- include/grpc++/ext/reflection.grpc.pb.h
|
||||
- include/grpc++/ext/reflection.pb.h
|
||||
src:
|
||||
- src/cpp/ext/reflection.grpc.pb.cc
|
||||
- src/cpp/ext/reflection.pb.cc
|
||||
uses:
|
||||
- grpc++_codegen_proto
|
||||
libs:
|
||||
- name: gpr
|
||||
build: all
|
||||
|
|
@ -808,6 +827,7 @@ libs:
|
|||
- grpc_lb_policy_grpclb
|
||||
- grpc_lb_policy_pick_first
|
||||
- grpc_lb_policy_round_robin
|
||||
- grpc_lb_policy_grpclb
|
||||
- grpc_resolver_dns_native
|
||||
- grpc_resolver_sockaddr
|
||||
- grpc_load_reporting
|
||||
|
|
@ -874,6 +894,7 @@ libs:
|
|||
- grpc
|
||||
filegroups:
|
||||
- grpc_test_util_base
|
||||
- grpc_base
|
||||
vs_project_guid: '{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}'
|
||||
- name: grpc_test_util_unsecure
|
||||
build: private
|
||||
|
|
@ -905,6 +926,7 @@ libs:
|
|||
- grpc_lb_policy_grpclb
|
||||
- grpc_lb_policy_pick_first
|
||||
- grpc_lb_policy_round_robin
|
||||
- grpc_lb_policy_grpclb
|
||||
- census
|
||||
generate_plugin_registry: true
|
||||
secure: false
|
||||
|
|
@ -964,19 +986,20 @@ libs:
|
|||
language: c++
|
||||
public_headers:
|
||||
- include/grpc++/ext/proto_server_reflection_plugin.h
|
||||
- include/grpc++/ext/reflection.grpc.pb.h
|
||||
- include/grpc++/ext/reflection.pb.h
|
||||
headers:
|
||||
- src/cpp/ext/proto_server_reflection.h
|
||||
src:
|
||||
- src/cpp/ext/proto_server_reflection.cc
|
||||
- src/cpp/ext/proto_server_reflection_plugin.cc
|
||||
- src/cpp/ext/reflection.grpc.pb.cc
|
||||
- src/cpp/ext/reflection.pb.cc
|
||||
deps:
|
||||
- grpc++
|
||||
filegroups:
|
||||
- grpc++_codegen_proto
|
||||
- grpc++_reflection_proto
|
||||
- name: grpc++_reflection_codegen
|
||||
build: private
|
||||
language: c++
|
||||
src:
|
||||
- src/proto/grpc/reflection/v1alpha/reflection.proto
|
||||
- name: grpc++_test_config
|
||||
build: private
|
||||
language: c++
|
||||
|
|
@ -1286,6 +1309,16 @@ targets:
|
|||
- grpc
|
||||
- gpr_test_util
|
||||
- gpr
|
||||
- name: census_resource_test
|
||||
build: test
|
||||
language: c
|
||||
src:
|
||||
- test/core/census/resource_test.c
|
||||
deps:
|
||||
- grpc_test_util
|
||||
- grpc
|
||||
- gpr_test_util
|
||||
- gpr
|
||||
- name: channel_create_test
|
||||
build: test
|
||||
language: c
|
||||
|
|
@ -2360,7 +2393,7 @@ targets:
|
|||
build: test
|
||||
language: c
|
||||
src:
|
||||
- test/core/transport/chttp2/timeout_encoding_test.c
|
||||
- test/core/transport/timeout_encoding_test.c
|
||||
deps:
|
||||
- grpc_test_util
|
||||
- grpc
|
||||
|
|
@ -2761,6 +2794,20 @@ targets:
|
|||
- grpc_test_util
|
||||
- grpc++
|
||||
- grpc
|
||||
- name: grpclb_test
|
||||
gtest: false
|
||||
build: test
|
||||
language: c++
|
||||
src:
|
||||
- src/proto/grpc/lb/v1/load_balancer.proto
|
||||
- test/cpp/grpclb/grpclb_test.cc
|
||||
deps:
|
||||
- gpr
|
||||
- gpr_test_util
|
||||
- grpc
|
||||
- grpc++
|
||||
- grpc++_test_util
|
||||
- grpc_test_util
|
||||
- name: hybrid_end2end_test
|
||||
gtest: true
|
||||
build: test
|
||||
|
|
@ -3381,6 +3428,7 @@ php_config_m4:
|
|||
- src/php/ext/grpc/channel.h
|
||||
- src/php/ext/grpc/channel_credentials.h
|
||||
- src/php/ext/grpc/completion_queue.h
|
||||
- src/php/ext/grpc/php7_wrapper.h
|
||||
- src/php/ext/grpc/php_grpc.h
|
||||
- src/php/ext/grpc/server.h
|
||||
- src/php/ext/grpc/server_credentials.h
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ if test "$PHP_GRPC" != "no"; then
|
|||
src/core/lib/channel/channel_stack_builder.c \
|
||||
src/core/lib/channel/compress_filter.c \
|
||||
src/core/lib/channel/connected_channel.c \
|
||||
src/core/lib/channel/handshaker.c \
|
||||
src/core/lib/channel/http_client_filter.c \
|
||||
src/core/lib/channel/http_server_filter.c \
|
||||
src/core/lib/compression/compression.c \
|
||||
|
|
@ -169,6 +170,7 @@ if test "$PHP_GRPC" != "no"; then
|
|||
src/core/lib/transport/metadata.c \
|
||||
src/core/lib/transport/metadata_batch.c \
|
||||
src/core/lib/transport/static_metadata.c \
|
||||
src/core/lib/transport/timeout_encoding.c \
|
||||
src/core/lib/transport/transport.c \
|
||||
src/core/lib/transport/transport_op_string.c \
|
||||
src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c \
|
||||
|
|
@ -191,7 +193,6 @@ if test "$PHP_GRPC" != "no"; then
|
|||
src/core/ext/transport/chttp2/transport/status_conversion.c \
|
||||
src/core/ext/transport/chttp2/transport/stream_lists.c \
|
||||
src/core/ext/transport/chttp2/transport/stream_map.c \
|
||||
src/core/ext/transport/chttp2/transport/timeout_encoding.c \
|
||||
src/core/ext/transport/chttp2/transport/varint.c \
|
||||
src/core/ext/transport/chttp2/transport/writing.c \
|
||||
src/core/ext/transport/chttp2/alpn/alpn.c \
|
||||
|
|
@ -247,6 +248,7 @@ if test "$PHP_GRPC" != "no"; then
|
|||
src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \
|
||||
src/core/ext/transport/chttp2/client/insecure/channel_create.c \
|
||||
src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \
|
||||
src/core/ext/lb_policy/grpclb/grpclb.c \
|
||||
src/core/ext/lb_policy/grpclb/load_balancer_api.c \
|
||||
src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c \
|
||||
third_party/nanopb/pb_common.c \
|
||||
|
|
@ -258,6 +260,7 @@ if test "$PHP_GRPC" != "no"; then
|
|||
src/core/ext/resolver/sockaddr/sockaddr_resolver.c \
|
||||
src/core/ext/load_reporting/load_reporting.c \
|
||||
src/core/ext/load_reporting/load_reporting_filter.c \
|
||||
src/core/ext/census/base_resources.c \
|
||||
src/core/ext/census/context.c \
|
||||
src/core/ext/census/gen/census.pb.c \
|
||||
src/core/ext/census/grpc_context.c \
|
||||
|
|
@ -267,6 +270,7 @@ if test "$PHP_GRPC" != "no"; then
|
|||
src/core/ext/census/mlog.c \
|
||||
src/core/ext/census/operation.c \
|
||||
src/core/ext/census/placeholders.c \
|
||||
src/core/ext/census/resource.c \
|
||||
src/core/ext/census/tracing.c \
|
||||
src/core/plugin_registry/grpc_plugin_registry.c \
|
||||
src/boringssl/err_data.c \
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
build/
|
||||
src/
|
||||
1293
etc/roots.pem
1293
etc/roots.pem
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,49 @@
|
|||
# Minimum CMake required
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
# Project
|
||||
project(HelloWorld CXX)
|
||||
|
||||
# Protobuf
|
||||
set(protobuf_MODULE_COMPATIBLE TRUE)
|
||||
find_package(protobuf CONFIG REQUIRED)
|
||||
message(STATUS "Using protobuf ${protobuf_VERSION}")
|
||||
|
||||
# gRPC
|
||||
find_package(gRPC CONFIG REQUIRED)
|
||||
message(STATUS "Using gRPC ${gRPC_VERSION}")
|
||||
|
||||
# gRPC C++ plugin
|
||||
get_target_property(gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin
|
||||
IMPORTED_LOCATION_RELEASE)
|
||||
|
||||
# Proto file
|
||||
get_filename_component(hw_proto "../../protos/helloworld.proto" ABSOLUTE)
|
||||
get_filename_component(hw_proto_path "${hw_proto}" PATH)
|
||||
|
||||
# Generated sources
|
||||
protobuf_generate_cpp(hw_proto_srcs hw_proto_hdrs "${hw_proto}")
|
||||
set(hw_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc")
|
||||
set(hw_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.h")
|
||||
add_custom_command(
|
||||
OUTPUT "${hw_grpc_srcs}" "${hw_grpc_hdrs}"
|
||||
COMMAND protobuf::protoc
|
||||
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}" -I "${hw_proto_path}"
|
||||
--plugin=protoc-gen-grpc="${gRPC_CPP_PLUGIN_EXECUTABLE}"
|
||||
"${hw_proto}"
|
||||
DEPENDS "${hw_proto}")
|
||||
|
||||
# Generated include directory
|
||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# Targets greeter_[async_](client|server)
|
||||
foreach(_target
|
||||
greeter_client greeter_server
|
||||
greeter_async_client greeter_async_server)
|
||||
add_executable(${_target} "${_target}.cc"
|
||||
${hw_proto_srcs}
|
||||
${hw_grpc_srcs})
|
||||
target_link_libraries(${_target}
|
||||
protobuf::libprotobuf
|
||||
gRPC::grpc++_unsecure)
|
||||
endforeach()
|
||||
|
|
@ -29,10 +29,20 @@
|
|||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
|
||||
SYSTEM ?= $(HOST_SYSTEM)
|
||||
CXX = g++
|
||||
CPPFLAGS += -I/usr/local/include -pthread
|
||||
CXXFLAGS += -std=c++11
|
||||
LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++ grpc` -lprotobuf -lpthread -ldl
|
||||
ifeq ($(SYSTEM),Darwin)
|
||||
LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++ grpc` \
|
||||
-lgrpc++_reflection \
|
||||
-lprotobuf -lpthread -ldl
|
||||
else
|
||||
LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++ grpc` \
|
||||
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed \
|
||||
-lprotobuf -lpthread -ldl
|
||||
endif
|
||||
PROTOC = protoc
|
||||
GRPC_CPP_PLUGIN = grpc_cpp_plugin
|
||||
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
|
||||
|
|
|
|||
|
|
@ -29,10 +29,20 @@
|
|||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
HOST_SYSTEM = $(shell uname | cut -f 1 -d_)
|
||||
SYSTEM ?= $(HOST_SYSTEM)
|
||||
CXX = g++
|
||||
CPPFLAGS += -I/usr/local/include -pthread
|
||||
CXXFLAGS += -std=c++11
|
||||
LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++` -lprotobuf -lpthread -ldl
|
||||
ifeq ($(SYSTEM),Darwin)
|
||||
LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++` \
|
||||
-lgrpc++_reflection \
|
||||
-lprotobuf -lpthread -ldl
|
||||
else
|
||||
LDFLAGS += -L/usr/local/lib `pkg-config --libs grpc++` \
|
||||
-Wl,--no-as-needed -lgrpc++_reflection -Wl,--as-needed \
|
||||
-lprotobuf -lpthread -ldl
|
||||
endif
|
||||
PROTOC = protoc
|
||||
GRPC_CPP_PLUGIN = grpc_cpp_plugin
|
||||
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
|||
src = "../../protos"
|
||||
|
||||
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
|
||||
s.dependency "!ProtoCompiler-gRPCPlugin", "~> 0.14"
|
||||
s.dependency "!ProtoCompiler-gRPCPlugin", "~> 1.0.0-pre1"
|
||||
|
||||
# Pods directory corresponding to this app's Podfile, relative to the location of this podspec.
|
||||
pods_root = 'Pods'
|
||||
|
|
|
|||
|
|
@ -2,9 +2,39 @@
|
|||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AD_UNIT_ID_FOR_BANNER_TEST</key>
|
||||
<string>redacted</string>
|
||||
<key>AD_UNIT_ID_FOR_INTERSTITIAL_TEST</key>
|
||||
<string>redacted</string>
|
||||
<key>CLIENT_ID</key>
|
||||
<string>15087385131-lh9bpkiai9nls53uadju0if6k7un3uih.apps.googleusercontent.com</string>
|
||||
<key>REVERSED_CLIENT_ID</key>
|
||||
<string>com.googleusercontent.apps.15087385131-lh9bpkiai9nls53uadju0if6k7un3uih</string>
|
||||
<key>API_KEY</key>
|
||||
<string>redacted</string>
|
||||
<key>GCM_SENDER_ID</key>
|
||||
<string>redacted</string>
|
||||
<key>PLIST_VERSION</key>
|
||||
<string>1</string>
|
||||
<key>BUNDLE_ID</key>
|
||||
<string>io.grpc.AuthSample</string>
|
||||
<key>PROJECT_ID</key>
|
||||
<string>grpc-authsample</string>
|
||||
<key>STORAGE_BUCKET</key>
|
||||
<string>grpc-authsample.appspot.com</string>
|
||||
<key>IS_ADS_ENABLED</key>
|
||||
<false/>
|
||||
<key>IS_ANALYTICS_ENABLED</key>
|
||||
<false/>
|
||||
<key>IS_APPINVITE_ENABLED</key>
|
||||
<false/>
|
||||
<key>IS_GCM_ENABLED</key>
|
||||
<false/>
|
||||
<key>IS_SIGNIN_ENABLED</key>
|
||||
<true/>
|
||||
<key>GOOGLE_APP_ID</key>
|
||||
<string>1:15087385131:ios:d547168abe3c362f</string>
|
||||
<key>DATABASE_URL</key>
|
||||
<string>https://grpc-authsample.firebaseio.com</string>
|
||||
</dict>
|
||||
</plist>
|
||||
</plist>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
|||
src = "../../protos"
|
||||
|
||||
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
|
||||
s.dependency "!ProtoCompiler-gRPCPlugin", "~> 0.14"
|
||||
s.dependency "!ProtoCompiler-gRPCPlugin", "~> 1.0.0-pre1"
|
||||
|
||||
# Pods directory corresponding to this app's Podfile, relative to the location of this podspec.
|
||||
pods_root = 'Pods'
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
|||
src = "../../protos"
|
||||
|
||||
# Run protoc with the Objective-C and gRPC plugins to generate protocol messages and gRPC clients.
|
||||
s.dependency "!ProtoCompiler-gRPCPlugin", "~> 0.14"
|
||||
s.dependency "!ProtoCompiler-gRPCPlugin", "~> 1.0.0-pre1"
|
||||
|
||||
# Pods directory corresponding to this app's Podfile, relative to the location of this podspec.
|
||||
pods_root = 'Pods'
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@
|
|||
"description": "gRPC example for PHP",
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"grpc/grpc": "v0.15.0"
|
||||
"grpc/grpc": "v0.15.2"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,17 +31,15 @@
|
|||
|
||||
from __future__ import print_function
|
||||
|
||||
from grpc.beta import implementations
|
||||
import grpc
|
||||
|
||||
import helloworld_pb2
|
||||
|
||||
_TIMEOUT_SECONDS = 10
|
||||
|
||||
|
||||
def run():
|
||||
channel = implementations.insecure_channel('localhost', 50051)
|
||||
stub = helloworld_pb2.beta_create_Greeter_stub(channel)
|
||||
response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'), _TIMEOUT_SECONDS)
|
||||
channel = grpc.insecure_channel('localhost:50051')
|
||||
stub = helloworld_pb2.GreeterStub(channel)
|
||||
response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
|
||||
print("Greeter client received: " + response.message)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,21 +29,25 @@
|
|||
|
||||
"""The Python implementation of the GRPC helloworld.Greeter server."""
|
||||
|
||||
from concurrent import futures
|
||||
import time
|
||||
|
||||
import grpc
|
||||
|
||||
import helloworld_pb2
|
||||
|
||||
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
|
||||
|
||||
|
||||
class Greeter(helloworld_pb2.BetaGreeterServicer):
|
||||
class Greeter(helloworld_pb2.GreeterServicer):
|
||||
|
||||
def SayHello(self, request, context):
|
||||
return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
|
||||
|
||||
|
||||
def serve():
|
||||
server = helloworld_pb2.beta_create_Greeter_server(Greeter())
|
||||
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
|
||||
helloworld_pb2.add_GreeterServicer_to_server(Greeter(), server)
|
||||
server.add_insecure_port('[::]:50051')
|
||||
server.start()
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -107,13 +107,55 @@ _sym_db.RegisterMessage(HelloReply)
|
|||
|
||||
DESCRIPTOR.has_options = True
|
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW'))
|
||||
import abc
|
||||
import six
|
||||
import grpc
|
||||
from grpc.beta import implementations as beta_implementations
|
||||
from grpc.beta import interfaces as beta_interfaces
|
||||
from grpc.framework.common import cardinality
|
||||
from grpc.framework.interfaces.face import utilities as face_utilities
|
||||
|
||||
|
||||
class GreeterStub(object):
|
||||
"""The greeting service definition.
|
||||
"""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.SayHello = channel.unary_unary(
|
||||
'/helloworld.Greeter/SayHello',
|
||||
request_serializer=HelloRequest.SerializeToString,
|
||||
response_deserializer=HelloReply.FromString,
|
||||
)
|
||||
|
||||
|
||||
class GreeterServicer(object):
|
||||
"""The greeting service definition.
|
||||
"""
|
||||
|
||||
def SayHello(self, request, context):
|
||||
"""Sends a greeting
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'SayHello': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.SayHello,
|
||||
request_deserializer=HelloRequest.FromString,
|
||||
response_serializer=HelloReply.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'helloworld.Greeter', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
class BetaGreeterServicer(object):
|
||||
"""The greeting service definition.
|
||||
"""
|
||||
|
|
@ -122,23 +164,23 @@ class BetaGreeterServicer(object):
|
|||
"""
|
||||
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
|
||||
|
||||
|
||||
class BetaGreeterStub(object):
|
||||
"""The greeting service definition.
|
||||
"""
|
||||
def SayHello(self, request, timeout):
|
||||
def SayHello(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""Sends a greeting
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
SayHello.future = None
|
||||
|
||||
|
||||
def beta_create_Greeter_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None):
|
||||
import helloworld_pb2
|
||||
import helloworld_pb2
|
||||
request_deserializers = {
|
||||
('helloworld.Greeter', 'SayHello'): helloworld_pb2.HelloRequest.FromString,
|
||||
('helloworld.Greeter', 'SayHello'): HelloRequest.FromString,
|
||||
}
|
||||
response_serializers = {
|
||||
('helloworld.Greeter', 'SayHello'): helloworld_pb2.HelloReply.SerializeToString,
|
||||
('helloworld.Greeter', 'SayHello'): HelloReply.SerializeToString,
|
||||
}
|
||||
method_implementations = {
|
||||
('helloworld.Greeter', 'SayHello'): face_utilities.unary_unary_inline(servicer.SayHello),
|
||||
|
|
@ -146,14 +188,13 @@ def beta_create_Greeter_server(servicer, pool=None, pool_size=None, default_time
|
|||
server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout)
|
||||
return beta_implementations.server(method_implementations, options=server_options)
|
||||
|
||||
|
||||
def beta_create_Greeter_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None):
|
||||
import helloworld_pb2
|
||||
import helloworld_pb2
|
||||
request_serializers = {
|
||||
('helloworld.Greeter', 'SayHello'): helloworld_pb2.HelloRequest.SerializeToString,
|
||||
('helloworld.Greeter', 'SayHello'): HelloRequest.SerializeToString,
|
||||
}
|
||||
response_deserializers = {
|
||||
('helloworld.Greeter', 'SayHello'): helloworld_pb2.HelloReply.FromString,
|
||||
('helloworld.Greeter', 'SayHello'): HelloReply.FromString,
|
||||
}
|
||||
cardinalities = {
|
||||
'SayHello': cardinality.Cardinality.UNARY_UNARY,
|
||||
|
|
|
|||
16
examples/python/route_guide/run_codegen.sh → examples/python/helloworld/run_codegen.py
Executable file → Normal file
16
examples/python/route_guide/run_codegen.sh → examples/python/helloworld/run_codegen.py
Executable file → Normal file
|
|
@ -1,4 +1,3 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2015, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
|
@ -28,5 +27,16 @@
|
|||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# Runs the protoc with gRPC plugin to generate protocol messages and gRPC stubs.
|
||||
python -m grpc.tools.protoc -I../../protos --python_out=. --grpc_python_out=. ../../protos/route_guide.proto
|
||||
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs."""
|
||||
|
||||
from grpc.tools import protoc
|
||||
|
||||
protoc.main(
|
||||
(
|
||||
'',
|
||||
'-I../../protos',
|
||||
'--python_out=.',
|
||||
'--grpc_python_out=.',
|
||||
'../../protos/helloworld.proto',
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1 @@
|
|||
*.pyc
|
||||
|
|
@ -0,0 +1 @@
|
|||
An example showing two stubs sharing a channel and two servicers sharing a server.
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: helloworld.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='helloworld.proto',
|
||||
package='helloworld',
|
||||
syntax='proto3',
|
||||
serialized_pb=_b('\n\x10helloworld.proto\x12\nhelloworld\"\x1c\n\x0cHelloRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\x1d\n\nHelloReply\x12\x0f\n\x07message\x18\x01 \x01(\t2I\n\x07Greeter\x12>\n\x08SayHello\x12\x18.helloworld.HelloRequest\x1a\x16.helloworld.HelloReply\"\x00\x42\x36\n\x1bio.grpc.examples.helloworldB\x0fHelloWorldProtoP\x01\xa2\x02\x03HLWb\x06proto3')
|
||||
)
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
|
||||
|
||||
|
||||
_HELLOREQUEST = _descriptor.Descriptor(
|
||||
name='HelloRequest',
|
||||
full_name='helloworld.HelloRequest',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='name', full_name='helloworld.HelloRequest.name', index=0,
|
||||
number=1, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=32,
|
||||
serialized_end=60,
|
||||
)
|
||||
|
||||
|
||||
_HELLOREPLY = _descriptor.Descriptor(
|
||||
name='HelloReply',
|
||||
full_name='helloworld.HelloReply',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='message', full_name='helloworld.HelloReply.message', index=0,
|
||||
number=1, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=62,
|
||||
serialized_end=91,
|
||||
)
|
||||
|
||||
DESCRIPTOR.message_types_by_name['HelloRequest'] = _HELLOREQUEST
|
||||
DESCRIPTOR.message_types_by_name['HelloReply'] = _HELLOREPLY
|
||||
|
||||
HelloRequest = _reflection.GeneratedProtocolMessageType('HelloRequest', (_message.Message,), dict(
|
||||
DESCRIPTOR = _HELLOREQUEST,
|
||||
__module__ = 'helloworld_pb2'
|
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloRequest)
|
||||
))
|
||||
_sym_db.RegisterMessage(HelloRequest)
|
||||
|
||||
HelloReply = _reflection.GeneratedProtocolMessageType('HelloReply', (_message.Message,), dict(
|
||||
DESCRIPTOR = _HELLOREPLY,
|
||||
__module__ = 'helloworld_pb2'
|
||||
# @@protoc_insertion_point(class_scope:helloworld.HelloReply)
|
||||
))
|
||||
_sym_db.RegisterMessage(HelloReply)
|
||||
|
||||
|
||||
DESCRIPTOR.has_options = True
|
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.helloworldB\017HelloWorldProtoP\001\242\002\003HLW'))
|
||||
import grpc
|
||||
from grpc.beta import implementations as beta_implementations
|
||||
from grpc.beta import interfaces as beta_interfaces
|
||||
from grpc.framework.common import cardinality
|
||||
from grpc.framework.interfaces.face import utilities as face_utilities
|
||||
|
||||
|
||||
class GreeterStub(object):
|
||||
"""The greeting service definition.
|
||||
"""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.SayHello = channel.unary_unary(
|
||||
'/helloworld.Greeter/SayHello',
|
||||
request_serializer=HelloRequest.SerializeToString,
|
||||
response_deserializer=HelloReply.FromString,
|
||||
)
|
||||
|
||||
|
||||
class GreeterServicer(object):
|
||||
"""The greeting service definition.
|
||||
"""
|
||||
|
||||
def SayHello(self, request, context):
|
||||
"""Sends a greeting
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_GreeterServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'SayHello': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.SayHello,
|
||||
request_deserializer=HelloRequest.FromString,
|
||||
response_serializer=HelloReply.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'helloworld.Greeter', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
class BetaGreeterServicer(object):
|
||||
"""The greeting service definition.
|
||||
"""
|
||||
def SayHello(self, request, context):
|
||||
"""Sends a greeting
|
||||
"""
|
||||
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
|
||||
|
||||
|
||||
class BetaGreeterStub(object):
|
||||
"""The greeting service definition.
|
||||
"""
|
||||
def SayHello(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""Sends a greeting
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
SayHello.future = None
|
||||
|
||||
|
||||
def beta_create_Greeter_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None):
|
||||
request_deserializers = {
|
||||
('helloworld.Greeter', 'SayHello'): HelloRequest.FromString,
|
||||
}
|
||||
response_serializers = {
|
||||
('helloworld.Greeter', 'SayHello'): HelloReply.SerializeToString,
|
||||
}
|
||||
method_implementations = {
|
||||
('helloworld.Greeter', 'SayHello'): face_utilities.unary_unary_inline(servicer.SayHello),
|
||||
}
|
||||
server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout)
|
||||
return beta_implementations.server(method_implementations, options=server_options)
|
||||
|
||||
|
||||
def beta_create_Greeter_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None):
|
||||
request_serializers = {
|
||||
('helloworld.Greeter', 'SayHello'): HelloRequest.SerializeToString,
|
||||
}
|
||||
response_deserializers = {
|
||||
('helloworld.Greeter', 'SayHello'): HelloReply.FromString,
|
||||
}
|
||||
cardinalities = {
|
||||
'SayHello': cardinality.Cardinality.UNARY_UNARY,
|
||||
}
|
||||
stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size)
|
||||
return beta_implementations.dynamic_stub(channel, 'helloworld.Greeter', cardinalities, options=stub_options)
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
# Copyright 2016, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""A client that makes both Greeter and RouteGuide RPCs."""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import random
|
||||
import time
|
||||
|
||||
import grpc
|
||||
|
||||
import helloworld_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_resources
|
||||
|
||||
|
||||
def make_route_note(message, latitude, longitude):
|
||||
return route_guide_pb2.RouteNote(
|
||||
message=message,
|
||||
location=route_guide_pb2.Point(latitude=latitude, longitude=longitude))
|
||||
|
||||
|
||||
def guide_get_one_feature(route_guide_stub, point):
|
||||
feature = route_guide_stub.GetFeature(point)
|
||||
if not feature.location:
|
||||
print("Server returned incomplete feature")
|
||||
return
|
||||
|
||||
if feature.name:
|
||||
print("Feature called %s at %s" % (feature.name, feature.location))
|
||||
else:
|
||||
print("Found no feature at %s" % feature.location)
|
||||
|
||||
|
||||
def guide_get_feature(route_guide_stub):
|
||||
guide_get_one_feature(
|
||||
route_guide_stub,
|
||||
route_guide_pb2.Point(latitude=409146138, longitude=-746188906))
|
||||
guide_get_one_feature(
|
||||
route_guide_stub, route_guide_pb2.Point(latitude=0, longitude=0))
|
||||
|
||||
|
||||
def guide_list_features(route_guide_stub):
|
||||
rectangle = route_guide_pb2.Rectangle(
|
||||
lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
|
||||
hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
|
||||
print("Looking for features between 40, -75 and 42, -73")
|
||||
|
||||
features = route_guide_stub.ListFeatures(rectangle)
|
||||
|
||||
for feature in features:
|
||||
print("Feature called %s at %s" % (feature.name, feature.location))
|
||||
|
||||
|
||||
def generate_route(feature_list):
|
||||
for _ in range(0, 10):
|
||||
random_feature = feature_list[random.randint(0, len(feature_list) - 1)]
|
||||
print("Visiting point %s" % random_feature.location)
|
||||
yield random_feature.location
|
||||
time.sleep(random.uniform(0.5, 1.5))
|
||||
|
||||
|
||||
def guide_record_route(route_guide_stub):
|
||||
feature_list = route_guide_resources.read_route_guide_database()
|
||||
|
||||
route_iterator = generate_route(feature_list)
|
||||
route_summary = route_guide_stub.RecordRoute(route_iterator)
|
||||
print("Finished trip with %s points " % route_summary.point_count)
|
||||
print("Passed %s features " % route_summary.feature_count)
|
||||
print("Travelled %s meters " % route_summary.distance)
|
||||
print("It took %s seconds " % route_summary.elapsed_time)
|
||||
|
||||
|
||||
def generate_messages():
|
||||
messages = [
|
||||
make_route_note("First message", 0, 0),
|
||||
make_route_note("Second message", 0, 1),
|
||||
make_route_note("Third message", 1, 0),
|
||||
make_route_note("Fourth message", 0, 0),
|
||||
make_route_note("Fifth message", 1, 0),
|
||||
]
|
||||
for msg in messages:
|
||||
print("Sending %s at %s" % (msg.message, msg.location))
|
||||
yield msg
|
||||
time.sleep(random.uniform(0.5, 1.0))
|
||||
|
||||
|
||||
def guide_route_chat(route_guide_stub):
|
||||
responses = route_guide_stub.RouteChat(generate_messages())
|
||||
for response in responses:
|
||||
print("Received message %s at %s" % (response.message, response.location))
|
||||
|
||||
|
||||
def run():
|
||||
channel = grpc.insecure_channel('localhost:50051')
|
||||
greeter_stub = helloworld_pb2.GreeterStub(channel)
|
||||
route_guide_stub = route_guide_pb2.RouteGuideStub(channel)
|
||||
greeter_response = greeter_stub.SayHello(
|
||||
helloworld_pb2.HelloRequest(name='you'))
|
||||
print("Greeter client received: " + greeter_response.message)
|
||||
print("-------------- GetFeature --------------")
|
||||
guide_get_feature(route_guide_stub)
|
||||
print("-------------- ListFeatures --------------")
|
||||
guide_list_features(route_guide_stub)
|
||||
print("-------------- RecordRoute --------------")
|
||||
guide_record_route(route_guide_stub)
|
||||
print("-------------- RouteChat --------------")
|
||||
guide_route_chat(route_guide_stub)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
# Copyright 2016, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""A gRPC server servicing both Greeter and RouteGuide RPCs."""
|
||||
|
||||
from concurrent import futures
|
||||
import time
|
||||
import math
|
||||
|
||||
import grpc
|
||||
|
||||
import helloworld_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_resources
|
||||
|
||||
_ONE_DAY_IN_SECONDS = 60 * 60 * 24
|
||||
|
||||
|
||||
def _get_feature(feature_db, point):
|
||||
"""Returns Feature at given location or None."""
|
||||
for feature in feature_db:
|
||||
if feature.location == point:
|
||||
return feature
|
||||
return None
|
||||
|
||||
|
||||
def _get_distance(start, end):
|
||||
"""Distance between two points."""
|
||||
coord_factor = 10000000.0
|
||||
lat_1 = start.latitude / coord_factor
|
||||
lat_2 = end.latitude / coord_factor
|
||||
lon_1 = start.longitude / coord_factor
|
||||
lon_2 = end.longitude / coord_factor
|
||||
lat_rad_1 = math.radians(lat_1)
|
||||
lat_rad_2 = math.radians(lat_2)
|
||||
delta_lat_rad = math.radians(lat_2 - lat_1)
|
||||
delta_lon_rad = math.radians(lon_2 - lon_1)
|
||||
|
||||
a = (pow(math.sin(delta_lat_rad / 2), 2) +
|
||||
(math.cos(lat_rad_1) * math.cos(lat_rad_2) *
|
||||
pow(math.sin(delta_lon_rad / 2), 2)))
|
||||
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
|
||||
R = 6371000; # metres
|
||||
return R * c;
|
||||
|
||||
|
||||
class _GreeterServicer(helloworld_pb2.GreeterServicer):
|
||||
|
||||
def SayHello(self, request, context):
|
||||
return helloworld_pb2.HelloReply(message='Hello, {}!'.format(request.name))
|
||||
|
||||
|
||||
class _RouteGuideServicer(route_guide_pb2.RouteGuideServicer):
|
||||
"""Provides methods that implement functionality of route guide server."""
|
||||
|
||||
def __init__(self):
|
||||
self.db = route_guide_resources.read_route_guide_database()
|
||||
|
||||
def GetFeature(self, request, context):
|
||||
feature = _get_feature(self.db, request)
|
||||
if feature is None:
|
||||
return route_guide_pb2.Feature(name="", location=request)
|
||||
else:
|
||||
return feature
|
||||
|
||||
def ListFeatures(self, request, context):
|
||||
left = min(request.lo.longitude, request.hi.longitude)
|
||||
right = max(request.lo.longitude, request.hi.longitude)
|
||||
top = max(request.lo.latitude, request.hi.latitude)
|
||||
bottom = min(request.lo.latitude, request.hi.latitude)
|
||||
for feature in self.db:
|
||||
if (feature.location.longitude >= left and
|
||||
feature.location.longitude <= right and
|
||||
feature.location.latitude >= bottom and
|
||||
feature.location.latitude <= top):
|
||||
yield feature
|
||||
|
||||
def RecordRoute(self, request_iterator, context):
|
||||
point_count = 0
|
||||
feature_count = 0
|
||||
distance = 0.0
|
||||
prev_point = None
|
||||
|
||||
start_time = time.time()
|
||||
for point in request_iterator:
|
||||
point_count += 1
|
||||
if _get_feature(self.db, point):
|
||||
feature_count += 1
|
||||
if prev_point:
|
||||
distance += _get_distance(prev_point, point)
|
||||
prev_point = point
|
||||
|
||||
elapsed_time = time.time() - start_time
|
||||
return route_guide_pb2.RouteSummary(point_count=point_count,
|
||||
feature_count=feature_count,
|
||||
distance=int(distance),
|
||||
elapsed_time=int(elapsed_time))
|
||||
|
||||
def RouteChat(self, request_iterator, context):
|
||||
prev_notes = []
|
||||
for new_note in request_iterator:
|
||||
for prev_note in prev_notes:
|
||||
if prev_note.location == new_note.location:
|
||||
yield prev_note
|
||||
prev_notes.append(new_note)
|
||||
|
||||
|
||||
def serve():
|
||||
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
|
||||
helloworld_pb2.add_GreeterServicer_to_server(_GreeterServicer(), server)
|
||||
route_guide_pb2.add_RouteGuideServicer_to_server(
|
||||
_RouteGuideServicer(), server)
|
||||
server.add_insecure_port('[::]:50051')
|
||||
server.start()
|
||||
try:
|
||||
while True:
|
||||
time.sleep(_ONE_DAY_IN_SECONDS)
|
||||
except KeyboardInterrupt:
|
||||
server.stop(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
serve()
|
||||
|
|
@ -0,0 +1,601 @@
|
|||
[{
|
||||
"location": {
|
||||
"latitude": 407838351,
|
||||
"longitude": -746143763
|
||||
},
|
||||
"name": "Patriots Path, Mendham, NJ 07945, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 408122808,
|
||||
"longitude": -743999179
|
||||
},
|
||||
"name": "101 New Jersey 10, Whippany, NJ 07981, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 413628156,
|
||||
"longitude": -749015468
|
||||
},
|
||||
"name": "U.S. 6, Shohola, PA 18458, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 419999544,
|
||||
"longitude": -740371136
|
||||
},
|
||||
"name": "5 Conners Road, Kingston, NY 12401, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 414008389,
|
||||
"longitude": -743951297
|
||||
},
|
||||
"name": "Mid Hudson Psychiatric Center, New Hampton, NY 10958, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 419611318,
|
||||
"longitude": -746524769
|
||||
},
|
||||
"name": "287 Flugertown Road, Livingston Manor, NY 12758, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406109563,
|
||||
"longitude": -742186778
|
||||
},
|
||||
"name": "4001 Tremley Point Road, Linden, NJ 07036, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 416802456,
|
||||
"longitude": -742370183
|
||||
},
|
||||
"name": "352 South Mountain Road, Wallkill, NY 12589, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412950425,
|
||||
"longitude": -741077389
|
||||
},
|
||||
"name": "Bailey Turn Road, Harriman, NY 10926, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412144655,
|
||||
"longitude": -743949739
|
||||
},
|
||||
"name": "193-199 Wawayanda Road, Hewitt, NJ 07421, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 415736605,
|
||||
"longitude": -742847522
|
||||
},
|
||||
"name": "406-496 Ward Avenue, Pine Bush, NY 12566, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 413843930,
|
||||
"longitude": -740501726
|
||||
},
|
||||
"name": "162 Merrill Road, Highland Mills, NY 10930, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 410873075,
|
||||
"longitude": -744459023
|
||||
},
|
||||
"name": "Clinton Road, West Milford, NJ 07480, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412346009,
|
||||
"longitude": -744026814
|
||||
},
|
||||
"name": "16 Old Brook Lane, Warwick, NY 10990, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 402948455,
|
||||
"longitude": -747903913
|
||||
},
|
||||
"name": "3 Drake Lane, Pennington, NJ 08534, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406337092,
|
||||
"longitude": -740122226
|
||||
},
|
||||
"name": "6324 8th Avenue, Brooklyn, NY 11220, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406421967,
|
||||
"longitude": -747727624
|
||||
},
|
||||
"name": "1 Merck Access Road, Whitehouse Station, NJ 08889, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 416318082,
|
||||
"longitude": -749677716
|
||||
},
|
||||
"name": "78-98 Schalck Road, Narrowsburg, NY 12764, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 415301720,
|
||||
"longitude": -748416257
|
||||
},
|
||||
"name": "282 Lakeview Drive Road, Highland Lake, NY 12743, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 402647019,
|
||||
"longitude": -747071791
|
||||
},
|
||||
"name": "330 Evelyn Avenue, Hamilton Township, NJ 08619, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412567807,
|
||||
"longitude": -741058078
|
||||
},
|
||||
"name": "New York State Reference Route 987E, Southfields, NY 10975, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 416855156,
|
||||
"longitude": -744420597
|
||||
},
|
||||
"name": "103-271 Tempaloni Road, Ellenville, NY 12428, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404663628,
|
||||
"longitude": -744820157
|
||||
},
|
||||
"name": "1300 Airport Road, North Brunswick Township, NJ 08902, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 407113723,
|
||||
"longitude": -749746483
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 402133926,
|
||||
"longitude": -743613249
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 400273442,
|
||||
"longitude": -741220915
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 411236786,
|
||||
"longitude": -744070769
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 411633782,
|
||||
"longitude": -746784970
|
||||
},
|
||||
"name": "211-225 Plains Road, Augusta, NJ 07822, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 415830701,
|
||||
"longitude": -742952812
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 413447164,
|
||||
"longitude": -748712898
|
||||
},
|
||||
"name": "165 Pedersen Ridge Road, Milford, PA 18337, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 405047245,
|
||||
"longitude": -749800722
|
||||
},
|
||||
"name": "100-122 Locktown Road, Frenchtown, NJ 08825, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 418858923,
|
||||
"longitude": -746156790
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 417951888,
|
||||
"longitude": -748484944
|
||||
},
|
||||
"name": "650-652 Willi Hill Road, Swan Lake, NY 12783, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 407033786,
|
||||
"longitude": -743977337
|
||||
},
|
||||
"name": "26 East 3rd Street, New Providence, NJ 07974, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 417548014,
|
||||
"longitude": -740075041
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 410395868,
|
||||
"longitude": -744972325
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404615353,
|
||||
"longitude": -745129803
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406589790,
|
||||
"longitude": -743560121
|
||||
},
|
||||
"name": "611 Lawrence Avenue, Westfield, NJ 07090, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 414653148,
|
||||
"longitude": -740477477
|
||||
},
|
||||
"name": "18 Lannis Avenue, New Windsor, NY 12553, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 405957808,
|
||||
"longitude": -743255336
|
||||
},
|
||||
"name": "82-104 Amherst Avenue, Colonia, NJ 07067, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 411733589,
|
||||
"longitude": -741648093
|
||||
},
|
||||
"name": "170 Seven Lakes Drive, Sloatsburg, NY 10974, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412676291,
|
||||
"longitude": -742606606
|
||||
},
|
||||
"name": "1270 Lakes Road, Monroe, NY 10950, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 409224445,
|
||||
"longitude": -748286738
|
||||
},
|
||||
"name": "509-535 Alphano Road, Great Meadows, NJ 07838, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406523420,
|
||||
"longitude": -742135517
|
||||
},
|
||||
"name": "652 Garden Street, Elizabeth, NJ 07202, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 401827388,
|
||||
"longitude": -740294537
|
||||
},
|
||||
"name": "349 Sea Spray Court, Neptune City, NJ 07753, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 410564152,
|
||||
"longitude": -743685054
|
||||
},
|
||||
"name": "13-17 Stanley Street, West Milford, NJ 07480, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 408472324,
|
||||
"longitude": -740726046
|
||||
},
|
||||
"name": "47 Industrial Avenue, Teterboro, NJ 07608, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412452168,
|
||||
"longitude": -740214052
|
||||
},
|
||||
"name": "5 White Oak Lane, Stony Point, NY 10980, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 409146138,
|
||||
"longitude": -746188906
|
||||
},
|
||||
"name": "Berkshire Valley Management Area Trail, Jefferson, NJ, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404701380,
|
||||
"longitude": -744781745
|
||||
},
|
||||
"name": "1007 Jersey Avenue, New Brunswick, NJ 08901, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 409642566,
|
||||
"longitude": -746017679
|
||||
},
|
||||
"name": "6 East Emerald Isle Drive, Lake Hopatcong, NJ 07849, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 408031728,
|
||||
"longitude": -748645385
|
||||
},
|
||||
"name": "1358-1474 New Jersey 57, Port Murray, NJ 07865, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 413700272,
|
||||
"longitude": -742135189
|
||||
},
|
||||
"name": "367 Prospect Road, Chester, NY 10918, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404310607,
|
||||
"longitude": -740282632
|
||||
},
|
||||
"name": "10 Simon Lake Drive, Atlantic Highlands, NJ 07716, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 409319800,
|
||||
"longitude": -746201391
|
||||
},
|
||||
"name": "11 Ward Street, Mount Arlington, NJ 07856, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406685311,
|
||||
"longitude": -742108603
|
||||
},
|
||||
"name": "300-398 Jefferson Avenue, Elizabeth, NJ 07201, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 419018117,
|
||||
"longitude": -749142781
|
||||
},
|
||||
"name": "43 Dreher Road, Roscoe, NY 12776, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412856162,
|
||||
"longitude": -745148837
|
||||
},
|
||||
"name": "Swan Street, Pine Island, NY 10969, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 416560744,
|
||||
"longitude": -746721964
|
||||
},
|
||||
"name": "66 Pleasantview Avenue, Monticello, NY 12701, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 405314270,
|
||||
"longitude": -749836354
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 414219548,
|
||||
"longitude": -743327440
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 415534177,
|
||||
"longitude": -742900616
|
||||
},
|
||||
"name": "565 Winding Hills Road, Montgomery, NY 12549, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406898530,
|
||||
"longitude": -749127080
|
||||
},
|
||||
"name": "231 Rocky Run Road, Glen Gardner, NJ 08826, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 407586880,
|
||||
"longitude": -741670168
|
||||
},
|
||||
"name": "100 Mount Pleasant Avenue, Newark, NJ 07104, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 400106455,
|
||||
"longitude": -742870190
|
||||
},
|
||||
"name": "517-521 Huntington Drive, Manchester Township, NJ 08759, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 400066188,
|
||||
"longitude": -746793294
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 418803880,
|
||||
"longitude": -744102673
|
||||
},
|
||||
"name": "40 Mountain Road, Napanoch, NY 12458, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 414204288,
|
||||
"longitude": -747895140
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 414777405,
|
||||
"longitude": -740615601
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 415464475,
|
||||
"longitude": -747175374
|
||||
},
|
||||
"name": "48 North Road, Forestburgh, NY 12777, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404062378,
|
||||
"longitude": -746376177
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 405688272,
|
||||
"longitude": -749285130
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 400342070,
|
||||
"longitude": -748788996
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 401809022,
|
||||
"longitude": -744157964
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404226644,
|
||||
"longitude": -740517141
|
||||
},
|
||||
"name": "9 Thompson Avenue, Leonardo, NJ 07737, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 410322033,
|
||||
"longitude": -747871659
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 407100674,
|
||||
"longitude": -747742727
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 418811433,
|
||||
"longitude": -741718005
|
||||
},
|
||||
"name": "213 Bush Road, Stone Ridge, NY 12484, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 415034302,
|
||||
"longitude": -743850945
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 411349992,
|
||||
"longitude": -743694161
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404839914,
|
||||
"longitude": -744759616
|
||||
},
|
||||
"name": "1-17 Bergen Court, New Brunswick, NJ 08901, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 414638017,
|
||||
"longitude": -745957854
|
||||
},
|
||||
"name": "35 Oakland Valley Road, Cuddebackville, NY 12729, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412127800,
|
||||
"longitude": -740173578
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 401263460,
|
||||
"longitude": -747964303
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 412843391,
|
||||
"longitude": -749086026
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 418512773,
|
||||
"longitude": -743067823
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404318328,
|
||||
"longitude": -740835638
|
||||
},
|
||||
"name": "42-102 Main Street, Belford, NJ 07718, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 419020746,
|
||||
"longitude": -741172328
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404080723,
|
||||
"longitude": -746119569
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 401012643,
|
||||
"longitude": -744035134
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 404306372,
|
||||
"longitude": -741079661
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 403966326,
|
||||
"longitude": -748519297
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 405002031,
|
||||
"longitude": -748407866
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 409532885,
|
||||
"longitude": -742200683
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 416851321,
|
||||
"longitude": -742674555
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 406411633,
|
||||
"longitude": -741722051
|
||||
},
|
||||
"name": "3387 Richmond Terrace, Staten Island, NY 10303, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 413069058,
|
||||
"longitude": -744597778
|
||||
},
|
||||
"name": "261 Van Sickle Road, Goshen, NY 10924, USA"
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 418465462,
|
||||
"longitude": -746859398
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 411733222,
|
||||
"longitude": -744228360
|
||||
},
|
||||
"name": ""
|
||||
}, {
|
||||
"location": {
|
||||
"latitude": 410248224,
|
||||
"longitude": -747127767
|
||||
},
|
||||
"name": "3 Hasta Way, Newton, NJ 07860, USA"
|
||||
}]
|
||||
|
|
@ -0,0 +1,516 @@
|
|||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: route_guide.proto
|
||||
|
||||
import sys
|
||||
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf import descriptor_pb2
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor.FileDescriptor(
|
||||
name='route_guide.proto',
|
||||
package='routeguide',
|
||||
syntax='proto3',
|
||||
serialized_pb=_b('\n\x11route_guide.proto\x12\nrouteguide\",\n\x05Point\x12\x10\n\x08latitude\x18\x01 \x01(\x05\x12\x11\n\tlongitude\x18\x02 \x01(\x05\"I\n\tRectangle\x12\x1d\n\x02lo\x18\x01 \x01(\x0b\x32\x11.routeguide.Point\x12\x1d\n\x02hi\x18\x02 \x01(\x0b\x32\x11.routeguide.Point\"<\n\x07\x46\x65\x61ture\x12\x0c\n\x04name\x18\x01 \x01(\t\x12#\n\x08location\x18\x02 \x01(\x0b\x32\x11.routeguide.Point\"A\n\tRouteNote\x12#\n\x08location\x18\x01 \x01(\x0b\x32\x11.routeguide.Point\x12\x0f\n\x07message\x18\x02 \x01(\t\"b\n\x0cRouteSummary\x12\x13\n\x0bpoint_count\x18\x01 \x01(\x05\x12\x15\n\rfeature_count\x18\x02 \x01(\x05\x12\x10\n\x08\x64istance\x18\x03 \x01(\x05\x12\x14\n\x0c\x65lapsed_time\x18\x04 \x01(\x05\x32\x85\x02\n\nRouteGuide\x12\x36\n\nGetFeature\x12\x11.routeguide.Point\x1a\x13.routeguide.Feature\"\x00\x12>\n\x0cListFeatures\x12\x15.routeguide.Rectangle\x1a\x13.routeguide.Feature\"\x00\x30\x01\x12>\n\x0bRecordRoute\x12\x11.routeguide.Point\x1a\x18.routeguide.RouteSummary\"\x00(\x01\x12?\n\tRouteChat\x12\x15.routeguide.RouteNote\x1a\x15.routeguide.RouteNote\"\x00(\x01\x30\x01\x42\x36\n\x1bio.grpc.examples.routeguideB\x0fRouteGuideProtoP\x01\xa2\x02\x03RTGb\x06proto3')
|
||||
)
|
||||
_sym_db.RegisterFileDescriptor(DESCRIPTOR)
|
||||
|
||||
|
||||
|
||||
|
||||
_POINT = _descriptor.Descriptor(
|
||||
name='Point',
|
||||
full_name='routeguide.Point',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='latitude', full_name='routeguide.Point.latitude', index=0,
|
||||
number=1, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='longitude', full_name='routeguide.Point.longitude', index=1,
|
||||
number=2, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=33,
|
||||
serialized_end=77,
|
||||
)
|
||||
|
||||
|
||||
_RECTANGLE = _descriptor.Descriptor(
|
||||
name='Rectangle',
|
||||
full_name='routeguide.Rectangle',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='lo', full_name='routeguide.Rectangle.lo', index=0,
|
||||
number=1, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='hi', full_name='routeguide.Rectangle.hi', index=1,
|
||||
number=2, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=79,
|
||||
serialized_end=152,
|
||||
)
|
||||
|
||||
|
||||
_FEATURE = _descriptor.Descriptor(
|
||||
name='Feature',
|
||||
full_name='routeguide.Feature',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='name', full_name='routeguide.Feature.name', index=0,
|
||||
number=1, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='location', full_name='routeguide.Feature.location', index=1,
|
||||
number=2, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=154,
|
||||
serialized_end=214,
|
||||
)
|
||||
|
||||
|
||||
_ROUTENOTE = _descriptor.Descriptor(
|
||||
name='RouteNote',
|
||||
full_name='routeguide.RouteNote',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='location', full_name='routeguide.RouteNote.location', index=0,
|
||||
number=1, type=11, cpp_type=10, label=1,
|
||||
has_default_value=False, default_value=None,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='message', full_name='routeguide.RouteNote.message', index=1,
|
||||
number=2, type=9, cpp_type=9, label=1,
|
||||
has_default_value=False, default_value=_b("").decode('utf-8'),
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=216,
|
||||
serialized_end=281,
|
||||
)
|
||||
|
||||
|
||||
_ROUTESUMMARY = _descriptor.Descriptor(
|
||||
name='RouteSummary',
|
||||
full_name='routeguide.RouteSummary',
|
||||
filename=None,
|
||||
file=DESCRIPTOR,
|
||||
containing_type=None,
|
||||
fields=[
|
||||
_descriptor.FieldDescriptor(
|
||||
name='point_count', full_name='routeguide.RouteSummary.point_count', index=0,
|
||||
number=1, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='feature_count', full_name='routeguide.RouteSummary.feature_count', index=1,
|
||||
number=2, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='distance', full_name='routeguide.RouteSummary.distance', index=2,
|
||||
number=3, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
_descriptor.FieldDescriptor(
|
||||
name='elapsed_time', full_name='routeguide.RouteSummary.elapsed_time', index=3,
|
||||
number=4, type=5, cpp_type=1, label=1,
|
||||
has_default_value=False, default_value=0,
|
||||
message_type=None, enum_type=None, containing_type=None,
|
||||
is_extension=False, extension_scope=None,
|
||||
options=None),
|
||||
],
|
||||
extensions=[
|
||||
],
|
||||
nested_types=[],
|
||||
enum_types=[
|
||||
],
|
||||
options=None,
|
||||
is_extendable=False,
|
||||
syntax='proto3',
|
||||
extension_ranges=[],
|
||||
oneofs=[
|
||||
],
|
||||
serialized_start=283,
|
||||
serialized_end=381,
|
||||
)
|
||||
|
||||
_RECTANGLE.fields_by_name['lo'].message_type = _POINT
|
||||
_RECTANGLE.fields_by_name['hi'].message_type = _POINT
|
||||
_FEATURE.fields_by_name['location'].message_type = _POINT
|
||||
_ROUTENOTE.fields_by_name['location'].message_type = _POINT
|
||||
DESCRIPTOR.message_types_by_name['Point'] = _POINT
|
||||
DESCRIPTOR.message_types_by_name['Rectangle'] = _RECTANGLE
|
||||
DESCRIPTOR.message_types_by_name['Feature'] = _FEATURE
|
||||
DESCRIPTOR.message_types_by_name['RouteNote'] = _ROUTENOTE
|
||||
DESCRIPTOR.message_types_by_name['RouteSummary'] = _ROUTESUMMARY
|
||||
|
||||
Point = _reflection.GeneratedProtocolMessageType('Point', (_message.Message,), dict(
|
||||
DESCRIPTOR = _POINT,
|
||||
__module__ = 'route_guide_pb2'
|
||||
# @@protoc_insertion_point(class_scope:routeguide.Point)
|
||||
))
|
||||
_sym_db.RegisterMessage(Point)
|
||||
|
||||
Rectangle = _reflection.GeneratedProtocolMessageType('Rectangle', (_message.Message,), dict(
|
||||
DESCRIPTOR = _RECTANGLE,
|
||||
__module__ = 'route_guide_pb2'
|
||||
# @@protoc_insertion_point(class_scope:routeguide.Rectangle)
|
||||
))
|
||||
_sym_db.RegisterMessage(Rectangle)
|
||||
|
||||
Feature = _reflection.GeneratedProtocolMessageType('Feature', (_message.Message,), dict(
|
||||
DESCRIPTOR = _FEATURE,
|
||||
__module__ = 'route_guide_pb2'
|
||||
# @@protoc_insertion_point(class_scope:routeguide.Feature)
|
||||
))
|
||||
_sym_db.RegisterMessage(Feature)
|
||||
|
||||
RouteNote = _reflection.GeneratedProtocolMessageType('RouteNote', (_message.Message,), dict(
|
||||
DESCRIPTOR = _ROUTENOTE,
|
||||
__module__ = 'route_guide_pb2'
|
||||
# @@protoc_insertion_point(class_scope:routeguide.RouteNote)
|
||||
))
|
||||
_sym_db.RegisterMessage(RouteNote)
|
||||
|
||||
RouteSummary = _reflection.GeneratedProtocolMessageType('RouteSummary', (_message.Message,), dict(
|
||||
DESCRIPTOR = _ROUTESUMMARY,
|
||||
__module__ = 'route_guide_pb2'
|
||||
# @@protoc_insertion_point(class_scope:routeguide.RouteSummary)
|
||||
))
|
||||
_sym_db.RegisterMessage(RouteSummary)
|
||||
|
||||
|
||||
DESCRIPTOR.has_options = True
|
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.routeguideB\017RouteGuideProtoP\001\242\002\003RTG'))
|
||||
import grpc
|
||||
from grpc.beta import implementations as beta_implementations
|
||||
from grpc.beta import interfaces as beta_interfaces
|
||||
from grpc.framework.common import cardinality
|
||||
from grpc.framework.interfaces.face import utilities as face_utilities
|
||||
|
||||
|
||||
class RouteGuideStub(object):
|
||||
"""Interface exported by the server.
|
||||
"""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.GetFeature = channel.unary_unary(
|
||||
'/routeguide.RouteGuide/GetFeature',
|
||||
request_serializer=Point.SerializeToString,
|
||||
response_deserializer=Feature.FromString,
|
||||
)
|
||||
self.ListFeatures = channel.unary_stream(
|
||||
'/routeguide.RouteGuide/ListFeatures',
|
||||
request_serializer=Rectangle.SerializeToString,
|
||||
response_deserializer=Feature.FromString,
|
||||
)
|
||||
self.RecordRoute = channel.stream_unary(
|
||||
'/routeguide.RouteGuide/RecordRoute',
|
||||
request_serializer=Point.SerializeToString,
|
||||
response_deserializer=RouteSummary.FromString,
|
||||
)
|
||||
self.RouteChat = channel.stream_stream(
|
||||
'/routeguide.RouteGuide/RouteChat',
|
||||
request_serializer=RouteNote.SerializeToString,
|
||||
response_deserializer=RouteNote.FromString,
|
||||
)
|
||||
|
||||
|
||||
class RouteGuideServicer(object):
|
||||
"""Interface exported by the server.
|
||||
"""
|
||||
|
||||
def GetFeature(self, request, context):
|
||||
"""A simple RPC.
|
||||
|
||||
Obtains the feature at a given position.
|
||||
|
||||
A feature with an empty name is returned if there's no feature at the given
|
||||
position.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ListFeatures(self, request, context):
|
||||
"""A server-to-client streaming RPC.
|
||||
|
||||
Obtains the Features available within the given Rectangle. Results are
|
||||
streamed rather than returned at once (e.g. in a response message with a
|
||||
repeated field), as the rectangle may cover a large area and contain a
|
||||
huge number of features.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def RecordRoute(self, request_iterator, context):
|
||||
"""A client-to-server streaming RPC.
|
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a
|
||||
RouteSummary when traversal is completed.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def RouteChat(self, request_iterator, context):
|
||||
"""A Bidirectional streaming RPC.
|
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed,
|
||||
while receiving other RouteNotes (e.g. from other users).
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_RouteGuideServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'GetFeature': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetFeature,
|
||||
request_deserializer=Point.FromString,
|
||||
response_serializer=Feature.SerializeToString,
|
||||
),
|
||||
'ListFeatures': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.ListFeatures,
|
||||
request_deserializer=Rectangle.FromString,
|
||||
response_serializer=Feature.SerializeToString,
|
||||
),
|
||||
'RecordRoute': grpc.stream_unary_rpc_method_handler(
|
||||
servicer.RecordRoute,
|
||||
request_deserializer=Point.FromString,
|
||||
response_serializer=RouteSummary.SerializeToString,
|
||||
),
|
||||
'RouteChat': grpc.stream_stream_rpc_method_handler(
|
||||
servicer.RouteChat,
|
||||
request_deserializer=RouteNote.FromString,
|
||||
response_serializer=RouteNote.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'routeguide.RouteGuide', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
class BetaRouteGuideServicer(object):
|
||||
"""Interface exported by the server.
|
||||
"""
|
||||
def GetFeature(self, request, context):
|
||||
"""A simple RPC.
|
||||
|
||||
Obtains the feature at a given position.
|
||||
|
||||
A feature with an empty name is returned if there's no feature at the given
|
||||
position.
|
||||
"""
|
||||
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
|
||||
def ListFeatures(self, request, context):
|
||||
"""A server-to-client streaming RPC.
|
||||
|
||||
Obtains the Features available within the given Rectangle. Results are
|
||||
streamed rather than returned at once (e.g. in a response message with a
|
||||
repeated field), as the rectangle may cover a large area and contain a
|
||||
huge number of features.
|
||||
"""
|
||||
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
|
||||
def RecordRoute(self, request_iterator, context):
|
||||
"""A client-to-server streaming RPC.
|
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a
|
||||
RouteSummary when traversal is completed.
|
||||
"""
|
||||
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
|
||||
def RouteChat(self, request_iterator, context):
|
||||
"""A Bidirectional streaming RPC.
|
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed,
|
||||
while receiving other RouteNotes (e.g. from other users).
|
||||
"""
|
||||
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
|
||||
|
||||
|
||||
class BetaRouteGuideStub(object):
|
||||
"""Interface exported by the server.
|
||||
"""
|
||||
def GetFeature(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""A simple RPC.
|
||||
|
||||
Obtains the feature at a given position.
|
||||
|
||||
A feature with an empty name is returned if there's no feature at the given
|
||||
position.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
GetFeature.future = None
|
||||
def ListFeatures(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""A server-to-client streaming RPC.
|
||||
|
||||
Obtains the Features available within the given Rectangle. Results are
|
||||
streamed rather than returned at once (e.g. in a response message with a
|
||||
repeated field), as the rectangle may cover a large area and contain a
|
||||
huge number of features.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
def RecordRoute(self, request_iterator, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""A client-to-server streaming RPC.
|
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a
|
||||
RouteSummary when traversal is completed.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
RecordRoute.future = None
|
||||
def RouteChat(self, request_iterator, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""A Bidirectional streaming RPC.
|
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed,
|
||||
while receiving other RouteNotes (e.g. from other users).
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
def beta_create_RouteGuide_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None):
|
||||
request_deserializers = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): Point.FromString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): Rectangle.FromString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): Point.FromString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): RouteNote.FromString,
|
||||
}
|
||||
response_serializers = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): Feature.SerializeToString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): Feature.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): RouteSummary.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): RouteNote.SerializeToString,
|
||||
}
|
||||
method_implementations = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): face_utilities.unary_unary_inline(servicer.GetFeature),
|
||||
('routeguide.RouteGuide', 'ListFeatures'): face_utilities.unary_stream_inline(servicer.ListFeatures),
|
||||
('routeguide.RouteGuide', 'RecordRoute'): face_utilities.stream_unary_inline(servicer.RecordRoute),
|
||||
('routeguide.RouteGuide', 'RouteChat'): face_utilities.stream_stream_inline(servicer.RouteChat),
|
||||
}
|
||||
server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout)
|
||||
return beta_implementations.server(method_implementations, options=server_options)
|
||||
|
||||
|
||||
def beta_create_RouteGuide_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None):
|
||||
request_serializers = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): Point.SerializeToString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): Rectangle.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): Point.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): RouteNote.SerializeToString,
|
||||
}
|
||||
response_deserializers = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): Feature.FromString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): Feature.FromString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): RouteSummary.FromString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): RouteNote.FromString,
|
||||
}
|
||||
cardinalities = {
|
||||
'GetFeature': cardinality.Cardinality.UNARY_UNARY,
|
||||
'ListFeatures': cardinality.Cardinality.UNARY_STREAM,
|
||||
'RecordRoute': cardinality.Cardinality.STREAM_UNARY,
|
||||
'RouteChat': cardinality.Cardinality.STREAM_STREAM,
|
||||
}
|
||||
stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size)
|
||||
return beta_implementations.dynamic_stub(channel, 'routeguide.RouteGuide', cardinalities, options=stub_options)
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
# Copyright 2015, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""Common resources used in the gRPC route guide example."""
|
||||
|
||||
import json
|
||||
|
||||
import route_guide_pb2
|
||||
|
||||
|
||||
def read_route_guide_database():
|
||||
"""Reads the route guide database.
|
||||
|
||||
Returns:
|
||||
The full contents of the route guide database as a sequence of
|
||||
route_guide_pb2.Features.
|
||||
"""
|
||||
feature_list = []
|
||||
with open("route_guide_db.json") as route_guide_db_file:
|
||||
for item in json.load(route_guide_db_file):
|
||||
feature = route_guide_pb2.Feature(
|
||||
name=item["name"],
|
||||
location=route_guide_pb2.Point(
|
||||
latitude=item["location"]["latitude"],
|
||||
longitude=item["location"]["longitude"]))
|
||||
feature_list.append(feature)
|
||||
return feature_list
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
# Copyright 2016, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following disclaimer
|
||||
# in the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the name of Google Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from
|
||||
# this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
"""Generates protocol messages and gRPC stubs."""
|
||||
|
||||
from grpc.tools import protoc
|
||||
|
||||
protoc.main(
|
||||
(
|
||||
'',
|
||||
'-I../../protos',
|
||||
'--python_out=.',
|
||||
'--grpc_python_out=.',
|
||||
'../../protos/helloworld.proto',
|
||||
)
|
||||
)
|
||||
protoc.main(
|
||||
(
|
||||
'',
|
||||
'-I../../protos',
|
||||
'--python_out=.',
|
||||
'--grpc_python_out=.',
|
||||
'../../protos/route_guide.proto',
|
||||
)
|
||||
)
|
||||
|
|
@ -34,13 +34,11 @@ from __future__ import print_function
|
|||
import random
|
||||
import time
|
||||
|
||||
from grpc.beta import implementations
|
||||
import grpc
|
||||
|
||||
import route_guide_pb2
|
||||
import route_guide_resources
|
||||
|
||||
_TIMEOUT_SECONDS = 30
|
||||
|
||||
|
||||
def make_route_note(message, latitude, longitude):
|
||||
return route_guide_pb2.RouteNote(
|
||||
|
|
@ -49,7 +47,7 @@ def make_route_note(message, latitude, longitude):
|
|||
|
||||
|
||||
def guide_get_one_feature(stub, point):
|
||||
feature = stub.GetFeature(point, _TIMEOUT_SECONDS)
|
||||
feature = stub.GetFeature(point)
|
||||
if not feature.location:
|
||||
print("Server returned incomplete feature")
|
||||
return
|
||||
|
|
@ -66,14 +64,12 @@ def guide_get_feature(stub):
|
|||
|
||||
|
||||
def guide_list_features(stub):
|
||||
rect = route_guide_pb2.Rectangle(
|
||||
lo=route_guide_pb2.Point(
|
||||
latitude=400000000, longitude = -750000000),
|
||||
hi=route_guide_pb2.Point(
|
||||
latitude = 420000000, longitude = -730000000))
|
||||
rectangle = route_guide_pb2.Rectangle(
|
||||
lo=route_guide_pb2.Point(latitude=400000000, longitude=-750000000),
|
||||
hi=route_guide_pb2.Point(latitude=420000000, longitude=-730000000))
|
||||
print("Looking for features between 40, -75 and 42, -73")
|
||||
|
||||
features = stub.ListFeatures(rect, _TIMEOUT_SECONDS)
|
||||
features = stub.ListFeatures(rectangle)
|
||||
|
||||
for feature in features:
|
||||
print("Feature called %s at %s" % (feature.name, feature.location))
|
||||
|
|
@ -90,8 +86,8 @@ def generate_route(feature_list):
|
|||
def guide_record_route(stub):
|
||||
feature_list = route_guide_resources.read_route_guide_database()
|
||||
|
||||
route_iter = generate_route(feature_list)
|
||||
route_summary = stub.RecordRoute(route_iter, _TIMEOUT_SECONDS)
|
||||
route_iterator = generate_route(feature_list)
|
||||
route_summary = stub.RecordRoute(route_iterator)
|
||||
print("Finished trip with %s points " % route_summary.point_count)
|
||||
print("Passed %s features " % route_summary.feature_count)
|
||||
print("Travelled %s meters " % route_summary.distance)
|
||||
|
|
@ -113,14 +109,14 @@ def generate_messages():
|
|||
|
||||
|
||||
def guide_route_chat(stub):
|
||||
responses = stub.RouteChat(generate_messages(), _TIMEOUT_SECONDS)
|
||||
responses = stub.RouteChat(generate_messages())
|
||||
for response in responses:
|
||||
print("Received message %s at %s" % (response.message, response.location))
|
||||
|
||||
|
||||
def run():
|
||||
channel = implementations.insecure_channel('localhost', 50051)
|
||||
stub = route_guide_pb2.beta_create_RouteGuide_stub(channel)
|
||||
channel = grpc.insecure_channel('localhost:50051')
|
||||
stub = route_guide_pb2.RouteGuideStub(channel)
|
||||
print("-------------- GetFeature --------------")
|
||||
guide_get_feature(stub)
|
||||
print("-------------- ListFeatures --------------")
|
||||
|
|
|
|||
|
|
@ -277,13 +277,122 @@ _sym_db.RegisterMessage(RouteSummary)
|
|||
|
||||
DESCRIPTOR.has_options = True
|
||||
DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\033io.grpc.examples.routeguideB\017RouteGuideProtoP\001\242\002\003RTG'))
|
||||
import abc
|
||||
import six
|
||||
import grpc
|
||||
from grpc.beta import implementations as beta_implementations
|
||||
from grpc.beta import interfaces as beta_interfaces
|
||||
from grpc.framework.common import cardinality
|
||||
from grpc.framework.interfaces.face import utilities as face_utilities
|
||||
|
||||
|
||||
class RouteGuideStub(object):
|
||||
"""Interface exported by the server.
|
||||
"""
|
||||
|
||||
def __init__(self, channel):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
channel: A grpc.Channel.
|
||||
"""
|
||||
self.GetFeature = channel.unary_unary(
|
||||
'/routeguide.RouteGuide/GetFeature',
|
||||
request_serializer=Point.SerializeToString,
|
||||
response_deserializer=Feature.FromString,
|
||||
)
|
||||
self.ListFeatures = channel.unary_stream(
|
||||
'/routeguide.RouteGuide/ListFeatures',
|
||||
request_serializer=Rectangle.SerializeToString,
|
||||
response_deserializer=Feature.FromString,
|
||||
)
|
||||
self.RecordRoute = channel.stream_unary(
|
||||
'/routeguide.RouteGuide/RecordRoute',
|
||||
request_serializer=Point.SerializeToString,
|
||||
response_deserializer=RouteSummary.FromString,
|
||||
)
|
||||
self.RouteChat = channel.stream_stream(
|
||||
'/routeguide.RouteGuide/RouteChat',
|
||||
request_serializer=RouteNote.SerializeToString,
|
||||
response_deserializer=RouteNote.FromString,
|
||||
)
|
||||
|
||||
|
||||
class RouteGuideServicer(object):
|
||||
"""Interface exported by the server.
|
||||
"""
|
||||
|
||||
def GetFeature(self, request, context):
|
||||
"""A simple RPC.
|
||||
|
||||
Obtains the feature at a given position.
|
||||
|
||||
A feature with an empty name is returned if there's no feature at the given
|
||||
position.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def ListFeatures(self, request, context):
|
||||
"""A server-to-client streaming RPC.
|
||||
|
||||
Obtains the Features available within the given Rectangle. Results are
|
||||
streamed rather than returned at once (e.g. in a response message with a
|
||||
repeated field), as the rectangle may cover a large area and contain a
|
||||
huge number of features.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def RecordRoute(self, request_iterator, context):
|
||||
"""A client-to-server streaming RPC.
|
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a
|
||||
RouteSummary when traversal is completed.
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
def RouteChat(self, request_iterator, context):
|
||||
"""A Bidirectional streaming RPC.
|
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed,
|
||||
while receiving other RouteNotes (e.g. from other users).
|
||||
"""
|
||||
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
|
||||
context.set_details('Method not implemented!')
|
||||
raise NotImplementedError('Method not implemented!')
|
||||
|
||||
|
||||
def add_RouteGuideServicer_to_server(servicer, server):
|
||||
rpc_method_handlers = {
|
||||
'GetFeature': grpc.unary_unary_rpc_method_handler(
|
||||
servicer.GetFeature,
|
||||
request_deserializer=Point.FromString,
|
||||
response_serializer=Feature.SerializeToString,
|
||||
),
|
||||
'ListFeatures': grpc.unary_stream_rpc_method_handler(
|
||||
servicer.ListFeatures,
|
||||
request_deserializer=Rectangle.FromString,
|
||||
response_serializer=Feature.SerializeToString,
|
||||
),
|
||||
'RecordRoute': grpc.stream_unary_rpc_method_handler(
|
||||
servicer.RecordRoute,
|
||||
request_deserializer=Point.FromString,
|
||||
response_serializer=RouteSummary.SerializeToString,
|
||||
),
|
||||
'RouteChat': grpc.stream_stream_rpc_method_handler(
|
||||
servicer.RouteChat,
|
||||
request_deserializer=RouteNote.FromString,
|
||||
response_serializer=RouteNote.SerializeToString,
|
||||
),
|
||||
}
|
||||
generic_handler = grpc.method_handlers_generic_handler(
|
||||
'routeguide.RouteGuide', rpc_method_handlers)
|
||||
server.add_generic_rpc_handlers((generic_handler,))
|
||||
|
||||
|
||||
class BetaRouteGuideServicer(object):
|
||||
"""Interface exported by the server.
|
||||
"""
|
||||
|
|
@ -320,10 +429,11 @@ class BetaRouteGuideServicer(object):
|
|||
"""
|
||||
context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)
|
||||
|
||||
|
||||
class BetaRouteGuideStub(object):
|
||||
"""Interface exported by the server.
|
||||
"""
|
||||
def GetFeature(self, request, timeout):
|
||||
def GetFeature(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""A simple RPC.
|
||||
|
||||
Obtains the feature at a given position.
|
||||
|
|
@ -333,7 +443,7 @@ class BetaRouteGuideStub(object):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
GetFeature.future = None
|
||||
def ListFeatures(self, request, timeout):
|
||||
def ListFeatures(self, request, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""A server-to-client streaming RPC.
|
||||
|
||||
Obtains the Features available within the given Rectangle. Results are
|
||||
|
|
@ -342,7 +452,7 @@ class BetaRouteGuideStub(object):
|
|||
huge number of features.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
def RecordRoute(self, request_iterator, timeout):
|
||||
def RecordRoute(self, request_iterator, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""A client-to-server streaming RPC.
|
||||
|
||||
Accepts a stream of Points on a route being traversed, returning a
|
||||
|
|
@ -350,7 +460,7 @@ class BetaRouteGuideStub(object):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
RecordRoute.future = None
|
||||
def RouteChat(self, request_iterator, timeout):
|
||||
def RouteChat(self, request_iterator, timeout, metadata=None, with_call=False, protocol_options=None):
|
||||
"""A Bidirectional streaming RPC.
|
||||
|
||||
Accepts a stream of RouteNotes sent while a route is being traversed,
|
||||
|
|
@ -358,26 +468,19 @@ class BetaRouteGuideStub(object):
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
def beta_create_RouteGuide_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None):
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
request_deserializers = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): route_guide_pb2.Point.FromString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): route_guide_pb2.Rectangle.FromString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): route_guide_pb2.Point.FromString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): route_guide_pb2.RouteNote.FromString,
|
||||
('routeguide.RouteGuide', 'GetFeature'): Point.FromString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): Rectangle.FromString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): Point.FromString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): RouteNote.FromString,
|
||||
}
|
||||
response_serializers = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): route_guide_pb2.Feature.SerializeToString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): route_guide_pb2.Feature.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): route_guide_pb2.RouteSummary.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): route_guide_pb2.RouteNote.SerializeToString,
|
||||
('routeguide.RouteGuide', 'GetFeature'): Feature.SerializeToString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): Feature.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): RouteSummary.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): RouteNote.SerializeToString,
|
||||
}
|
||||
method_implementations = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): face_utilities.unary_unary_inline(servicer.GetFeature),
|
||||
|
|
@ -388,26 +491,19 @@ def beta_create_RouteGuide_server(servicer, pool=None, pool_size=None, default_t
|
|||
server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout)
|
||||
return beta_implementations.server(method_implementations, options=server_options)
|
||||
|
||||
|
||||
def beta_create_RouteGuide_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None):
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
import route_guide_pb2
|
||||
request_serializers = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): route_guide_pb2.Point.SerializeToString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): route_guide_pb2.Rectangle.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): route_guide_pb2.Point.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): route_guide_pb2.RouteNote.SerializeToString,
|
||||
('routeguide.RouteGuide', 'GetFeature'): Point.SerializeToString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): Rectangle.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): Point.SerializeToString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): RouteNote.SerializeToString,
|
||||
}
|
||||
response_deserializers = {
|
||||
('routeguide.RouteGuide', 'GetFeature'): route_guide_pb2.Feature.FromString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): route_guide_pb2.Feature.FromString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): route_guide_pb2.RouteSummary.FromString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): route_guide_pb2.RouteNote.FromString,
|
||||
('routeguide.RouteGuide', 'GetFeature'): Feature.FromString,
|
||||
('routeguide.RouteGuide', 'ListFeatures'): Feature.FromString,
|
||||
('routeguide.RouteGuide', 'RecordRoute'): RouteSummary.FromString,
|
||||
('routeguide.RouteGuide', 'RouteChat'): RouteNote.FromString,
|
||||
}
|
||||
cardinalities = {
|
||||
'GetFeature': cardinality.Cardinality.UNARY_UNARY,
|
||||
|
|
|
|||
|
|
@ -29,9 +29,12 @@
|
|||
|
||||
"""The Python implementation of the gRPC route guide server."""
|
||||
|
||||
from concurrent import futures
|
||||
import time
|
||||
import math
|
||||
|
||||
import grpc
|
||||
|
||||
import route_guide_pb2
|
||||
import route_guide_resources
|
||||
|
||||
|
|
@ -121,7 +124,9 @@ class RouteGuideServicer(route_guide_pb2.BetaRouteGuideServicer):
|
|||
|
||||
|
||||
def serve():
|
||||
server = route_guide_pb2.beta_create_RouteGuide_server(RouteGuideServicer())
|
||||
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
|
||||
route_guide_pb2.add_RouteGuideServicer_to_server(
|
||||
RouteGuideServicer(), server)
|
||||
server.add_insecure_port('[::]:50051')
|
||||
server.start()
|
||||
try:
|
||||
|
|
|
|||
23
src/ruby/tools/bin/grpc_tools_ruby_protoc.rb → examples/python/route_guide/run_codegen.py
Executable file → Normal file
23
src/ruby/tools/bin/grpc_tools_ruby_protoc.rb → examples/python/route_guide/run_codegen.py
Executable file → Normal file
|
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env ruby
|
||||
# Copyright 2016, Google Inc.
|
||||
# Copyright 2015, Google Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -28,14 +27,16 @@
|
|||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
require 'rbconfig'
|
||||
"""Runs protoc with the gRPC plugin to generate messages and gRPC stubs."""
|
||||
|
||||
require_relative '../os_check'
|
||||
from grpc.tools import protoc
|
||||
|
||||
protoc_name = 'protoc' + RbConfig::CONFIG['EXEEXT']
|
||||
|
||||
protoc_path = File.join(File.dirname(__FILE__),
|
||||
RbConfig::CONFIG['host_cpu'] + '-' + OS.os_name,
|
||||
protoc_name)
|
||||
|
||||
exec([ protoc_path, protoc_path ], *ARGV)
|
||||
protoc.main(
|
||||
(
|
||||
'',
|
||||
'-I../../protos',
|
||||
'--python_out=.',
|
||||
'--grpc_python_out=.',
|
||||
'../../protos/route_guide.proto',
|
||||
)
|
||||
)
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-Core'
|
||||
version = '0.14.0'
|
||||
version = '1.0.0-pre1'
|
||||
s.version = version
|
||||
s.summary = 'Core cross-platform gRPC library, written in C'
|
||||
s.homepage = 'http://www.grpc.io'
|
||||
|
|
@ -44,7 +44,7 @@ Pod::Spec.new do |s|
|
|||
|
||||
s.source = {
|
||||
:git => 'https://github.com/grpc/grpc.git',
|
||||
:tag => "release-#{version.gsub(/\./, '_')}-objectivec-#{version}",
|
||||
:tag => "objective-c-v#{version}",
|
||||
# TODO(jcanizales): Depend explicitly on the nanopb pod, and disable submodules.
|
||||
:submodules => true,
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ Pod::Spec.new do |s|
|
|||
ss.header_mappings_dir = '.'
|
||||
ss.libraries = 'z'
|
||||
ss.dependency "#{s.name}/Interface", version
|
||||
ss.dependency 'BoringSSL', '~> 4.0'
|
||||
ss.dependency 'BoringSSL', '~> 5.0'
|
||||
|
||||
# To save you from scrolling, this is the last part of the podspec.
|
||||
ss.source_files = 'src/core/lib/profiling/timers.h',
|
||||
|
|
@ -260,6 +260,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/channel/compress_filter.h',
|
||||
'src/core/lib/channel/connected_channel.h',
|
||||
'src/core/lib/channel/context.h',
|
||||
'src/core/lib/channel/handshaker.h',
|
||||
'src/core/lib/channel/http_client_filter.h',
|
||||
'src/core/lib/channel/http_server_filter.h',
|
||||
'src/core/lib/compression/algorithm_metadata.h',
|
||||
|
|
@ -331,6 +332,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/transport/metadata.h',
|
||||
'src/core/lib/transport/metadata_batch.h',
|
||||
'src/core/lib/transport/static_metadata.h',
|
||||
'src/core/lib/transport/timeout_encoding.h',
|
||||
'src/core/lib/transport/transport.h',
|
||||
'src/core/lib/transport/transport_impl.h',
|
||||
'src/core/ext/transport/chttp2/transport/bin_decoder.h',
|
||||
|
|
@ -352,7 +354,6 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/transport/chttp2/transport/internal.h',
|
||||
'src/core/ext/transport/chttp2/transport/status_conversion.h',
|
||||
'src/core/ext/transport/chttp2/transport/stream_map.h',
|
||||
'src/core/ext/transport/chttp2/transport/timeout_encoding.h',
|
||||
'src/core/ext/transport/chttp2/transport/varint.h',
|
||||
'src/core/ext/transport/chttp2/alpn/alpn.h',
|
||||
'src/core/lib/security/context/security_context.h',
|
||||
|
|
@ -395,6 +396,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/client_config/subchannel_call_holder.h',
|
||||
'src/core/ext/client_config/subchannel_index.h',
|
||||
'src/core/ext/client_config/uri_parser.h',
|
||||
'src/core/ext/lb_policy/grpclb/grpclb.h',
|
||||
'src/core/ext/lb_policy/grpclb/load_balancer_api.h',
|
||||
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
|
||||
'third_party/nanopb/pb.h',
|
||||
|
|
@ -404,11 +406,13 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/load_reporting/load_reporting.h',
|
||||
'src/core/ext/load_reporting/load_reporting_filter.h',
|
||||
'src/core/ext/census/aggregation.h',
|
||||
'src/core/ext/census/base_resources.h',
|
||||
'src/core/ext/census/census_interface.h',
|
||||
'src/core/ext/census/census_rpc_stats.h',
|
||||
'src/core/ext/census/gen/census.pb.h',
|
||||
'src/core/ext/census/grpc_filter.h',
|
||||
'src/core/ext/census/mlog.h',
|
||||
'src/core/ext/census/resource.h',
|
||||
'src/core/ext/census/rpc_metric_id.h',
|
||||
'src/core/lib/surface/init.c',
|
||||
'src/core/lib/channel/channel_args.c',
|
||||
|
|
@ -416,6 +420,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/channel/channel_stack_builder.c',
|
||||
'src/core/lib/channel/compress_filter.c',
|
||||
'src/core/lib/channel/connected_channel.c',
|
||||
'src/core/lib/channel/handshaker.c',
|
||||
'src/core/lib/channel/http_client_filter.c',
|
||||
'src/core/lib/channel/http_server_filter.c',
|
||||
'src/core/lib/compression/compression.c',
|
||||
|
|
@ -497,6 +502,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/transport/metadata.c',
|
||||
'src/core/lib/transport/metadata_batch.c',
|
||||
'src/core/lib/transport/static_metadata.c',
|
||||
'src/core/lib/transport/timeout_encoding.c',
|
||||
'src/core/lib/transport/transport.c',
|
||||
'src/core/lib/transport/transport_op_string.c',
|
||||
'src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c',
|
||||
|
|
@ -519,7 +525,6 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/transport/chttp2/transport/status_conversion.c',
|
||||
'src/core/ext/transport/chttp2/transport/stream_lists.c',
|
||||
'src/core/ext/transport/chttp2/transport/stream_map.c',
|
||||
'src/core/ext/transport/chttp2/transport/timeout_encoding.c',
|
||||
'src/core/ext/transport/chttp2/transport/varint.c',
|
||||
'src/core/ext/transport/chttp2/transport/writing.c',
|
||||
'src/core/ext/transport/chttp2/alpn/alpn.c',
|
||||
|
|
@ -575,6 +580,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c',
|
||||
'src/core/ext/transport/chttp2/client/insecure/channel_create.c',
|
||||
'src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c',
|
||||
'src/core/ext/lb_policy/grpclb/grpclb.c',
|
||||
'src/core/ext/lb_policy/grpclb/load_balancer_api.c',
|
||||
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c',
|
||||
'third_party/nanopb/pb_common.c',
|
||||
|
|
@ -586,6 +592,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/resolver/sockaddr/sockaddr_resolver.c',
|
||||
'src/core/ext/load_reporting/load_reporting.c',
|
||||
'src/core/ext/load_reporting/load_reporting_filter.c',
|
||||
'src/core/ext/census/base_resources.c',
|
||||
'src/core/ext/census/context.c',
|
||||
'src/core/ext/census/gen/census.pb.c',
|
||||
'src/core/ext/census/grpc_context.c',
|
||||
|
|
@ -595,6 +602,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/census/mlog.c',
|
||||
'src/core/ext/census/operation.c',
|
||||
'src/core/ext/census/placeholders.c',
|
||||
'src/core/ext/census/resource.c',
|
||||
'src/core/ext/census/tracing.c',
|
||||
'src/core/plugin_registry/grpc_plugin_registry.c'
|
||||
|
||||
|
|
@ -616,6 +624,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/channel/compress_filter.h',
|
||||
'src/core/lib/channel/connected_channel.h',
|
||||
'src/core/lib/channel/context.h',
|
||||
'src/core/lib/channel/handshaker.h',
|
||||
'src/core/lib/channel/http_client_filter.h',
|
||||
'src/core/lib/channel/http_server_filter.h',
|
||||
'src/core/lib/compression/algorithm_metadata.h',
|
||||
|
|
@ -687,6 +696,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/lib/transport/metadata.h',
|
||||
'src/core/lib/transport/metadata_batch.h',
|
||||
'src/core/lib/transport/static_metadata.h',
|
||||
'src/core/lib/transport/timeout_encoding.h',
|
||||
'src/core/lib/transport/transport.h',
|
||||
'src/core/lib/transport/transport_impl.h',
|
||||
'src/core/ext/transport/chttp2/transport/bin_decoder.h',
|
||||
|
|
@ -708,7 +718,6 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/transport/chttp2/transport/internal.h',
|
||||
'src/core/ext/transport/chttp2/transport/status_conversion.h',
|
||||
'src/core/ext/transport/chttp2/transport/stream_map.h',
|
||||
'src/core/ext/transport/chttp2/transport/timeout_encoding.h',
|
||||
'src/core/ext/transport/chttp2/transport/varint.h',
|
||||
'src/core/ext/transport/chttp2/alpn/alpn.h',
|
||||
'src/core/lib/security/context/security_context.h',
|
||||
|
|
@ -751,6 +760,7 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/client_config/subchannel_call_holder.h',
|
||||
'src/core/ext/client_config/subchannel_index.h',
|
||||
'src/core/ext/client_config/uri_parser.h',
|
||||
'src/core/ext/lb_policy/grpclb/grpclb.h',
|
||||
'src/core/ext/lb_policy/grpclb/load_balancer_api.h',
|
||||
'src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h',
|
||||
'third_party/nanopb/pb.h',
|
||||
|
|
@ -760,11 +770,13 @@ Pod::Spec.new do |s|
|
|||
'src/core/ext/load_reporting/load_reporting.h',
|
||||
'src/core/ext/load_reporting/load_reporting_filter.h',
|
||||
'src/core/ext/census/aggregation.h',
|
||||
'src/core/ext/census/base_resources.h',
|
||||
'src/core/ext/census/census_interface.h',
|
||||
'src/core/ext/census/census_rpc_stats.h',
|
||||
'src/core/ext/census/gen/census.pb.h',
|
||||
'src/core/ext/census/grpc_filter.h',
|
||||
'src/core/ext/census/mlog.h',
|
||||
'src/core/ext/census/resource.h',
|
||||
'src/core/ext/census/rpc_metric_id.h'
|
||||
end
|
||||
|
||||
|
|
@ -773,12 +785,16 @@ Pod::Spec.new do |s|
|
|||
ss.source_files = 'include/grpc/grpc_cronet.h'
|
||||
end
|
||||
|
||||
s.subspec 'Cronet-Tests' do |ss|
|
||||
s.subspec 'Cronet-Implementation' do |ss|
|
||||
ss.header_mappings_dir = '.'
|
||||
ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c',
|
||||
'src/core/ext/transport/cronet/transport/cronet_transport.c'
|
||||
end
|
||||
|
||||
s.subspec 'Tests' do |ss|
|
||||
ss.header_mappings_dir = '.'
|
||||
|
||||
ss.source_files = 'src/core/ext/transport/cronet/client/secure/cronet_channel_create.c',
|
||||
'src/core/ext/transport/cronet/transport/cronet_transport.c',
|
||||
'test/core/end2end/cq_verifier.{c,h}',
|
||||
ss.source_files = 'test/core/end2end/cq_verifier.{c,h}',
|
||||
'test/core/end2end/end2end_tests.{c,h}',
|
||||
'test/core/end2end/tests/*.{c,h}',
|
||||
'test/core/end2end/data/*.{c,h}',
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-ProtoRPC'
|
||||
version = '0.14.0'
|
||||
version = '1.0.0-pre1'
|
||||
s.version = version
|
||||
s.summary = 'RPC library for Protocol Buffers, based on gRPC'
|
||||
s.homepage = 'http://www.grpc.io'
|
||||
|
|
@ -45,7 +45,7 @@ Pod::Spec.new do |s|
|
|||
|
||||
s.source = {
|
||||
:git => 'https://github.com/grpc/grpc.git',
|
||||
:tag => "release-#{version.gsub(/\./, '_')}-objectivec-#{version}",
|
||||
:tag => "objective-c-v#{version}",
|
||||
}
|
||||
|
||||
s.ios.deployment_target = '7.1'
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC-RxLibrary'
|
||||
version = '0.14.0'
|
||||
version = '1.0.0-pre1'
|
||||
s.version = version
|
||||
s.summary = 'Reactive Extensions library for iOS/OSX.'
|
||||
s.homepage = 'http://www.grpc.io'
|
||||
|
|
@ -45,7 +45,7 @@ Pod::Spec.new do |s|
|
|||
|
||||
s.source = {
|
||||
:git => 'https://github.com/grpc/grpc.git',
|
||||
:tag => "release-#{version.gsub(/\./, '_')}-objectivec-#{version}",
|
||||
:tag => "objective-c-v#{version}",
|
||||
}
|
||||
|
||||
s.ios.deployment_target = '7.1'
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'gRPC'
|
||||
version = '0.14.0'
|
||||
version = '1.0.0-pre1'
|
||||
s.version = version
|
||||
s.summary = 'gRPC client library for iOS/OSX'
|
||||
s.homepage = 'http://www.grpc.io'
|
||||
|
|
@ -45,7 +45,7 @@ Pod::Spec.new do |s|
|
|||
|
||||
s.source = {
|
||||
:git => 'https://github.com/grpc/grpc.git',
|
||||
:tag => "release-#{version.gsub(/\./, '_')}-objectivec-#{version}",
|
||||
:tag => "objective-c-v#{version}",
|
||||
}
|
||||
|
||||
s.ios.deployment_target = '7.1'
|
||||
|
|
|
|||
11
grpc.def
11
grpc.def
|
|
@ -23,15 +23,10 @@ EXPORTS
|
|||
census_trace_scan_start
|
||||
census_get_trace_record
|
||||
census_trace_scan_end
|
||||
census_define_resource
|
||||
census_delete_resource
|
||||
census_resource_id
|
||||
census_record_values
|
||||
census_view_create
|
||||
census_view_delete
|
||||
census_view_metric
|
||||
census_view_naggregations
|
||||
census_view_tags
|
||||
census_view_aggregrations
|
||||
census_view_get_data
|
||||
census_view_reset
|
||||
grpc_compression_algorithm_parse
|
||||
grpc_compression_algorithm_name
|
||||
grpc_compression_algorithm_for_level
|
||||
|
|
|
|||
12
grpc.gemspec
12
grpc.gemspec
|
|
@ -179,6 +179,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/lib/channel/compress_filter.h )
|
||||
s.files += %w( src/core/lib/channel/connected_channel.h )
|
||||
s.files += %w( src/core/lib/channel/context.h )
|
||||
s.files += %w( src/core/lib/channel/handshaker.h )
|
||||
s.files += %w( src/core/lib/channel/http_client_filter.h )
|
||||
s.files += %w( src/core/lib/channel/http_server_filter.h )
|
||||
s.files += %w( src/core/lib/compression/algorithm_metadata.h )
|
||||
|
|
@ -250,6 +251,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/lib/transport/metadata.h )
|
||||
s.files += %w( src/core/lib/transport/metadata_batch.h )
|
||||
s.files += %w( src/core/lib/transport/static_metadata.h )
|
||||
s.files += %w( src/core/lib/transport/timeout_encoding.h )
|
||||
s.files += %w( src/core/lib/transport/transport.h )
|
||||
s.files += %w( src/core/lib/transport/transport_impl.h )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/bin_decoder.h )
|
||||
|
|
@ -271,7 +273,6 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/transport/chttp2/transport/internal.h )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/status_conversion.h )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/stream_map.h )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/timeout_encoding.h )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/varint.h )
|
||||
s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.h )
|
||||
s.files += %w( src/core/lib/security/context/security_context.h )
|
||||
|
|
@ -314,6 +315,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/client_config/subchannel_call_holder.h )
|
||||
s.files += %w( src/core/ext/client_config/subchannel_index.h )
|
||||
s.files += %w( src/core/ext/client_config/uri_parser.h )
|
||||
s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.h )
|
||||
s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.h )
|
||||
s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h )
|
||||
s.files += %w( third_party/nanopb/pb.h )
|
||||
|
|
@ -323,11 +325,13 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/load_reporting/load_reporting.h )
|
||||
s.files += %w( src/core/ext/load_reporting/load_reporting_filter.h )
|
||||
s.files += %w( src/core/ext/census/aggregation.h )
|
||||
s.files += %w( src/core/ext/census/base_resources.h )
|
||||
s.files += %w( src/core/ext/census/census_interface.h )
|
||||
s.files += %w( src/core/ext/census/census_rpc_stats.h )
|
||||
s.files += %w( src/core/ext/census/gen/census.pb.h )
|
||||
s.files += %w( src/core/ext/census/grpc_filter.h )
|
||||
s.files += %w( src/core/ext/census/mlog.h )
|
||||
s.files += %w( src/core/ext/census/resource.h )
|
||||
s.files += %w( src/core/ext/census/rpc_metric_id.h )
|
||||
s.files += %w( src/core/lib/surface/init.c )
|
||||
s.files += %w( src/core/lib/channel/channel_args.c )
|
||||
|
|
@ -335,6 +339,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/lib/channel/channel_stack_builder.c )
|
||||
s.files += %w( src/core/lib/channel/compress_filter.c )
|
||||
s.files += %w( src/core/lib/channel/connected_channel.c )
|
||||
s.files += %w( src/core/lib/channel/handshaker.c )
|
||||
s.files += %w( src/core/lib/channel/http_client_filter.c )
|
||||
s.files += %w( src/core/lib/channel/http_server_filter.c )
|
||||
s.files += %w( src/core/lib/compression/compression.c )
|
||||
|
|
@ -416,6 +421,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/lib/transport/metadata.c )
|
||||
s.files += %w( src/core/lib/transport/metadata_batch.c )
|
||||
s.files += %w( src/core/lib/transport/static_metadata.c )
|
||||
s.files += %w( src/core/lib/transport/timeout_encoding.c )
|
||||
s.files += %w( src/core/lib/transport/transport.c )
|
||||
s.files += %w( src/core/lib/transport/transport_op_string.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c )
|
||||
|
|
@ -438,7 +444,6 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/transport/chttp2/transport/status_conversion.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/stream_lists.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/stream_map.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/timeout_encoding.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/varint.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/transport/writing.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.c )
|
||||
|
|
@ -494,6 +499,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create.c )
|
||||
s.files += %w( src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c )
|
||||
s.files += %w( src/core/ext/lb_policy/grpclb/grpclb.c )
|
||||
s.files += %w( src/core/ext/lb_policy/grpclb/load_balancer_api.c )
|
||||
s.files += %w( src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c )
|
||||
s.files += %w( third_party/nanopb/pb_common.c )
|
||||
|
|
@ -505,6 +511,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/resolver/sockaddr/sockaddr_resolver.c )
|
||||
s.files += %w( src/core/ext/load_reporting/load_reporting.c )
|
||||
s.files += %w( src/core/ext/load_reporting/load_reporting_filter.c )
|
||||
s.files += %w( src/core/ext/census/base_resources.c )
|
||||
s.files += %w( src/core/ext/census/context.c )
|
||||
s.files += %w( src/core/ext/census/gen/census.pb.c )
|
||||
s.files += %w( src/core/ext/census/grpc_context.c )
|
||||
|
|
@ -514,6 +521,7 @@ Gem::Specification.new do |s|
|
|||
s.files += %w( src/core/ext/census/mlog.c )
|
||||
s.files += %w( src/core/ext/census/operation.c )
|
||||
s.files += %w( src/core/ext/census/placeholders.c )
|
||||
s.files += %w( src/core/ext/census/resource.c )
|
||||
s.files += %w( src/core/ext/census/tracing.c )
|
||||
s.files += %w( src/core/plugin_registry/grpc_plugin_registry.c )
|
||||
s.files += %w( third_party/boringssl/crypto/aes/internal.h )
|
||||
|
|
|
|||
|
|
@ -330,6 +330,9 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface<W, R> {
|
|||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
meta_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
|
@ -345,6 +348,9 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface<W, R> {
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
finish_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// The response is dropped if the status is not OK.
|
||||
|
|
@ -363,6 +369,9 @@ class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface<W, R> {
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
finish_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
|
||||
|
|
@ -400,6 +409,9 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface<W> {
|
|||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
meta_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
|
@ -409,6 +421,9 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface<W> {
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
write_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
write_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// TODO(ctiller): don't assert
|
||||
|
|
@ -421,6 +436,9 @@ class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface<W> {
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
finish_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
|
||||
|
|
@ -459,6 +477,9 @@ class ServerAsyncReaderWriter GRPC_FINAL
|
|||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
meta_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
|
@ -474,6 +495,9 @@ class ServerAsyncReaderWriter GRPC_FINAL
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
write_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
write_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// TODO(ctiller): don't assert
|
||||
|
|
@ -486,6 +510,9 @@ class ServerAsyncReaderWriter GRPC_FINAL
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
finish_ops_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
|
||||
|
|
|
|||
|
|
@ -126,6 +126,9 @@ class ServerAsyncResponseWriter GRPC_FINAL
|
|||
meta_buf_.set_output_tag(tag);
|
||||
meta_buf_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
meta_buf_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_.PerformOps(&meta_buf_);
|
||||
}
|
||||
|
|
@ -135,6 +138,9 @@ class ServerAsyncResponseWriter GRPC_FINAL
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_buf_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
finish_buf_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// The response is dropped if the status is not OK.
|
||||
|
|
@ -153,6 +159,9 @@ class ServerAsyncResponseWriter GRPC_FINAL
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_buf_.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
finish_buf_.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
finish_buf_.ServerSendStatus(ctx_->trailing_metadata_, status);
|
||||
|
|
|
|||
|
|
@ -180,17 +180,23 @@ class CallNoOp {
|
|||
|
||||
class CallOpSendInitialMetadata {
|
||||
public:
|
||||
CallOpSendInitialMetadata() : send_(false) {}
|
||||
CallOpSendInitialMetadata() : send_(false) {
|
||||
maybe_compression_level_.is_set = false;
|
||||
}
|
||||
|
||||
void SendInitialMetadata(
|
||||
const std::multimap<grpc::string, grpc::string>& metadata,
|
||||
uint32_t flags) {
|
||||
maybe_compression_level_.is_set = false;
|
||||
send_ = true;
|
||||
flags_ = flags;
|
||||
initial_metadata_count_ = metadata.size();
|
||||
initial_metadata_ = FillMetadataArray(metadata);
|
||||
// TODO(dgq): expose compression level in API so it can be properly set.
|
||||
maybe_compression_level_.is_set = false;
|
||||
}
|
||||
|
||||
void set_compression_level(grpc_compression_level level) {
|
||||
maybe_compression_level_.is_set = true;
|
||||
maybe_compression_level_.level = level;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -62,6 +62,13 @@
|
|||
#define GRPC_CUSTOM_SOURCELOCATION ::google::protobuf::SourceLocation
|
||||
#endif
|
||||
|
||||
#ifndef GRPC_CUSTOM_DESCRIPTORDATABASE
|
||||
#include <google/protobuf/descriptor_database.h>
|
||||
#define GRPC_CUSTOM_DESCRIPTORDATABASE ::google::protobuf::DescriptorDatabase
|
||||
#define GRPC_CUSTOM_SIMPLEDESCRIPTORDATABASE \
|
||||
::google::protobuf::SimpleDescriptorDatabase
|
||||
#endif
|
||||
|
||||
#ifndef GRPC_CUSTOM_ZEROCOPYOUTPUTSTREAM
|
||||
#include <google/protobuf/io/coded_stream.h>
|
||||
#include <google/protobuf/io/zero_copy_stream.h>
|
||||
|
|
@ -80,11 +87,13 @@ typedef GRPC_CUSTOM_PROTOBUF_INT64 int64;
|
|||
|
||||
typedef GRPC_CUSTOM_DESCRIPTOR Descriptor;
|
||||
typedef GRPC_CUSTOM_DESCRIPTORPOOL DescriptorPool;
|
||||
typedef GRPC_CUSTOM_DESCRIPTORDATABASE DescriptorDatabase;
|
||||
typedef GRPC_CUSTOM_FIELDDESCRIPTOR FieldDescriptor;
|
||||
typedef GRPC_CUSTOM_FILEDESCRIPTOR FileDescriptor;
|
||||
typedef GRPC_CUSTOM_FILEDESCRIPTORPROTO FileDescriptorProto;
|
||||
typedef GRPC_CUSTOM_METHODDESCRIPTOR MethodDescriptor;
|
||||
typedef GRPC_CUSTOM_SERVICEDESCRIPTOR ServiceDescriptor;
|
||||
typedef GRPC_CUSTOM_SIMPLEDESCRIPTORDATABASE SimpleDescriptorDatabase;
|
||||
typedef GRPC_CUSTOM_SOURCELOCATION SourceLocation;
|
||||
|
||||
namespace io {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
|
||||
#define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
|
||||
|
||||
// This file should be compiled as part of grpc++.
|
||||
|
||||
#include <grpc++/impl/codegen/core_codegen_interface.h>
|
||||
|
|
@ -83,3 +86,5 @@ class CoreCodegen : public CoreCodegenInterface {
|
|||
};
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
|
||||
|
|
|
|||
|
|
@ -1,486 +0,0 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2015, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GRPCXX_IMPL_CODEGEN_IMPL_ASYNC_STREAM_H
|
||||
#define GRPCXX_IMPL_CODEGEN_IMPL_ASYNC_STREAM_H
|
||||
|
||||
#include <grpc++/impl/codegen/call.h>
|
||||
#include <grpc++/impl/codegen/channel_interface.h>
|
||||
#include <grpc++/impl/codegen/core_codegen_interface.h>
|
||||
#include <grpc++/impl/codegen/server_context.h>
|
||||
#include <grpc++/impl/codegen/service_type.h>
|
||||
#include <grpc++/impl/codegen/status.h>
|
||||
|
||||
namespace grpc {
|
||||
|
||||
class CompletionQueue;
|
||||
|
||||
/// Common interface for all client side asynchronous streaming.
|
||||
class ClientAsyncStreamingInterface {
|
||||
public:
|
||||
virtual ~ClientAsyncStreamingInterface() {}
|
||||
|
||||
/// Request notification of the reading of the initial metadata. Completion
|
||||
/// will be notified by \a tag on the associated completion queue.
|
||||
///
|
||||
/// \param[in] tag Tag identifying this request.
|
||||
virtual void ReadInitialMetadata(void* tag) = 0;
|
||||
|
||||
/// Request notification completion.
|
||||
///
|
||||
/// \param[out] status To be updated with the operation status.
|
||||
/// \param[in] tag Tag identifying this request.
|
||||
virtual void Finish(Status* status, void* tag) = 0;
|
||||
};
|
||||
|
||||
/// An interface that yields a sequence of messages of type \a R.
|
||||
template <class R>
|
||||
class AsyncReaderInterface {
|
||||
public:
|
||||
virtual ~AsyncReaderInterface() {}
|
||||
|
||||
/// Read a message of type \a R into \a msg. Completion will be notified by \a
|
||||
/// tag on the associated completion queue.
|
||||
///
|
||||
/// \param[out] msg Where to eventually store the read message.
|
||||
/// \param[in] tag The tag identifying the operation.
|
||||
virtual void Read(R* msg, void* tag) = 0;
|
||||
};
|
||||
|
||||
/// An interface that can be fed a sequence of messages of type \a W.
|
||||
template <class W>
|
||||
class AsyncWriterInterface {
|
||||
public:
|
||||
virtual ~AsyncWriterInterface() {}
|
||||
|
||||
/// Request the writing of \a msg with identifying tag \a tag.
|
||||
///
|
||||
/// Only one write may be outstanding at any given time. This means that
|
||||
/// after calling Write, one must wait to receive \a tag from the completion
|
||||
/// queue BEFORE calling Write again.
|
||||
///
|
||||
/// \param[in] msg The message to be written.
|
||||
/// \param[in] tag The tag identifying the operation.
|
||||
virtual void Write(const W& msg, void* tag) = 0;
|
||||
};
|
||||
|
||||
template <class R>
|
||||
class ClientAsyncReaderInterface : public ClientAsyncStreamingInterface,
|
||||
public AsyncReaderInterface<R> {};
|
||||
|
||||
template <class R>
|
||||
class ClientAsyncReader GRPC_FINAL : public ClientAsyncReaderInterface<R> {
|
||||
public:
|
||||
/// Create a stream and write the first request out.
|
||||
template <class W>
|
||||
ClientAsyncReader(ChannelInterface* channel, CompletionQueue* cq,
|
||||
const RpcMethod& method, ClientContext* context,
|
||||
const W& request, void* tag)
|
||||
: context_(context), call_(channel->CreateCall(method, context, cq)) {
|
||||
init_ops_.set_output_tag(tag);
|
||||
init_ops_.SendInitialMetadata(context->send_initial_metadata_);
|
||||
// TODO(ctiller): don't assert
|
||||
GPR_CODEGEN_ASSERT(init_ops_.SendMessage(request).ok());
|
||||
init_ops_.ClientSendClose();
|
||||
call_.PerformOps(&init_ops_);
|
||||
}
|
||||
|
||||
void ReadInitialMetadata(void* tag) GRPC_OVERRIDE {
|
||||
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.RecvInitialMetadata(context_);
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
||||
void Read(R* msg, void* tag) GRPC_OVERRIDE {
|
||||
read_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
read_ops_.RecvInitialMetadata(context_);
|
||||
}
|
||||
read_ops_.RecvMessage(msg);
|
||||
call_.PerformOps(&read_ops_);
|
||||
}
|
||||
|
||||
void Finish(Status* status, void* tag) GRPC_OVERRIDE {
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
finish_ops_.RecvInitialMetadata(context_);
|
||||
}
|
||||
finish_ops_.ClientRecvStatus(context_, status);
|
||||
call_.PerformOps(&finish_ops_);
|
||||
}
|
||||
|
||||
private:
|
||||
ClientContext* context_;
|
||||
Call call_;
|
||||
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose>
|
||||
init_ops_;
|
||||
CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
|
||||
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> read_ops_;
|
||||
CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> finish_ops_;
|
||||
};
|
||||
|
||||
/// Common interface for client side asynchronous writing.
|
||||
template <class W>
|
||||
class ClientAsyncWriterInterface : public ClientAsyncStreamingInterface,
|
||||
public AsyncWriterInterface<W> {
|
||||
public:
|
||||
/// Signal the client is done with the writes.
|
||||
///
|
||||
/// \param[in] tag The tag identifying the operation.
|
||||
virtual void WritesDone(void* tag) = 0;
|
||||
};
|
||||
|
||||
template <class W>
|
||||
class ClientAsyncWriter GRPC_FINAL : public ClientAsyncWriterInterface<W> {
|
||||
public:
|
||||
template <class R>
|
||||
ClientAsyncWriter(ChannelInterface* channel, CompletionQueue* cq,
|
||||
const RpcMethod& method, ClientContext* context,
|
||||
R* response, void* tag)
|
||||
: context_(context), call_(channel->CreateCall(method, context, cq)) {
|
||||
finish_ops_.RecvMessage(response);
|
||||
|
||||
init_ops_.set_output_tag(tag);
|
||||
init_ops_.SendInitialMetadata(context->send_initial_metadata_);
|
||||
call_.PerformOps(&init_ops_);
|
||||
}
|
||||
|
||||
void ReadInitialMetadata(void* tag) GRPC_OVERRIDE {
|
||||
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.RecvInitialMetadata(context_);
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
||||
void Write(const W& msg, void* tag) GRPC_OVERRIDE {
|
||||
write_ops_.set_output_tag(tag);
|
||||
// TODO(ctiller): don't assert
|
||||
GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void WritesDone(void* tag) GRPC_OVERRIDE {
|
||||
writes_done_ops_.set_output_tag(tag);
|
||||
writes_done_ops_.ClientSendClose();
|
||||
call_.PerformOps(&writes_done_ops_);
|
||||
}
|
||||
|
||||
void Finish(Status* status, void* tag) GRPC_OVERRIDE {
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
finish_ops_.RecvInitialMetadata(context_);
|
||||
}
|
||||
finish_ops_.ClientRecvStatus(context_, status);
|
||||
call_.PerformOps(&finish_ops_);
|
||||
}
|
||||
|
||||
private:
|
||||
ClientContext* context_;
|
||||
Call call_;
|
||||
CallOpSet<CallOpSendInitialMetadata> init_ops_;
|
||||
CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
|
||||
CallOpSet<CallOpSendMessage> write_ops_;
|
||||
CallOpSet<CallOpClientSendClose> writes_done_ops_;
|
||||
CallOpSet<CallOpRecvInitialMetadata, CallOpGenericRecvMessage,
|
||||
CallOpClientRecvStatus>
|
||||
finish_ops_;
|
||||
};
|
||||
|
||||
/// Client-side interface for asynchronous bi-directional streaming.
|
||||
template <class W, class R>
|
||||
class ClientAsyncReaderWriterInterface : public ClientAsyncStreamingInterface,
|
||||
public AsyncWriterInterface<W>,
|
||||
public AsyncReaderInterface<R> {
|
||||
public:
|
||||
/// Signal the client is done with the writes.
|
||||
///
|
||||
/// \param[in] tag The tag identifying the operation.
|
||||
virtual void WritesDone(void* tag) = 0;
|
||||
};
|
||||
|
||||
template <class W, class R>
|
||||
class ClientAsyncReaderWriter GRPC_FINAL
|
||||
: public ClientAsyncReaderWriterInterface<W, R> {
|
||||
public:
|
||||
ClientAsyncReaderWriter(ChannelInterface* channel, CompletionQueue* cq,
|
||||
const RpcMethod& method, ClientContext* context,
|
||||
void* tag)
|
||||
: context_(context), call_(channel->CreateCall(method, context, cq)) {
|
||||
init_ops_.set_output_tag(tag);
|
||||
init_ops_.SendInitialMetadata(context->send_initial_metadata_);
|
||||
call_.PerformOps(&init_ops_);
|
||||
}
|
||||
|
||||
void ReadInitialMetadata(void* tag) GRPC_OVERRIDE {
|
||||
GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.RecvInitialMetadata(context_);
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
||||
void Read(R* msg, void* tag) GRPC_OVERRIDE {
|
||||
read_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
read_ops_.RecvInitialMetadata(context_);
|
||||
}
|
||||
read_ops_.RecvMessage(msg);
|
||||
call_.PerformOps(&read_ops_);
|
||||
}
|
||||
|
||||
void Write(const W& msg, void* tag) GRPC_OVERRIDE {
|
||||
write_ops_.set_output_tag(tag);
|
||||
// TODO(ctiller): don't assert
|
||||
GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void WritesDone(void* tag) GRPC_OVERRIDE {
|
||||
writes_done_ops_.set_output_tag(tag);
|
||||
writes_done_ops_.ClientSendClose();
|
||||
call_.PerformOps(&writes_done_ops_);
|
||||
}
|
||||
|
||||
void Finish(Status* status, void* tag) GRPC_OVERRIDE {
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!context_->initial_metadata_received_) {
|
||||
finish_ops_.RecvInitialMetadata(context_);
|
||||
}
|
||||
finish_ops_.ClientRecvStatus(context_, status);
|
||||
call_.PerformOps(&finish_ops_);
|
||||
}
|
||||
|
||||
private:
|
||||
ClientContext* context_;
|
||||
Call call_;
|
||||
CallOpSet<CallOpSendInitialMetadata> init_ops_;
|
||||
CallOpSet<CallOpRecvInitialMetadata> meta_ops_;
|
||||
CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>> read_ops_;
|
||||
CallOpSet<CallOpSendMessage> write_ops_;
|
||||
CallOpSet<CallOpClientSendClose> writes_done_ops_;
|
||||
CallOpSet<CallOpRecvInitialMetadata, CallOpClientRecvStatus> finish_ops_;
|
||||
};
|
||||
|
||||
template <class W, class R>
|
||||
class ServerAsyncReaderInterface : public ServerAsyncStreamingInterface,
|
||||
public AsyncReaderInterface<R> {
|
||||
public:
|
||||
virtual void Finish(const W& msg, const Status& status, void* tag) = 0;
|
||||
|
||||
virtual void FinishWithError(const Status& status, void* tag) = 0;
|
||||
};
|
||||
|
||||
template <class W, class R>
|
||||
class ServerAsyncReader GRPC_FINAL : public ServerAsyncReaderInterface<W, R> {
|
||||
public:
|
||||
explicit ServerAsyncReader(ServerContext* ctx)
|
||||
: call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
|
||||
|
||||
void SendInitialMetadata(void* tag) GRPC_OVERRIDE {
|
||||
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
||||
void Read(R* msg, void* tag) GRPC_OVERRIDE {
|
||||
read_ops_.set_output_tag(tag);
|
||||
read_ops_.RecvMessage(msg);
|
||||
call_.PerformOps(&read_ops_);
|
||||
}
|
||||
|
||||
void Finish(const W& msg, const Status& status, void* tag) GRPC_OVERRIDE {
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// The response is dropped if the status is not OK.
|
||||
if (status.ok()) {
|
||||
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_,
|
||||
finish_ops_.SendMessage(msg));
|
||||
} else {
|
||||
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
|
||||
}
|
||||
call_.PerformOps(&finish_ops_);
|
||||
}
|
||||
|
||||
void FinishWithError(const Status& status, void* tag) GRPC_OVERRIDE {
|
||||
GPR_CODEGEN_ASSERT(!status.ok());
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
|
||||
call_.PerformOps(&finish_ops_);
|
||||
}
|
||||
|
||||
private:
|
||||
void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; }
|
||||
|
||||
Call call_;
|
||||
ServerContext* ctx_;
|
||||
CallOpSet<CallOpSendInitialMetadata> meta_ops_;
|
||||
CallOpSet<CallOpRecvMessage<R>> read_ops_;
|
||||
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage,
|
||||
CallOpServerSendStatus>
|
||||
finish_ops_;
|
||||
};
|
||||
|
||||
template <class W>
|
||||
class ServerAsyncWriterInterface : public ServerAsyncStreamingInterface,
|
||||
public AsyncWriterInterface<W> {
|
||||
public:
|
||||
virtual void Finish(const Status& status, void* tag) = 0;
|
||||
};
|
||||
|
||||
template <class W>
|
||||
class ServerAsyncWriter GRPC_FINAL : public ServerAsyncWriterInterface<W> {
|
||||
public:
|
||||
explicit ServerAsyncWriter(ServerContext* ctx)
|
||||
: call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
|
||||
|
||||
void SendInitialMetadata(void* tag) GRPC_OVERRIDE {
|
||||
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
||||
void Write(const W& msg, void* tag) GRPC_OVERRIDE {
|
||||
write_ops_.set_output_tag(tag);
|
||||
if (!ctx_->sent_initial_metadata_) {
|
||||
write_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// TODO(ctiller): don't assert
|
||||
GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void Finish(const Status& status, void* tag) GRPC_OVERRIDE {
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
|
||||
call_.PerformOps(&finish_ops_);
|
||||
}
|
||||
|
||||
private:
|
||||
void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; }
|
||||
|
||||
Call call_;
|
||||
ServerContext* ctx_;
|
||||
CallOpSet<CallOpSendInitialMetadata> meta_ops_;
|
||||
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage> write_ops_;
|
||||
CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> finish_ops_;
|
||||
};
|
||||
|
||||
/// Server-side interface for asynchronous bi-directional streaming.
|
||||
template <class W, class R>
|
||||
class ServerAsyncReaderWriterInterface : public ServerAsyncStreamingInterface,
|
||||
public AsyncWriterInterface<W>,
|
||||
public AsyncReaderInterface<R> {
|
||||
public:
|
||||
virtual void Finish(const Status& status, void* tag) = 0;
|
||||
};
|
||||
|
||||
template <class W, class R>
|
||||
class ServerAsyncReaderWriter GRPC_FINAL
|
||||
: public ServerAsyncReaderWriterInterface<W, R> {
|
||||
public:
|
||||
explicit ServerAsyncReaderWriter(ServerContext* ctx)
|
||||
: call_(nullptr, nullptr, nullptr), ctx_(ctx) {}
|
||||
|
||||
void SendInitialMetadata(void* tag) GRPC_OVERRIDE {
|
||||
GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_);
|
||||
|
||||
meta_ops_.set_output_tag(tag);
|
||||
meta_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_.PerformOps(&meta_ops_);
|
||||
}
|
||||
|
||||
void Read(R* msg, void* tag) GRPC_OVERRIDE {
|
||||
read_ops_.set_output_tag(tag);
|
||||
read_ops_.RecvMessage(msg);
|
||||
call_.PerformOps(&read_ops_);
|
||||
}
|
||||
|
||||
void Write(const W& msg, void* tag) GRPC_OVERRIDE {
|
||||
write_ops_.set_output_tag(tag);
|
||||
if (!ctx_->sent_initial_metadata_) {
|
||||
write_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
// TODO(ctiller): don't assert
|
||||
GPR_CODEGEN_ASSERT(write_ops_.SendMessage(msg).ok());
|
||||
call_.PerformOps(&write_ops_);
|
||||
}
|
||||
|
||||
void Finish(const Status& status, void* tag) GRPC_OVERRIDE {
|
||||
finish_ops_.set_output_tag(tag);
|
||||
if (!ctx_->sent_initial_metadata_) {
|
||||
finish_ops_.SendInitialMetadata(ctx_->initial_metadata_);
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
finish_ops_.ServerSendStatus(ctx_->trailing_metadata_, status);
|
||||
call_.PerformOps(&finish_ops_);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class ::grpc::Server;
|
||||
|
||||
void BindCall(Call* call) GRPC_OVERRIDE { call_ = *call; }
|
||||
|
||||
Call call_;
|
||||
ServerContext* ctx_;
|
||||
CallOpSet<CallOpSendInitialMetadata> meta_ops_;
|
||||
CallOpSet<CallOpRecvMessage<R>> read_ops_;
|
||||
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage> write_ops_;
|
||||
CallOpSet<CallOpSendInitialMetadata, CallOpServerSendStatus> finish_ops_;
|
||||
};
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCXX_IMPL_CODEGEN_IMPL_ASYNC_STREAM_H
|
||||
|
|
@ -65,6 +65,9 @@ class RpcMethodHandler : public MethodHandler {
|
|||
ops;
|
||||
ops.SendInitialMetadata(param.server_context->initial_metadata_,
|
||||
param.server_context->initial_metadata_flags());
|
||||
if (param.server_context->compression_level_set()) {
|
||||
ops.set_compression_level(param.server_context->compression_level());
|
||||
}
|
||||
if (status.ok()) {
|
||||
status = ops.SendMessage(rsp);
|
||||
}
|
||||
|
|
@ -104,6 +107,9 @@ class ClientStreamingHandler : public MethodHandler {
|
|||
ops;
|
||||
ops.SendInitialMetadata(param.server_context->initial_metadata_,
|
||||
param.server_context->initial_metadata_flags());
|
||||
if (param.server_context->compression_level_set()) {
|
||||
ops.set_compression_level(param.server_context->compression_level());
|
||||
}
|
||||
if (status.ok()) {
|
||||
status = ops.SendMessage(rsp);
|
||||
}
|
||||
|
|
@ -144,6 +150,9 @@ class ServerStreamingHandler : public MethodHandler {
|
|||
if (!param.server_context->sent_initial_metadata_) {
|
||||
ops.SendInitialMetadata(param.server_context->initial_metadata_,
|
||||
param.server_context->initial_metadata_flags());
|
||||
if (param.server_context->compression_level_set()) {
|
||||
ops.set_compression_level(param.server_context->compression_level());
|
||||
}
|
||||
}
|
||||
ops.ServerSendStatus(param.server_context->trailing_metadata_, status);
|
||||
param.call->PerformOps(&ops);
|
||||
|
|
@ -177,6 +186,9 @@ class BidiStreamingHandler : public MethodHandler {
|
|||
if (!param.server_context->sent_initial_metadata_) {
|
||||
ops.SendInitialMetadata(param.server_context->initial_metadata_,
|
||||
param.server_context->initial_metadata_flags());
|
||||
if (param.server_context->compression_level_set()) {
|
||||
ops.set_compression_level(param.server_context->compression_level());
|
||||
}
|
||||
}
|
||||
ops.ServerSendStatus(param.server_context->trailing_metadata_, status);
|
||||
param.call->PerformOps(&ops);
|
||||
|
|
@ -199,6 +211,9 @@ class UnknownMethodHandler : public MethodHandler {
|
|||
if (!context->sent_initial_metadata_) {
|
||||
ops->SendInitialMetadata(context->initial_metadata_,
|
||||
context->initial_metadata_flags());
|
||||
if (context->compression_level_set()) {
|
||||
ops->set_compression_level(context->compression_level());
|
||||
}
|
||||
context->sent_initial_metadata_ = true;
|
||||
}
|
||||
ops->ServerSendStatus(context->trailing_metadata_, status);
|
||||
|
|
|
|||
|
|
@ -130,7 +130,13 @@ class ServerContext {
|
|||
grpc_compression_level compression_level() const {
|
||||
return compression_level_;
|
||||
}
|
||||
void set_compression_level(grpc_compression_level level);
|
||||
|
||||
void set_compression_level(grpc_compression_level level) {
|
||||
compression_level_set_ = true;
|
||||
compression_level_ = level;
|
||||
}
|
||||
|
||||
bool compression_level_set() const { return compression_level_set_; }
|
||||
|
||||
grpc_compression_algorithm compression_algorithm() const {
|
||||
return compression_algorithm_;
|
||||
|
|
@ -217,6 +223,7 @@ class ServerContext {
|
|||
std::multimap<grpc::string, grpc::string> initial_metadata_;
|
||||
std::multimap<grpc::string, grpc::string> trailing_metadata_;
|
||||
|
||||
bool compression_level_set_;
|
||||
grpc_compression_level compression_level_;
|
||||
grpc_compression_algorithm compression_algorithm_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -347,6 +347,9 @@ class ServerReader GRPC_FINAL : public ReaderInterface<R> {
|
|||
CallOpSet<CallOpSendInitialMetadata> ops;
|
||||
ops.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
ops.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_->PerformOps(&ops);
|
||||
call_->cq()->Pluck(&ops);
|
||||
|
|
@ -375,6 +378,9 @@ class ServerWriter GRPC_FINAL : public WriterInterface<W> {
|
|||
CallOpSet<CallOpSendInitialMetadata> ops;
|
||||
ops.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
ops.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_->PerformOps(&ops);
|
||||
call_->cq()->Pluck(&ops);
|
||||
|
|
@ -389,6 +395,9 @@ class ServerWriter GRPC_FINAL : public WriterInterface<W> {
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
ops.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
ops.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
call_->PerformOps(&ops);
|
||||
|
|
@ -413,6 +422,9 @@ class ServerReaderWriter GRPC_FINAL : public WriterInterface<W>,
|
|||
CallOpSet<CallOpSendInitialMetadata> ops;
|
||||
ops.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
ops.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
call_->PerformOps(&ops);
|
||||
call_->cq()->Pluck(&ops);
|
||||
|
|
@ -434,6 +446,9 @@ class ServerReaderWriter GRPC_FINAL : public WriterInterface<W>,
|
|||
if (!ctx_->sent_initial_metadata_) {
|
||||
ops.SendInitialMetadata(ctx_->initial_metadata_,
|
||||
ctx_->initial_metadata_flags());
|
||||
if (ctx_->compression_level_set()) {
|
||||
ops.set_compression_level(ctx_->compression_level());
|
||||
}
|
||||
ctx_->sent_initial_metadata_ = true;
|
||||
}
|
||||
call_->PerformOps(&ops);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2015, Google Inc.
|
||||
* Copyright 2015-2016, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -56,9 +56,11 @@ enum census_features {
|
|||
|
||||
/** Shutdown and startup census subsystem. The 'features' argument should be
|
||||
* the OR (|) of census_features values. If census fails to initialize, then
|
||||
* census_initialize() will return a non-zero value. It is an error to call
|
||||
* census_initialize() more than once (without an intervening
|
||||
* census_shutdown()). */
|
||||
* census_initialize() will return -1, otherwise the set of enabled features
|
||||
* (which may be smaller than that provided in the `features` argument, see
|
||||
* census_supported()) is returned. It is an error to call census_initialize()
|
||||
* more than once (without an intervening census_shutdown()). These functions
|
||||
* are not thread-safe. */
|
||||
CENSUSAPI int census_initialize(int features);
|
||||
CENSUSAPI void census_shutdown(void);
|
||||
|
||||
|
|
@ -430,30 +432,44 @@ CENSUSAPI int census_get_trace_record(census_trace_record *trace_record);
|
|||
CENSUSAPI void census_trace_scan_end();
|
||||
|
||||
/* Core stats collection API's. The following concepts are used:
|
||||
* Aggregation: A collection of values. Census supports the following
|
||||
aggregation types:
|
||||
Sum - a single summation type. Typically used for keeping (e.g.)
|
||||
counts of events.
|
||||
Distribution - statistical distribution information, used for
|
||||
recording average, standard deviation etc.
|
||||
Histogram - a histogram of measurements falling in defined bucket
|
||||
boundaries.
|
||||
Window - a count of events that happen in reolling time window.
|
||||
New aggregation types can be added by the user, if desired (see
|
||||
census_register_aggregation()).
|
||||
* Metric: Each measurement is for a single metric. Examples include RPC
|
||||
latency, CPU seconds consumed, and bytes transmitted.
|
||||
* View: A view is a combination of a metric, a tag set (in which the tag
|
||||
values are regular expressions) and a set of aggregations. When a
|
||||
measurement for a metric matches the view tags, it is recorded (for each
|
||||
unique set of tags) against each aggregation. Each metric can have an
|
||||
arbitrary number of views by which it will be broken down.
|
||||
* Resource: Users record measurements for a single resource. Examples
|
||||
include RPC latency, CPU seconds consumed, and bytes transmitted.
|
||||
* Aggregation: An aggregation of a set of measurements. Census supports the
|
||||
following aggregation types:
|
||||
* Distribution - statistical distribution information, used for
|
||||
recording average, standard deviation etc. Can include a histogram.
|
||||
* Interval - a count of events that happen in a rolling time window.
|
||||
* View: A view is a combination of a Resource, a set of tag keys and an
|
||||
Aggregation. When a measurement for a Resource matches the View tags, it is
|
||||
recorded (for each unique set of tag values) using the Aggregation type.
|
||||
Each resource can have an arbitrary number of views by which it will be
|
||||
broken down.
|
||||
|
||||
Census uses protos to define each of the above, and output results. This
|
||||
ensures unification across the different language and runtime
|
||||
implementations. The proto definitions can be found in src/proto/census.
|
||||
*/
|
||||
|
||||
/* Define a new resource. `resource_pb` should contain an encoded Resource
|
||||
protobuf, `resource_pb_size` being the size of the buffer. Returns a -ve
|
||||
value on error, or a positive (>= 0) resource id (for use in
|
||||
census_delete_resource() and census_record_values()). In order to be valid, a
|
||||
resource must have a name, and at least one numerator in it's unit type. The
|
||||
resource name must be unique, and an error will be returned if it is not. */
|
||||
CENSUSAPI int32_t census_define_resource(const uint8_t *resource_pb,
|
||||
size_t resource_pb_size);
|
||||
|
||||
/* Delete a resource created by census_define_resource(). */
|
||||
CENSUSAPI void census_delete_resource(int32_t resource_id);
|
||||
|
||||
/* Determine the id of a resource, given it's name. returns -1 if the resource
|
||||
does not exist. */
|
||||
CENSUSAPI int32_t census_resource_id(const char *name);
|
||||
|
||||
/* A single value to be recorded comprises two parts: an ID for the particular
|
||||
* metric and the value to be recorded against it. */
|
||||
* resource and the value to be recorded against it. */
|
||||
typedef struct {
|
||||
uint32_t metric_id;
|
||||
int32_t resource_id;
|
||||
double value;
|
||||
} census_value;
|
||||
|
||||
|
|
@ -461,78 +477,6 @@ typedef struct {
|
|||
CENSUSAPI void census_record_values(census_context *context,
|
||||
census_value *values, size_t nvalues);
|
||||
|
||||
/** Type representing a particular aggregation */
|
||||
typedef struct census_aggregation_ops census_aggregation_ops;
|
||||
|
||||
/* Predefined aggregation types, for use with census_view_create(). */
|
||||
extern census_aggregation_ops census_agg_sum;
|
||||
extern census_aggregation_ops census_agg_distribution;
|
||||
extern census_aggregation_ops census_agg_histogram;
|
||||
extern census_aggregation_ops census_agg_window;
|
||||
|
||||
/** Information needed to instantiate a new aggregation. Used in view
|
||||
construction via census_define_view(). */
|
||||
typedef struct {
|
||||
const census_aggregation_ops *ops;
|
||||
const void *create_arg; /* Aaggregation initialization argument. */
|
||||
} census_aggregation;
|
||||
|
||||
/** A census view type. Opaque. */
|
||||
typedef struct census_view census_view;
|
||||
|
||||
/** Create a new view.
|
||||
@param metric_id Metric with which this view is associated.
|
||||
@param tags tags that define the view.
|
||||
@param aggregations aggregations to associate with the view
|
||||
@param naggregations number of aggregations
|
||||
|
||||
@return A new census view
|
||||
*/
|
||||
|
||||
/* TODO(aveitch): consider if context is the right argument type to pass in
|
||||
tags. */
|
||||
CENSUSAPI census_view *census_view_create(
|
||||
uint32_t metric_id, const census_context *tags,
|
||||
const census_aggregation *aggregations, size_t naggregations);
|
||||
|
||||
/** Destroy a previously created view. */
|
||||
CENSUSAPI void census_view_delete(census_view *view);
|
||||
|
||||
/** Metric ID associated with a view */
|
||||
CENSUSAPI size_t census_view_metric(const census_view *view);
|
||||
|
||||
/** Number of aggregations associated with view. */
|
||||
CENSUSAPI size_t census_view_naggregations(const census_view *view);
|
||||
|
||||
/** Get tags associated with view. */
|
||||
CENSUSAPI const census_context *census_view_tags(const census_view *view);
|
||||
|
||||
/** Get aggregation descriptors associated with a view. */
|
||||
CENSUSAPI const census_aggregation *census_view_aggregrations(
|
||||
const census_view *view);
|
||||
|
||||
/** Holds all the aggregation data for a particular view instantiation. Forms
|
||||
part of the data returned by census_view_data(). */
|
||||
typedef struct {
|
||||
const census_context *tags; /* Tags for this set of aggregations. */
|
||||
const void **data; /* One data set for every aggregation in the view. */
|
||||
} census_view_aggregation_data;
|
||||
|
||||
/** Census view data as returned by census_view_get_data(). */
|
||||
typedef struct {
|
||||
size_t n_tag_sets; /* Number of unique tag sets that matched view. */
|
||||
const census_view_aggregation_data *data; /* n_tag_sets entries */
|
||||
} census_view_data;
|
||||
|
||||
/** Get data from aggregations associated with a view.
|
||||
@param view View from which to get data.
|
||||
@return Full set of data for all aggregations for the view.
|
||||
*/
|
||||
CENSUSAPI const census_view_data *census_view_get_data(const census_view *view);
|
||||
|
||||
/** Reset all view data to zero for the specified view */
|
||||
CENSUSAPI void census_view_reset(census_view *view);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@
|
|||
// libraries; it should be integrated with the `__linux__` definitions below.
|
||||
#define GPR_PLATFORM_STRING "manylinux"
|
||||
#define GPR_POSIX_CRASH_HANDLER 1
|
||||
#define GPR_CPU_LINUX 1
|
||||
#define GPR_CPU_POSIX 1
|
||||
#define GPR_GCC_ATOMIC 1
|
||||
#define GPR_GCC_TLS 1
|
||||
#define GPR_LINUX 1
|
||||
|
|
|
|||
|
|
@ -1,5 +1,15 @@
|
|||
framework module grpc {
|
||||
umbrella header "grpc.h"
|
||||
|
||||
header "byte_buffer_reader.h"
|
||||
header "grpc_security.h"
|
||||
header "grpc_security_constants.h"
|
||||
header "impl/codegen/alloc.h"
|
||||
header "impl/codegen/byte_buffer_reader.h"
|
||||
header "support/alloc.h"
|
||||
header "support/port_platform.h"
|
||||
header "support/string_util.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
|
|
|
|||
32
package.xml
32
package.xml
|
|
@ -10,7 +10,7 @@
|
|||
<email>grpc-packages@google.com</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2016-07-21</date>
|
||||
<date>2016-07-28</date>
|
||||
<time>16:06:07</time>
|
||||
<version>
|
||||
<release>1.1.0</release>
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
</stability>
|
||||
<license>BSD</license>
|
||||
<notes>
|
||||
- PHP7 Support #7464
|
||||
- PHP7 Support continued, reduce code duplication #7543
|
||||
</notes>
|
||||
<contents>
|
||||
<dir baseinstalldir="/" name="/">
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
<file baseinstalldir="/" name="src/php/ext/grpc/channel.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/php/ext/grpc/channel_credentials.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/php/ext/grpc/completion_queue.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/php/ext/grpc/php7_wrapper.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/php/ext/grpc/php_grpc.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/php/ext/grpc/server.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/php/ext/grpc/server_credentials.h" role="src" />
|
||||
|
|
@ -186,6 +187,7 @@
|
|||
<file baseinstalldir="/" name="src/core/lib/channel/compress_filter.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/connected_channel.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/context.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/handshaker.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/http_client_filter.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/http_server_filter.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/compression/algorithm_metadata.h" role="src" />
|
||||
|
|
@ -257,6 +259,7 @@
|
|||
<file baseinstalldir="/" name="src/core/lib/transport/metadata.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/static_metadata.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/transport.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/transport_impl.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/bin_decoder.h" role="src" />
|
||||
|
|
@ -278,7 +281,6 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/internal.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/status_conversion.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/stream_map.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/timeout_encoding.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/varint.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/alpn/alpn.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/security/context/security_context.h" role="src" />
|
||||
|
|
@ -321,6 +323,7 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/client_config/subchannel_call_holder.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/client_config/subchannel_index.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/client_config/uri_parser.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/grpclb.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/load_balancer_api.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h" role="src" />
|
||||
<file baseinstalldir="/" name="third_party/nanopb/pb.h" role="src" />
|
||||
|
|
@ -330,11 +333,13 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting_filter.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/aggregation.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/base_resources.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/census_interface.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/census_rpc_stats.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/gen/census.pb.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/grpc_filter.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/mlog.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/resource.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/rpc_metric_id.h" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/surface/init.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/channel_args.c" role="src" />
|
||||
|
|
@ -342,6 +347,7 @@
|
|||
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack_builder.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/compress_filter.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/connected_channel.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/handshaker.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/http_client_filter.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/channel/http_server_filter.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/compression/compression.c" role="src" />
|
||||
|
|
@ -423,6 +429,7 @@
|
|||
<file baseinstalldir="/" name="src/core/lib/transport/metadata.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/static_metadata.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/transport.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/lib/transport/transport_op_string.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c" role="src" />
|
||||
|
|
@ -445,7 +452,6 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/status_conversion.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/stream_lists.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/stream_map.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/timeout_encoding.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/varint.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/transport/writing.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/alpn/alpn.c" role="src" />
|
||||
|
|
@ -501,6 +507,7 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/grpclb.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/load_balancer_api.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c" role="src" />
|
||||
<file baseinstalldir="/" name="third_party/nanopb/pb_common.c" role="src" />
|
||||
|
|
@ -512,6 +519,7 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/resolver/sockaddr/sockaddr_resolver.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/load_reporting/load_reporting_filter.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/base_resources.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/context.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/gen/census.pb.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/grpc_context.c" role="src" />
|
||||
|
|
@ -521,6 +529,7 @@
|
|||
<file baseinstalldir="/" name="src/core/ext/census/mlog.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/operation.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/placeholders.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/resource.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/ext/census/tracing.c" role="src" />
|
||||
<file baseinstalldir="/" name="src/core/plugin_registry/grpc_plugin_registry.c" role="src" />
|
||||
<file baseinstalldir="/" name="third_party/boringssl/crypto/aes/internal.h" role="src" />
|
||||
|
|
@ -1119,5 +1128,20 @@ Update to wrap gRPC C Core version 0.10.0
|
|||
- PHP7 Support #7464
|
||||
</notes>
|
||||
</release>
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0RC3</release>
|
||||
<api>1.0.0RC3</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2016-07-28</date>
|
||||
<license>BSD</license>
|
||||
<notes>
|
||||
- PHP7 Support continued, reduce code duplication #7543
|
||||
</notes>
|
||||
</release>
|
||||
</changelog>
|
||||
</package>
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ build_base=python_build
|
|||
[build_ext]
|
||||
inplace=1
|
||||
|
||||
[build_proto_modules]
|
||||
[build_package_protos]
|
||||
exclude=.*protoc_plugin/protoc_plugin_test\.proto$
|
||||
|
|
|
|||
98
setup.py
98
setup.py
|
|
@ -29,17 +29,18 @@
|
|||
|
||||
"""A setup module for the GRPC Python package."""
|
||||
|
||||
from distutils import extension as _extension
|
||||
from distutils import util
|
||||
import os
|
||||
import os.path
|
||||
import pkg_resources
|
||||
import platform
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import sys
|
||||
import sysconfig
|
||||
|
||||
from distutils import core as _core
|
||||
from distutils import extension as _extension
|
||||
import pkg_resources
|
||||
import setuptools
|
||||
from setuptools.command import egg_info
|
||||
|
||||
|
|
@ -47,10 +48,10 @@ from setuptools.command import egg_info
|
|||
egg_info.manifest_maker.template = 'PYTHON-MANIFEST.in'
|
||||
|
||||
PY3 = sys.version_info.major == 3
|
||||
PYTHON_STEM = './src/python/grpcio'
|
||||
CORE_INCLUDE = ('./include', '.',)
|
||||
BORINGSSL_INCLUDE = ('./third_party/boringssl/include',)
|
||||
ZLIB_INCLUDE = ('./third_party/zlib',)
|
||||
PYTHON_STEM = os.path.join('src', 'python', 'grpcio')
|
||||
CORE_INCLUDE = ('include', '.',)
|
||||
BORINGSSL_INCLUDE = (os.path.join('third_party', 'boringssl', 'include'),)
|
||||
ZLIB_INCLUDE = (os.path.join('third_party', 'zlib'),)
|
||||
|
||||
# Ensure we're in the proper directory whether or not we're being used by pip.
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
|
@ -123,10 +124,7 @@ CYTHON_EXTENSION_PACKAGE_NAMES = ()
|
|||
|
||||
CYTHON_EXTENSION_MODULE_NAMES = ('grpc._cython.cygrpc',)
|
||||
|
||||
CYTHON_HELPER_C_FILES = (
|
||||
os.path.join(PYTHON_STEM, 'grpc/_cython/loader.c'),
|
||||
os.path.join(PYTHON_STEM, 'grpc/_cython/imports.generated.c'),
|
||||
)
|
||||
CYTHON_HELPER_C_FILES = ()
|
||||
|
||||
CORE_C_FILES = tuple(grpc_core_dependencies.CORE_SOURCE_FILES)
|
||||
|
||||
|
|
@ -141,7 +139,9 @@ if not "win32" in sys.platform:
|
|||
if "win32" in sys.platform:
|
||||
EXTENSION_LIBRARIES += ('ws2_32',)
|
||||
|
||||
DEFINE_MACROS = (('OPENSSL_NO_ASM', 1), ('_WIN32_WINNT', 0x600), ('GPR_BACKWARDS_COMPATIBILITY_MODE', 1),)
|
||||
DEFINE_MACROS = (
|
||||
('OPENSSL_NO_ASM', 1), ('_WIN32_WINNT', 0x600),
|
||||
('GPR_BACKWARDS_COMPATIBILITY_MODE', 1),)
|
||||
if "win32" in sys.platform:
|
||||
DEFINE_MACROS += (('OPENSSL_WINDOWS', 1), ('WIN32_LEAN_AND_MEAN', 1),)
|
||||
if '64bit' in platform.architecture()[0]:
|
||||
|
|
@ -163,56 +163,32 @@ if 'darwin' in sys.platform and PY3:
|
|||
if mac_target and (pkg_resources.parse_version(mac_target) <
|
||||
pkg_resources.parse_version('10.7.0')):
|
||||
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.7'
|
||||
os.environ['_PYTHON_HOST_PLATFORM'] = re.sub(
|
||||
r'macosx-[0-9]+\.[0-9]+-(.+)',
|
||||
r'macosx-10.7-\1',
|
||||
util.get_platform())
|
||||
|
||||
|
||||
def cython_extensions():
|
||||
module_names = list(CYTHON_EXTENSION_MODULE_NAMES)
|
||||
extra_sources = list(CYTHON_HELPER_C_FILES) + list(CORE_C_FILES)
|
||||
include_dirs = list(EXTENSION_INCLUDE_DIRECTORIES)
|
||||
libraries = list(EXTENSION_LIBRARIES)
|
||||
define_macros = list(DEFINE_MACROS)
|
||||
build_with_cython = bool(BUILD_WITH_CYTHON)
|
||||
# Set compiler directives linetrace argument only if we care about tracing;
|
||||
# this is due to Cython having different behavior between linetrace being
|
||||
# False and linetrace being unset. See issue #5689.
|
||||
cython_compiler_directives = {}
|
||||
if ENABLE_CYTHON_TRACING:
|
||||
define_macros = define_macros + [('CYTHON_TRACE_NOGIL', 1)]
|
||||
cython_compiler_directives['linetrace'] = True
|
||||
pyx_module_files = [os.path.join(PYTHON_STEM,
|
||||
name.replace('.', '/') + '.pyx')
|
||||
for name in module_names]
|
||||
c_module_files = [os.path.join(PYTHON_STEM,
|
||||
name.replace('.', '/') + '.c')
|
||||
for name in module_names]
|
||||
if not build_with_cython:
|
||||
for module_file in c_module_files:
|
||||
if not os.path.isfile(module_file):
|
||||
sys.stderr.write('Cython-generated files are missing; '
|
||||
'forcing Cython build...\n')
|
||||
build_with_cython = True
|
||||
break
|
||||
module_files = pyx_module_files if build_with_cython else c_module_files
|
||||
def cython_extensions_and_necessity():
|
||||
cython_module_files = [os.path.join(PYTHON_STEM,
|
||||
name.replace('.', '/') + '.pyx')
|
||||
for name in CYTHON_EXTENSION_MODULE_NAMES]
|
||||
extensions = [
|
||||
_extension.Extension(
|
||||
name=module_name,
|
||||
sources=[module_file] + extra_sources,
|
||||
include_dirs=include_dirs, libraries=libraries,
|
||||
define_macros=define_macros,
|
||||
sources=[module_file] + list(CYTHON_HELPER_C_FILES) + list(CORE_C_FILES),
|
||||
include_dirs=list(EXTENSION_INCLUDE_DIRECTORIES),
|
||||
libraries=list(EXTENSION_LIBRARIES),
|
||||
define_macros=list(DEFINE_MACROS),
|
||||
extra_compile_args=list(CFLAGS),
|
||||
extra_link_args=list(LDFLAGS),
|
||||
) for (module_name, module_file) in zip(module_names, module_files)
|
||||
) for (module_name, module_file) in zip(list(CYTHON_EXTENSION_MODULE_NAMES), cython_module_files)
|
||||
]
|
||||
if build_with_cython:
|
||||
import Cython.Build
|
||||
return Cython.Build.cythonize(
|
||||
extensions,
|
||||
include_path=include_dirs,
|
||||
compiler_directives=cython_compiler_directives)
|
||||
else:
|
||||
return extensions
|
||||
need_cython = BUILD_WITH_CYTHON
|
||||
if not BUILD_WITH_CYTHON:
|
||||
need_cython = need_cython or not commands.check_and_update_cythonization(extensions)
|
||||
return commands.try_cythonize(extensions, linetracing=ENABLE_CYTHON_TRACING, mandatory=BUILD_WITH_CYTHON), need_cython
|
||||
|
||||
CYTHON_EXTENSION_MODULES = cython_extensions()
|
||||
CYTHON_EXTENSION_MODULES, need_cython = cython_extensions_and_necessity()
|
||||
|
||||
PACKAGE_DIRECTORIES = {
|
||||
'': PYTHON_STEM,
|
||||
|
|
@ -232,6 +208,15 @@ SETUP_REQUIRES = INSTALL_REQUIRES + (
|
|||
'sphinx_rtd_theme>=0.1.8',
|
||||
'six>=1.10',
|
||||
)
|
||||
if BUILD_WITH_CYTHON:
|
||||
sys.stderr.write(
|
||||
"You requested a Cython build via GRPC_PYTHON_BUILD_WITH_CYTHON, "
|
||||
"but do not have Cython installed. We won't stop you from using "
|
||||
"other commands, but the extension files will fail to build.\n")
|
||||
elif need_cython:
|
||||
sys.stderr.write(
|
||||
'We could not find Cython. Setup may take 10-20 minutes.\n')
|
||||
SETUP_REQUIRES += ('cython>=0.23',)
|
||||
|
||||
COMMAND_CLASS = {
|
||||
'doc': commands.SphinxDocumentation,
|
||||
|
|
@ -242,12 +227,13 @@ COMMAND_CLASS = {
|
|||
}
|
||||
|
||||
# Ensure that package data is copied over before any commands have been run:
|
||||
credentials_dir = os.path.join(PYTHON_STEM, 'grpc/_cython/_credentials')
|
||||
credentials_dir = os.path.join(PYTHON_STEM, 'grpc', '_cython', '_credentials')
|
||||
try:
|
||||
os.mkdir(credentials_dir)
|
||||
except OSError:
|
||||
pass
|
||||
shutil.copyfile('etc/roots.pem', os.path.join(credentials_dir, 'roots.pem'))
|
||||
shutil.copyfile(os.path.join('etc', 'roots.pem'),
|
||||
os.path.join(credentials_dir, 'roots.pem'))
|
||||
|
||||
PACKAGE_DATA = {
|
||||
# Binaries that may or may not be present in the final installation, but are
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
|
|||
file->name().find_last_of(".proto") == file->name().size() - 1) {
|
||||
*file_name_or_error =
|
||||
file->name().substr(0, file->name().size() - proto_suffix_length) +
|
||||
"_services.rb";
|
||||
"_services_pb.rb";
|
||||
return true;
|
||||
} else {
|
||||
*file_name_or_error = "Invalid proto file name: must end with .proto";
|
||||
|
|
@ -58,7 +58,7 @@ inline bool ServicesFilename(const grpc::protobuf::FileDescriptor *file,
|
|||
|
||||
inline grpc::string MessagesRequireName(
|
||||
const grpc::protobuf::FileDescriptor *file) {
|
||||
return Replace(file->name(), ".proto", "");
|
||||
return Replace(file->name(), ".proto", "_pb");
|
||||
}
|
||||
|
||||
// Get leading or trailing comments in a string. Comment lines start with "# ".
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright 2016, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/core/ext/census/base_resources.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <grpc/census.h>
|
||||
#include <grpc/support/log.h>
|
||||
|
||||
#include "src/core/ext/census/resource.h"
|
||||
|
||||
// Add base RPC resource definitions for use by RPC runtime.
|
||||
//
|
||||
// TODO(aveitch): All of these are currently hardwired definitions encoded in
|
||||
// the code in this file. These should be converted to use an external
|
||||
// configuration mechanism, in which these resources are defined in a text
|
||||
// file, which is compiled to .pb format and read by still-to-be-written
|
||||
// configuration functions.
|
||||
|
||||
// Define all base resources. This should be called by census initialization.
|
||||
void define_base_resources() {
|
||||
google_census_Resource_BasicUnit numerator =
|
||||
google_census_Resource_BasicUnit_SECS;
|
||||
resource r = {"client_rpc_latency", // name
|
||||
"Client RPC latency in seconds", // description
|
||||
0, // prefix
|
||||
1, // n_numerators
|
||||
&numerator, // numerators
|
||||
0, // n_denominators
|
||||
NULL}; // denominators
|
||||
define_resource(&r);
|
||||
r = (resource){"server_rpc_latency", // name
|
||||
"Server RPC latency in seconds", // description
|
||||
0, // prefix
|
||||
1, // n_numerators
|
||||
&numerator, // numerators
|
||||
0, // n_denominators
|
||||
NULL}; // denominators
|
||||
define_resource(&r);
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2016, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
|
@ -31,7 +30,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/* TODO(atash) remove cruft */
|
||||
#include <grpc/support/port_platform.h>
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H
|
||||
#define GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H
|
||||
|
||||
#include "imports.generated.h"
|
||||
/* Define all base resources. This should be called by census initialization. */
|
||||
void define_base_resources();
|
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_BASE_RESOURCES_H */
|
||||
|
|
@ -53,29 +53,24 @@ const pb_field_t google_census_Timestamp_fields[3] = {
|
|||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t google_census_Metric_fields[5] = {
|
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Metric, name, name, 0),
|
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Metric, description, name, 0),
|
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, unit, description, &google_census_Metric_MeasurementUnit_fields),
|
||||
PB_FIELD( 4, INT32 , OPTIONAL, STATIC , OTHER, google_census_Metric, id, unit, 0),
|
||||
const pb_field_t google_census_Resource_fields[4] = {
|
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Resource, name, name, 0),
|
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Resource, description, name, 0),
|
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Resource, unit, description, &google_census_Resource_MeasurementUnit_fields),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t google_census_Metric_BasicUnit_fields[2] = {
|
||||
PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, google_census_Metric_BasicUnit, type, type, 0),
|
||||
const pb_field_t google_census_Resource_MeasurementUnit_fields[4] = {
|
||||
PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, google_census_Resource_MeasurementUnit, prefix, prefix, 0),
|
||||
PB_FIELD( 2, UENUM , REPEATED, CALLBACK, OTHER, google_census_Resource_MeasurementUnit, numerator, prefix, 0),
|
||||
PB_FIELD( 3, UENUM , REPEATED, CALLBACK, OTHER, google_census_Resource_MeasurementUnit, denominator, numerator, 0),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t google_census_Metric_MeasurementUnit_fields[4] = {
|
||||
PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, google_census_Metric_MeasurementUnit, prefix, prefix, 0),
|
||||
PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric_MeasurementUnit, numerator, prefix, &google_census_Metric_BasicUnit_fields),
|
||||
PB_FIELD( 3, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric_MeasurementUnit, denominator, numerator, &google_census_Metric_BasicUnit_fields),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t google_census_AggregationDescriptor_fields[3] = {
|
||||
PB_ONEOF_FIELD(options, 1, MESSAGE , ONEOF, STATIC , FIRST, google_census_AggregationDescriptor, bucket_boundaries, bucket_boundaries, &google_census_AggregationDescriptor_BucketBoundaries_fields),
|
||||
PB_ONEOF_FIELD(options, 2, MESSAGE , ONEOF, STATIC , FIRST, google_census_AggregationDescriptor, interval_boundaries, interval_boundaries, &google_census_AggregationDescriptor_IntervalBoundaries_fields),
|
||||
const pb_field_t google_census_AggregationDescriptor_fields[4] = {
|
||||
PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, google_census_AggregationDescriptor, type, type, 0),
|
||||
PB_ONEOF_FIELD(options, 2, MESSAGE , ONEOF, STATIC , OTHER, google_census_AggregationDescriptor, bucket_boundaries, type, &google_census_AggregationDescriptor_BucketBoundaries_fields),
|
||||
PB_ONEOF_FIELD(options, 3, MESSAGE , ONEOF, STATIC , OTHER, google_census_AggregationDescriptor, interval_boundaries, type, &google_census_AggregationDescriptor_IntervalBoundaries_fields),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
|
|
@ -124,25 +119,27 @@ const pb_field_t google_census_Tag_fields[3] = {
|
|||
const pb_field_t google_census_View_fields[6] = {
|
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_View, name, name, 0),
|
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, description, name, 0),
|
||||
PB_FIELD( 3, INT32 , OPTIONAL, STATIC , OTHER, google_census_View, metric_id, description, 0),
|
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_View, aggregation, metric_id, &google_census_AggregationDescriptor_fields),
|
||||
PB_FIELD( 3, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, resource_name, description, 0),
|
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_View, aggregation, resource_name, &google_census_AggregationDescriptor_fields),
|
||||
PB_FIELD( 5, STRING , REPEATED, CALLBACK, OTHER, google_census_View, tag_key, aggregation, 0),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t google_census_Aggregation_fields[6] = {
|
||||
const pb_field_t google_census_Aggregation_fields[7] = {
|
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Aggregation, name, name, 0),
|
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Aggregation, description, name, 0),
|
||||
PB_ONEOF_FIELD(data, 3, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, distribution, description, &google_census_Distribution_fields),
|
||||
PB_ONEOF_FIELD(data, 4, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, interval_stats, description, &google_census_IntervalStats_fields),
|
||||
PB_FIELD( 5, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Aggregation, tag, data.interval_stats, &google_census_Tag_fields),
|
||||
PB_ONEOF_FIELD(data, 3, UINT64 , ONEOF, STATIC , OTHER, google_census_Aggregation, count, description, 0),
|
||||
PB_ONEOF_FIELD(data, 4, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, distribution, description, &google_census_Distribution_fields),
|
||||
PB_ONEOF_FIELD(data, 5, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, interval_stats, description, &google_census_IntervalStats_fields),
|
||||
PB_FIELD( 6, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Aggregation, tag, data.interval_stats, &google_census_Tag_fields),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
const pb_field_t google_census_ViewAggregations_fields[4] = {
|
||||
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_census_ViewAggregations, aggregation, aggregation, &google_census_Aggregation_fields),
|
||||
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_ViewAggregations, start, aggregation, &google_census_Timestamp_fields),
|
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_ViewAggregations, end, start, &google_census_Timestamp_fields),
|
||||
const pb_field_t google_census_Metric_fields[5] = {
|
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Metric, view_name, view_name, 0),
|
||||
PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric, aggregation, view_name, &google_census_Aggregation_fields),
|
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, start, aggregation, &google_census_Timestamp_fields),
|
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, end, start, &google_census_Timestamp_fields),
|
||||
PB_LAST_FIELD
|
||||
};
|
||||
|
||||
|
|
@ -156,7 +153,7 @@ const pb_field_t google_census_ViewAggregations_fields[4] = {
|
|||
* numbers or field sizes that are larger than what can fit in 8 or 16 bit
|
||||
* field descriptors.
|
||||
*/
|
||||
PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Aggregation, tag) < 65536 && pb_membersize(google_census_ViewAggregations, aggregation) < 65536 && pb_membersize(google_census_ViewAggregations, start) < 65536 && pb_membersize(google_census_ViewAggregations, end) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Metric_google_census_Metric_BasicUnit_google_census_Metric_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_ViewAggregations)
|
||||
PB_STATIC_ASSERT((pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Resource, unit) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Aggregation, tag) < 65536 && pb_membersize(google_census_Metric, aggregation) < 65536 && pb_membersize(google_census_Metric, start) < 65536 && pb_membersize(google_census_Metric, end) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Resource_google_census_Resource_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_Metric)
|
||||
#endif
|
||||
|
||||
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
|
||||
|
|
@ -167,7 +164,7 @@ PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 65536 && pb_member
|
|||
* numbers or field sizes that are larger than what can fit in the default
|
||||
* 8 bit descriptors.
|
||||
*/
|
||||
PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Aggregation, tag) < 256 && pb_membersize(google_census_ViewAggregations, aggregation) < 256 && pb_membersize(google_census_ViewAggregations, start) < 256 && pb_membersize(google_census_ViewAggregations, end) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Metric_google_census_Metric_BasicUnit_google_census_Metric_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_ViewAggregations)
|
||||
PB_STATIC_ASSERT((pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Resource, unit) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Aggregation, tag) < 256 && pb_membersize(google_census_Metric, aggregation) < 256 && pb_membersize(google_census_Metric, start) < 256 && pb_membersize(google_census_Metric, end) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Resource_google_census_Resource_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_Metric)
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -45,14 +45,21 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* Enum definitions */
|
||||
typedef enum _google_census_Metric_BasicUnit_Measure {
|
||||
google_census_Metric_BasicUnit_Measure_UNKNOWN = 0,
|
||||
google_census_Metric_BasicUnit_Measure_BITS = 1,
|
||||
google_census_Metric_BasicUnit_Measure_BYTES = 2,
|
||||
google_census_Metric_BasicUnit_Measure_SECS = 3,
|
||||
google_census_Metric_BasicUnit_Measure_CORES = 4,
|
||||
google_census_Metric_BasicUnit_Measure_MAX_UNITS = 5
|
||||
} google_census_Metric_BasicUnit_Measure;
|
||||
typedef enum _google_census_Resource_BasicUnit {
|
||||
google_census_Resource_BasicUnit_UNKNOWN = 0,
|
||||
google_census_Resource_BasicUnit_BITS = 1,
|
||||
google_census_Resource_BasicUnit_BYTES = 2,
|
||||
google_census_Resource_BasicUnit_SECS = 3,
|
||||
google_census_Resource_BasicUnit_CORES = 4,
|
||||
google_census_Resource_BasicUnit_MAX_UNITS = 5
|
||||
} google_census_Resource_BasicUnit;
|
||||
|
||||
typedef enum _google_census_AggregationDescriptor_AggregationType {
|
||||
google_census_AggregationDescriptor_AggregationType_UNKNOWN = 0,
|
||||
google_census_AggregationDescriptor_AggregationType_COUNT = 1,
|
||||
google_census_AggregationDescriptor_AggregationType_DISTRIBUTION = 2,
|
||||
google_census_AggregationDescriptor_AggregationType_INTERVAL = 3
|
||||
} google_census_AggregationDescriptor_AggregationType;
|
||||
|
||||
/* Struct definitions */
|
||||
typedef struct _google_census_AggregationDescriptor_BucketBoundaries {
|
||||
|
|
@ -68,6 +75,8 @@ typedef struct _google_census_IntervalStats {
|
|||
} google_census_IntervalStats;
|
||||
|
||||
typedef struct _google_census_AggregationDescriptor {
|
||||
bool has_type;
|
||||
google_census_AggregationDescriptor_AggregationType type;
|
||||
pb_size_t which_options;
|
||||
union {
|
||||
google_census_AggregationDescriptor_BucketBoundaries bucket_boundaries;
|
||||
|
|
@ -89,17 +98,12 @@ typedef struct _google_census_Duration {
|
|||
int32_t nanos;
|
||||
} google_census_Duration;
|
||||
|
||||
typedef struct _google_census_Metric_BasicUnit {
|
||||
bool has_type;
|
||||
google_census_Metric_BasicUnit_Measure type;
|
||||
} google_census_Metric_BasicUnit;
|
||||
|
||||
typedef struct _google_census_Metric_MeasurementUnit {
|
||||
typedef struct _google_census_Resource_MeasurementUnit {
|
||||
bool has_prefix;
|
||||
int32_t prefix;
|
||||
pb_callback_t numerator;
|
||||
pb_callback_t denominator;
|
||||
} google_census_Metric_MeasurementUnit;
|
||||
} google_census_Resource_MeasurementUnit;
|
||||
|
||||
typedef struct _google_census_Tag {
|
||||
bool has_key;
|
||||
|
|
@ -135,37 +139,36 @@ typedef struct _google_census_IntervalStats_Window {
|
|||
} google_census_IntervalStats_Window;
|
||||
|
||||
typedef struct _google_census_Metric {
|
||||
pb_callback_t name;
|
||||
pb_callback_t description;
|
||||
bool has_unit;
|
||||
google_census_Metric_MeasurementUnit unit;
|
||||
bool has_id;
|
||||
int32_t id;
|
||||
} google_census_Metric;
|
||||
|
||||
typedef struct _google_census_View {
|
||||
pb_callback_t name;
|
||||
pb_callback_t description;
|
||||
bool has_metric_id;
|
||||
int32_t metric_id;
|
||||
bool has_aggregation;
|
||||
google_census_AggregationDescriptor aggregation;
|
||||
pb_callback_t tag_key;
|
||||
} google_census_View;
|
||||
|
||||
typedef struct _google_census_ViewAggregations {
|
||||
pb_callback_t view_name;
|
||||
pb_callback_t aggregation;
|
||||
bool has_start;
|
||||
google_census_Timestamp start;
|
||||
bool has_end;
|
||||
google_census_Timestamp end;
|
||||
} google_census_ViewAggregations;
|
||||
} google_census_Metric;
|
||||
|
||||
typedef struct _google_census_Resource {
|
||||
pb_callback_t name;
|
||||
pb_callback_t description;
|
||||
bool has_unit;
|
||||
google_census_Resource_MeasurementUnit unit;
|
||||
} google_census_Resource;
|
||||
|
||||
typedef struct _google_census_View {
|
||||
pb_callback_t name;
|
||||
pb_callback_t description;
|
||||
pb_callback_t resource_name;
|
||||
bool has_aggregation;
|
||||
google_census_AggregationDescriptor aggregation;
|
||||
pb_callback_t tag_key;
|
||||
} google_census_View;
|
||||
|
||||
typedef struct _google_census_Aggregation {
|
||||
pb_callback_t name;
|
||||
pb_callback_t description;
|
||||
pb_size_t which_data;
|
||||
union {
|
||||
uint64_t count;
|
||||
google_census_Distribution distribution;
|
||||
google_census_IntervalStats interval_stats;
|
||||
} data;
|
||||
|
|
@ -177,10 +180,9 @@ typedef struct _google_census_Aggregation {
|
|||
/* Initializer values for message structs */
|
||||
#define google_census_Duration_init_default {false, 0, false, 0}
|
||||
#define google_census_Timestamp_init_default {false, 0, false, 0}
|
||||
#define google_census_Metric_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Metric_MeasurementUnit_init_default, false, 0}
|
||||
#define google_census_Metric_BasicUnit_init_default {false, (google_census_Metric_BasicUnit_Measure)0}
|
||||
#define google_census_Metric_MeasurementUnit_init_default {false, 0, {{NULL}, NULL}, {{NULL}, NULL}}
|
||||
#define google_census_AggregationDescriptor_init_default {0, {google_census_AggregationDescriptor_BucketBoundaries_init_default}}
|
||||
#define google_census_Resource_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Resource_MeasurementUnit_init_default}
|
||||
#define google_census_Resource_MeasurementUnit_init_default {false, 0, {{NULL}, NULL}, {{NULL}, NULL}}
|
||||
#define google_census_AggregationDescriptor_init_default {false, (google_census_AggregationDescriptor_AggregationType)0, 0, {google_census_AggregationDescriptor_BucketBoundaries_init_default}}
|
||||
#define google_census_AggregationDescriptor_BucketBoundaries_init_default {{{NULL}, NULL}}
|
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_init_default {{{NULL}, NULL}}
|
||||
#define google_census_Distribution_init_default {false, 0, false, 0, false, google_census_Distribution_Range_init_default, {{NULL}, NULL}}
|
||||
|
|
@ -188,15 +190,14 @@ typedef struct _google_census_Aggregation {
|
|||
#define google_census_IntervalStats_init_default {{{NULL}, NULL}}
|
||||
#define google_census_IntervalStats_Window_init_default {false, google_census_Duration_init_default, false, 0, false, 0}
|
||||
#define google_census_Tag_init_default {false, "", false, ""}
|
||||
#define google_census_View_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, 0, false, google_census_AggregationDescriptor_init_default, {{NULL}, NULL}}
|
||||
#define google_census_Aggregation_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {google_census_Distribution_init_default}, {{NULL}, NULL}}
|
||||
#define google_census_ViewAggregations_init_default {{{NULL}, NULL}, false, google_census_Timestamp_init_default, false, google_census_Timestamp_init_default}
|
||||
#define google_census_View_init_default {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, google_census_AggregationDescriptor_init_default, {{NULL}, NULL}}
|
||||
#define google_census_Aggregation_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {0}, {{NULL}, NULL}}
|
||||
#define google_census_Metric_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Timestamp_init_default, false, google_census_Timestamp_init_default}
|
||||
#define google_census_Duration_init_zero {false, 0, false, 0}
|
||||
#define google_census_Timestamp_init_zero {false, 0, false, 0}
|
||||
#define google_census_Metric_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Metric_MeasurementUnit_init_zero, false, 0}
|
||||
#define google_census_Metric_BasicUnit_init_zero {false, (google_census_Metric_BasicUnit_Measure)0}
|
||||
#define google_census_Metric_MeasurementUnit_init_zero {false, 0, {{NULL}, NULL}, {{NULL}, NULL}}
|
||||
#define google_census_AggregationDescriptor_init_zero {0, {google_census_AggregationDescriptor_BucketBoundaries_init_zero}}
|
||||
#define google_census_Resource_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Resource_MeasurementUnit_init_zero}
|
||||
#define google_census_Resource_MeasurementUnit_init_zero {false, 0, {{NULL}, NULL}, {{NULL}, NULL}}
|
||||
#define google_census_AggregationDescriptor_init_zero {false, (google_census_AggregationDescriptor_AggregationType)0, 0, {google_census_AggregationDescriptor_BucketBoundaries_init_zero}}
|
||||
#define google_census_AggregationDescriptor_BucketBoundaries_init_zero {{{NULL}, NULL}}
|
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_init_zero {{{NULL}, NULL}}
|
||||
#define google_census_Distribution_init_zero {false, 0, false, 0, false, google_census_Distribution_Range_init_zero, {{NULL}, NULL}}
|
||||
|
|
@ -204,25 +205,25 @@ typedef struct _google_census_Aggregation {
|
|||
#define google_census_IntervalStats_init_zero {{{NULL}, NULL}}
|
||||
#define google_census_IntervalStats_Window_init_zero {false, google_census_Duration_init_zero, false, 0, false, 0}
|
||||
#define google_census_Tag_init_zero {false, "", false, ""}
|
||||
#define google_census_View_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, 0, false, google_census_AggregationDescriptor_init_zero, {{NULL}, NULL}}
|
||||
#define google_census_Aggregation_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {google_census_Distribution_init_zero}, {{NULL}, NULL}}
|
||||
#define google_census_ViewAggregations_init_zero {{{NULL}, NULL}, false, google_census_Timestamp_init_zero, false, google_census_Timestamp_init_zero}
|
||||
#define google_census_View_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, {{NULL}, NULL}, false, google_census_AggregationDescriptor_init_zero, {{NULL}, NULL}}
|
||||
#define google_census_Aggregation_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {0}, {{NULL}, NULL}}
|
||||
#define google_census_Metric_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Timestamp_init_zero, false, google_census_Timestamp_init_zero}
|
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */
|
||||
#define google_census_AggregationDescriptor_BucketBoundaries_bounds_tag 1
|
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_window_size_tag 1
|
||||
#define google_census_IntervalStats_window_tag 1
|
||||
#define google_census_AggregationDescriptor_bucket_boundaries_tag 1
|
||||
#define google_census_AggregationDescriptor_bucket_boundaries_tag 2
|
||||
|
||||
#define google_census_AggregationDescriptor_interval_boundaries_tag 2
|
||||
#define google_census_AggregationDescriptor_interval_boundaries_tag 3
|
||||
#define google_census_AggregationDescriptor_type_tag 1
|
||||
#define google_census_Distribution_Range_min_tag 1
|
||||
#define google_census_Distribution_Range_max_tag 2
|
||||
#define google_census_Duration_seconds_tag 1
|
||||
#define google_census_Duration_nanos_tag 2
|
||||
#define google_census_Metric_BasicUnit_type_tag 1
|
||||
#define google_census_Metric_MeasurementUnit_prefix_tag 1
|
||||
#define google_census_Metric_MeasurementUnit_numerator_tag 2
|
||||
#define google_census_Metric_MeasurementUnit_denominator_tag 3
|
||||
#define google_census_Resource_MeasurementUnit_prefix_tag 1
|
||||
#define google_census_Resource_MeasurementUnit_numerator_tag 2
|
||||
#define google_census_Resource_MeasurementUnit_denominator_tag 3
|
||||
#define google_census_Tag_key_tag 1
|
||||
#define google_census_Tag_value_tag 2
|
||||
#define google_census_Timestamp_seconds_tag 1
|
||||
|
|
@ -234,32 +235,33 @@ typedef struct _google_census_Aggregation {
|
|||
#define google_census_IntervalStats_Window_window_size_tag 1
|
||||
#define google_census_IntervalStats_Window_count_tag 2
|
||||
#define google_census_IntervalStats_Window_mean_tag 3
|
||||
#define google_census_Metric_name_tag 1
|
||||
#define google_census_Metric_description_tag 2
|
||||
#define google_census_Metric_unit_tag 3
|
||||
#define google_census_Metric_id_tag 4
|
||||
#define google_census_Metric_view_name_tag 1
|
||||
#define google_census_Metric_aggregation_tag 2
|
||||
#define google_census_Metric_start_tag 3
|
||||
#define google_census_Metric_end_tag 4
|
||||
#define google_census_Resource_name_tag 1
|
||||
#define google_census_Resource_description_tag 2
|
||||
#define google_census_Resource_unit_tag 3
|
||||
#define google_census_View_name_tag 1
|
||||
#define google_census_View_description_tag 2
|
||||
#define google_census_View_metric_id_tag 3
|
||||
#define google_census_View_resource_name_tag 3
|
||||
#define google_census_View_aggregation_tag 4
|
||||
#define google_census_View_tag_key_tag 5
|
||||
#define google_census_ViewAggregations_aggregation_tag 1
|
||||
#define google_census_ViewAggregations_start_tag 2
|
||||
#define google_census_ViewAggregations_end_tag 3
|
||||
#define google_census_Aggregation_distribution_tag 3
|
||||
#define google_census_Aggregation_count_tag 3
|
||||
|
||||
#define google_census_Aggregation_interval_stats_tag 4
|
||||
#define google_census_Aggregation_distribution_tag 4
|
||||
|
||||
#define google_census_Aggregation_interval_stats_tag 5
|
||||
#define google_census_Aggregation_name_tag 1
|
||||
#define google_census_Aggregation_description_tag 2
|
||||
#define google_census_Aggregation_tag_tag 5
|
||||
#define google_census_Aggregation_tag_tag 6
|
||||
|
||||
/* Struct field encoding specification for nanopb */
|
||||
extern const pb_field_t google_census_Duration_fields[3];
|
||||
extern const pb_field_t google_census_Timestamp_fields[3];
|
||||
extern const pb_field_t google_census_Metric_fields[5];
|
||||
extern const pb_field_t google_census_Metric_BasicUnit_fields[2];
|
||||
extern const pb_field_t google_census_Metric_MeasurementUnit_fields[4];
|
||||
extern const pb_field_t google_census_AggregationDescriptor_fields[3];
|
||||
extern const pb_field_t google_census_Resource_fields[4];
|
||||
extern const pb_field_t google_census_Resource_MeasurementUnit_fields[4];
|
||||
extern const pb_field_t google_census_AggregationDescriptor_fields[4];
|
||||
extern const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2];
|
||||
extern const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2];
|
||||
extern const pb_field_t google_census_Distribution_fields[5];
|
||||
|
|
@ -268,13 +270,12 @@ extern const pb_field_t google_census_IntervalStats_fields[2];
|
|||
extern const pb_field_t google_census_IntervalStats_Window_fields[4];
|
||||
extern const pb_field_t google_census_Tag_fields[3];
|
||||
extern const pb_field_t google_census_View_fields[6];
|
||||
extern const pb_field_t google_census_Aggregation_fields[6];
|
||||
extern const pb_field_t google_census_ViewAggregations_fields[4];
|
||||
extern const pb_field_t google_census_Aggregation_fields[7];
|
||||
extern const pb_field_t google_census_Metric_fields[5];
|
||||
|
||||
/* Maximum encoded size of messages (where known) */
|
||||
#define google_census_Duration_size 22
|
||||
#define google_census_Timestamp_size 22
|
||||
#define google_census_Metric_BasicUnit_size 2
|
||||
#define google_census_Distribution_Range_size 18
|
||||
#define google_census_IntervalStats_Window_size 44
|
||||
#define google_census_Tag_size 516
|
||||
|
|
|
|||
|
|
@ -127,38 +127,40 @@ static void server_start_transport_op(grpc_exec_ctx *exec_ctx,
|
|||
grpc_call_next_op(exec_ctx, elem, op);
|
||||
}
|
||||
|
||||
static void client_init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
static grpc_error *client_init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
call_data *d = elem->call_data;
|
||||
GPR_ASSERT(d != NULL);
|
||||
memset(d, 0, sizeof(*d));
|
||||
d->start_ts = gpr_now(GPR_CLOCK_REALTIME);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
static void client_destroy_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
const grpc_call_stats *stats,
|
||||
const grpc_call_final_info *final_info,
|
||||
void *ignored) {
|
||||
call_data *d = elem->call_data;
|
||||
GPR_ASSERT(d != NULL);
|
||||
/* TODO(hongyu): record rpc client stats and census_rpc_end_op here */
|
||||
}
|
||||
|
||||
static void server_init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
static grpc_error *server_init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
call_data *d = elem->call_data;
|
||||
GPR_ASSERT(d != NULL);
|
||||
memset(d, 0, sizeof(*d));
|
||||
d->start_ts = gpr_now(GPR_CLOCK_REALTIME);
|
||||
/* TODO(hongyu): call census_tracing_start_op here. */
|
||||
grpc_closure_init(&d->finish_recv, server_on_done_recv, elem);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
static void server_destroy_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
const grpc_call_stats *stats,
|
||||
const grpc_call_final_info *final_info,
|
||||
void *ignored) {
|
||||
call_data *d = elem->call_data;
|
||||
GPR_ASSERT(d != NULL);
|
||||
|
|
|
|||
|
|
@ -32,19 +32,31 @@
|
|||
*/
|
||||
|
||||
#include <grpc/census.h>
|
||||
#include "src/core/ext/census/base_resources.h"
|
||||
#include "src/core/ext/census/resource.h"
|
||||
|
||||
static int features_enabled = CENSUS_FEATURE_NONE;
|
||||
|
||||
int census_initialize(int features) {
|
||||
if (features_enabled != CENSUS_FEATURE_NONE) {
|
||||
// Must have been a previous call to census_initialize; return error
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
features_enabled = features;
|
||||
return 0;
|
||||
features_enabled = features & CENSUS_FEATURE_ALL;
|
||||
if (features & CENSUS_FEATURE_STATS) {
|
||||
initialize_resources();
|
||||
define_base_resources();
|
||||
}
|
||||
|
||||
return features_enabled;
|
||||
}
|
||||
|
||||
void census_shutdown(void) { features_enabled = CENSUS_FEATURE_NONE; }
|
||||
void census_shutdown(void) {
|
||||
if (features_enabled & CENSUS_FEATURE_STATS) {
|
||||
shutdown_resources();
|
||||
}
|
||||
features_enabled = CENSUS_FEATURE_NONE;
|
||||
}
|
||||
|
||||
int census_supported(void) {
|
||||
/* TODO(aveitch): improve this as we implement features... */
|
||||
|
|
|
|||
|
|
@ -62,48 +62,3 @@ int census_trace_scan_start(int consume) {
|
|||
(void)consume;
|
||||
abort();
|
||||
}
|
||||
|
||||
const census_aggregation *census_view_aggregrations(const census_view *view) {
|
||||
(void)view;
|
||||
abort();
|
||||
}
|
||||
|
||||
census_view *census_view_create(uint32_t metric_id, const census_context *tags,
|
||||
const census_aggregation *aggregations,
|
||||
size_t naggregations) {
|
||||
(void)metric_id;
|
||||
(void)tags;
|
||||
(void)aggregations;
|
||||
(void)naggregations;
|
||||
abort();
|
||||
}
|
||||
|
||||
const census_context *census_view_tags(const census_view *view) {
|
||||
(void)view;
|
||||
abort();
|
||||
}
|
||||
|
||||
void census_view_delete(census_view *view) {
|
||||
(void)view;
|
||||
abort();
|
||||
}
|
||||
|
||||
const census_view_data *census_view_get_data(const census_view *view) {
|
||||
(void)view;
|
||||
abort();
|
||||
}
|
||||
|
||||
size_t census_view_metric(const census_view *view) {
|
||||
(void)view;
|
||||
abort();
|
||||
}
|
||||
|
||||
size_t census_view_naggregations(const census_view *view) {
|
||||
(void)view;
|
||||
abort();
|
||||
}
|
||||
|
||||
void census_view_reset(census_view *view) {
|
||||
(void)view;
|
||||
abort();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,312 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2016, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/core/ext/census/resource.h"
|
||||
#include "third_party/nanopb/pb_decode.h"
|
||||
|
||||
#include <grpc/census.h>
|
||||
#include <grpc/support/alloc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/sync.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
// Protect local resource data structures.
|
||||
static gpr_mu resource_lock;
|
||||
|
||||
// Deleteing and creating resources are relatively rare events, and should not
|
||||
// be done in the critical path of performance sensitive code. We record
|
||||
// current resource id's used in a simple array, and just search it each time
|
||||
// we need to assign a new id, or look up a resource.
|
||||
static resource **resources = NULL;
|
||||
|
||||
// Number of entries in *resources
|
||||
static size_t n_resources = 0;
|
||||
|
||||
// Number of defined resources
|
||||
static size_t n_defined_resources = 0;
|
||||
|
||||
void initialize_resources(void) {
|
||||
gpr_mu_init(&resource_lock);
|
||||
gpr_mu_lock(&resource_lock);
|
||||
GPR_ASSERT(resources == NULL && n_resources == 0 && n_defined_resources == 0);
|
||||
gpr_mu_unlock(&resource_lock);
|
||||
}
|
||||
|
||||
// Delete a resource given it's ID. The ID must be a valid resource ID. Must be
|
||||
// called with resource_lock held.
|
||||
static void delete_resource_locked(size_t rid) {
|
||||
GPR_ASSERT(resources[rid] != NULL);
|
||||
gpr_free(resources[rid]->name);
|
||||
gpr_free(resources[rid]->description);
|
||||
gpr_free(resources[rid]->numerators);
|
||||
gpr_free(resources[rid]->denominators);
|
||||
gpr_free(resources[rid]);
|
||||
resources[rid] = NULL;
|
||||
n_defined_resources--;
|
||||
}
|
||||
|
||||
void shutdown_resources(void) {
|
||||
gpr_mu_lock(&resource_lock);
|
||||
for (size_t i = 0; i < n_resources; i++) {
|
||||
if (resources[i] != NULL) {
|
||||
delete_resource_locked(i);
|
||||
}
|
||||
}
|
||||
GPR_ASSERT(n_defined_resources == 0);
|
||||
gpr_free(resources);
|
||||
resources = NULL;
|
||||
n_resources = 0;
|
||||
gpr_mu_unlock(&resource_lock);
|
||||
}
|
||||
|
||||
// Check the contents of string fields in a resource proto.
|
||||
static bool validate_string(pb_istream_t *stream, const pb_field_t *field,
|
||||
void **arg) {
|
||||
resource *vresource = (resource *)*arg;
|
||||
switch (field->tag) {
|
||||
case google_census_Resource_name_tag:
|
||||
// Name must have at least one character
|
||||
if (stream->bytes_left == 0) {
|
||||
gpr_log(GPR_INFO, "Zero-length Resource name.");
|
||||
return false;
|
||||
}
|
||||
vresource->name = gpr_malloc(stream->bytes_left + 1);
|
||||
vresource->name[stream->bytes_left] = '\0';
|
||||
if (!pb_read(stream, (uint8_t *)vresource->name, stream->bytes_left)) {
|
||||
return false;
|
||||
}
|
||||
// Can't have same name as an existing resource.
|
||||
for (size_t i = 0; i < n_resources; i++) {
|
||||
resource *compare = resources[i];
|
||||
if (compare == vresource || compare == NULL) continue;
|
||||
if (strcmp(compare->name, vresource->name) == 0) {
|
||||
gpr_log(GPR_INFO, "Duplicate Resource name %s.", vresource->name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case google_census_Resource_description_tag:
|
||||
if (stream->bytes_left == 0) {
|
||||
return true;
|
||||
}
|
||||
vresource->description = gpr_malloc(stream->bytes_left + 1);
|
||||
vresource->description[stream->bytes_left] = '\0';
|
||||
if (!pb_read(stream, (uint8_t *)vresource->description,
|
||||
stream->bytes_left)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// No other string fields in Resource. Print warning and skip.
|
||||
gpr_log(GPR_INFO, "Unknown string field type in Resource protobuf.");
|
||||
if (!pb_read(stream, NULL, stream->bytes_left)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Decode numerators/denominators in a stream. The `count` and `bup`
|
||||
// (BasicUnit pointer) are pointers to the approriate fields in a resource
|
||||
// struct.
|
||||
static bool validate_units_helper(pb_istream_t *stream, int *count,
|
||||
google_census_Resource_BasicUnit **bup) {
|
||||
while (stream->bytes_left) {
|
||||
(*count)++;
|
||||
// Have to allocate a new array of values. Normal case is 0 or 1, so
|
||||
// this should normally not be an issue.
|
||||
google_census_Resource_BasicUnit *new_bup =
|
||||
gpr_malloc((size_t)*count * sizeof(google_census_Resource_BasicUnit));
|
||||
if (*count != 1) {
|
||||
memcpy(new_bup, *bup,
|
||||
(size_t)(*count - 1) * sizeof(google_census_Resource_BasicUnit));
|
||||
gpr_free(*bup);
|
||||
}
|
||||
*bup = new_bup;
|
||||
uint64_t value;
|
||||
if (!pb_decode_varint(stream, &value)) {
|
||||
return false;
|
||||
}
|
||||
*(*bup + *count - 1) = (google_census_Resource_BasicUnit)value;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Validate units field of a Resource proto.
|
||||
static bool validate_units(pb_istream_t *stream, const pb_field_t *field,
|
||||
void **arg) {
|
||||
resource *vresource = (resource *)(*arg);
|
||||
switch (field->tag) {
|
||||
case google_census_Resource_MeasurementUnit_numerator_tag:
|
||||
return validate_units_helper(stream, &vresource->n_numerators,
|
||||
&vresource->numerators);
|
||||
break;
|
||||
case google_census_Resource_MeasurementUnit_denominator_tag:
|
||||
return validate_units_helper(stream, &vresource->n_denominators,
|
||||
&vresource->denominators);
|
||||
break;
|
||||
default:
|
||||
gpr_log(GPR_ERROR, "Unknown field type.");
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Validate the contents of a Resource proto. `id` is the intended resource id.
|
||||
static bool validate_resource_pb(const uint8_t *resource_pb,
|
||||
size_t resource_pb_size, size_t id) {
|
||||
GPR_ASSERT(id < n_resources);
|
||||
if (resource_pb == NULL) {
|
||||
return false;
|
||||
}
|
||||
google_census_Resource vresource;
|
||||
vresource.name.funcs.decode = &validate_string;
|
||||
vresource.name.arg = resources[id];
|
||||
vresource.description.funcs.decode = &validate_string;
|
||||
vresource.description.arg = resources[id];
|
||||
vresource.unit.numerator.funcs.decode = &validate_units;
|
||||
vresource.unit.numerator.arg = resources[id];
|
||||
vresource.unit.denominator.funcs.decode = &validate_units;
|
||||
vresource.unit.denominator.arg = resources[id];
|
||||
|
||||
pb_istream_t stream =
|
||||
pb_istream_from_buffer((uint8_t *)resource_pb, resource_pb_size);
|
||||
if (!pb_decode(&stream, google_census_Resource_fields, &vresource)) {
|
||||
return false;
|
||||
}
|
||||
// A Resource must have a name, a unit, with at least one numerator.
|
||||
return (resources[id]->name != NULL && vresource.has_unit &&
|
||||
resources[id]->n_numerators > 0);
|
||||
}
|
||||
|
||||
// Allocate a blank resource, and return associated ID. Must be called with
|
||||
// resource_lock held.
|
||||
size_t allocate_resource(void) {
|
||||
// use next_id to optimize expected placement of next new resource.
|
||||
static size_t next_id = 0;
|
||||
size_t id = n_resources; // resource ID - initialize to invalid value.
|
||||
// Expand resources if needed.
|
||||
if (n_resources == n_defined_resources) {
|
||||
size_t new_n_resources = n_resources ? n_resources * 2 : 2;
|
||||
resource **new_resources = gpr_malloc(new_n_resources * sizeof(resource *));
|
||||
memcpy(new_resources, resources, n_resources * sizeof(resource *));
|
||||
memset(new_resources + n_resources, 0,
|
||||
(new_n_resources - n_resources) * sizeof(resource *));
|
||||
gpr_free(resources);
|
||||
resources = new_resources;
|
||||
n_resources = new_n_resources;
|
||||
id = n_defined_resources;
|
||||
} else {
|
||||
GPR_ASSERT(n_defined_resources < n_resources);
|
||||
// Find a free id.
|
||||
for (size_t base = 0; base < n_resources; base++) {
|
||||
id = (next_id + base) % n_resources;
|
||||
if (resources[id] == NULL) break;
|
||||
}
|
||||
}
|
||||
GPR_ASSERT(id < n_resources && resources[id] == NULL);
|
||||
resources[id] = gpr_malloc(sizeof(resource));
|
||||
memset(resources[id], 0, sizeof(resource));
|
||||
n_defined_resources++;
|
||||
next_id = (id + 1) % n_resources;
|
||||
return id;
|
||||
}
|
||||
|
||||
int32_t census_define_resource(const uint8_t *resource_pb,
|
||||
size_t resource_pb_size) {
|
||||
if (resource_pb == NULL) {
|
||||
return -1;
|
||||
}
|
||||
gpr_mu_lock(&resource_lock);
|
||||
size_t id = allocate_resource();
|
||||
// Validate pb, extract name.
|
||||
if (!validate_resource_pb(resource_pb, resource_pb_size, id)) {
|
||||
delete_resource_locked(id);
|
||||
gpr_mu_unlock(&resource_lock);
|
||||
return -1;
|
||||
}
|
||||
gpr_mu_unlock(&resource_lock);
|
||||
return (int32_t)id;
|
||||
}
|
||||
|
||||
void census_delete_resource(int32_t rid) {
|
||||
gpr_mu_lock(&resource_lock);
|
||||
if (rid >= 0 && (size_t)rid < n_resources && resources[rid] != NULL) {
|
||||
delete_resource_locked((size_t)rid);
|
||||
}
|
||||
gpr_mu_unlock(&resource_lock);
|
||||
}
|
||||
|
||||
int32_t census_resource_id(const char *name) {
|
||||
gpr_mu_lock(&resource_lock);
|
||||
for (int32_t id = 0; (size_t)id < n_resources; id++) {
|
||||
if (resources[id] != NULL && strcmp(resources[id]->name, name) == 0) {
|
||||
gpr_mu_unlock(&resource_lock);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
gpr_mu_unlock(&resource_lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t define_resource(const resource *base) {
|
||||
GPR_ASSERT(base != NULL && base->name != NULL && base->n_numerators > 0 &&
|
||||
base->numerators != NULL);
|
||||
gpr_mu_lock(&resource_lock);
|
||||
size_t id = allocate_resource();
|
||||
size_t len = strlen(base->name) + 1;
|
||||
resources[id]->name = gpr_malloc(len);
|
||||
memcpy(resources[id]->name, base->name, len);
|
||||
if (base->description) {
|
||||
len = strlen(base->description) + 1;
|
||||
resources[id]->description = gpr_malloc(len);
|
||||
memcpy(resources[id]->description, base->description, len);
|
||||
}
|
||||
resources[id]->prefix = base->prefix;
|
||||
resources[id]->n_numerators = base->n_numerators;
|
||||
len = (size_t)base->n_numerators * sizeof(*base->numerators);
|
||||
resources[id]->numerators = gpr_malloc(len);
|
||||
memcpy(resources[id]->numerators, base->numerators, len);
|
||||
resources[id]->n_denominators = base->n_denominators;
|
||||
if (base->n_denominators != 0) {
|
||||
len = (size_t)base->n_denominators * sizeof(*base->denominators);
|
||||
resources[id]->denominators = gpr_malloc(len);
|
||||
memcpy(resources[id]->denominators, base->denominators, len);
|
||||
}
|
||||
gpr_mu_unlock(&resource_lock);
|
||||
return (int32_t)id;
|
||||
}
|
||||
|
|
@ -31,22 +31,33 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <Python.h>
|
||||
#include "loader.h"
|
||||
/* Census-internal resource definition and manipluation functions. */
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_RESOURCE_H
|
||||
#define GRPC_CORE_EXT_CENSUS_RESOURCE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cpluslus */
|
||||
#include <grpc/grpc.h>
|
||||
#include "src/core/ext/census/gen/census.pb.h"
|
||||
|
||||
int pygrpc_load_core(char *path) { return 1; }
|
||||
/* Internal representation of a resource. */
|
||||
typedef struct {
|
||||
char *name;
|
||||
char *description;
|
||||
int32_t prefix;
|
||||
int n_numerators;
|
||||
google_census_Resource_BasicUnit *numerators;
|
||||
int n_denominators;
|
||||
google_census_Resource_BasicUnit *denominators;
|
||||
} resource;
|
||||
|
||||
// Cython doesn't have Py_AtExit bindings, so we call the C_API directly
|
||||
int pygrpc_initialize_core(void) {
|
||||
grpc_init();
|
||||
return Py_AtExit(grpc_shutdown) < 0 ? 0 : 1;
|
||||
}
|
||||
/* Initialize and shutdown the resources subsystem. */
|
||||
void initialize_resources(void);
|
||||
void shutdown_resources(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cpluslus */
|
||||
/* Add a new resource, given a proposed resource structure. Returns the
|
||||
resource ID, or -ve on failure.
|
||||
TODO(aveitch): this function exists to support addition of the base
|
||||
resources. It should be removed when we have the ability to add resources
|
||||
from configuration files. */
|
||||
int32_t define_resource(const resource *base);
|
||||
|
||||
#endif /* GRPC_CORE_EXT_CENSUS_RESOURCE_H */
|
||||
|
|
@ -436,15 +436,17 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp,
|
|||
}
|
||||
|
||||
/* Constructor for call_data */
|
||||
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
grpc_subchannel_call_holder_init(elem->call_data, cc_pick_subchannel, elem,
|
||||
args->call_stack);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
/* Destructor for call_data */
|
||||
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
const grpc_call_stats *stats,
|
||||
const grpc_call_final_info *final_info,
|
||||
void *and_free_memory) {
|
||||
grpc_subchannel_call_holder_destroy(exec_ctx, elem->call_data);
|
||||
gpr_free(and_free_memory);
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ struct grpc_lb_policy_vtable {
|
|||
void (*ping_one)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
||||
grpc_closure *closure);
|
||||
|
||||
/** try to enter a READY connectivity state */
|
||||
/** Try to enter a READY connectivity state */
|
||||
void (*exit_idle)(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
|
||||
|
||||
/** check the current connectivity of the lb_policy */
|
||||
|
|
@ -82,7 +82,9 @@ struct grpc_lb_policy_vtable {
|
|||
grpc_error **connectivity_error);
|
||||
|
||||
/** call notify when the connectivity state of a channel changes from *state.
|
||||
Updates *state with the new state of the policy */
|
||||
Updates *state with the new state of the policy. Calling with a NULL \a
|
||||
state cancels the subscription.
|
||||
*/
|
||||
void (*notify_on_state_change)(grpc_exec_ctx *exec_ctx,
|
||||
grpc_lb_policy *policy,
|
||||
grpc_connectivity_state *state,
|
||||
|
|
@ -125,7 +127,7 @@ void grpc_lb_policy_init(grpc_lb_policy *policy,
|
|||
/** Given initial metadata in \a initial_metadata, find an appropriate
|
||||
target for this rpc, and 'return' it by calling \a on_complete after setting
|
||||
\a target.
|
||||
Picking can be asynchronous. Any IO should be done under \a pollset. */
|
||||
Picking can be asynchronous. Any IO should be done under \a pollent. */
|
||||
int grpc_lb_policy_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
|
||||
grpc_polling_entity *pollent,
|
||||
grpc_metadata_batch *initial_metadata,
|
||||
|
|
@ -147,8 +149,11 @@ void grpc_lb_policy_cancel_picks(grpc_exec_ctx *exec_ctx,
|
|||
uint32_t initial_metadata_flags_mask,
|
||||
uint32_t initial_metadata_flags_eq);
|
||||
|
||||
/** Try to enter a READY connectivity state */
|
||||
void grpc_lb_policy_exit_idle(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy);
|
||||
|
||||
/* Call notify when the connectivity state of a channel changes from \a *state.
|
||||
* Updates \a *state with the new state of the policy */
|
||||
void grpc_lb_policy_notify_on_state_change(grpc_exec_ctx *exec_ctx,
|
||||
grpc_lb_policy *policy,
|
||||
grpc_connectivity_state *state,
|
||||
|
|
|
|||
|
|
@ -700,19 +700,26 @@ grpc_connected_subchannel *grpc_subchannel_get_connected_subchannel(
|
|||
return GET_CONNECTED_SUBCHANNEL(c, acq);
|
||||
}
|
||||
|
||||
grpc_subchannel_call *grpc_connected_subchannel_create_call(
|
||||
grpc_error *grpc_connected_subchannel_create_call(
|
||||
grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *con,
|
||||
grpc_polling_entity *pollent) {
|
||||
grpc_polling_entity *pollent, grpc_subchannel_call **call) {
|
||||
grpc_channel_stack *chanstk = CHANNEL_STACK_FROM_CONNECTION(con);
|
||||
grpc_subchannel_call *call =
|
||||
gpr_malloc(sizeof(grpc_subchannel_call) + chanstk->call_stack_size);
|
||||
grpc_call_stack *callstk = SUBCHANNEL_CALL_TO_CALL_STACK(call);
|
||||
call->connection = con;
|
||||
*call = gpr_malloc(sizeof(grpc_subchannel_call) + chanstk->call_stack_size);
|
||||
grpc_call_stack *callstk = SUBCHANNEL_CALL_TO_CALL_STACK(*call);
|
||||
(*call)->connection = con; // Ref is added below.
|
||||
grpc_error *error =
|
||||
grpc_call_stack_init(exec_ctx, chanstk, 1, subchannel_call_destroy, *call,
|
||||
NULL, NULL, callstk);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
const char *error_string = grpc_error_string(error);
|
||||
gpr_log(GPR_ERROR, "error: %s", error_string);
|
||||
grpc_error_free_string(error_string);
|
||||
gpr_free(*call);
|
||||
return error;
|
||||
}
|
||||
GRPC_CONNECTED_SUBCHANNEL_REF(con, "subchannel_call");
|
||||
grpc_call_stack_init(exec_ctx, chanstk, 1, subchannel_call_destroy, call,
|
||||
NULL, NULL, callstk);
|
||||
grpc_call_stack_set_pollset_or_pollset_set(exec_ctx, callstk, pollent);
|
||||
return call;
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
grpc_call_stack *grpc_subchannel_call_get_call_stack(
|
||||
|
|
|
|||
|
|
@ -108,9 +108,9 @@ void grpc_subchannel_call_unref(grpc_exec_ctx *exec_ctx,
|
|||
GRPC_SUBCHANNEL_REF_EXTRA_ARGS);
|
||||
|
||||
/** construct a subchannel call */
|
||||
grpc_subchannel_call *grpc_connected_subchannel_create_call(
|
||||
grpc_error *grpc_connected_subchannel_create_call(
|
||||
grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *connected_subchannel,
|
||||
grpc_polling_entity *pollent);
|
||||
grpc_polling_entity *pollent, grpc_subchannel_call **subchannel_call);
|
||||
|
||||
/** process a transport level op */
|
||||
void grpc_connected_subchannel_process_transport_op(
|
||||
|
|
|
|||
|
|
@ -84,6 +84,11 @@ void grpc_subchannel_call_holder_destroy(grpc_exec_ctx *exec_ctx,
|
|||
gpr_free(holder->waiting_ops);
|
||||
}
|
||||
|
||||
// The logic here is fairly complicated, due to (a) the fact that we
|
||||
// need to handle the case where we receive the send op before the
|
||||
// initial metadata op, and (b) the need for efficiency, especially in
|
||||
// the streaming case.
|
||||
// TODO(ctiller): Explain this more thoroughly.
|
||||
void grpc_subchannel_call_holder_perform_op(grpc_exec_ctx *exec_ctx,
|
||||
grpc_subchannel_call_holder *holder,
|
||||
grpc_transport_stream_op *op) {
|
||||
|
|
@ -121,7 +126,8 @@ retry:
|
|||
}
|
||||
/* if this is a cancellation, then we can raise our cancelled flag */
|
||||
if (op->cancel_error != GRPC_ERROR_NONE) {
|
||||
if (!gpr_atm_rel_cas(&holder->subchannel_call, 0, 1)) {
|
||||
if (!gpr_atm_rel_cas(&holder->subchannel_call, 0,
|
||||
(gpr_atm)(uintptr_t)CANCELLED_CALL)) {
|
||||
goto retry;
|
||||
} else {
|
||||
switch (holder->creation_phase) {
|
||||
|
|
@ -158,10 +164,17 @@ retry:
|
|||
/* if we've got a subchannel, then let's ask it to create a call */
|
||||
if (holder->creation_phase == GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING &&
|
||||
holder->connected_subchannel != NULL) {
|
||||
gpr_atm_rel_store(
|
||||
&holder->subchannel_call,
|
||||
(gpr_atm)(uintptr_t)grpc_connected_subchannel_create_call(
|
||||
exec_ctx, holder->connected_subchannel, holder->pollent));
|
||||
grpc_subchannel_call *subchannel_call = NULL;
|
||||
grpc_error *error = grpc_connected_subchannel_create_call(
|
||||
exec_ctx, holder->connected_subchannel, holder->pollent,
|
||||
&subchannel_call);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
subchannel_call = CANCELLED_CALL;
|
||||
fail_locked(exec_ctx, holder, GRPC_ERROR_REF(error));
|
||||
grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error);
|
||||
}
|
||||
gpr_atm_rel_store(&holder->subchannel_call,
|
||||
(gpr_atm)(uintptr_t)subchannel_call);
|
||||
retry_waiting_locked(exec_ctx, holder);
|
||||
goto retry;
|
||||
}
|
||||
|
|
@ -189,10 +202,17 @@ static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg,
|
|||
GRPC_ERROR_CREATE_REFERENCING(
|
||||
"Cancelled before creating subchannel", &error, 1));
|
||||
} else {
|
||||
gpr_atm_rel_store(
|
||||
&holder->subchannel_call,
|
||||
(gpr_atm)(uintptr_t)grpc_connected_subchannel_create_call(
|
||||
exec_ctx, holder->connected_subchannel, holder->pollent));
|
||||
grpc_subchannel_call *subchannel_call = NULL;
|
||||
grpc_error *new_error = grpc_connected_subchannel_create_call(
|
||||
exec_ctx, holder->connected_subchannel, holder->pollent,
|
||||
&subchannel_call);
|
||||
if (new_error != GRPC_ERROR_NONE) {
|
||||
new_error = grpc_error_add_child(new_error, error);
|
||||
subchannel_call = CANCELLED_CALL;
|
||||
fail_locked(exec_ctx, holder, new_error);
|
||||
}
|
||||
gpr_atm_rel_store(&holder->subchannel_call,
|
||||
(gpr_atm)(uintptr_t)subchannel_call);
|
||||
retry_waiting_locked(exec_ctx, holder);
|
||||
}
|
||||
gpr_mu_unlock(&holder->mu);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -31,20 +31,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/* TODO(atash) remove cruft */
|
||||
#ifndef PYGRPC_CYTHON_WINDOWS_IMPORTS_H_
|
||||
#define PYGRPC_CYTHON_WINDOWS_IMPORTS_H_
|
||||
#ifndef GRPC_CORE_EXT_LB_POLICY_GRPCLB_GRPCLB_H
|
||||
#define GRPC_CORE_EXT_LB_POLICY_GRPCLB_GRPCLB_H
|
||||
|
||||
#include <grpc/support/port_platform.h>
|
||||
#include "src/core/ext/client_config/lb_policy_factory.h"
|
||||
|
||||
#include <grpc/byte_buffer.h>
|
||||
#include <grpc/byte_buffer_reader.h>
|
||||
#include <grpc/compression.h>
|
||||
#include <grpc/grpc.h>
|
||||
#include <grpc/grpc_security.h>
|
||||
#include <grpc/support/alloc.h>
|
||||
#include <grpc/support/slice.h>
|
||||
#include <grpc/support/time.h>
|
||||
#include <grpc/status.h>
|
||||
/** Returns a load balancing factory for the glb policy, which tries to connect
|
||||
* to a load balancing server to decide the next successfully connected
|
||||
* subchannel to pick. */
|
||||
grpc_lb_policy_factory *grpc_glb_lb_factory_create();
|
||||
|
||||
#endif
|
||||
#endif /* GRPC_CORE_EXT_LB_POLICY_GRPCLB_GRPCLB_H */
|
||||
|
|
@ -38,9 +38,15 @@
|
|||
#include <grpc/support/alloc.h>
|
||||
|
||||
typedef struct decode_serverlist_arg {
|
||||
int first_pass;
|
||||
int i;
|
||||
/* The first pass counts the number of servers in the server list. The second
|
||||
* one allocates and decodes. */
|
||||
bool first_pass;
|
||||
/* The decoding callback is invoked once per server in serverlist. Remember
|
||||
* which index of the serverlist are we currently decoding */
|
||||
size_t decoding_idx;
|
||||
/* Populated after the first pass. Number of server in the input serverlist */
|
||||
size_t num_servers;
|
||||
/* The decoded serverlist */
|
||||
grpc_grpclb_server **servers;
|
||||
} decode_serverlist_arg;
|
||||
|
||||
|
|
@ -48,23 +54,24 @@ typedef struct decode_serverlist_arg {
|
|||
static bool decode_serverlist(pb_istream_t *stream, const pb_field_t *field,
|
||||
void **arg) {
|
||||
decode_serverlist_arg *dec_arg = *arg;
|
||||
if (dec_arg->first_pass != 0) { /* first pass */
|
||||
if (dec_arg->first_pass) { /* count how many server do we have */
|
||||
grpc_grpclb_server server;
|
||||
if (!pb_decode(stream, grpc_lb_v1_Server_fields, &server)) {
|
||||
return false;
|
||||
}
|
||||
dec_arg->num_servers++;
|
||||
} else { /* second pass */
|
||||
} else { /* second pass. Actually decode. */
|
||||
grpc_grpclb_server *server = gpr_malloc(sizeof(grpc_grpclb_server));
|
||||
memset(server, 0, sizeof(grpc_grpclb_server));
|
||||
GPR_ASSERT(dec_arg->num_servers > 0);
|
||||
if (dec_arg->i == 0) { /* first iteration of second pass */
|
||||
if (dec_arg->decoding_idx == 0) { /* first iteration of second pass */
|
||||
dec_arg->servers =
|
||||
gpr_malloc(sizeof(grpc_grpclb_server *) * dec_arg->num_servers);
|
||||
}
|
||||
if (!pb_decode(stream, grpc_lb_v1_Server_fields, server)) {
|
||||
return false;
|
||||
}
|
||||
dec_arg->servers[dec_arg->i++] = server;
|
||||
dec_arg->servers[dec_arg->decoding_idx++] = server;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -102,57 +109,59 @@ void grpc_grpclb_request_destroy(grpc_grpclb_request *request) {
|
|||
gpr_free(request);
|
||||
}
|
||||
|
||||
grpc_grpclb_response *grpc_grpclb_response_parse(gpr_slice encoded_response) {
|
||||
bool status;
|
||||
typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response;
|
||||
grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
|
||||
gpr_slice encoded_grpc_grpclb_response) {
|
||||
pb_istream_t stream =
|
||||
pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_response),
|
||||
GPR_SLICE_LENGTH(encoded_response));
|
||||
grpc_grpclb_response *res = gpr_malloc(sizeof(grpc_grpclb_response));
|
||||
memset(res, 0, sizeof(*res));
|
||||
status = pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, res);
|
||||
if (!status) {
|
||||
grpc_grpclb_response_destroy(res);
|
||||
pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_grpc_grpclb_response),
|
||||
GPR_SLICE_LENGTH(encoded_grpc_grpclb_response));
|
||||
grpc_grpclb_response res;
|
||||
memset(&res, 0, sizeof(grpc_grpclb_response));
|
||||
if (!pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res)) {
|
||||
return NULL;
|
||||
}
|
||||
return res;
|
||||
grpc_grpclb_initial_response *initial_res =
|
||||
gpr_malloc(sizeof(grpc_grpclb_initial_response));
|
||||
memcpy(initial_res, &res.initial_response,
|
||||
sizeof(grpc_grpclb_initial_response));
|
||||
|
||||
return initial_res;
|
||||
}
|
||||
|
||||
grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
|
||||
gpr_slice encoded_response) {
|
||||
gpr_slice encoded_grpc_grpclb_response) {
|
||||
bool status;
|
||||
decode_serverlist_arg arg;
|
||||
pb_istream_t stream =
|
||||
pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_response),
|
||||
GPR_SLICE_LENGTH(encoded_response));
|
||||
pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_grpc_grpclb_response),
|
||||
GPR_SLICE_LENGTH(encoded_grpc_grpclb_response));
|
||||
pb_istream_t stream_at_start = stream;
|
||||
grpc_grpclb_response *res = gpr_malloc(sizeof(grpc_grpclb_response));
|
||||
memset(res, 0, sizeof(*res));
|
||||
grpc_grpclb_response res;
|
||||
memset(&res, 0, sizeof(grpc_grpclb_response));
|
||||
memset(&arg, 0, sizeof(decode_serverlist_arg));
|
||||
|
||||
res->server_list.servers.funcs.decode = decode_serverlist;
|
||||
res->server_list.servers.arg = &arg;
|
||||
arg.first_pass = 1;
|
||||
status = pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, res);
|
||||
res.server_list.servers.funcs.decode = decode_serverlist;
|
||||
res.server_list.servers.arg = &arg;
|
||||
arg.first_pass = true;
|
||||
status = pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res);
|
||||
if (!status) {
|
||||
grpc_grpclb_response_destroy(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
arg.first_pass = 0;
|
||||
arg.first_pass = false;
|
||||
status =
|
||||
pb_decode(&stream_at_start, grpc_lb_v1_LoadBalanceResponse_fields, res);
|
||||
pb_decode(&stream_at_start, grpc_lb_v1_LoadBalanceResponse_fields, &res);
|
||||
if (!status) {
|
||||
grpc_grpclb_response_destroy(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
grpc_grpclb_serverlist *sl = gpr_malloc(sizeof(grpc_grpclb_serverlist));
|
||||
memset(sl, 0, sizeof(*sl));
|
||||
sl->num_servers = arg.num_servers;
|
||||
sl->servers = arg.servers;
|
||||
if (res->server_list.has_expiration_interval) {
|
||||
sl->expiration_interval = res->server_list.expiration_interval;
|
||||
if (res.server_list.has_expiration_interval) {
|
||||
sl->expiration_interval = res.server_list.expiration_interval;
|
||||
}
|
||||
grpc_grpclb_response_destroy(res);
|
||||
return sl;
|
||||
}
|
||||
|
||||
|
|
@ -167,6 +176,72 @@ void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist) {
|
|||
gpr_free(serverlist);
|
||||
}
|
||||
|
||||
void grpc_grpclb_response_destroy(grpc_grpclb_response *response) {
|
||||
grpc_grpclb_serverlist *grpc_grpclb_serverlist_copy(
|
||||
const grpc_grpclb_serverlist *sl) {
|
||||
grpc_grpclb_serverlist *copy = gpr_malloc(sizeof(grpc_grpclb_serverlist));
|
||||
memset(copy, 0, sizeof(grpc_grpclb_serverlist));
|
||||
copy->num_servers = sl->num_servers;
|
||||
memcpy(©->expiration_interval, &sl->expiration_interval,
|
||||
sizeof(grpc_grpclb_duration));
|
||||
copy->servers = gpr_malloc(sizeof(grpc_grpclb_server *) * sl->num_servers);
|
||||
for (size_t i = 0; i < sl->num_servers; i++) {
|
||||
copy->servers[i] = gpr_malloc(sizeof(grpc_grpclb_server));
|
||||
memcpy(copy->servers[i], sl->servers[i], sizeof(grpc_grpclb_server));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist *lhs,
|
||||
const grpc_grpclb_serverlist *rhs) {
|
||||
if ((lhs == NULL) || (rhs == NULL)) {
|
||||
return false;
|
||||
}
|
||||
if (lhs->num_servers != rhs->num_servers) {
|
||||
return false;
|
||||
}
|
||||
if (grpc_grpclb_duration_compare(&lhs->expiration_interval,
|
||||
&rhs->expiration_interval) != 0) {
|
||||
return false;
|
||||
}
|
||||
for (size_t i = 0; i < lhs->num_servers; i++) {
|
||||
if (!grpc_grpclb_server_equals(lhs->servers[i], rhs->servers[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool grpc_grpclb_server_equals(const grpc_grpclb_server *lhs,
|
||||
const grpc_grpclb_server *rhs) {
|
||||
return memcmp(lhs, rhs, sizeof(grpc_grpclb_server)) == 0;
|
||||
}
|
||||
|
||||
int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
|
||||
const grpc_grpclb_duration *rhs) {
|
||||
GPR_ASSERT(lhs && rhs);
|
||||
if (lhs->has_seconds && rhs->has_seconds) {
|
||||
if (lhs->seconds < rhs->seconds) return -1;
|
||||
if (lhs->seconds > rhs->seconds) return 1;
|
||||
} else if (lhs->has_seconds) {
|
||||
return 1;
|
||||
} else if (rhs->has_seconds) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
GPR_ASSERT(lhs->seconds == rhs->seconds);
|
||||
if (lhs->has_nanos && rhs->has_nanos) {
|
||||
if (lhs->nanos < rhs->nanos) return -1;
|
||||
if (lhs->nanos > rhs->nanos) return 1;
|
||||
} else if (lhs->has_nanos) {
|
||||
return 1;
|
||||
} else if (rhs->has_nanos) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void grpc_grpclb_initial_response_destroy(
|
||||
grpc_grpclb_initial_response *response) {
|
||||
gpr_free(response);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ extern "C" {
|
|||
#define GRPC_GRPCLB_SERVICE_NAME_MAX_LENGTH 128
|
||||
|
||||
typedef grpc_lb_v1_LoadBalanceRequest grpc_grpclb_request;
|
||||
typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response;
|
||||
typedef grpc_lb_v1_InitialLoadBalanceResponse grpc_grpclb_initial_response;
|
||||
typedef grpc_lb_v1_Server grpc_grpclb_server;
|
||||
typedef grpc_lb_v1_Duration grpc_grpclb_duration;
|
||||
typedef struct grpc_grpclb_serverlist {
|
||||
|
|
@ -64,19 +64,37 @@ gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request);
|
|||
/** Destroy \a request */
|
||||
void grpc_grpclb_request_destroy(grpc_grpclb_request *request);
|
||||
|
||||
/** Parse (ie, decode) the bytes in \a encoded_response as a \a
|
||||
* grpc_grpclb_response */
|
||||
grpc_grpclb_response *grpc_grpclb_response_parse(gpr_slice encoded_response);
|
||||
/** Parse (ie, decode) the bytes in \a encoded_grpc_grpclb_response as a \a
|
||||
* grpc_grpclb_initial_response */
|
||||
grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
|
||||
gpr_slice encoded_grpc_grpclb_response);
|
||||
|
||||
/** Parse the list of servers from an encoded \a grpc_grpclb_response */
|
||||
grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
|
||||
gpr_slice encoded_grpc_grpclb_response);
|
||||
|
||||
/** Return a copy of \a sl. The caller is responsible for calling \a
|
||||
* grpc_grpclb_destroy_serverlist on the returned copy. */
|
||||
grpc_grpclb_serverlist *grpc_grpclb_serverlist_copy(
|
||||
const grpc_grpclb_serverlist *sl);
|
||||
|
||||
bool grpc_grpclb_serverlist_equals(const grpc_grpclb_serverlist *lhs,
|
||||
const grpc_grpclb_serverlist *rhs);
|
||||
|
||||
bool grpc_grpclb_server_equals(const grpc_grpclb_server *lhs,
|
||||
const grpc_grpclb_server *rhs);
|
||||
|
||||
/** Destroy \a serverlist */
|
||||
void grpc_grpclb_destroy_serverlist(grpc_grpclb_serverlist *serverlist);
|
||||
|
||||
/** Parse the list of servers from an encoded \a grpc_grpclb_response */
|
||||
grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
|
||||
gpr_slice encoded_response);
|
||||
/** Compare \a lhs against \a rhs and return 0 if \a lhs and \a rhs are equal,
|
||||
* < 0 if \a lhs represents a duration shorter than \a rhs and > 0 otherwise */
|
||||
int grpc_grpclb_duration_compare(const grpc_grpclb_duration *lhs,
|
||||
const grpc_grpclb_duration *rhs);
|
||||
|
||||
/** Destroy \a response */
|
||||
void grpc_grpclb_response_destroy(grpc_grpclb_response *response);
|
||||
/** Destroy \a initial_response */
|
||||
void grpc_grpclb_initial_response_destroy(
|
||||
grpc_grpclb_initial_response *response);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,42 +42,12 @@
|
|||
#include "src/core/lib/channel/channel_stack_builder.h"
|
||||
#include "src/core/lib/surface/channel_init.h"
|
||||
|
||||
struct grpc_load_reporting_config {
|
||||
grpc_load_reporting_fn fn;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
grpc_load_reporting_config *grpc_load_reporting_config_create(
|
||||
grpc_load_reporting_fn fn, void *user_data) {
|
||||
GPR_ASSERT(fn != NULL);
|
||||
grpc_load_reporting_config *lrc =
|
||||
gpr_malloc(sizeof(grpc_load_reporting_config));
|
||||
lrc->fn = fn;
|
||||
lrc->user_data = user_data;
|
||||
return lrc;
|
||||
}
|
||||
|
||||
grpc_load_reporting_config *grpc_load_reporting_config_copy(
|
||||
grpc_load_reporting_config *src) {
|
||||
return grpc_load_reporting_config_create(src->fn, src->user_data);
|
||||
}
|
||||
|
||||
void grpc_load_reporting_config_destroy(grpc_load_reporting_config *lrc) {
|
||||
gpr_free(lrc);
|
||||
}
|
||||
|
||||
void grpc_load_reporting_config_call(
|
||||
grpc_load_reporting_config *lrc,
|
||||
const grpc_load_reporting_call_data *call_data) {
|
||||
lrc->fn(call_data, lrc->user_data);
|
||||
}
|
||||
|
||||
static bool is_load_reporting_enabled(const grpc_channel_args *a) {
|
||||
if (a == NULL) return false;
|
||||
for (size_t i = 0; i < a->num_args; i++) {
|
||||
if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_LOAD_REPORTING)) {
|
||||
return a->args[i].type == GRPC_ARG_POINTER &&
|
||||
a->args[i].value.pointer.p != NULL;
|
||||
return a->args[i].type == GRPC_ARG_INTEGER &&
|
||||
a->args[i].value.integer != 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -94,37 +64,17 @@ static bool maybe_add_load_reporting_filter(grpc_channel_stack_builder *builder,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void lrd_arg_destroy(void *p) { grpc_load_reporting_config_destroy(p); }
|
||||
|
||||
static void *lrd_arg_copy(void *p) {
|
||||
return grpc_load_reporting_config_copy(p);
|
||||
}
|
||||
|
||||
static int lrd_arg_cmp(void *a, void *b) {
|
||||
grpc_load_reporting_config *lhs = a;
|
||||
grpc_load_reporting_config *rhs = b;
|
||||
return !(lhs->fn == rhs->fn && lhs->user_data == rhs->user_data);
|
||||
}
|
||||
|
||||
static const grpc_arg_pointer_vtable lrd_ptr_vtable = {
|
||||
lrd_arg_copy, lrd_arg_destroy, lrd_arg_cmp};
|
||||
|
||||
grpc_arg grpc_load_reporting_config_create_arg(
|
||||
grpc_load_reporting_config *lrc) {
|
||||
grpc_arg grpc_load_reporting_enable_arg() {
|
||||
grpc_arg arg;
|
||||
arg.type = GRPC_ARG_POINTER;
|
||||
arg.type = GRPC_ARG_INTEGER;
|
||||
arg.key = GRPC_ARG_ENABLE_LOAD_REPORTING;
|
||||
arg.value.pointer.p = lrc;
|
||||
arg.value.pointer.vtable = &lrd_ptr_vtable;
|
||||
arg.value.integer = 1;
|
||||
return arg;
|
||||
}
|
||||
|
||||
/* Plugin registration */
|
||||
|
||||
void grpc_load_reporting_plugin_init(void) {
|
||||
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX,
|
||||
maybe_add_load_reporting_filter,
|
||||
(void *)&grpc_load_reporting_filter);
|
||||
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX,
|
||||
maybe_add_load_reporting_filter,
|
||||
(void *)&grpc_load_reporting_filter);
|
||||
|
|
|
|||
|
|
@ -34,42 +34,47 @@
|
|||
#ifndef GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_H
|
||||
#define GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_H
|
||||
|
||||
#include "src/core/lib/iomgr/closure.h"
|
||||
#include "src/core/lib/surface/call.h"
|
||||
#include <grpc/impl/codegen/grpc_types.h>
|
||||
#include "src/core/lib/channel/channel_stack.h"
|
||||
|
||||
typedef struct grpc_load_reporting_config grpc_load_reporting_config;
|
||||
/** Metadata key for initial metadata coming from clients */
|
||||
/* TODO(dgq): change to the final value TBD */
|
||||
#define GRPC_LOAD_REPORTING_INITIAL_MD_KEY "load-reporting-initial"
|
||||
|
||||
/** Call information to be passed to the provided load reporting function upon
|
||||
* completion of the call */
|
||||
/** Metadata key for trailing metadata from servers */
|
||||
/* TODO(dgq): change to the final value TBD */
|
||||
#define GRPC_LOAD_REPORTING_TRAILING_MD_KEY "load-reporting-trailing"
|
||||
|
||||
/** Identifiers for the invocation point of the users LR callback */
|
||||
typedef enum grpc_load_reporting_source {
|
||||
GRPC_LR_POINT_UNKNOWN = 0,
|
||||
GRPC_LR_POINT_CHANNEL_CREATION,
|
||||
GRPC_LR_POINT_CHANNEL_DESTRUCTION,
|
||||
GRPC_LR_POINT_CALL_CREATION,
|
||||
GRPC_LR_POINT_CALL_DESTRUCTION
|
||||
} grpc_load_reporting_source;
|
||||
|
||||
/** Call information to be passed to the provided LR callback. */
|
||||
typedef struct grpc_load_reporting_call_data {
|
||||
const grpc_call_stats *stats; /**< Stats for the call */
|
||||
const char *trailing_md_string; /**< LR trailing metadata info */
|
||||
const grpc_load_reporting_source source; /**< point of last data update. */
|
||||
|
||||
/** Unique identifier for the channel associated with the data */
|
||||
intptr_t channel_id;
|
||||
|
||||
/** Unique identifier for the call associated with the data. If the call
|
||||
* hasn't been created yet, it'll have a value of zero. */
|
||||
intptr_t call_id;
|
||||
|
||||
/** Only valid when \a source is \a GRPC_LR_POINT_CALL_DESTRUCTION, that is,
|
||||
* once the call has completed */
|
||||
const grpc_call_final_info *final_info;
|
||||
|
||||
const char *initial_md_string; /**< value string for LR's initial md key */
|
||||
const char *trailing_md_string; /**< value string for LR's trailing md key */
|
||||
const char *method_name; /**< Corresponds to :path header */
|
||||
} grpc_load_reporting_call_data;
|
||||
|
||||
/** Custom function to be called by the load reporting filter. */
|
||||
typedef void (*grpc_load_reporting_fn)(
|
||||
const grpc_load_reporting_call_data *call_data, void *user_data);
|
||||
|
||||
/** Register \a fn as the function to be invoked by the load reporting filter.
|
||||
* \a fn will be invoked at the beginning and at the end of the call.
|
||||
*
|
||||
* For the first invocation, \a fn's first argument
|
||||
* (grpc_load_reporting_call_data*) will be NULL. \a user_data is always passed
|
||||
* as-is. */
|
||||
grpc_load_reporting_config *grpc_load_reporting_config_create(
|
||||
grpc_load_reporting_fn fn, void *user_data);
|
||||
|
||||
grpc_load_reporting_config *grpc_load_reporting_config_copy(
|
||||
grpc_load_reporting_config *src);
|
||||
|
||||
void grpc_load_reporting_config_destroy(grpc_load_reporting_config *lrc);
|
||||
|
||||
/** Invoke the function registered by \a grpc_load_reporting_init. */
|
||||
void grpc_load_reporting_config_call(
|
||||
grpc_load_reporting_config *lrc,
|
||||
const grpc_load_reporting_call_data *call_data);
|
||||
|
||||
/** Return a \a grpc_arg enabling load reporting */
|
||||
grpc_arg grpc_load_reporting_config_create_arg(grpc_load_reporting_config *lrc);
|
||||
grpc_arg grpc_load_reporting_enable_arg();
|
||||
|
||||
#endif /* GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_H */
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <grpc/support/alloc.h>
|
||||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/string_util.h>
|
||||
#include <grpc/support/sync.h>
|
||||
|
|
@ -42,38 +43,112 @@
|
|||
#include "src/core/lib/profiling/timers.h"
|
||||
#include "src/core/lib/transport/static_metadata.h"
|
||||
|
||||
typedef struct call_data { const char *trailing_md_string; } call_data;
|
||||
typedef struct call_data {
|
||||
intptr_t id; /**< an id unique to the call */
|
||||
char *trailing_md_string;
|
||||
char *initial_md_string;
|
||||
const char *service_method;
|
||||
|
||||
/* stores the recv_initial_metadata op's ready closure, which we wrap with our
|
||||
* own (on_initial_md_ready) in order to capture the incoming initial metadata
|
||||
* */
|
||||
grpc_closure *ops_recv_initial_metadata_ready;
|
||||
|
||||
/* to get notified of the availability of the incoming initial metadata. */
|
||||
grpc_closure on_initial_md_ready;
|
||||
grpc_metadata_batch *recv_initial_metadata;
|
||||
} call_data;
|
||||
|
||||
typedef struct channel_data {
|
||||
gpr_mu mu;
|
||||
grpc_load_reporting_config *lrc;
|
||||
intptr_t id; /**< an id unique to the channel */
|
||||
} channel_data;
|
||||
|
||||
static void invoke_lr_fn_locked(grpc_load_reporting_config *lrc,
|
||||
grpc_load_reporting_call_data *lr_call_data) {
|
||||
GPR_TIMER_BEGIN("load_reporting_config_fn", 0);
|
||||
grpc_load_reporting_config_call(lrc, lr_call_data);
|
||||
GPR_TIMER_END("load_reporting_config_fn", 0);
|
||||
typedef struct {
|
||||
grpc_call_element *elem;
|
||||
grpc_exec_ctx *exec_ctx;
|
||||
} recv_md_filter_args;
|
||||
|
||||
static grpc_mdelem *recv_md_filter(void *user_data, grpc_mdelem *md) {
|
||||
recv_md_filter_args *a = user_data;
|
||||
grpc_call_element *elem = a->elem;
|
||||
call_data *calld = elem->call_data;
|
||||
|
||||
if (md->key == GRPC_MDSTR_PATH) {
|
||||
calld->service_method = grpc_mdstr_as_c_string(md->value);
|
||||
} else if (md->key == GRPC_MDSTR_LOAD_REPORTING_INITIAL) {
|
||||
calld->initial_md_string = gpr_strdup(grpc_mdstr_as_c_string(md->value));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data,
|
||||
grpc_error *err) {
|
||||
grpc_call_element *elem = user_data;
|
||||
call_data *calld = elem->call_data;
|
||||
|
||||
if (err == GRPC_ERROR_NONE) {
|
||||
recv_md_filter_args a;
|
||||
a.elem = elem;
|
||||
a.exec_ctx = exec_ctx;
|
||||
grpc_metadata_batch_filter(calld->recv_initial_metadata, recv_md_filter,
|
||||
&a);
|
||||
if (calld->service_method == NULL) {
|
||||
err =
|
||||
grpc_error_add_child(err, GRPC_ERROR_CREATE("Missing :path header"));
|
||||
}
|
||||
} else {
|
||||
GRPC_ERROR_REF(err);
|
||||
}
|
||||
calld->ops_recv_initial_metadata_ready->cb(
|
||||
exec_ctx, calld->ops_recv_initial_metadata_ready->cb_arg, err);
|
||||
GRPC_ERROR_UNREF(err);
|
||||
}
|
||||
|
||||
/* Constructor for call_data */
|
||||
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
call_data *calld = elem->call_data;
|
||||
memset(calld, 0, sizeof(call_data));
|
||||
|
||||
calld->id = (intptr_t)args->call_stack;
|
||||
grpc_closure_init(&calld->on_initial_md_ready, on_initial_md_ready, elem);
|
||||
|
||||
/* TODO(dgq): do something with the data
|
||||
channel_data *chand = elem->channel_data;
|
||||
grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CALL_CREATION,
|
||||
(intptr_t)chand->id,
|
||||
(intptr_t)calld->id,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
*/
|
||||
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
/* Destructor for call_data */
|
||||
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
const grpc_call_stats *stats, void *ignored) {
|
||||
channel_data *chand = elem->channel_data;
|
||||
const grpc_call_final_info *final_info,
|
||||
void *ignored) {
|
||||
call_data *calld = elem->call_data;
|
||||
|
||||
grpc_load_reporting_call_data lr_call_data = {stats,
|
||||
calld->trailing_md_string};
|
||||
/* TODO(dgq): do something with the data
|
||||
channel_data *chand = elem->channel_data;
|
||||
grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CALL_DESTRUCTION,
|
||||
(intptr_t)chand->id,
|
||||
(intptr_t)calld->id,
|
||||
final_info,
|
||||
calld->initial_md_string,
|
||||
calld->trailing_md_string,
|
||||
calld->service_method};
|
||||
*/
|
||||
|
||||
gpr_mu_lock(&chand->mu);
|
||||
invoke_lr_fn_locked(chand->lrc, &lr_call_data);
|
||||
gpr_mu_unlock(&chand->mu);
|
||||
gpr_free(calld->initial_md_string);
|
||||
gpr_free(calld->trailing_md_string);
|
||||
}
|
||||
|
||||
/* Constructor for channel_data */
|
||||
|
|
@ -85,37 +160,40 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
|
|||
channel_data *chand = elem->channel_data;
|
||||
memset(chand, 0, sizeof(channel_data));
|
||||
|
||||
gpr_mu_init(&chand->mu);
|
||||
for (size_t i = 0; i < args->channel_args->num_args; i++) {
|
||||
if (0 == strcmp(args->channel_args->args[i].key,
|
||||
GRPC_ARG_ENABLE_LOAD_REPORTING)) {
|
||||
grpc_load_reporting_config *arg_lrc =
|
||||
args->channel_args->args[i].value.pointer.p;
|
||||
chand->lrc = grpc_load_reporting_config_copy(arg_lrc);
|
||||
GPR_ASSERT(chand->lrc != NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
GPR_ASSERT(chand->lrc != NULL); /* arg actually found */
|
||||
chand->id = (intptr_t)args->channel_stack;
|
||||
|
||||
gpr_mu_lock(&chand->mu);
|
||||
invoke_lr_fn_locked(chand->lrc, NULL);
|
||||
gpr_mu_unlock(&chand->mu);
|
||||
/* TODO(dgq): do something with the data
|
||||
grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CHANNEL_CREATION,
|
||||
(intptr_t)chand,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
*/
|
||||
}
|
||||
|
||||
/* Destructor for channel data */
|
||||
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_channel_element *elem) {
|
||||
/* TODO(dgq): do something with the data
|
||||
channel_data *chand = elem->channel_data;
|
||||
gpr_mu_destroy(&chand->mu);
|
||||
grpc_load_reporting_config_destroy(chand->lrc);
|
||||
grpc_load_reporting_call_data lr_call_data = {
|
||||
GRPC_LR_POINT_CHANNEL_DESTRUCTION,
|
||||
(intptr_t)chand->id,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL};
|
||||
*/
|
||||
}
|
||||
|
||||
static grpc_mdelem *lr_trailing_md_filter(void *user_data, grpc_mdelem *md) {
|
||||
grpc_call_element *elem = user_data;
|
||||
call_data *calld = elem->call_data;
|
||||
|
||||
if (md->key == GRPC_MDSTR_LOAD_REPORTING) {
|
||||
if (md->key == GRPC_MDSTR_LOAD_REPORTING_TRAILING) {
|
||||
calld->trailing_md_string = gpr_strdup(grpc_mdstr_as_c_string(md->value));
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -127,8 +205,14 @@ static void lr_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
|
|||
grpc_call_element *elem,
|
||||
grpc_transport_stream_op *op) {
|
||||
GPR_TIMER_BEGIN("lr_start_transport_stream_op", 0);
|
||||
call_data *calld = elem->call_data;
|
||||
|
||||
if (op->send_trailing_metadata) {
|
||||
if (op->recv_initial_metadata) {
|
||||
calld->recv_initial_metadata = op->recv_initial_metadata;
|
||||
/* substitute our callback for the higher callback */
|
||||
calld->ops_recv_initial_metadata_ready = op->recv_initial_metadata_ready;
|
||||
op->recv_initial_metadata_ready = &calld->on_initial_md_ready;
|
||||
} else if (op->send_trailing_metadata) {
|
||||
grpc_metadata_batch_filter(op->send_trailing_metadata,
|
||||
lr_trailing_md_filter, elem);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#ifndef GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_FILTER_H
|
||||
#define GRPC_CORE_EXT_LOAD_REPORTING_LOAD_REPORTING_FILTER_H
|
||||
|
||||
#include "src/core/ext/load_reporting/load_reporting.h"
|
||||
#include "src/core/lib/channel/channel_stack.h"
|
||||
|
||||
extern const grpc_channel_filter grpc_load_reporting_filter;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/channel/compress_filter.h"
|
||||
#include "src/core/lib/channel/handshaker.h"
|
||||
#include "src/core/lib/channel/http_client_filter.h"
|
||||
#include "src/core/lib/iomgr/tcp_client.h"
|
||||
#include "src/core/lib/surface/api_trace.h"
|
||||
|
|
@ -63,6 +64,8 @@ typedef struct {
|
|||
grpc_endpoint *tcp;
|
||||
|
||||
grpc_closure connected;
|
||||
|
||||
grpc_handshake_manager *handshake_mgr;
|
||||
} connector;
|
||||
|
||||
static void connector_ref(grpc_connector *con) {
|
||||
|
|
@ -74,6 +77,7 @@ static void connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *con) {
|
|||
connector *c = (connector *)con;
|
||||
if (gpr_unref(&c->refs)) {
|
||||
/* c->initial_string_buffer does not need to be destroyed */
|
||||
grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
|
||||
gpr_free(c);
|
||||
}
|
||||
}
|
||||
|
|
@ -83,9 +87,22 @@ static void on_initial_connect_string_sent(grpc_exec_ctx *exec_ctx, void *arg,
|
|||
connector_unref(exec_ctx, arg);
|
||||
}
|
||||
|
||||
static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint,
|
||||
grpc_channel_args *args, void *user_data,
|
||||
grpc_error *error) {
|
||||
connector *c = user_data;
|
||||
c->result->transport =
|
||||
grpc_create_chttp2_transport(exec_ctx, args, endpoint, 1);
|
||||
GPR_ASSERT(c->result->transport);
|
||||
grpc_chttp2_transport_start_reading(exec_ctx, c->result->transport, NULL, 0);
|
||||
c->result->channel_args = args;
|
||||
grpc_closure *notify = c->notify;
|
||||
c->notify = NULL;
|
||||
grpc_exec_ctx_sched(exec_ctx, notify, error, NULL);
|
||||
}
|
||||
|
||||
static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
||||
connector *c = arg;
|
||||
grpc_closure *notify;
|
||||
grpc_endpoint *tcp = c->tcp;
|
||||
if (tcp != NULL) {
|
||||
if (!GPR_SLICE_IS_EMPTY(c->args.initial_connect_string)) {
|
||||
|
|
@ -97,19 +114,17 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
|||
connector_ref(arg);
|
||||
grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer,
|
||||
&c->initial_string_sent);
|
||||
} else {
|
||||
grpc_handshake_manager_do_handshake(
|
||||
exec_ctx, c->handshake_mgr, tcp, c->args.channel_args,
|
||||
c->args.deadline, NULL /* acceptor */, on_handshake_done, c);
|
||||
}
|
||||
c->result->transport =
|
||||
grpc_create_chttp2_transport(exec_ctx, c->args.channel_args, tcp, 1);
|
||||
grpc_chttp2_transport_start_reading(exec_ctx, c->result->transport, NULL,
|
||||
0);
|
||||
GPR_ASSERT(c->result->transport);
|
||||
c->result->channel_args = grpc_channel_args_copy(c->args.channel_args);
|
||||
} else {
|
||||
memset(c->result, 0, sizeof(*c->result));
|
||||
grpc_closure *notify = c->notify;
|
||||
c->notify = NULL;
|
||||
grpc_exec_ctx_sched(exec_ctx, notify, GRPC_ERROR_REF(error), NULL);
|
||||
}
|
||||
notify = c->notify;
|
||||
c->notify = NULL;
|
||||
grpc_exec_ctx_sched(exec_ctx, notify, GRPC_ERROR_REF(error), NULL);
|
||||
}
|
||||
|
||||
static void connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *con) {}
|
||||
|
|
@ -171,6 +186,7 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
|
|||
memset(c, 0, sizeof(*c));
|
||||
c->base.vtable = &connector_vtable;
|
||||
gpr_ref_init(&c->refs, 1);
|
||||
c->handshake_mgr = grpc_handshake_manager_create();
|
||||
args->args = final_args;
|
||||
s = grpc_subchannel_create(exec_ctx, &c->base, args);
|
||||
grpc_connector_unref(exec_ctx, &c->base);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include "src/core/ext/client_config/resolver_registry.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/channel/handshaker.h"
|
||||
#include "src/core/lib/iomgr/tcp_client.h"
|
||||
#include "src/core/lib/security/context/security_context.h"
|
||||
#include "src/core/lib/security/credentials/credentials.h"
|
||||
|
|
@ -69,6 +70,11 @@ typedef struct {
|
|||
grpc_endpoint *newly_connecting_endpoint;
|
||||
|
||||
grpc_closure connected_closure;
|
||||
|
||||
grpc_handshake_manager *handshake_mgr;
|
||||
|
||||
// TODO(roth): Remove once we eliminate on_secure_handshake_done().
|
||||
grpc_channel_args *tmp_args;
|
||||
} connector;
|
||||
|
||||
static void connector_ref(grpc_connector *con) {
|
||||
|
|
@ -80,6 +86,8 @@ static void connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *con) {
|
|||
connector *c = (connector *)con;
|
||||
if (gpr_unref(&c->refs)) {
|
||||
/* c->initial_string_buffer does not need to be destroyed */
|
||||
grpc_channel_args_destroy(c->tmp_args);
|
||||
grpc_handshake_manager_destroy(exec_ctx, c->handshake_mgr);
|
||||
gpr_free(c);
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +97,6 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
|
|||
grpc_endpoint *secure_endpoint,
|
||||
grpc_auth_context *auth_context) {
|
||||
connector *c = arg;
|
||||
grpc_closure *notify;
|
||||
gpr_mu_lock(&c->mu);
|
||||
grpc_error *error = GRPC_ERROR_NONE;
|
||||
if (c->connecting_endpoint == NULL) {
|
||||
|
|
@ -110,25 +117,43 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
|
|||
grpc_chttp2_transport_start_reading(exec_ctx, c->result->transport, NULL,
|
||||
0);
|
||||
auth_context_arg = grpc_auth_context_to_arg(auth_context);
|
||||
c->result->channel_args = grpc_channel_args_copy_and_add(
|
||||
c->args.channel_args, &auth_context_arg, 1);
|
||||
c->result->channel_args =
|
||||
grpc_channel_args_copy_and_add(c->tmp_args, &auth_context_arg, 1);
|
||||
}
|
||||
notify = c->notify;
|
||||
grpc_closure *notify = c->notify;
|
||||
c->notify = NULL;
|
||||
grpc_exec_ctx_sched(exec_ctx, notify, error, NULL);
|
||||
}
|
||||
|
||||
static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint,
|
||||
grpc_channel_args *args, void *user_data,
|
||||
grpc_error *error) {
|
||||
connector *c = user_data;
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
grpc_closure *notify = c->notify;
|
||||
c->notify = NULL;
|
||||
grpc_exec_ctx_sched(exec_ctx, notify, error, NULL);
|
||||
} else {
|
||||
// TODO(roth, jboeuf): Convert security connector handshaking to use new
|
||||
// handshake API, and then move the code from on_secure_handshake_done()
|
||||
// into this function.
|
||||
c->tmp_args = args;
|
||||
grpc_channel_security_connector_do_handshake(
|
||||
exec_ctx, c->security_connector, endpoint, c->args.deadline,
|
||||
on_secure_handshake_done, c);
|
||||
}
|
||||
}
|
||||
|
||||
static void on_initial_connect_string_sent(grpc_exec_ctx *exec_ctx, void *arg,
|
||||
grpc_error *error) {
|
||||
connector *c = arg;
|
||||
grpc_channel_security_connector_do_handshake(
|
||||
exec_ctx, c->security_connector, c->connecting_endpoint, c->args.deadline,
|
||||
on_secure_handshake_done, c);
|
||||
grpc_handshake_manager_do_handshake(
|
||||
exec_ctx, c->handshake_mgr, c->connecting_endpoint, c->args.channel_args,
|
||||
c->args.deadline, NULL /* acceptor */, on_handshake_done, c);
|
||||
}
|
||||
|
||||
static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
||||
connector *c = arg;
|
||||
grpc_closure *notify;
|
||||
grpc_endpoint *tcp = c->newly_connecting_endpoint;
|
||||
if (tcp != NULL) {
|
||||
gpr_mu_lock(&c->mu);
|
||||
|
|
@ -144,13 +169,13 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
|
|||
grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer,
|
||||
&c->initial_string_sent);
|
||||
} else {
|
||||
grpc_channel_security_connector_do_handshake(
|
||||
exec_ctx, c->security_connector, tcp, c->args.deadline,
|
||||
on_secure_handshake_done, c);
|
||||
grpc_handshake_manager_do_handshake(
|
||||
exec_ctx, c->handshake_mgr, tcp, c->args.channel_args,
|
||||
c->args.deadline, NULL /* acceptor */, on_handshake_done, c);
|
||||
}
|
||||
} else {
|
||||
memset(c->result, 0, sizeof(*c->result));
|
||||
notify = c->notify;
|
||||
grpc_closure *notify = c->notify;
|
||||
c->notify = NULL;
|
||||
grpc_exec_ctx_sched(exec_ctx, notify, GRPC_ERROR_REF(error), NULL);
|
||||
}
|
||||
|
|
@ -229,6 +254,7 @@ static grpc_subchannel *client_channel_factory_create_subchannel(
|
|||
memset(c, 0, sizeof(*c));
|
||||
c->base.vtable = &connector_vtable;
|
||||
c->security_connector = f->security_connector;
|
||||
c->handshake_mgr = grpc_handshake_manager_create();
|
||||
gpr_mu_init(&c->mu);
|
||||
gpr_ref_init(&c->refs, 1);
|
||||
args->args = final_args;
|
||||
|
|
|
|||
|
|
@ -37,35 +37,74 @@
|
|||
#include <grpc/support/log.h>
|
||||
#include <grpc/support/string_util.h>
|
||||
#include <grpc/support/useful.h>
|
||||
|
||||
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/channel/handshaker.h"
|
||||
#include "src/core/lib/channel/http_server_filter.h"
|
||||
#include "src/core/lib/iomgr/resolve_address.h"
|
||||
#include "src/core/lib/iomgr/tcp_server.h"
|
||||
#include "src/core/lib/surface/api_trace.h"
|
||||
#include "src/core/lib/surface/server.h"
|
||||
|
||||
static void new_transport(grpc_exec_ctx *exec_ctx, void *server,
|
||||
grpc_endpoint *tcp, grpc_pollset *accepting_pollset,
|
||||
grpc_tcp_server_acceptor *acceptor) {
|
||||
/*
|
||||
* Beware that the call to grpc_create_chttp2_transport() has to happen before
|
||||
* grpc_tcp_server_destroy(). This is fine here, but similar code
|
||||
* asynchronously doing a handshake instead of calling grpc_tcp_server_start()
|
||||
* (as in server_secure_chttp2.c) needs to add synchronization to avoid this
|
||||
* case.
|
||||
*/
|
||||
grpc_transport *transport = grpc_create_chttp2_transport(
|
||||
exec_ctx, grpc_server_get_channel_args(server), tcp, 0);
|
||||
grpc_server_setup_transport(exec_ctx, server, transport, accepting_pollset,
|
||||
grpc_server_get_channel_args(server));
|
||||
grpc_chttp2_transport_start_reading(exec_ctx, transport, NULL, 0);
|
||||
typedef struct server_connect_state {
|
||||
grpc_server *server;
|
||||
grpc_pollset *accepting_pollset;
|
||||
grpc_tcp_server_acceptor *acceptor;
|
||||
grpc_handshake_manager *handshake_mgr;
|
||||
} server_connect_state;
|
||||
|
||||
static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint,
|
||||
grpc_channel_args *args, void *user_data,
|
||||
grpc_error *error) {
|
||||
server_connect_state *state = user_data;
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
const char *error_str = grpc_error_string(error);
|
||||
gpr_log(GPR_ERROR, "Handshaking failed: %s", error_str);
|
||||
grpc_error_free_string(error_str);
|
||||
GRPC_ERROR_UNREF(error);
|
||||
grpc_handshake_manager_shutdown(exec_ctx, state->handshake_mgr);
|
||||
} else {
|
||||
// Beware that the call to grpc_create_chttp2_transport() has to happen
|
||||
// before grpc_tcp_server_destroy(). This is fine here, but similar code
|
||||
// asynchronously doing a handshake instead of calling
|
||||
// grpc_tcp_server_start() (as in server_secure_chttp2.c) needs to add
|
||||
// synchronization to avoid this case.
|
||||
grpc_transport *transport =
|
||||
grpc_create_chttp2_transport(exec_ctx, args, endpoint, 0);
|
||||
grpc_server_setup_transport(exec_ctx, state->server, transport,
|
||||
state->accepting_pollset,
|
||||
grpc_server_get_channel_args(state->server));
|
||||
grpc_chttp2_transport_start_reading(exec_ctx, transport, NULL, 0);
|
||||
}
|
||||
// Clean up.
|
||||
grpc_channel_args_destroy(args);
|
||||
grpc_handshake_manager_destroy(exec_ctx, state->handshake_mgr);
|
||||
gpr_free(state);
|
||||
}
|
||||
|
||||
static void on_accept(grpc_exec_ctx *exec_ctx, void *server, grpc_endpoint *tcp,
|
||||
grpc_pollset *accepting_pollset,
|
||||
grpc_tcp_server_acceptor *acceptor) {
|
||||
server_connect_state *state = gpr_malloc(sizeof(server_connect_state));
|
||||
state->server = server;
|
||||
state->accepting_pollset = accepting_pollset;
|
||||
state->acceptor = acceptor;
|
||||
state->handshake_mgr = grpc_handshake_manager_create();
|
||||
// TODO(roth): We should really get this timeout value from channel
|
||||
// args instead of hard-coding it.
|
||||
const gpr_timespec deadline = gpr_time_add(
|
||||
gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(120, GPR_TIMESPAN));
|
||||
grpc_handshake_manager_do_handshake(
|
||||
exec_ctx, state->handshake_mgr, tcp, grpc_server_get_channel_args(server),
|
||||
deadline, acceptor, on_handshake_done, state);
|
||||
}
|
||||
|
||||
/* Server callback: start listening on our ports */
|
||||
static void start(grpc_exec_ctx *exec_ctx, grpc_server *server, void *tcpp,
|
||||
grpc_pollset **pollsets, size_t pollset_count) {
|
||||
grpc_tcp_server *tcp = tcpp;
|
||||
grpc_tcp_server_start(exec_ctx, tcp, pollsets, pollset_count, new_transport,
|
||||
grpc_tcp_server_start(exec_ctx, tcp, pollsets, pollset_count, on_accept,
|
||||
server);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include <grpc/support/useful.h>
|
||||
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/channel/handshaker.h"
|
||||
#include "src/core/lib/channel/http_server_filter.h"
|
||||
#include "src/core/lib/iomgr/endpoint.h"
|
||||
#include "src/core/lib/iomgr/resolve_address.h"
|
||||
|
|
@ -58,7 +59,7 @@ typedef struct server_secure_state {
|
|||
grpc_tcp_server *tcp;
|
||||
grpc_server_security_connector *sc;
|
||||
grpc_server_credentials *creds;
|
||||
int is_shutdown;
|
||||
bool is_shutdown;
|
||||
gpr_mu mu;
|
||||
gpr_refcount refcount;
|
||||
grpc_closure destroy_closure;
|
||||
|
|
@ -68,6 +69,12 @@ typedef struct server_secure_state {
|
|||
typedef struct server_secure_connect {
|
||||
server_secure_state *state;
|
||||
grpc_pollset *accepting_pollset;
|
||||
grpc_tcp_server_acceptor *acceptor;
|
||||
grpc_handshake_manager *handshake_mgr;
|
||||
// TODO(roth): Remove the following two fields when we eliminate
|
||||
// grpc_server_security_connector_do_handshake().
|
||||
gpr_timespec deadline;
|
||||
grpc_channel_args *args;
|
||||
} server_secure_connect;
|
||||
|
||||
static void state_ref(server_secure_state *state) { gpr_ref(&state->refcount); }
|
||||
|
|
@ -89,21 +96,18 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *statep,
|
|||
grpc_endpoint *secure_endpoint,
|
||||
grpc_auth_context *auth_context) {
|
||||
server_secure_connect *state = statep;
|
||||
grpc_transport *transport;
|
||||
if (status == GRPC_SECURITY_OK) {
|
||||
if (secure_endpoint) {
|
||||
gpr_mu_lock(&state->state->mu);
|
||||
if (!state->state->is_shutdown) {
|
||||
transport = grpc_create_chttp2_transport(
|
||||
grpc_transport *transport = grpc_create_chttp2_transport(
|
||||
exec_ctx, grpc_server_get_channel_args(state->state->server),
|
||||
secure_endpoint, 0);
|
||||
grpc_channel_args *args_copy;
|
||||
grpc_arg args_to_add[2];
|
||||
args_to_add[0] = grpc_server_credentials_to_arg(state->state->creds);
|
||||
args_to_add[1] = grpc_auth_context_to_arg(auth_context);
|
||||
args_copy = grpc_channel_args_copy_and_add(
|
||||
grpc_server_get_channel_args(state->state->server), args_to_add,
|
||||
GPR_ARRAY_SIZE(args_to_add));
|
||||
grpc_channel_args *args_copy = grpc_channel_args_copy_and_add(
|
||||
state->args, args_to_add, GPR_ARRAY_SIZE(args_to_add));
|
||||
grpc_server_setup_transport(exec_ctx, state->state->server, transport,
|
||||
state->accepting_pollset, args_copy);
|
||||
grpc_channel_args_destroy(args_copy);
|
||||
|
|
@ -118,10 +122,38 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *statep,
|
|||
} else {
|
||||
gpr_log(GPR_ERROR, "Secure transport failed with error %d", status);
|
||||
}
|
||||
grpc_channel_args_destroy(state->args);
|
||||
state_unref(state->state);
|
||||
gpr_free(state);
|
||||
}
|
||||
|
||||
static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint,
|
||||
grpc_channel_args *args, void *user_data,
|
||||
grpc_error *error) {
|
||||
server_secure_connect *state = user_data;
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
const char *error_str = grpc_error_string(error);
|
||||
gpr_log(GPR_ERROR, "Handshaking failed: %s", error_str);
|
||||
grpc_error_free_string(error_str);
|
||||
GRPC_ERROR_UNREF(error);
|
||||
grpc_handshake_manager_shutdown(exec_ctx, state->handshake_mgr);
|
||||
grpc_handshake_manager_destroy(exec_ctx, state->handshake_mgr);
|
||||
grpc_channel_args_destroy(args);
|
||||
state_unref(state->state);
|
||||
gpr_free(state);
|
||||
return;
|
||||
}
|
||||
grpc_handshake_manager_destroy(exec_ctx, state->handshake_mgr);
|
||||
state->handshake_mgr = NULL;
|
||||
// TODO(roth, jboeuf): Convert security connector handshaking to use new
|
||||
// handshake API, and then move the code from on_secure_handshake_done()
|
||||
// into this function.
|
||||
state->args = args;
|
||||
grpc_server_security_connector_do_handshake(
|
||||
exec_ctx, state->state->sc, state->acceptor, endpoint, state->deadline,
|
||||
on_secure_handshake_done, state);
|
||||
}
|
||||
|
||||
static void on_accept(grpc_exec_ctx *exec_ctx, void *statep, grpc_endpoint *tcp,
|
||||
grpc_pollset *accepting_pollset,
|
||||
grpc_tcp_server_acceptor *acceptor) {
|
||||
|
|
@ -129,11 +161,16 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *statep, grpc_endpoint *tcp,
|
|||
state->state = statep;
|
||||
state_ref(state->state);
|
||||
state->accepting_pollset = accepting_pollset;
|
||||
grpc_server_security_connector_do_handshake(
|
||||
exec_ctx, state->state->sc, acceptor, tcp,
|
||||
gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
|
||||
gpr_time_from_seconds(120, GPR_TIMESPAN)),
|
||||
on_secure_handshake_done, state);
|
||||
state->acceptor = acceptor;
|
||||
state->handshake_mgr = grpc_handshake_manager_create();
|
||||
// TODO(roth): We should really get this timeout value from channel
|
||||
// args instead of hard-coding it.
|
||||
state->deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC),
|
||||
gpr_time_from_seconds(120, GPR_TIMESPAN));
|
||||
grpc_handshake_manager_do_handshake(
|
||||
exec_ctx, state->handshake_mgr, tcp,
|
||||
grpc_server_get_channel_args(state->state->server), state->deadline,
|
||||
acceptor, on_handshake_done, state);
|
||||
}
|
||||
|
||||
/* Server callback: start listening on our ports */
|
||||
|
|
@ -162,7 +199,7 @@ static void destroy(grpc_exec_ctx *exec_ctx, grpc_server *server, void *statep,
|
|||
server_secure_state *state = statep;
|
||||
grpc_tcp_server *tcp;
|
||||
gpr_mu_lock(&state->mu);
|
||||
state->is_shutdown = 1;
|
||||
state->is_shutdown = true;
|
||||
state->destroy_callback = callback;
|
||||
tcp = state->tcp;
|
||||
gpr_mu_unlock(&state->mu);
|
||||
|
|
@ -227,7 +264,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
|
|||
state->tcp = tcp;
|
||||
state->sc = sc;
|
||||
state->creds = grpc_server_credentials_ref(creds);
|
||||
state->is_shutdown = 0;
|
||||
state->is_shutdown = false;
|
||||
gpr_mu_init(&state->mu);
|
||||
gpr_ref_init(&state->refcount, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@
|
|||
#include "src/core/ext/transport/chttp2/transport/http2_errors.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/internal.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/status_conversion.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/timeout_encoding.h"
|
||||
#include "src/core/lib/http/parser.h"
|
||||
#include "src/core/lib/iomgr/workqueue.h"
|
||||
#include "src/core/lib/profiling/timers.h"
|
||||
#include "src/core/lib/support/string.h"
|
||||
#include "src/core/lib/transport/static_metadata.h"
|
||||
#include "src/core/lib/transport/timeout_encoding.h"
|
||||
#include "src/core/lib/transport/transport_impl.h"
|
||||
|
||||
#define DEFAULT_WINDOW 65535
|
||||
|
|
@ -1940,6 +1940,7 @@ static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx,
|
|||
static void parsing_action(grpc_exec_ctx *exec_ctx, void *arg,
|
||||
grpc_error *error) {
|
||||
grpc_chttp2_transport *t = arg;
|
||||
grpc_error *err = GRPC_ERROR_NONE;
|
||||
GPR_TIMER_BEGIN("reading_action.parse", 0);
|
||||
size_t i = 0;
|
||||
grpc_error *errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE,
|
||||
|
|
@ -1948,15 +1949,13 @@ static void parsing_action(grpc_exec_ctx *exec_ctx, void *arg,
|
|||
errors[1] = grpc_chttp2_perform_read(exec_ctx, &t->parsing,
|
||||
t->read_buffer.slices[i]);
|
||||
};
|
||||
if (i != t->read_buffer.count) {
|
||||
if (errors[1] == GRPC_ERROR_NONE) {
|
||||
err = GRPC_ERROR_REF(error);
|
||||
} else {
|
||||
errors[2] = try_http_parsing(exec_ctx, t);
|
||||
err = GRPC_ERROR_CREATE_REFERENCING("Failed parsing HTTP/2", errors,
|
||||
GPR_ARRAY_SIZE(errors));
|
||||
}
|
||||
grpc_error *err =
|
||||
errors[0] == GRPC_ERROR_NONE && errors[1] == GRPC_ERROR_NONE &&
|
||||
errors[2] == GRPC_ERROR_NONE
|
||||
? GRPC_ERROR_NONE
|
||||
: GRPC_ERROR_CREATE_REFERENCING("Failed parsing HTTP/2", errors,
|
||||
GPR_ARRAY_SIZE(errors));
|
||||
for (i = 0; i < GPR_ARRAY_SIZE(errors); i++) {
|
||||
GRPC_ERROR_UNREF(errors[i]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@
|
|||
|
||||
#include "src/core/ext/transport/chttp2/transport/bin_encoder.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/hpack_table.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/timeout_encoding.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/varint.h"
|
||||
#include "src/core/lib/transport/metadata.h"
|
||||
#include "src/core/lib/transport/static_metadata.h"
|
||||
#include "src/core/lib/transport/timeout_encoding.h"
|
||||
|
||||
#define HASH_FRAGMENT_1(x) ((x)&255)
|
||||
#define HASH_FRAGMENT_2(x) ((x >> 8) & 255)
|
||||
|
|
@ -456,9 +456,9 @@ static void hpack_enc(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem,
|
|||
|
||||
static void deadline_enc(grpc_chttp2_hpack_compressor *c, gpr_timespec deadline,
|
||||
framer_state *st) {
|
||||
char timeout_str[GRPC_CHTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
|
||||
char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
|
||||
grpc_mdelem *mdelem;
|
||||
grpc_chttp2_encode_timeout(
|
||||
grpc_http2_encode_timeout(
|
||||
gpr_time_sub(deadline, gpr_now(deadline.clock_type)), timeout_str);
|
||||
mdelem = grpc_mdelem_from_metadata_strings(
|
||||
GRPC_MDSTR_GRPC_TIMEOUT, grpc_mdstr_from_string(timeout_str));
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@
|
|||
|
||||
#include "src/core/ext/transport/chttp2/transport/http2_errors.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/status_conversion.h"
|
||||
#include "src/core/ext/transport/chttp2/transport/timeout_encoding.h"
|
||||
#include "src/core/lib/profiling/timers.h"
|
||||
#include "src/core/lib/transport/static_metadata.h"
|
||||
#include "src/core/lib/transport/timeout_encoding.h"
|
||||
|
||||
#define TRANSPORT_FROM_PARSING(tp) \
|
||||
((grpc_chttp2_transport *)((char *)(tp)-offsetof(grpc_chttp2_transport, \
|
||||
|
|
@ -672,8 +672,8 @@ static void on_initial_header(void *tp, grpc_mdelem *md) {
|
|||
if (!cached_timeout) {
|
||||
/* not already parsed: parse it now, and store the result away */
|
||||
cached_timeout = gpr_malloc(sizeof(gpr_timespec));
|
||||
if (!grpc_chttp2_decode_timeout(grpc_mdstr_as_c_string(md->value),
|
||||
cached_timeout)) {
|
||||
if (!grpc_http2_decode_timeout(grpc_mdstr_as_c_string(md->value),
|
||||
cached_timeout)) {
|
||||
gpr_log(GPR_ERROR, "Ignoring bad timeout value '%s'",
|
||||
grpc_mdstr_as_c_string(md->value));
|
||||
*cached_timeout = gpr_inf_future(GPR_TIMESPAN);
|
||||
|
|
|
|||
|
|
@ -203,6 +203,7 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
|
|||
|
||||
GPR_TIMER_BEGIN("finalize_outbuf", 0);
|
||||
|
||||
bool is_first_data_frame = true;
|
||||
while (
|
||||
grpc_chttp2_list_pop_writing_stream(transport_writing, &stream_writing)) {
|
||||
uint32_t max_outgoing =
|
||||
|
|
@ -267,6 +268,11 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx,
|
|||
stream_writing->id, &stream_writing->flow_controlled_buffer,
|
||||
send_bytes, is_last_frame, &stream_writing->stats,
|
||||
&transport_writing->outbuf);
|
||||
if (is_first_data_frame) {
|
||||
/* TODO(dgq): this is a hack. It'll be fix in a future refactoring */
|
||||
stream_writing->stats.data_bytes -= 5; /* discount grpc framing */
|
||||
is_first_data_frame = false;
|
||||
}
|
||||
GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", transport_writing,
|
||||
stream_writing, outgoing_window,
|
||||
send_bytes);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@
|
|||
#include <grpc/compression.h>
|
||||
#include <grpc/grpc.h>
|
||||
|
||||
// Channel args are intentionally immutable, to avoid the need for locking.
|
||||
|
||||
/** Copy the arguments in \a src into a new instance */
|
||||
grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src);
|
||||
|
||||
|
|
|
|||
|
|
@ -158,12 +158,13 @@ void grpc_channel_stack_destroy(grpc_exec_ctx *exec_ctx,
|
|||
}
|
||||
}
|
||||
|
||||
void grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
|
||||
grpc_channel_stack *channel_stack, int initial_refs,
|
||||
grpc_iomgr_cb_func destroy, void *destroy_arg,
|
||||
grpc_call_context_element *context,
|
||||
const void *transport_server_data,
|
||||
grpc_call_stack *call_stack) {
|
||||
grpc_error *grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
|
||||
grpc_channel_stack *channel_stack,
|
||||
int initial_refs, grpc_iomgr_cb_func destroy,
|
||||
void *destroy_arg,
|
||||
grpc_call_context_element *context,
|
||||
const void *transport_server_data,
|
||||
grpc_call_stack *call_stack) {
|
||||
grpc_channel_element *channel_elems = CHANNEL_ELEMS_FROM_STACK(channel_stack);
|
||||
grpc_call_element_args args;
|
||||
size_t count = channel_stack->count;
|
||||
|
|
@ -179,6 +180,7 @@ void grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
|
|||
ROUND_UP_TO_ALIGNMENT_SIZE(count * sizeof(grpc_call_element));
|
||||
|
||||
/* init per-filter data */
|
||||
grpc_error *first_error = GRPC_ERROR_NONE;
|
||||
for (i = 0; i < count; i++) {
|
||||
args.call_stack = call_stack;
|
||||
args.server_transport_data = transport_server_data;
|
||||
|
|
@ -186,10 +188,19 @@ void grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
|
|||
call_elems[i].filter = channel_elems[i].filter;
|
||||
call_elems[i].channel_data = channel_elems[i].channel_data;
|
||||
call_elems[i].call_data = user_data;
|
||||
call_elems[i].filter->init_call_elem(exec_ctx, &call_elems[i], &args);
|
||||
grpc_error *error =
|
||||
call_elems[i].filter->init_call_elem(exec_ctx, &call_elems[i], &args);
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
if (first_error == GRPC_ERROR_NONE) {
|
||||
first_error = error;
|
||||
} else {
|
||||
GRPC_ERROR_UNREF(error);
|
||||
}
|
||||
}
|
||||
user_data +=
|
||||
ROUND_UP_TO_ALIGNMENT_SIZE(call_elems[i].filter->sizeof_call_data);
|
||||
}
|
||||
return first_error;
|
||||
}
|
||||
|
||||
void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
|
||||
|
|
@ -218,7 +229,7 @@ void grpc_call_stack_ignore_set_pollset_or_pollset_set(
|
|||
grpc_polling_entity *pollent) {}
|
||||
|
||||
void grpc_call_stack_destroy(grpc_exec_ctx *exec_ctx, grpc_call_stack *stack,
|
||||
const grpc_call_stats *call_stats,
|
||||
const grpc_call_final_info *final_info,
|
||||
void *and_free_memory) {
|
||||
grpc_call_element *elems = CALL_ELEMS_FROM_STACK(stack);
|
||||
size_t count = stack->count;
|
||||
|
|
@ -226,7 +237,7 @@ void grpc_call_stack_destroy(grpc_exec_ctx *exec_ctx, grpc_call_stack *stack,
|
|||
|
||||
/* destroy per-filter data */
|
||||
for (i = 0; i < count; i++) {
|
||||
elems[i].filter->destroy_call_elem(exec_ctx, &elems[i], call_stats,
|
||||
elems[i].filter->destroy_call_elem(exec_ctx, &elems[i], final_info,
|
||||
i == count - 1 ? and_free_memory : NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,9 +75,14 @@ typedef struct {
|
|||
typedef struct {
|
||||
grpc_transport_stream_stats transport_stream_stats;
|
||||
gpr_timespec latency; /* From call creating to enqueing of received status */
|
||||
grpc_status_code final_status;
|
||||
} grpc_call_stats;
|
||||
|
||||
/** Information about the call upon completion. */
|
||||
typedef struct {
|
||||
grpc_call_stats stats;
|
||||
grpc_status_code final_status;
|
||||
} grpc_call_final_info;
|
||||
|
||||
/* Channel filters specify:
|
||||
1. the amount of memory needed in the channel & call (via the sizeof_XXX
|
||||
members)
|
||||
|
|
@ -110,8 +115,9 @@ typedef struct {
|
|||
on a client; if it is non-NULL, then it points to memory owned by the
|
||||
transport and is on the server. Most filters want to ignore this
|
||||
argument. */
|
||||
void (*init_call_elem)(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
grpc_call_element_args *args);
|
||||
grpc_error *(*init_call_elem)(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args);
|
||||
void (*set_pollset_or_pollset_set)(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_polling_entity *pollent);
|
||||
|
|
@ -119,16 +125,17 @@ typedef struct {
|
|||
The filter does not need to do any chaining.
|
||||
The bottom filter of a stack will be passed a non-NULL pointer to
|
||||
\a and_free_memory that should be passed to gpr_free when destruction
|
||||
is complete. */
|
||||
is complete. \a final_info contains data about the completed call, mainly
|
||||
for reporting purposes. */
|
||||
void (*destroy_call_elem)(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
const grpc_call_stats *stats,
|
||||
const grpc_call_final_info *final_info,
|
||||
void *and_free_memory);
|
||||
|
||||
/* sizeof(per channel data) */
|
||||
size_t sizeof_channel_data;
|
||||
/* Initialize per-channel data.
|
||||
elem is initialized at the start of the call, and elem->channel_data is
|
||||
what needs initializing.
|
||||
elem is initialized at the creating of the channel, and elem->channel_data
|
||||
is what needs initializing.
|
||||
is_first, is_last designate this elements position in the stack, and are
|
||||
useful for asserting correct configuration by upper layer code.
|
||||
The filter does not need to do any chaining */
|
||||
|
|
@ -209,12 +216,13 @@ void grpc_channel_stack_destroy(grpc_exec_ctx *exec_ctx,
|
|||
/* Initialize a call stack given a channel stack. transport_server_data is
|
||||
expected to be NULL on a client, or an opaque transport owned pointer on the
|
||||
server. */
|
||||
void grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
|
||||
grpc_channel_stack *channel_stack, int initial_refs,
|
||||
grpc_iomgr_cb_func destroy, void *destroy_arg,
|
||||
grpc_call_context_element *context,
|
||||
const void *transport_server_data,
|
||||
grpc_call_stack *call_stack);
|
||||
grpc_error *grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
|
||||
grpc_channel_stack *channel_stack,
|
||||
int initial_refs, grpc_iomgr_cb_func destroy,
|
||||
void *destroy_arg,
|
||||
grpc_call_context_element *context,
|
||||
const void *transport_server_data,
|
||||
grpc_call_stack *call_stack);
|
||||
/* Set a pollset or a pollset_set for a call stack: must occur before the first
|
||||
* op is started */
|
||||
void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
|
||||
|
|
@ -243,7 +251,7 @@ void grpc_call_stack_set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
|
|||
|
||||
/* Destroy a call stack */
|
||||
void grpc_call_stack_destroy(grpc_exec_ctx *exec_ctx, grpc_call_stack *stack,
|
||||
const grpc_call_stats *call_stats,
|
||||
const grpc_call_final_info *final_info,
|
||||
void *and_free_memory);
|
||||
|
||||
/* Ignore set pollset{_set} - used by filters if they don't care about pollsets
|
||||
|
|
|
|||
|
|
@ -256,8 +256,9 @@ static void compress_start_transport_stream_op(grpc_exec_ctx *exec_ctx,
|
|||
}
|
||||
|
||||
/* Constructor for call_data */
|
||||
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
/* grab pointers to our data from the call element */
|
||||
call_data *calld = elem->call_data;
|
||||
|
||||
|
|
@ -266,11 +267,14 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
|||
calld->has_compression_algorithm = 0;
|
||||
grpc_closure_init(&calld->got_slice, got_slice, elem);
|
||||
grpc_closure_init(&calld->send_done, send_done, elem);
|
||||
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
/* Destructor for call_data */
|
||||
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
const grpc_call_stats *stats, void *ignored) {
|
||||
const grpc_call_final_info *final_info,
|
||||
void *ignored) {
|
||||
/* grab pointers to our data from the call element */
|
||||
call_data *calld = elem->call_data;
|
||||
gpr_slice_buffer_destroy(&calld->slices);
|
||||
|
|
|
|||
|
|
@ -81,16 +81,16 @@ static void con_start_transport_op(grpc_exec_ctx *exec_ctx,
|
|||
}
|
||||
|
||||
/* Constructor for call_data */
|
||||
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
call_data *calld = elem->call_data;
|
||||
channel_data *chand = elem->channel_data;
|
||||
int r;
|
||||
|
||||
r = grpc_transport_init_stream(
|
||||
int r = grpc_transport_init_stream(
|
||||
exec_ctx, chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
|
||||
&args->call_stack->refcount, args->server_transport_data);
|
||||
GPR_ASSERT(r == 0);
|
||||
return r == 0 ? GRPC_ERROR_NONE
|
||||
: GRPC_ERROR_CREATE("transport stream initialization failed");
|
||||
}
|
||||
|
||||
static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
|
||||
|
|
@ -104,7 +104,7 @@ static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
|
|||
|
||||
/* Destructor for call_data */
|
||||
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
const grpc_call_stats *stats,
|
||||
const grpc_call_final_info *final_info,
|
||||
void *and_free_memory) {
|
||||
call_data *calld = elem->call_data;
|
||||
channel_data *chand = elem->channel_data;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,197 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2016, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <grpc/impl/codegen/alloc.h>
|
||||
#include <grpc/impl/codegen/log.h>
|
||||
|
||||
#include "src/core/lib/channel/channel_args.h"
|
||||
#include "src/core/lib/channel/handshaker.h"
|
||||
|
||||
//
|
||||
// grpc_handshaker
|
||||
//
|
||||
|
||||
void grpc_handshaker_init(const struct grpc_handshaker_vtable* vtable,
|
||||
grpc_handshaker* handshaker) {
|
||||
handshaker->vtable = vtable;
|
||||
}
|
||||
|
||||
void grpc_handshaker_destroy(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshaker* handshaker) {
|
||||
handshaker->vtable->destroy(exec_ctx, handshaker);
|
||||
}
|
||||
|
||||
void grpc_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshaker* handshaker) {
|
||||
handshaker->vtable->shutdown(exec_ctx, handshaker);
|
||||
}
|
||||
|
||||
void grpc_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshaker* handshaker,
|
||||
grpc_endpoint* endpoint,
|
||||
grpc_channel_args* args,
|
||||
gpr_timespec deadline,
|
||||
grpc_tcp_server_acceptor* acceptor,
|
||||
grpc_handshaker_done_cb cb, void* user_data) {
|
||||
handshaker->vtable->do_handshake(exec_ctx, handshaker, endpoint, args,
|
||||
deadline, acceptor, cb, user_data);
|
||||
}
|
||||
|
||||
//
|
||||
// grpc_handshake_manager
|
||||
//
|
||||
|
||||
// State used while chaining handshakers.
|
||||
struct grpc_handshaker_state {
|
||||
// The index of the handshaker to invoke next.
|
||||
size_t index;
|
||||
// The deadline for all handshakers.
|
||||
gpr_timespec deadline;
|
||||
// The acceptor to call the handshakers with.
|
||||
grpc_tcp_server_acceptor* acceptor;
|
||||
// The final callback and user_data to invoke after the last handshaker.
|
||||
grpc_handshaker_done_cb final_cb;
|
||||
void* final_user_data;
|
||||
};
|
||||
|
||||
struct grpc_handshake_manager {
|
||||
// An array of handshakers added via grpc_handshake_manager_add().
|
||||
size_t count;
|
||||
grpc_handshaker** handshakers;
|
||||
// State used while chaining handshakers.
|
||||
struct grpc_handshaker_state* state;
|
||||
};
|
||||
|
||||
grpc_handshake_manager* grpc_handshake_manager_create() {
|
||||
grpc_handshake_manager* mgr = gpr_malloc(sizeof(grpc_handshake_manager));
|
||||
memset(mgr, 0, sizeof(*mgr));
|
||||
return mgr;
|
||||
}
|
||||
|
||||
static bool is_power_of_2(size_t n) { return (n & (n - 1)) == 0; }
|
||||
|
||||
void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
|
||||
grpc_handshaker* handshaker) {
|
||||
// To avoid allocating memory for each handshaker we add, we double
|
||||
// the number of elements every time we need more.
|
||||
size_t realloc_count = 0;
|
||||
if (mgr->count == 0) {
|
||||
realloc_count = 2;
|
||||
} else if (mgr->count >= 2 && is_power_of_2(mgr->count)) {
|
||||
realloc_count = mgr->count * 2;
|
||||
}
|
||||
if (realloc_count > 0) {
|
||||
mgr->handshakers =
|
||||
gpr_realloc(mgr->handshakers, realloc_count * sizeof(grpc_handshaker*));
|
||||
}
|
||||
mgr->handshakers[mgr->count++] = handshaker;
|
||||
}
|
||||
|
||||
void grpc_handshake_manager_destroy(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshake_manager* mgr) {
|
||||
for (size_t i = 0; i < mgr->count; ++i) {
|
||||
grpc_handshaker_destroy(exec_ctx, mgr->handshakers[i]);
|
||||
}
|
||||
gpr_free(mgr->handshakers);
|
||||
gpr_free(mgr);
|
||||
}
|
||||
|
||||
void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshake_manager* mgr) {
|
||||
for (size_t i = 0; i < mgr->count; ++i) {
|
||||
grpc_handshaker_shutdown(exec_ctx, mgr->handshakers[i]);
|
||||
}
|
||||
if (mgr->state != NULL) {
|
||||
gpr_free(mgr->state);
|
||||
mgr->state = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// A function used as the handshaker-done callback when chaining
|
||||
// handshakers together.
|
||||
static void call_next_handshaker(grpc_exec_ctx* exec_ctx,
|
||||
grpc_endpoint* endpoint,
|
||||
grpc_channel_args* args, void* user_data,
|
||||
grpc_error* error) {
|
||||
grpc_handshake_manager* mgr = user_data;
|
||||
GPR_ASSERT(mgr->state != NULL);
|
||||
GPR_ASSERT(mgr->state->index < mgr->count);
|
||||
// If we got an error, skip all remaining handshakers and invoke the
|
||||
// caller-supplied callback immediately.
|
||||
if (error != GRPC_ERROR_NONE) {
|
||||
mgr->state->final_cb(exec_ctx, endpoint, args, mgr->state->final_user_data,
|
||||
error);
|
||||
return;
|
||||
}
|
||||
grpc_handshaker_done_cb cb = call_next_handshaker;
|
||||
// If this is the last handshaker, use the caller-supplied callback
|
||||
// and user_data instead of chaining back to this function again.
|
||||
if (mgr->state->index == mgr->count - 1) {
|
||||
cb = mgr->state->final_cb;
|
||||
user_data = mgr->state->final_user_data;
|
||||
}
|
||||
// Invoke handshaker.
|
||||
grpc_handshaker_do_handshake(exec_ctx, mgr->handshakers[mgr->state->index],
|
||||
endpoint, args, mgr->state->deadline,
|
||||
mgr->state->acceptor, cb, user_data);
|
||||
++mgr->state->index;
|
||||
// If this is the last handshaker, clean up state.
|
||||
if (mgr->state->index == mgr->count) {
|
||||
gpr_free(mgr->state);
|
||||
mgr->state = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void grpc_handshake_manager_do_handshake(
|
||||
grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
|
||||
grpc_endpoint* endpoint, const grpc_channel_args* args,
|
||||
gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor,
|
||||
grpc_handshaker_done_cb cb, void* user_data) {
|
||||
grpc_channel_args* args_copy = grpc_channel_args_copy(args);
|
||||
if (mgr->count == 0) {
|
||||
// No handshakers registered, so we just immediately call the done
|
||||
// callback with the passed-in endpoint.
|
||||
cb(exec_ctx, endpoint, args_copy, user_data, GRPC_ERROR_NONE);
|
||||
} else {
|
||||
GPR_ASSERT(mgr->state == NULL);
|
||||
mgr->state = gpr_malloc(sizeof(struct grpc_handshaker_state));
|
||||
memset(mgr->state, 0, sizeof(*mgr->state));
|
||||
mgr->state->deadline = deadline;
|
||||
mgr->state->acceptor = acceptor;
|
||||
mgr->state->final_cb = cb;
|
||||
mgr->state->final_user_data = user_data;
|
||||
call_next_handshaker(exec_ctx, endpoint, args_copy, mgr, GRPC_ERROR_NONE);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
*
|
||||
* Copyright 2016, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H
|
||||
#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H
|
||||
|
||||
#include <grpc/impl/codegen/grpc_types.h>
|
||||
#include <grpc/impl/codegen/time.h>
|
||||
|
||||
#include "src/core/lib/iomgr/closure.h"
|
||||
#include "src/core/lib/iomgr/endpoint.h"
|
||||
#include "src/core/lib/iomgr/exec_ctx.h"
|
||||
#include "src/core/lib/iomgr/tcp_server.h"
|
||||
|
||||
/// Handshakers are used to perform initial handshakes on a connection
|
||||
/// before the client sends the initial request. Some examples of what
|
||||
/// a handshaker can be used for includes support for HTTP CONNECT on
|
||||
/// the client side and various types of security initialization.
|
||||
///
|
||||
/// In general, handshakers should be used via a handshake manager.
|
||||
|
||||
///
|
||||
/// grpc_handshaker
|
||||
///
|
||||
|
||||
typedef struct grpc_handshaker grpc_handshaker;
|
||||
|
||||
/// Callback type invoked when a handshaker is done.
|
||||
/// Takes ownership of \a args.
|
||||
typedef void (*grpc_handshaker_done_cb)(grpc_exec_ctx* exec_ctx,
|
||||
grpc_endpoint* endpoint,
|
||||
grpc_channel_args* args,
|
||||
void* user_data, grpc_error* error);
|
||||
|
||||
struct grpc_handshaker_vtable {
|
||||
/// Destroys the handshaker.
|
||||
void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker);
|
||||
|
||||
/// Shuts down the handshaker (e.g., to clean up when the operation is
|
||||
/// aborted in the middle).
|
||||
void (*shutdown)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker);
|
||||
|
||||
/// Performs handshaking. When finished, calls \a cb with \a user_data.
|
||||
/// Takes ownership of \a args.
|
||||
/// \a acceptor will be NULL for client-side handshakers.
|
||||
void (*do_handshake)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker,
|
||||
grpc_endpoint* endpoint, grpc_channel_args* args,
|
||||
gpr_timespec deadline,
|
||||
grpc_tcp_server_acceptor* acceptor,
|
||||
grpc_handshaker_done_cb cb, void* user_data);
|
||||
};
|
||||
|
||||
/// Base struct. To subclass, make this the first member of the
|
||||
/// implementation struct.
|
||||
struct grpc_handshaker {
|
||||
const struct grpc_handshaker_vtable* vtable;
|
||||
};
|
||||
|
||||
/// Called by concrete implementations to initialize the base struct.
|
||||
void grpc_handshaker_init(const struct grpc_handshaker_vtable* vtable,
|
||||
grpc_handshaker* handshaker);
|
||||
|
||||
/// Convenient wrappers for invoking methods via the vtable.
|
||||
/// These probably do not need to be called from anywhere but
|
||||
/// grpc_handshake_manager.
|
||||
void grpc_handshaker_destroy(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshaker* handshaker);
|
||||
void grpc_handshaker_shutdown(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshaker* handshaker);
|
||||
void grpc_handshaker_do_handshake(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshaker* handshaker,
|
||||
grpc_endpoint* endpoint,
|
||||
grpc_channel_args* args,
|
||||
gpr_timespec deadline,
|
||||
grpc_tcp_server_acceptor* acceptor,
|
||||
grpc_handshaker_done_cb cb, void* user_data);
|
||||
|
||||
///
|
||||
/// grpc_handshake_manager
|
||||
///
|
||||
|
||||
typedef struct grpc_handshake_manager grpc_handshake_manager;
|
||||
|
||||
/// Creates a new handshake manager. Caller takes ownership.
|
||||
grpc_handshake_manager* grpc_handshake_manager_create();
|
||||
|
||||
/// Adds a handshaker to the handshake manager.
|
||||
/// Takes ownership of \a handshaker.
|
||||
void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
|
||||
grpc_handshaker* handshaker);
|
||||
|
||||
/// Destroys the handshake manager.
|
||||
void grpc_handshake_manager_destroy(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshake_manager* mgr);
|
||||
|
||||
/// Shuts down the handshake manager (e.g., to clean up when the operation is
|
||||
/// aborted in the middle).
|
||||
/// The caller must still call grpc_handshake_manager_destroy() after
|
||||
/// calling this function.
|
||||
void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx,
|
||||
grpc_handshake_manager* mgr);
|
||||
|
||||
/// Invokes handshakers in the order they were added.
|
||||
/// Does NOT take ownership of \a args. Instead, makes a copy before
|
||||
/// invoking the first handshaker.
|
||||
/// \a acceptor will be NULL for client-side handshakers.
|
||||
/// Invokes \a cb with \a user_data after either a handshaker fails or
|
||||
/// all handshakers have completed successfully.
|
||||
void grpc_handshake_manager_do_handshake(
|
||||
grpc_exec_ctx* exec_ctx, grpc_handshake_manager* mgr,
|
||||
grpc_endpoint* endpoint, const grpc_channel_args* args,
|
||||
gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor,
|
||||
grpc_handshaker_done_cb cb, void* user_data);
|
||||
|
||||
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */
|
||||
|
|
@ -175,16 +175,19 @@ static void hc_start_transport_op(grpc_exec_ctx *exec_ctx,
|
|||
}
|
||||
|
||||
/* Constructor for call_data */
|
||||
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
call_data *calld = elem->call_data;
|
||||
calld->on_done_recv = NULL;
|
||||
grpc_closure_init(&calld->hc_on_recv, hc_on_recv, elem);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
/* Destructor for call_data */
|
||||
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
const grpc_call_stats *stats, void *ignored) {}
|
||||
const grpc_call_final_info *final_info,
|
||||
void *ignored) {}
|
||||
|
||||
static grpc_mdelem *scheme_from_args(const grpc_channel_args *args) {
|
||||
unsigned i;
|
||||
|
|
|
|||
|
|
@ -224,18 +224,21 @@ static void hs_start_transport_op(grpc_exec_ctx *exec_ctx,
|
|||
}
|
||||
|
||||
/* Constructor for call_data */
|
||||
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
|
||||
grpc_call_element *elem,
|
||||
grpc_call_element_args *args) {
|
||||
/* grab pointers to our data from the call element */
|
||||
call_data *calld = elem->call_data;
|
||||
/* initialize members */
|
||||
memset(calld, 0, sizeof(*calld));
|
||||
grpc_closure_init(&calld->hs_on_recv, hs_on_recv, elem);
|
||||
return GRPC_ERROR_NONE;
|
||||
}
|
||||
|
||||
/* Destructor for call_data */
|
||||
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
|
||||
const grpc_call_stats *stats, void *ignored) {}
|
||||
const grpc_call_final_info *final_info,
|
||||
void *ignored) {}
|
||||
|
||||
/* Constructor for channel_data */
|
||||
static void init_channel_elem(grpc_exec_ctx *exec_ctx,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue