grpc 1.25.0 → 1.26.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +782 -291
- data/include/grpc/impl/codegen/grpc_types.h +4 -0
- data/include/grpc/impl/codegen/port_platform.h +7 -0
- data/include/grpc/support/alloc.h +0 -16
- data/src/core/ext/filters/client_channel/backend_metric.cc +2 -2
- data/src/core/ext/filters/client_channel/backup_poller.cc +1 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +95 -88
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +7 -7
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +4 -2
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -3
- data/src/core/ext/filters/client_channel/connector.h +40 -45
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +10 -10
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -13
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +66 -37
- data/src/core/ext/filters/client_channel/http_proxy.cc +107 -116
- data/src/core/ext/filters/client_channel/http_proxy.h +5 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy.h +9 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +10 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +18 -19
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +4 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +6 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +368 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +157 -77
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +5 -5
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +8 -8
- data/src/core/ext/filters/client_channel/proxy_mapper.h +14 -34
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +46 -79
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +23 -17
- data/src/core/ext/filters/client_channel/resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver.h +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +13 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +3 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +9 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +17 -16
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +9 -9
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -3
- data/src/core/ext/filters/client_channel/resolver_registry.cc +14 -12
- data/src/core/ext/filters/client_channel/resolver_registry.h +6 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +6 -6
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +6 -6
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +5 -5
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +3 -3
- data/src/core/ext/filters/client_channel/service_config.cc +15 -14
- data/src/core/ext/filters/client_channel/service_config.h +14 -19
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -36
- data/src/core/ext/filters/client_channel/subchannel.h +11 -12
- data/src/core/ext/filters/client_channel/subchannel_interface.h +1 -1
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +19 -9
- data/src/core/ext/filters/client_channel/xds/xds_api.h +19 -9
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +3 -3
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +6 -5
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +58 -31
- data/src/core/ext/filters/client_channel/xds/xds_client.h +20 -15
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -3
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -15
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +10 -10
- data/src/core/ext/filters/deadline/deadline_filter.cc +15 -13
- data/src/core/ext/filters/http/client/http_client_filter.cc +12 -12
- data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +13 -7
- data/src/core/ext/filters/http/server/http_server_filter.cc +14 -13
- data/src/core/ext/filters/max_age/max_age_filter.cc +16 -14
- data/src/core/ext/filters/message_size/message_size_filter.cc +10 -8
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +9 -8
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +141 -174
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +31 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +7 -6
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +14 -12
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +8 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +46 -38
- data/src/core/ext/transport/chttp2/transport/context_list.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +0 -5
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +6 -7
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +11 -8
- data/src/core/ext/transport/chttp2/transport/internal.h +3 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -2
- data/src/core/ext/transport/inproc/inproc_transport.cc +65 -41
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +141 -70
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +352 -118
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +8 -4
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +65 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +16 -2
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +36 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +12 -5
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +13 -12
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +28 -24
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +5 -4
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +13 -0
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +23 -23
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +48 -44
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/http.upb.c +16 -0
- data/src/core/ext/upb-generated/envoy/type/http.upb.h +36 -0
- data/src/core/ext/upb-generated/envoy/type/percent.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/range.upb.c +0 -1
- data/src/core/lib/avl/avl.cc +1 -1
- data/src/core/lib/channel/channel_stack.cc +1 -1
- data/src/core/lib/channel/channel_stack.h +16 -4
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channelz.cc +46 -46
- data/src/core/lib/channel/channelz.h +37 -35
- data/src/core/lib/channel/channelz_registry.cc +2 -2
- data/src/core/lib/channel/channelz_registry.h +1 -1
- data/src/core/lib/channel/connected_channel.cc +3 -2
- data/src/core/lib/channel/handshaker.cc +1 -1
- data/src/core/lib/channel/handshaker_registry.cc +5 -5
- data/src/core/lib/channel/handshaker_registry.h +3 -3
- data/src/core/lib/compression/message_compress.cc +3 -2
- data/src/core/lib/compression/stream_compression_identity.cc +5 -7
- data/src/core/lib/gpr/alloc.cc +4 -29
- data/src/core/lib/gpr/cpu_linux.cc +1 -1
- data/src/core/lib/gprpp/fork.cc +4 -4
- data/src/core/lib/gprpp/global_config_env.cc +7 -7
- data/src/core/lib/gprpp/global_config_env.h +2 -2
- data/src/core/lib/gprpp/host_port.cc +8 -8
- data/src/core/lib/gprpp/host_port.h +3 -3
- data/src/core/lib/gprpp/inlined_vector.h +13 -0
- data/src/core/lib/gprpp/map.h +2 -9
- data/src/core/lib/gprpp/memory.h +12 -98
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/ref_counted.h +3 -3
- data/src/core/lib/gprpp/ref_counted_ptr.h +1 -1
- data/src/core/lib/gprpp/string_view.h +45 -23
- data/src/core/lib/gprpp/thd.h +1 -1
- data/src/core/lib/gprpp/thd_posix.cc +6 -5
- data/src/core/lib/gprpp/thd_windows.cc +3 -3
- data/src/core/lib/http/httpcli.cc +1 -1
- data/src/core/lib/http/httpcli_security_connector.cc +3 -3
- data/src/core/lib/iomgr/buffer_list.cc +10 -5
- data/src/core/lib/iomgr/call_combiner.cc +7 -6
- data/src/core/lib/iomgr/call_combiner.h +4 -3
- data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
- data/src/core/lib/iomgr/closure.h +33 -135
- data/src/core/lib/iomgr/combiner.cc +10 -17
- data/src/core/lib/iomgr/combiner.h +0 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +2 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -2
- data/src/core/lib/iomgr/ev_epollex_linux.cc +23 -13
- data/src/core/lib/iomgr/ev_poll_posix.cc +30 -17
- data/src/core/lib/iomgr/exec_ctx.cc +52 -5
- data/src/core/lib/iomgr/exec_ctx.h +6 -2
- data/src/core/lib/iomgr/executor.cc +16 -37
- data/src/core/lib/iomgr/executor.h +4 -7
- data/src/core/lib/iomgr/executor/threadpool.cc +4 -4
- data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
- data/src/core/lib/iomgr/lockfree_event.cc +9 -8
- data/src/core/lib/iomgr/logical_thread.cc +103 -0
- data/src/core/lib/iomgr/logical_thread.h +52 -0
- data/src/core/lib/iomgr/pollset_custom.cc +5 -5
- data/src/core/lib/iomgr/pollset_set_custom.cc +9 -9
- data/src/core/lib/iomgr/pollset_windows.cc +16 -2
- data/src/core/lib/iomgr/port.h +3 -0
- data/src/core/lib/iomgr/resolve_address_custom.cc +4 -4
- data/src/core/lib/iomgr/resolve_address_posix.cc +8 -9
- data/src/core/lib/iomgr/resolve_address_windows.cc +4 -6
- data/src/core/lib/iomgr/resource_quota.cc +26 -21
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +11 -0
- data/src/core/lib/iomgr/socket_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +5 -4
- data/src/core/lib/iomgr/tcp_client_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_custom.cc +10 -9
- data/src/core/lib/iomgr/tcp_posix.cc +19 -15
- data/src/core/lib/iomgr/tcp_server_custom.cc +3 -2
- data/src/core/lib/iomgr/tcp_server_posix.cc +5 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +5 -3
- data/src/core/lib/iomgr/tcp_windows.cc +16 -13
- data/src/core/lib/iomgr/timer_custom.cc +4 -3
- data/src/core/lib/iomgr/timer_generic.cc +11 -9
- data/src/core/lib/iomgr/udp_server.cc +16 -13
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +8 -5
- data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +45 -57
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -6
- data/src/core/lib/security/credentials/credentials.cc +8 -8
- data/src/core/lib/security/credentials/credentials.h +5 -5
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -5
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -1
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +4 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -4
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -2
- data/src/core/lib/security/credentials/local/local_credentials.cc +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +13 -11
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -5
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +4 -4
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +5 -5
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +2 -2
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +28 -22
- data/src/core/lib/security/security_connector/alts/alts_security_connector.h +5 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +10 -10
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -1
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +8 -8
- data/src/core/lib/security/security_connector/security_connector.h +1 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +9 -9
- data/src/core/lib/security/security_connector/ssl_utils.cc +5 -4
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -15
- data/src/core/lib/security/transport/client_auth_filter.cc +4 -3
- data/src/core/lib/security/transport/secure_endpoint.cc +9 -8
- data/src/core/lib/security/transport/security_handshaker.cc +67 -23
- data/src/core/lib/security/transport/server_auth_filter.cc +6 -5
- data/src/core/lib/security/transport/target_authority_table.h +1 -1
- data/src/core/lib/slice/b64.cc +3 -4
- data/src/core/lib/slice/b64.h +1 -2
- data/src/core/lib/slice/slice.cc +8 -13
- data/src/core/lib/surface/call.cc +19 -19
- data/src/core/lib/surface/call.h +6 -7
- data/src/core/lib/surface/call_log_batch.cc +1 -2
- data/src/core/lib/surface/channel.cc +17 -18
- data/src/core/lib/surface/channel.h +4 -19
- data/src/core/lib/surface/channel_ping.cc +1 -1
- data/src/core/lib/surface/completion_queue.cc +21 -22
- data/src/core/lib/surface/completion_queue_factory.cc +1 -1
- data/src/core/lib/surface/init.cc +1 -1
- data/src/core/lib/surface/init_secure.cc +2 -2
- data/src/core/lib/surface/lame_client.cc +10 -12
- data/src/core/lib/surface/server.cc +24 -18
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +2 -2
- data/src/core/lib/transport/byte_stream.h +2 -1
- data/src/core/lib/transport/connectivity_state.cc +4 -4
- data/src/core/lib/transport/connectivity_state.h +2 -2
- data/src/core/lib/transport/metadata.cc +8 -10
- data/src/core/lib/transport/metadata.h +5 -8
- data/src/core/lib/transport/metadata_batch.cc +6 -0
- data/src/core/lib/transport/static_metadata.cc +2 -4
- data/src/core/lib/transport/status_metadata.cc +7 -0
- data/src/core/lib/transport/status_metadata.h +18 -0
- data/src/core/lib/transport/transport.cc +9 -7
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +292 -43
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +197 -46
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +4 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +5 -0
- data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -4
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +0 -6
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/upb/upb/decode.c +1 -0
- metadata +34 -32
- data/src/core/ext/filters/client_channel/connector.cc +0 -41
- data/src/core/ext/filters/client_channel/proxy_mapper.cc +0 -48
- data/src/core/lib/gprpp/set.h +0 -33
@@ -47,7 +47,8 @@ class ResolverRegistry {
|
|
47
47
|
/// Registers a resolver factory. The factory will be used to create a
|
48
48
|
/// resolver for any URI whose scheme matches that of the factory.
|
49
49
|
/// Calls InitRegistry() if it has not already been called.
|
50
|
-
static void RegisterResolverFactory(
|
50
|
+
static void RegisterResolverFactory(
|
51
|
+
std::unique_ptr<ResolverFactory> factory);
|
51
52
|
};
|
52
53
|
|
53
54
|
/// Checks whether the user input \a target is valid to create a resolver.
|
@@ -69,13 +70,14 @@ class ResolverRegistry {
|
|
69
70
|
static OrphanablePtr<Resolver> CreateResolver(
|
70
71
|
const char* target, const grpc_channel_args* args,
|
71
72
|
grpc_pollset_set* pollset_set, Combiner* combiner,
|
72
|
-
|
73
|
+
std::unique_ptr<Resolver::ResultHandler> result_handler);
|
73
74
|
|
74
75
|
/// Returns the default authority to pass from a client for \a target.
|
75
|
-
static UniquePtr<char> GetDefaultAuthority(const char* target);
|
76
|
+
static grpc_core::UniquePtr<char> GetDefaultAuthority(const char* target);
|
76
77
|
|
77
78
|
/// Returns \a target with the default prefix prepended, if needed.
|
78
|
-
static UniquePtr<char> AddDefaultPrefixIfNeeded(
|
79
|
+
static grpc_core::UniquePtr<char> AddDefaultPrefixIfNeeded(
|
80
|
+
const char* target);
|
79
81
|
|
80
82
|
/// Returns the resolver factory for \a scheme.
|
81
83
|
/// Caller does NOT own the return value.
|
@@ -66,7 +66,7 @@ bool ParseDuration(grpc_json* field, grpc_millis* duration) {
|
|
66
66
|
if (field->type != GRPC_JSON_STRING) return false;
|
67
67
|
size_t len = strlen(field->value);
|
68
68
|
if (field->value[len - 1] != 's') return false;
|
69
|
-
UniquePtr<char> buf(gpr_strdup(field->value));
|
69
|
+
grpc_core::UniquePtr<char> buf(gpr_strdup(field->value));
|
70
70
|
*(buf.get() + len - 1) = '\0'; // Remove trailing 's'.
|
71
71
|
char* decimal_point = strchr(buf.get(), '.');
|
72
72
|
int nanos = 0;
|
@@ -91,7 +91,7 @@ bool ParseDuration(grpc_json* field, grpc_millis* duration) {
|
|
91
91
|
return true;
|
92
92
|
}
|
93
93
|
|
94
|
-
|
94
|
+
std::unique_ptr<ClientChannelMethodParsedConfig::RetryPolicy> ParseRetryPolicy(
|
95
95
|
grpc_json* field, grpc_error** error) {
|
96
96
|
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
|
97
97
|
auto retry_policy =
|
@@ -262,13 +262,13 @@ const char* ParseHealthCheckConfig(const grpc_json* field, grpc_error** error) {
|
|
262
262
|
|
263
263
|
} // namespace
|
264
264
|
|
265
|
-
|
265
|
+
std::unique_ptr<ServiceConfig::ParsedConfig>
|
266
266
|
ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
|
267
267
|
grpc_error** error) {
|
268
268
|
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
|
269
269
|
InlinedVector<grpc_error*, 4> error_list;
|
270
270
|
RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config;
|
271
|
-
UniquePtr<char> lb_policy_name;
|
271
|
+
grpc_core::UniquePtr<char> lb_policy_name;
|
272
272
|
Optional<ClientChannelGlobalParsedConfig::RetryThrottling> retry_throttling;
|
273
273
|
const char* health_check_service_name = nullptr;
|
274
274
|
for (grpc_json* field = json->child; field != nullptr; field = field->next) {
|
@@ -445,14 +445,14 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
|
|
445
445
|
return nullptr;
|
446
446
|
}
|
447
447
|
|
448
|
-
|
448
|
+
std::unique_ptr<ServiceConfig::ParsedConfig>
|
449
449
|
ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json,
|
450
450
|
grpc_error** error) {
|
451
451
|
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
|
452
452
|
InlinedVector<grpc_error*, 4> error_list;
|
453
453
|
Optional<bool> wait_for_ready;
|
454
454
|
grpc_millis timeout = 0;
|
455
|
-
|
455
|
+
std::unique_ptr<ClientChannelMethodParsedConfig::RetryPolicy> retry_policy;
|
456
456
|
for (grpc_json* field = json->child; field != nullptr; field = field->next) {
|
457
457
|
if (field->key == nullptr) continue;
|
458
458
|
if (strcmp(field->key, "waitForReady") == 0) {
|
@@ -46,7 +46,7 @@ class ClientChannelGlobalParsedConfig : public ServiceConfig::ParsedConfig {
|
|
46
46
|
|
47
47
|
ClientChannelGlobalParsedConfig(
|
48
48
|
RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config,
|
49
|
-
UniquePtr<char> parsed_deprecated_lb_policy,
|
49
|
+
grpc_core::UniquePtr<char> parsed_deprecated_lb_policy,
|
50
50
|
const Optional<RetryThrottling>& retry_throttling,
|
51
51
|
const char* health_check_service_name)
|
52
52
|
: parsed_lb_config_(std::move(parsed_lb_config)),
|
@@ -72,7 +72,7 @@ class ClientChannelGlobalParsedConfig : public ServiceConfig::ParsedConfig {
|
|
72
72
|
|
73
73
|
private:
|
74
74
|
RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config_;
|
75
|
-
UniquePtr<char> parsed_deprecated_lb_policy_;
|
75
|
+
grpc_core::UniquePtr<char> parsed_deprecated_lb_policy_;
|
76
76
|
Optional<RetryThrottling> retry_throttling_;
|
77
77
|
const char* health_check_service_name_;
|
78
78
|
};
|
@@ -89,7 +89,7 @@ class ClientChannelMethodParsedConfig : public ServiceConfig::ParsedConfig {
|
|
89
89
|
|
90
90
|
ClientChannelMethodParsedConfig(grpc_millis timeout,
|
91
91
|
const Optional<bool>& wait_for_ready,
|
92
|
-
|
92
|
+
std::unique_ptr<RetryPolicy> retry_policy)
|
93
93
|
: timeout_(timeout),
|
94
94
|
wait_for_ready_(wait_for_ready),
|
95
95
|
retry_policy_(std::move(retry_policy)) {}
|
@@ -103,15 +103,15 @@ class ClientChannelMethodParsedConfig : public ServiceConfig::ParsedConfig {
|
|
103
103
|
private:
|
104
104
|
grpc_millis timeout_ = 0;
|
105
105
|
Optional<bool> wait_for_ready_;
|
106
|
-
|
106
|
+
std::unique_ptr<RetryPolicy> retry_policy_;
|
107
107
|
};
|
108
108
|
|
109
109
|
class ClientChannelServiceConfigParser : public ServiceConfig::Parser {
|
110
110
|
public:
|
111
|
-
|
111
|
+
std::unique_ptr<ServiceConfig::ParsedConfig> ParseGlobalParams(
|
112
112
|
const grpc_json* json, grpc_error** error) override;
|
113
113
|
|
114
|
-
|
114
|
+
std::unique_ptr<ServiceConfig::ParsedConfig> ParsePerMethodParams(
|
115
115
|
const grpc_json* json, grpc_error** error) override;
|
116
116
|
|
117
117
|
static size_t ParserIndex();
|
@@ -114,7 +114,7 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
|
|
114
114
|
}
|
115
115
|
|
116
116
|
void UpdateState(grpc_connectivity_state state,
|
117
|
-
|
117
|
+
std::unique_ptr<SubchannelPicker> picker) override {
|
118
118
|
if (parent_->resolver_ == nullptr) return; // Shutting down.
|
119
119
|
// If this request is from the pending child policy, ignore it until
|
120
120
|
// it reports READY, at which point we swap it into place.
|
@@ -177,7 +177,7 @@ class ResolvingLoadBalancingPolicy::ResolvingControlHelper
|
|
177
177
|
//
|
178
178
|
|
179
179
|
ResolvingLoadBalancingPolicy::ResolvingLoadBalancingPolicy(
|
180
|
-
Args args, TraceFlag* tracer, UniquePtr<char> target_uri,
|
180
|
+
Args args, TraceFlag* tracer, grpc_core::UniquePtr<char> target_uri,
|
181
181
|
ProcessResolverResultCallback process_resolver_result,
|
182
182
|
void* process_resolver_result_user_data)
|
183
183
|
: LoadBalancingPolicy(std::move(args)),
|
@@ -371,11 +371,11 @@ OrphanablePtr<LoadBalancingPolicy>
|
|
371
371
|
ResolvingLoadBalancingPolicy::CreateLbPolicyLocked(
|
372
372
|
const char* lb_policy_name, const grpc_channel_args& args,
|
373
373
|
TraceStringVector* trace_strings) {
|
374
|
-
ResolvingControlHelper* helper =
|
374
|
+
ResolvingControlHelper* helper = new ResolvingControlHelper(Ref());
|
375
375
|
LoadBalancingPolicy::Args lb_policy_args;
|
376
376
|
lb_policy_args.combiner = combiner();
|
377
377
|
lb_policy_args.channel_control_helper =
|
378
|
-
|
378
|
+
std::unique_ptr<ChannelControlHelper>(helper);
|
379
379
|
lb_policy_args.args = &args;
|
380
380
|
OrphanablePtr<LoadBalancingPolicy> lb_policy =
|
381
381
|
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
|
@@ -425,7 +425,7 @@ void ResolvingLoadBalancingPolicy::ConcatenateAndAddChannelTraceLocked(
|
|
425
425
|
gpr_strvec_add(&v, (*trace_strings)[i]);
|
426
426
|
}
|
427
427
|
size_t len = 0;
|
428
|
-
UniquePtr<char> message(gpr_strvec_flatten(&v, &len));
|
428
|
+
grpc_core::UniquePtr<char> message(gpr_strvec_flatten(&v, &len));
|
429
429
|
channel_control_helper()->AddTraceEvent(ChannelControlHelper::TRACE_INFO,
|
430
430
|
StringView(message.get()));
|
431
431
|
gpr_strvec_destroy(&v);
|
@@ -65,7 +65,7 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
|
|
65
65
|
// If error is set when this returns, then construction failed, and
|
66
66
|
// the caller may not use the new object.
|
67
67
|
ResolvingLoadBalancingPolicy(
|
68
|
-
Args args, TraceFlag* tracer, UniquePtr<char> target_uri,
|
68
|
+
Args args, TraceFlag* tracer, grpc_core::UniquePtr<char> target_uri,
|
69
69
|
ProcessResolverResultCallback process_resolver_result,
|
70
70
|
void* process_resolver_result_user_data);
|
71
71
|
|
@@ -106,10 +106,10 @@ class ResolvingLoadBalancingPolicy : public LoadBalancingPolicy {
|
|
106
106
|
|
107
107
|
// Passed in from caller at construction time.
|
108
108
|
TraceFlag* tracer_;
|
109
|
-
UniquePtr<char> target_uri_;
|
109
|
+
grpc_core::UniquePtr<char> target_uri_;
|
110
110
|
ProcessResolverResultCallback process_resolver_result_ = nullptr;
|
111
111
|
void* process_resolver_result_user_data_ = nullptr;
|
112
|
-
UniquePtr<char> child_policy_name_;
|
112
|
+
grpc_core::UniquePtr<char> child_policy_name_;
|
113
113
|
RefCountedPtr<LoadBalancingPolicy::Config> child_lb_config_;
|
114
114
|
|
115
115
|
// Resolver and associated state.
|
@@ -34,7 +34,7 @@
|
|
34
34
|
namespace grpc_core {
|
35
35
|
|
36
36
|
namespace {
|
37
|
-
typedef InlinedVector<
|
37
|
+
typedef InlinedVector<std::unique_ptr<ServiceConfig::Parser>,
|
38
38
|
ServiceConfig::kNumPreallocatedParsers>
|
39
39
|
ServiceConfigParserList;
|
40
40
|
ServiceConfigParserList* g_registered_parsers;
|
@@ -42,8 +42,8 @@ ServiceConfigParserList* g_registered_parsers;
|
|
42
42
|
|
43
43
|
RefCountedPtr<ServiceConfig> ServiceConfig::Create(const char* json,
|
44
44
|
grpc_error** error) {
|
45
|
-
UniquePtr<char> service_config_json(gpr_strdup(json));
|
46
|
-
UniquePtr<char> json_string(gpr_strdup(json));
|
45
|
+
grpc_core::UniquePtr<char> service_config_json(gpr_strdup(json));
|
46
|
+
grpc_core::UniquePtr<char> json_string(gpr_strdup(json));
|
47
47
|
GPR_DEBUG_ASSERT(error != nullptr);
|
48
48
|
grpc_json* json_tree = grpc_json_parse_string(json_string.get());
|
49
49
|
if (json_tree == nullptr) {
|
@@ -55,9 +55,9 @@ RefCountedPtr<ServiceConfig> ServiceConfig::Create(const char* json,
|
|
55
55
|
std::move(service_config_json), std::move(json_string), json_tree, error);
|
56
56
|
}
|
57
57
|
|
58
|
-
ServiceConfig::ServiceConfig(UniquePtr<char> service_config_json,
|
59
|
-
UniquePtr<char> json_string,
|
60
|
-
grpc_error** error)
|
58
|
+
ServiceConfig::ServiceConfig(grpc_core::UniquePtr<char> service_config_json,
|
59
|
+
grpc_core::UniquePtr<char> json_string,
|
60
|
+
grpc_json* json_tree, grpc_error** error)
|
61
61
|
: service_config_json_(std::move(service_config_json)),
|
62
62
|
json_string_(std::move(json_string)),
|
63
63
|
json_tree_(json_tree) {
|
@@ -121,7 +121,7 @@ grpc_error* ServiceConfig::ParseJsonMethodConfigToServiceConfigVectorTable(
|
|
121
121
|
[parsed_method_config_vectors_storage_.size() - 1]
|
122
122
|
.get();
|
123
123
|
// Construct list of paths.
|
124
|
-
InlinedVector<UniquePtr<char>, 10> paths;
|
124
|
+
InlinedVector<grpc_core::UniquePtr<char>, 10> paths;
|
125
125
|
for (grpc_json* child = json->child; child != nullptr; child = child->next) {
|
126
126
|
if (child->key == nullptr) continue;
|
127
127
|
if (strcmp(child->key, "name") == 0) {
|
@@ -132,7 +132,8 @@ grpc_error* ServiceConfig::ParseJsonMethodConfigToServiceConfigVectorTable(
|
|
132
132
|
}
|
133
133
|
for (grpc_json* name = child->child; name != nullptr; name = name->next) {
|
134
134
|
grpc_error* parse_error = GRPC_ERROR_NONE;
|
135
|
-
UniquePtr<char> path =
|
135
|
+
grpc_core::UniquePtr<char> path =
|
136
|
+
ParseJsonMethodName(name, &parse_error);
|
136
137
|
if (path == nullptr) {
|
137
138
|
error_list.push_back(parse_error);
|
138
139
|
} else {
|
@@ -228,8 +229,8 @@ int ServiceConfig::CountNamesInMethodConfig(grpc_json* json) {
|
|
228
229
|
return num_names;
|
229
230
|
}
|
230
231
|
|
231
|
-
UniquePtr<char> ServiceConfig::ParseJsonMethodName(
|
232
|
-
|
232
|
+
grpc_core::UniquePtr<char> ServiceConfig::ParseJsonMethodName(
|
233
|
+
grpc_json* json, grpc_error** error) {
|
233
234
|
if (json->type != GRPC_JSON_OBJECT) {
|
234
235
|
*error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
235
236
|
"field:name error:type is not object");
|
@@ -282,7 +283,7 @@ UniquePtr<char> ServiceConfig::ParseJsonMethodName(grpc_json* json,
|
|
282
283
|
char* path;
|
283
284
|
gpr_asprintf(&path, "/%s/%s", service_name,
|
284
285
|
method_name == nullptr ? "*" : method_name);
|
285
|
-
return UniquePtr<char>(path);
|
286
|
+
return grpc_core::UniquePtr<char>(path);
|
286
287
|
}
|
287
288
|
|
288
289
|
const ServiceConfig::ParsedConfigVector*
|
@@ -311,18 +312,18 @@ ServiceConfig::GetMethodParsedConfigVector(const grpc_slice& path) {
|
|
311
312
|
return *value;
|
312
313
|
}
|
313
314
|
|
314
|
-
size_t ServiceConfig::RegisterParser(
|
315
|
+
size_t ServiceConfig::RegisterParser(std::unique_ptr<Parser> parser) {
|
315
316
|
g_registered_parsers->push_back(std::move(parser));
|
316
317
|
return g_registered_parsers->size() - 1;
|
317
318
|
}
|
318
319
|
|
319
320
|
void ServiceConfig::Init() {
|
320
321
|
GPR_ASSERT(g_registered_parsers == nullptr);
|
321
|
-
g_registered_parsers =
|
322
|
+
g_registered_parsers = new ServiceConfigParserList();
|
322
323
|
}
|
323
324
|
|
324
325
|
void ServiceConfig::Shutdown() {
|
325
|
-
|
326
|
+
delete g_registered_parsers;
|
326
327
|
g_registered_parsers = nullptr;
|
327
328
|
}
|
328
329
|
|
@@ -69,7 +69,7 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
|
|
69
69
|
public:
|
70
70
|
virtual ~Parser() = default;
|
71
71
|
|
72
|
-
virtual
|
72
|
+
virtual std::unique_ptr<ParsedConfig> ParseGlobalParams(
|
73
73
|
const grpc_json* /* json */, grpc_error** error) {
|
74
74
|
// Avoid unused parameter warning on debug-only parameter
|
75
75
|
(void)error;
|
@@ -77,7 +77,7 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
|
|
77
77
|
return nullptr;
|
78
78
|
}
|
79
79
|
|
80
|
-
virtual
|
80
|
+
virtual std::unique_ptr<ParsedConfig> ParsePerMethodParams(
|
81
81
|
const grpc_json* /* json */, grpc_error** error) {
|
82
82
|
// Avoid unused parameter warning on debug-only parameter
|
83
83
|
(void)error;
|
@@ -87,7 +87,7 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
|
|
87
87
|
};
|
88
88
|
|
89
89
|
static constexpr int kNumPreallocatedParsers = 4;
|
90
|
-
typedef InlinedVector<
|
90
|
+
typedef InlinedVector<std::unique_ptr<ParsedConfig>, kNumPreallocatedParsers>
|
91
91
|
ParsedConfigVector;
|
92
92
|
|
93
93
|
/// When a service config is applied to a call in the client_channel_filter,
|
@@ -128,6 +128,10 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
|
|
128
128
|
static RefCountedPtr<ServiceConfig> Create(const char* json,
|
129
129
|
grpc_error** error);
|
130
130
|
|
131
|
+
// Takes ownership of \a json_tree.
|
132
|
+
ServiceConfig(grpc_core::UniquePtr<char> service_config_json,
|
133
|
+
grpc_core::UniquePtr<char> json_string, grpc_json* json_tree,
|
134
|
+
grpc_error** error);
|
131
135
|
~ServiceConfig();
|
132
136
|
|
133
137
|
const char* service_config_json() const { return service_config_json_.get(); }
|
@@ -151,22 +155,13 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
|
|
151
155
|
/// registered parser. Each parser is responsible for reading the service
|
152
156
|
/// config json and returning a parsed config. This parsed config can later be
|
153
157
|
/// retrieved using the same index that was returned at registration time.
|
154
|
-
static size_t RegisterParser(
|
158
|
+
static size_t RegisterParser(std::unique_ptr<Parser> parser);
|
155
159
|
|
156
160
|
static void Init();
|
157
161
|
|
158
162
|
static void Shutdown();
|
159
163
|
|
160
164
|
private:
|
161
|
-
// So New() can call our private ctor.
|
162
|
-
template <typename T, typename... Args>
|
163
|
-
friend T* New(Args&&... args);
|
164
|
-
|
165
|
-
// Takes ownership of \a json_tree.
|
166
|
-
ServiceConfig(UniquePtr<char> service_config_json,
|
167
|
-
UniquePtr<char> json_string, grpc_json* json_tree,
|
168
|
-
grpc_error** error);
|
169
|
-
|
170
165
|
// Helper functions to parse the service config
|
171
166
|
grpc_error* ParseGlobalParams(const grpc_json* json_tree);
|
172
167
|
grpc_error* ParsePerMethodParams(const grpc_json* json_tree);
|
@@ -176,18 +171,18 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
|
|
176
171
|
|
177
172
|
// Returns a path string for the JSON name object specified by \a json.
|
178
173
|
// Returns null on error, and stores error in \a error.
|
179
|
-
static UniquePtr<char> ParseJsonMethodName(grpc_json* json,
|
180
|
-
|
174
|
+
static grpc_core::UniquePtr<char> ParseJsonMethodName(grpc_json* json,
|
175
|
+
grpc_error** error);
|
181
176
|
|
182
177
|
grpc_error* ParseJsonMethodConfigToServiceConfigVectorTable(
|
183
178
|
const grpc_json* json,
|
184
179
|
SliceHashTable<const ParsedConfigVector*>::Entry* entries, size_t* idx);
|
185
180
|
|
186
|
-
UniquePtr<char> service_config_json_;
|
187
|
-
UniquePtr<char> json_string_; // Underlying storage for json_tree.
|
181
|
+
grpc_core::UniquePtr<char> service_config_json_;
|
182
|
+
grpc_core::UniquePtr<char> json_string_; // Underlying storage for json_tree.
|
188
183
|
grpc_json* json_tree_;
|
189
184
|
|
190
|
-
InlinedVector<
|
185
|
+
InlinedVector<std::unique_ptr<ParsedConfig>, kNumPreallocatedParsers>
|
191
186
|
parsed_global_configs_;
|
192
187
|
// A map from the method name to the parsed config vector. Note that we are
|
193
188
|
// using a raw pointer and not a unique pointer so that we can use the same
|
@@ -196,7 +191,7 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
|
|
196
191
|
parsed_method_configs_table_;
|
197
192
|
// Storage for all the vectors that are being used in
|
198
193
|
// parsed_method_configs_table_.
|
199
|
-
InlinedVector<
|
194
|
+
InlinedVector<std::unique_ptr<ParsedConfigVector>, 32>
|
200
195
|
parsed_method_config_vectors_storage_;
|
201
196
|
};
|
202
197
|
|
@@ -213,11 +213,12 @@ void SubchannelCall::Unref() {
|
|
213
213
|
GRPC_CALL_STACK_UNREF(SUBCHANNEL_CALL_TO_CALL_STACK(this), "");
|
214
214
|
}
|
215
215
|
|
216
|
-
void SubchannelCall::Unref(const DebugLocation& location
|
216
|
+
void SubchannelCall::Unref(const DebugLocation& /*location*/,
|
217
|
+
const char* reason) {
|
217
218
|
GRPC_CALL_STACK_UNREF(SUBCHANNEL_CALL_TO_CALL_STACK(this), reason);
|
218
219
|
}
|
219
220
|
|
220
|
-
void SubchannelCall::Destroy(void* arg, grpc_error* error) {
|
221
|
+
void SubchannelCall::Destroy(void* arg, grpc_error* /*error*/) {
|
221
222
|
GPR_TIMER_SCOPE("subchannel_call_destroy", 0);
|
222
223
|
SubchannelCall* self = static_cast<SubchannelCall*>(arg);
|
223
224
|
// Keep some members before destroying the subchannel call.
|
@@ -292,16 +293,16 @@ void SubchannelCall::RecvTrailingMetadataReady(void* arg, grpc_error* error) {
|
|
292
293
|
} else {
|
293
294
|
channelz_subchannel->RecordCallFailed();
|
294
295
|
}
|
295
|
-
|
296
|
-
|
296
|
+
Closure::Run(DEBUG_LOCATION, call->original_recv_trailing_metadata_,
|
297
|
+
GRPC_ERROR_REF(error));
|
297
298
|
}
|
298
299
|
|
299
300
|
void SubchannelCall::IncrementRefCount() {
|
300
301
|
GRPC_CALL_STACK_REF(SUBCHANNEL_CALL_TO_CALL_STACK(this), "");
|
301
302
|
}
|
302
303
|
|
303
|
-
void SubchannelCall::IncrementRefCount(
|
304
|
-
|
304
|
+
void SubchannelCall::IncrementRefCount(
|
305
|
+
const grpc_core::DebugLocation& /*location*/, const char* reason) {
|
305
306
|
GRPC_CALL_STACK_REF(SUBCHANNEL_CALL_TO_CALL_STACK(this), reason);
|
306
307
|
}
|
307
308
|
|
@@ -403,7 +404,8 @@ void Subchannel::ConnectivityStateWatcherList::NotifyLocked(
|
|
403
404
|
class Subchannel::HealthWatcherMap::HealthWatcher
|
404
405
|
: public AsyncConnectivityStateWatcherInterface {
|
405
406
|
public:
|
406
|
-
HealthWatcher(Subchannel* c,
|
407
|
+
HealthWatcher(Subchannel* c,
|
408
|
+
grpc_core::UniquePtr<char> health_check_service_name,
|
407
409
|
grpc_connectivity_state subchannel_state)
|
408
410
|
: subchannel_(c),
|
409
411
|
health_check_service_name_(std::move(health_check_service_name)),
|
@@ -488,7 +490,7 @@ class Subchannel::HealthWatcherMap::HealthWatcher
|
|
488
490
|
}
|
489
491
|
|
490
492
|
Subchannel* subchannel_;
|
491
|
-
UniquePtr<char> health_check_service_name_;
|
493
|
+
grpc_core::UniquePtr<char> health_check_service_name_;
|
492
494
|
OrphanablePtr<HealthCheckClient> health_check_client_;
|
493
495
|
grpc_connectivity_state state_;
|
494
496
|
ConnectivityStateWatcherList watcher_list_;
|
@@ -500,7 +502,7 @@ class Subchannel::HealthWatcherMap::HealthWatcher
|
|
500
502
|
|
501
503
|
void Subchannel::HealthWatcherMap::AddWatcherLocked(
|
502
504
|
Subchannel* subchannel, grpc_connectivity_state initial_state,
|
503
|
-
UniquePtr<char> health_check_service_name,
|
505
|
+
grpc_core::UniquePtr<char> health_check_service_name,
|
504
506
|
OrphanablePtr<ConnectivityStateWatcherInterface> watcher) {
|
505
507
|
// If the health check service name is not already present in the map,
|
506
508
|
// add it.
|
@@ -611,21 +613,21 @@ BackOff::Options ParseArgsForBackoffValues(
|
|
611
613
|
|
612
614
|
} // namespace
|
613
615
|
|
614
|
-
Subchannel::Subchannel(SubchannelKey* key,
|
616
|
+
Subchannel::Subchannel(SubchannelKey* key,
|
617
|
+
OrphanablePtr<SubchannelConnector> connector,
|
615
618
|
const grpc_channel_args* args)
|
616
619
|
: key_(key),
|
617
|
-
connector_(connector),
|
620
|
+
connector_(std::move(connector)),
|
618
621
|
backoff_(ParseArgsForBackoffValues(args, &min_connect_timeout_ms_)) {
|
619
622
|
GRPC_STATS_INC_CLIENT_SUBCHANNELS_CREATED();
|
620
623
|
gpr_atm_no_barrier_store(&ref_pair_, 1 << INTERNAL_REF_BITS);
|
621
|
-
grpc_connector_ref(connector_);
|
622
624
|
pollset_set_ = grpc_pollset_set_create();
|
623
625
|
grpc_resolved_address* addr =
|
624
626
|
static_cast<grpc_resolved_address*>(gpr_malloc(sizeof(*addr)));
|
625
627
|
GetAddressFromSubchannelAddressArg(args, addr);
|
626
628
|
grpc_resolved_address* new_address = nullptr;
|
627
629
|
grpc_channel_args* new_args = nullptr;
|
628
|
-
if (
|
630
|
+
if (ProxyMapperRegistry::MapAddress(*addr, args, &new_address, &new_args)) {
|
629
631
|
GPR_ASSERT(new_address != nullptr);
|
630
632
|
gpr_free(addr);
|
631
633
|
addr = new_address;
|
@@ -666,23 +668,23 @@ Subchannel::~Subchannel() {
|
|
666
668
|
channelz_node_->UpdateConnectivityState(GRPC_CHANNEL_SHUTDOWN);
|
667
669
|
}
|
668
670
|
grpc_channel_args_destroy(args_);
|
669
|
-
|
671
|
+
connector_.reset();
|
670
672
|
grpc_pollset_set_destroy(pollset_set_);
|
671
|
-
|
673
|
+
delete key_;
|
672
674
|
}
|
673
675
|
|
674
|
-
Subchannel* Subchannel::Create(
|
676
|
+
Subchannel* Subchannel::Create(OrphanablePtr<SubchannelConnector> connector,
|
675
677
|
const grpc_channel_args* args) {
|
676
|
-
SubchannelKey* key =
|
678
|
+
SubchannelKey* key = new SubchannelKey(args);
|
677
679
|
SubchannelPoolInterface* subchannel_pool =
|
678
680
|
SubchannelPoolInterface::GetSubchannelPoolFromChannelArgs(args);
|
679
681
|
GPR_ASSERT(subchannel_pool != nullptr);
|
680
682
|
Subchannel* c = subchannel_pool->FindSubchannel(key);
|
681
683
|
if (c != nullptr) {
|
682
|
-
|
684
|
+
delete key;
|
683
685
|
return c;
|
684
686
|
}
|
685
|
-
c =
|
687
|
+
c = new Subchannel(key, std::move(connector), args);
|
686
688
|
// Try to register the subchannel before setting the subchannel pool.
|
687
689
|
// Otherwise, in case of a registration race, unreffing c in
|
688
690
|
// RegisterSubchannel() will cause c to be tried to be unregistered, while
|
@@ -721,9 +723,9 @@ Subchannel* Subchannel::WeakRef(GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
|
|
721
723
|
|
722
724
|
namespace {
|
723
725
|
|
724
|
-
void subchannel_destroy(void* arg, grpc_error* error) {
|
726
|
+
void subchannel_destroy(void* arg, grpc_error* /*error*/) {
|
725
727
|
Subchannel* self = static_cast<Subchannel*>(arg);
|
726
|
-
|
728
|
+
delete self;
|
727
729
|
}
|
728
730
|
|
729
731
|
} // namespace
|
@@ -733,13 +735,14 @@ void Subchannel::WeakUnref(GRPC_SUBCHANNEL_REF_EXTRA_ARGS) {
|
|
733
735
|
old_refs = RefMutate(-static_cast<gpr_atm>(1),
|
734
736
|
1 GRPC_SUBCHANNEL_REF_MUTATE_PURPOSE("WEAK_UNREF"));
|
735
737
|
if (old_refs == 1) {
|
736
|
-
|
737
|
-
|
738
|
-
|
738
|
+
ExecCtx::Run(DEBUG_LOCATION,
|
739
|
+
GRPC_CLOSURE_CREATE(subchannel_destroy, this,
|
740
|
+
grpc_schedule_on_exec_ctx),
|
741
|
+
GRPC_ERROR_NONE);
|
739
742
|
}
|
740
743
|
}
|
741
744
|
|
742
|
-
Subchannel* Subchannel::RefFromWeakRef(
|
745
|
+
Subchannel* Subchannel::RefFromWeakRef() {
|
743
746
|
for (;;) {
|
744
747
|
gpr_atm old_refs = gpr_atm_acq_load(&ref_pair_);
|
745
748
|
if (old_refs >= (1 << INTERNAL_REF_BITS)) {
|
@@ -784,7 +787,7 @@ grpc_connectivity_state Subchannel::CheckConnectivityState(
|
|
784
787
|
|
785
788
|
void Subchannel::WatchConnectivityState(
|
786
789
|
grpc_connectivity_state initial_state,
|
787
|
-
UniquePtr<char> health_check_service_name,
|
790
|
+
grpc_core::UniquePtr<char> health_check_service_name,
|
788
791
|
OrphanablePtr<ConnectivityStateWatcherInterface> watcher) {
|
789
792
|
MutexLock lock(&mu_);
|
790
793
|
grpc_pollset_set* interested_parties = watcher->interested_parties();
|
@@ -972,7 +975,7 @@ void Subchannel::OnRetryAlarm(void* arg, grpc_error* error) {
|
|
972
975
|
}
|
973
976
|
|
974
977
|
void Subchannel::ContinueConnectingLocked() {
|
975
|
-
|
978
|
+
SubchannelConnector::Args args;
|
976
979
|
args.interested_parties = pollset_set_;
|
977
980
|
const grpc_millis min_deadline =
|
978
981
|
min_connect_timeout_ms_ + ExecCtx::Get()->Now();
|
@@ -980,13 +983,13 @@ void Subchannel::ContinueConnectingLocked() {
|
|
980
983
|
args.deadline = std::max(next_attempt_deadline_, min_deadline);
|
981
984
|
args.channel_args = args_;
|
982
985
|
SetConnectivityStateLocked(GRPC_CHANNEL_CONNECTING);
|
983
|
-
|
984
|
-
&on_connecting_finished_);
|
986
|
+
connector_->Connect(args, &connecting_result_, &on_connecting_finished_);
|
985
987
|
}
|
986
988
|
|
987
989
|
void Subchannel::OnConnectingFinished(void* arg, grpc_error* error) {
|
988
990
|
auto* c = static_cast<Subchannel*>(arg);
|
989
|
-
grpc_channel_args* delete_channel_args =
|
991
|
+
const grpc_channel_args* delete_channel_args =
|
992
|
+
c->connecting_result_.channel_args;
|
990
993
|
GRPC_SUBCHANNEL_WEAK_REF(c, "on_connecting_finished");
|
991
994
|
{
|
992
995
|
MutexLock lock(&c->mu_);
|
@@ -1008,7 +1011,7 @@ void Subchannel::OnConnectingFinished(void* arg, grpc_error* error) {
|
|
1008
1011
|
|
1009
1012
|
namespace {
|
1010
1013
|
|
1011
|
-
void ConnectionDestroy(void* arg, grpc_error* error) {
|
1014
|
+
void ConnectionDestroy(void* arg, grpc_error* /*error*/) {
|
1012
1015
|
grpc_channel_stack* stk = static_cast<grpc_channel_stack*>(arg);
|
1013
1016
|
grpc_channel_stack_destroy(stk);
|
1014
1017
|
gpr_free(stk);
|
@@ -1039,8 +1042,8 @@ bool Subchannel::PublishTransportLocked() {
|
|
1039
1042
|
return false;
|
1040
1043
|
}
|
1041
1044
|
RefCountedPtr<channelz::SocketNode> socket =
|
1042
|
-
std::move(connecting_result_.
|
1043
|
-
connecting_result_.
|
1045
|
+
std::move(connecting_result_.socket_node);
|
1046
|
+
connecting_result_.Reset();
|
1044
1047
|
if (disconnected_) {
|
1045
1048
|
grpc_channel_stack_destroy(stk);
|
1046
1049
|
gpr_free(stk);
|
@@ -1048,7 +1051,7 @@ bool Subchannel::PublishTransportLocked() {
|
|
1048
1051
|
}
|
1049
1052
|
// Publish.
|
1050
1053
|
connected_subchannel_.reset(
|
1051
|
-
|
1054
|
+
new ConnectedSubchannel(stk, args_, channelz_node_));
|
1052
1055
|
gpr_log(GPR_INFO, "New connected subchannel at %p for subchannel %p",
|
1053
1056
|
connected_subchannel_.get(), this);
|
1054
1057
|
if (channelz_node_ != nullptr) {
|
@@ -1072,8 +1075,7 @@ void Subchannel::Disconnect() {
|
|
1072
1075
|
MutexLock lock(&mu_);
|
1073
1076
|
GPR_ASSERT(!disconnected_);
|
1074
1077
|
disconnected_ = true;
|
1075
|
-
|
1076
|
-
"Subchannel disconnected"));
|
1078
|
+
connector_.reset();
|
1077
1079
|
connected_subchannel_.reset();
|
1078
1080
|
health_watcher_map_.ShutdownLocked();
|
1079
1081
|
}
|