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
@@ -34,7 +34,7 @@ class RegistryState {
|
|
34
34
|
RegistryState() {}
|
35
35
|
|
36
36
|
void RegisterLoadBalancingPolicyFactory(
|
37
|
-
|
37
|
+
std::unique_ptr<LoadBalancingPolicyFactory> factory) {
|
38
38
|
for (size_t i = 0; i < factories_.size(); ++i) {
|
39
39
|
GPR_ASSERT(strcmp(factories_[i]->name(), factory->name()) != 0);
|
40
40
|
}
|
@@ -52,7 +52,7 @@ class RegistryState {
|
|
52
52
|
}
|
53
53
|
|
54
54
|
private:
|
55
|
-
InlinedVector<
|
55
|
+
InlinedVector<std::unique_ptr<LoadBalancingPolicyFactory>, 10> factories_;
|
56
56
|
};
|
57
57
|
|
58
58
|
RegistryState* g_state = nullptr;
|
@@ -64,16 +64,16 @@ RegistryState* g_state = nullptr;
|
|
64
64
|
//
|
65
65
|
|
66
66
|
void LoadBalancingPolicyRegistry::Builder::InitRegistry() {
|
67
|
-
if (g_state == nullptr) g_state =
|
67
|
+
if (g_state == nullptr) g_state = new RegistryState();
|
68
68
|
}
|
69
69
|
|
70
70
|
void LoadBalancingPolicyRegistry::Builder::ShutdownRegistry() {
|
71
|
-
|
71
|
+
delete g_state;
|
72
72
|
g_state = nullptr;
|
73
73
|
}
|
74
74
|
|
75
75
|
void LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
|
76
|
-
|
76
|
+
std::unique_ptr<LoadBalancingPolicyFactory> factory) {
|
77
77
|
InitRegistry();
|
78
78
|
g_state->RegisterLoadBalancingPolicyFactory(std::move(factory));
|
79
79
|
}
|
@@ -41,7 +41,7 @@ class LoadBalancingPolicyRegistry {
|
|
41
41
|
/// Registers an LB policy factory. The factory will be used to create an
|
42
42
|
/// LB policy whose name matches that of the factory.
|
43
43
|
static void RegisterLoadBalancingPolicyFactory(
|
44
|
-
|
44
|
+
std::unique_ptr<LoadBalancingPolicyFactory> factory);
|
45
45
|
};
|
46
46
|
|
47
47
|
/// Creates an LB policy of the type specified by \a name.
|
@@ -43,7 +43,7 @@ Subchannel* LocalSubchannelPool::RegisterSubchannel(SubchannelKey* key,
|
|
43
43
|
GRPC_SUBCHANNEL_UNREF(constructed, "subchannel_register+found_existing");
|
44
44
|
} else {
|
45
45
|
// There hasn't been such subchannel. Add one.
|
46
|
-
subchannel_map_ = grpc_avl_add(subchannel_map_,
|
46
|
+
subchannel_map_ = grpc_avl_add(subchannel_map_, new SubchannelKey(*key),
|
47
47
|
constructed, nullptr);
|
48
48
|
c = constructed;
|
49
49
|
}
|
@@ -62,26 +62,26 @@ Subchannel* LocalSubchannelPool::FindSubchannel(SubchannelKey* key) {
|
|
62
62
|
|
63
63
|
namespace {
|
64
64
|
|
65
|
-
void sck_avl_destroy(void* p, void* user_data) {
|
65
|
+
void sck_avl_destroy(void* p, void* /*user_data*/) {
|
66
66
|
SubchannelKey* key = static_cast<SubchannelKey*>(p);
|
67
|
-
|
67
|
+
delete key;
|
68
68
|
}
|
69
69
|
|
70
|
-
void* sck_avl_copy(void* p, void* unused) {
|
70
|
+
void* sck_avl_copy(void* p, void* /*unused*/) {
|
71
71
|
const SubchannelKey* key = static_cast<const SubchannelKey*>(p);
|
72
|
-
auto new_key =
|
72
|
+
auto new_key = new SubchannelKey(*key);
|
73
73
|
return static_cast<void*>(new_key);
|
74
74
|
}
|
75
75
|
|
76
|
-
long sck_avl_compare(void* a, void* b, void* unused) {
|
76
|
+
long sck_avl_compare(void* a, void* b, void* /*unused*/) {
|
77
77
|
const SubchannelKey* key_a = static_cast<const SubchannelKey*>(a);
|
78
78
|
const SubchannelKey* key_b = static_cast<const SubchannelKey*>(b);
|
79
79
|
return key_a->Cmp(*key_b);
|
80
80
|
}
|
81
81
|
|
82
|
-
void scv_avl_destroy(void* p
|
82
|
+
void scv_avl_destroy(void* /*p*/, void* /*user_data*/) {}
|
83
83
|
|
84
|
-
void* scv_avl_copy(void* p, void* unused) { return p; }
|
84
|
+
void* scv_avl_copy(void* p, void* /*unused*/) { return p; }
|
85
85
|
|
86
86
|
} // namespace
|
87
87
|
|
@@ -21,54 +21,34 @@
|
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
-
#include <stdbool.h>
|
25
|
-
|
26
24
|
#include <grpc/impl/codegen/grpc_types.h>
|
27
25
|
|
28
26
|
#include "src/core/lib/iomgr/resolve_address.h"
|
29
27
|
|
30
|
-
|
28
|
+
namespace grpc_core {
|
29
|
+
|
30
|
+
class ProxyMapperInterface {
|
31
|
+
public:
|
32
|
+
virtual ~ProxyMapperInterface() = default;
|
31
33
|
|
32
|
-
typedef struct {
|
33
34
|
/// Determines the proxy name to resolve for \a server_uri.
|
34
35
|
/// If no proxy is needed, returns false.
|
35
36
|
/// Otherwise, sets \a name_to_resolve, optionally sets \a new_args,
|
36
37
|
/// and returns true.
|
37
|
-
bool (*
|
38
|
-
|
39
|
-
|
38
|
+
virtual bool MapName(const char* server_uri, const grpc_channel_args* args,
|
39
|
+
char** name_to_resolve,
|
40
|
+
grpc_channel_args** new_args) = 0;
|
41
|
+
|
40
42
|
/// Determines the proxy address to use to contact \a address.
|
41
43
|
/// If no proxy is needed, returns false.
|
42
44
|
/// Otherwise, sets \a new_address, optionally sets \a new_args, and
|
43
45
|
/// returns true.
|
44
|
-
bool (
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
grpc_channel_args** new_args);
|
49
|
-
/// Destroys \a mapper.
|
50
|
-
void (*destroy)(grpc_proxy_mapper* mapper);
|
51
|
-
} grpc_proxy_mapper_vtable;
|
52
|
-
|
53
|
-
struct grpc_proxy_mapper {
|
54
|
-
const grpc_proxy_mapper_vtable* vtable;
|
46
|
+
virtual bool MapAddress(const grpc_resolved_address& address,
|
47
|
+
const grpc_channel_args* args,
|
48
|
+
grpc_resolved_address** new_address,
|
49
|
+
grpc_channel_args** new_args) = 0;
|
55
50
|
};
|
56
51
|
|
57
|
-
|
58
|
-
grpc_proxy_mapper* mapper);
|
59
|
-
|
60
|
-
bool grpc_proxy_mapper_map_name(grpc_proxy_mapper* mapper,
|
61
|
-
const char* server_uri,
|
62
|
-
const grpc_channel_args* args,
|
63
|
-
char** name_to_resolve,
|
64
|
-
grpc_channel_args** new_args);
|
65
|
-
|
66
|
-
bool grpc_proxy_mapper_map_address(grpc_proxy_mapper* mapper,
|
67
|
-
const grpc_resolved_address* address,
|
68
|
-
const grpc_channel_args* args,
|
69
|
-
grpc_resolved_address** new_address,
|
70
|
-
grpc_channel_args** new_args);
|
71
|
-
|
72
|
-
void grpc_proxy_mapper_destroy(grpc_proxy_mapper* mapper);
|
52
|
+
} // namespace grpc_core
|
73
53
|
|
74
54
|
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_H */
|
@@ -20,103 +20,70 @@
|
|
20
20
|
|
21
21
|
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
|
22
22
|
|
23
|
-
#include <
|
23
|
+
#include <memory>
|
24
|
+
#include <vector>
|
24
25
|
|
25
|
-
|
26
|
+
namespace grpc_core {
|
26
27
|
|
27
|
-
|
28
|
-
// grpc_proxy_mapper_list
|
29
|
-
//
|
28
|
+
namespace {
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
size_t num_mappers;
|
34
|
-
} grpc_proxy_mapper_list;
|
30
|
+
using ProxyMapperList = std::vector<std::unique_ptr<ProxyMapperInterface>>;
|
31
|
+
ProxyMapperList* g_proxy_mapper_list;
|
35
32
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
} // namespace
|
34
|
+
|
35
|
+
void ProxyMapperRegistry::Init() {
|
36
|
+
if (g_proxy_mapper_list == nullptr) {
|
37
|
+
g_proxy_mapper_list = new ProxyMapperList();
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
void ProxyMapperRegistry::Shutdown() {
|
42
|
+
delete g_proxy_mapper_list;
|
43
|
+
// Clean up in case we re-initialze later.
|
44
|
+
// TODO(roth): This should ideally live in Init(). However, if we did this
|
45
|
+
// there, then we would do it AFTER we start registering proxy mappers from
|
46
|
+
// third-party plugins, so they'd never show up (and would leak memory).
|
47
|
+
// We probably need some sort of dependency system for plugins to fix
|
48
|
+
// this.
|
49
|
+
g_proxy_mapper_list = nullptr;
|
50
|
+
}
|
51
|
+
|
52
|
+
void ProxyMapperRegistry::Register(
|
53
|
+
bool at_start, std::unique_ptr<ProxyMapperInterface> mapper) {
|
54
|
+
Init();
|
41
55
|
if (at_start) {
|
42
|
-
|
43
|
-
|
44
|
-
list->list[0] = mapper;
|
56
|
+
g_proxy_mapper_list->insert(g_proxy_mapper_list->begin(),
|
57
|
+
std::move(mapper));
|
45
58
|
} else {
|
46
|
-
|
59
|
+
g_proxy_mapper_list->emplace_back(std::move(mapper));
|
47
60
|
}
|
48
|
-
++list->num_mappers;
|
49
61
|
}
|
50
62
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
for (
|
57
|
-
if (
|
58
|
-
name_to_resolve, new_args)) {
|
63
|
+
bool ProxyMapperRegistry::MapName(const char* server_uri,
|
64
|
+
const grpc_channel_args* args,
|
65
|
+
char** name_to_resolve,
|
66
|
+
grpc_channel_args** new_args) {
|
67
|
+
Init();
|
68
|
+
for (const auto& mapper : *g_proxy_mapper_list) {
|
69
|
+
if (mapper->MapName(server_uri, args, name_to_resolve, new_args)) {
|
59
70
|
return true;
|
60
71
|
}
|
61
72
|
}
|
62
73
|
return false;
|
63
74
|
}
|
64
75
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
76
|
+
bool ProxyMapperRegistry::MapAddress(const grpc_resolved_address& address,
|
77
|
+
const grpc_channel_args* args,
|
78
|
+
grpc_resolved_address** new_address,
|
79
|
+
grpc_channel_args** new_args) {
|
80
|
+
Init();
|
81
|
+
for (const auto& mapper : *g_proxy_mapper_list) {
|
82
|
+
if (mapper->MapAddress(address, args, new_address, new_args)) {
|
72
83
|
return true;
|
73
84
|
}
|
74
85
|
}
|
75
86
|
return false;
|
76
87
|
}
|
77
88
|
|
78
|
-
|
79
|
-
for (size_t i = 0; i < list->num_mappers; ++i) {
|
80
|
-
grpc_proxy_mapper_destroy(list->list[i]);
|
81
|
-
}
|
82
|
-
gpr_free(list->list);
|
83
|
-
// Clean up in case we re-initialze later.
|
84
|
-
// TODO(ctiller): This should ideally live in
|
85
|
-
// grpc_proxy_mapper_registry_init(). However, if we did this there,
|
86
|
-
// then we would do it AFTER we start registering proxy mappers from
|
87
|
-
// third-party plugins, so they'd never show up (and would leak memory).
|
88
|
-
// We probably need some sort of dependency system for plugins to fix
|
89
|
-
// this.
|
90
|
-
memset(list, 0, sizeof(*list));
|
91
|
-
}
|
92
|
-
|
93
|
-
//
|
94
|
-
// plugin
|
95
|
-
//
|
96
|
-
|
97
|
-
static grpc_proxy_mapper_list g_proxy_mapper_list;
|
98
|
-
|
99
|
-
void grpc_proxy_mapper_registry_init() {}
|
100
|
-
|
101
|
-
void grpc_proxy_mapper_registry_shutdown() {
|
102
|
-
grpc_proxy_mapper_list_destroy(&g_proxy_mapper_list);
|
103
|
-
}
|
104
|
-
|
105
|
-
void grpc_proxy_mapper_register(bool at_start, grpc_proxy_mapper* mapper) {
|
106
|
-
grpc_proxy_mapper_list_register(&g_proxy_mapper_list, at_start, mapper);
|
107
|
-
}
|
108
|
-
|
109
|
-
bool grpc_proxy_mappers_map_name(const char* server_uri,
|
110
|
-
const grpc_channel_args* args,
|
111
|
-
char** name_to_resolve,
|
112
|
-
grpc_channel_args** new_args) {
|
113
|
-
return grpc_proxy_mapper_list_map_name(&g_proxy_mapper_list, server_uri, args,
|
114
|
-
name_to_resolve, new_args);
|
115
|
-
}
|
116
|
-
bool grpc_proxy_mappers_map_address(const grpc_resolved_address* address,
|
117
|
-
const grpc_channel_args* args,
|
118
|
-
grpc_resolved_address** new_address,
|
119
|
-
grpc_channel_args** new_args) {
|
120
|
-
return grpc_proxy_mapper_list_map_address(&g_proxy_mapper_list, address, args,
|
121
|
-
new_address, new_args);
|
122
|
-
}
|
89
|
+
} // namespace grpc_core
|
@@ -23,22 +23,28 @@
|
|
23
23
|
|
24
24
|
#include "src/core/ext/filters/client_channel/proxy_mapper.h"
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
bool
|
40
|
-
|
41
|
-
|
42
|
-
|
26
|
+
namespace grpc_core {
|
27
|
+
|
28
|
+
class ProxyMapperRegistry {
|
29
|
+
public:
|
30
|
+
static void Init();
|
31
|
+
static void Shutdown();
|
32
|
+
|
33
|
+
/// Registers a new proxy mapper.
|
34
|
+
/// If \a at_start is true, the new mapper will be at the beginning of
|
35
|
+
/// the list. Otherwise, it will be added to the end.
|
36
|
+
static void Register(bool at_start,
|
37
|
+
std::unique_ptr<ProxyMapperInterface> mapper);
|
38
|
+
|
39
|
+
static bool MapName(const char* server_uri, const grpc_channel_args* args,
|
40
|
+
char** name_to_resolve, grpc_channel_args** new_args);
|
41
|
+
|
42
|
+
static bool MapAddress(const grpc_resolved_address& address,
|
43
|
+
const grpc_channel_args* args,
|
44
|
+
grpc_resolved_address** new_address,
|
45
|
+
grpc_channel_args** new_args);
|
46
|
+
};
|
47
|
+
|
48
|
+
} // namespace grpc_core
|
43
49
|
|
44
50
|
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_PROXY_MAPPER_REGISTRY_H */
|
@@ -30,7 +30,8 @@ namespace grpc_core {
|
|
30
30
|
// Resolver
|
31
31
|
//
|
32
32
|
|
33
|
-
Resolver::Resolver(Combiner* combiner,
|
33
|
+
Resolver::Resolver(Combiner* combiner,
|
34
|
+
std::unique_ptr<ResultHandler> result_handler)
|
34
35
|
: InternallyRefCounted(&grpc_trace_resolver_refcount),
|
35
36
|
result_handler_(std::move(result_handler)),
|
36
37
|
combiner_(GRPC_COMBINER_REF(combiner, "resolver")) {}
|
@@ -127,7 +127,7 @@ class Resolver : public InternallyRefCounted<Resolver> {
|
|
127
127
|
// API should change to take a RefCountedPtr<>, so that we always take
|
128
128
|
// ownership of a new ref.
|
129
129
|
explicit Resolver(Combiner* combiner,
|
130
|
-
|
130
|
+
std::unique_ptr<ResultHandler> result_handler);
|
131
131
|
|
132
132
|
/// Shuts down the resolver.
|
133
133
|
virtual void ShutdownLocked() = 0;
|
@@ -137,7 +137,7 @@ class Resolver : public InternallyRefCounted<Resolver> {
|
|
137
137
|
ResultHandler* result_handler() const { return result_handler_.get(); }
|
138
138
|
|
139
139
|
private:
|
140
|
-
|
140
|
+
std::unique_ptr<ResultHandler> result_handler_;
|
141
141
|
Combiner* combiner_;
|
142
142
|
};
|
143
143
|
|
@@ -108,7 +108,7 @@ class AresDnsResolver : public Resolver {
|
|
108
108
|
/// retry backoff state
|
109
109
|
BackOff backoff_;
|
110
110
|
/// currently resolving addresses
|
111
|
-
|
111
|
+
std::unique_ptr<ServerAddressList> addresses_;
|
112
112
|
/// currently resolving service config
|
113
113
|
char* service_config_json_ = nullptr;
|
114
114
|
// has shutdown been initiated
|
@@ -77,7 +77,7 @@ struct grpc_ares_ev_driver {
|
|
77
77
|
/** request object that's using this ev driver */
|
78
78
|
grpc_ares_request* request;
|
79
79
|
/** Owned by the ev_driver. Creates new GrpcPolledFd's */
|
80
|
-
|
80
|
+
std::unique_ptr<grpc_core::GrpcPolledFdFactory> polled_fd_factory;
|
81
81
|
/** query timeout in milliseconds */
|
82
82
|
int query_timeout_ms;
|
83
83
|
/** alarm to cancel active queries */
|
@@ -110,7 +110,7 @@ static void grpc_ares_ev_driver_unref(grpc_ares_ev_driver* ev_driver) {
|
|
110
110
|
GRPC_COMBINER_UNREF(ev_driver->combiner, "free ares event driver");
|
111
111
|
ares_destroy(ev_driver->channel);
|
112
112
|
grpc_ares_complete_request_locked(ev_driver->request);
|
113
|
-
|
113
|
+
delete ev_driver;
|
114
114
|
}
|
115
115
|
}
|
116
116
|
|
@@ -120,7 +120,7 @@ static void fd_node_destroy_locked(fd_node* fdn) {
|
|
120
120
|
GPR_ASSERT(!fdn->readable_registered);
|
121
121
|
GPR_ASSERT(!fdn->writable_registered);
|
122
122
|
GPR_ASSERT(fdn->already_shutdown);
|
123
|
-
|
123
|
+
delete fdn->grpc_polled_fd;
|
124
124
|
gpr_free(fdn);
|
125
125
|
}
|
126
126
|
|
@@ -148,7 +148,7 @@ grpc_error* grpc_ares_ev_driver_create_locked(grpc_ares_ev_driver** ev_driver,
|
|
148
148
|
int query_timeout_ms,
|
149
149
|
grpc_core::Combiner* combiner,
|
150
150
|
grpc_ares_request* request) {
|
151
|
-
*ev_driver =
|
151
|
+
*ev_driver = new grpc_ares_ev_driver();
|
152
152
|
ares_options opts;
|
153
153
|
memset(&opts, 0, sizeof(opts));
|
154
154
|
opts.flags |= ARES_FLAG_STAYOPEN;
|
@@ -95,7 +95,7 @@ class GrpcPolledFdFactory {
|
|
95
95
|
virtual void ConfigureAresChannelLocked(ares_channel channel) = 0;
|
96
96
|
};
|
97
97
|
|
98
|
-
|
98
|
+
std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(Combiner* combiner);
|
99
99
|
|
100
100
|
} // namespace grpc_core
|
101
101
|
|
@@ -37,14 +37,14 @@ namespace grpc_core {
|
|
37
37
|
|
38
38
|
void ares_uv_poll_cb(uv_poll_t* handle, int status, int events);
|
39
39
|
|
40
|
-
void ares_uv_poll_close_cb(uv_handle_t* handle) {
|
40
|
+
void ares_uv_poll_close_cb(uv_handle_t* handle) { delete handle; }
|
41
41
|
|
42
42
|
class GrpcPolledFdLibuv : public GrpcPolledFd {
|
43
43
|
public:
|
44
44
|
GrpcPolledFdLibuv(ares_socket_t as, Combiner* combiner)
|
45
45
|
: as_(as), combiner_(combiner) {
|
46
46
|
gpr_asprintf(&name_, "c-ares socket: %" PRIdPTR, (intptr_t)as);
|
47
|
-
handle_ =
|
47
|
+
handle_ = new uv_poll_t();
|
48
48
|
uv_poll_init_socket(uv_default_loop(), handle_, as);
|
49
49
|
handle_->data = this;
|
50
50
|
GRPC_COMBINER_REF(combiner_, "libuv ares event driver");
|
@@ -81,10 +81,12 @@ class GrpcPolledFdLibuv : public GrpcPolledFd {
|
|
81
81
|
uv_poll_stop(handle_);
|
82
82
|
uv_close(reinterpret_cast<uv_handle_t*>(handle_), ares_uv_poll_close_cb);
|
83
83
|
if (read_closure_ != nullptr) {
|
84
|
-
|
84
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, read_closure_,
|
85
|
+
GRPC_ERROR_CANCELLED);
|
85
86
|
}
|
86
87
|
if (write_closure_ != nullptr) {
|
87
|
-
|
88
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, write_closure_,
|
89
|
+
GRPC_ERROR_CANCELLED);
|
88
90
|
}
|
89
91
|
}
|
90
92
|
|
@@ -120,7 +122,7 @@ struct AresUvPollCbArg {
|
|
120
122
|
};
|
121
123
|
|
122
124
|
static void ares_uv_poll_cb_locked(void* arg, grpc_error* error) {
|
123
|
-
|
125
|
+
std::unique_ptr<AresUvPollCbArg> arg_struct(
|
124
126
|
reinterpret_cast<AresUvPollCbArg*>(arg));
|
125
127
|
uv_poll_t* handle = arg_struct->handle;
|
126
128
|
int status = arg_struct->status;
|
@@ -135,13 +137,13 @@ static void ares_uv_poll_cb_locked(void* arg, grpc_error* error) {
|
|
135
137
|
}
|
136
138
|
if (events & UV_READABLE) {
|
137
139
|
GPR_ASSERT(polled_fd->read_closure_ != nullptr);
|
138
|
-
|
140
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, polled_fd->read_closure_, error);
|
139
141
|
polled_fd->read_closure_ = nullptr;
|
140
142
|
polled_fd->poll_events_ &= ~UV_READABLE;
|
141
143
|
}
|
142
144
|
if (events & UV_WRITABLE) {
|
143
145
|
GPR_ASSERT(polled_fd->write_closure_ != nullptr);
|
144
|
-
|
146
|
+
grpc_core::ExecCtx::Run(DEBUG_LOCATION, polled_fd->write_closure_, error);
|
145
147
|
polled_fd->write_closure_ = nullptr;
|
146
148
|
polled_fd->poll_events_ &= ~UV_WRITABLE;
|
147
149
|
}
|
@@ -152,7 +154,7 @@ void ares_uv_poll_cb(uv_poll_t* handle, int status, int events) {
|
|
152
154
|
grpc_core::ExecCtx exec_ctx;
|
153
155
|
GrpcPolledFdLibuv* polled_fd =
|
154
156
|
reinterpret_cast<GrpcPolledFdLibuv*>(handle->data);
|
155
|
-
AresUvPollCbArg* arg =
|
157
|
+
AresUvPollCbArg* arg = new AresUvPollCbArg(handle, status, events);
|
156
158
|
polled_fd->combiner_->Run(
|
157
159
|
GRPC_CLOSURE_CREATE(ares_uv_poll_cb_locked, arg, nullptr),
|
158
160
|
GRPC_ERROR_NONE);
|
@@ -163,13 +165,14 @@ class GrpcPolledFdFactoryLibuv : public GrpcPolledFdFactory {
|
|
163
165
|
GrpcPolledFd* NewGrpcPolledFdLocked(ares_socket_t as,
|
164
166
|
grpc_pollset_set* driver_pollset_set,
|
165
167
|
Combiner* combiner) override {
|
166
|
-
return
|
168
|
+
return new GrpcPolledFdLibuv(as, combiner);
|
167
169
|
}
|
168
170
|
|
169
171
|
void ConfigureAresChannelLocked(ares_channel channel) override {}
|
170
172
|
};
|
171
173
|
|
172
|
-
|
174
|
+
std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(
|
175
|
+
Combiner* combiner) {
|
173
176
|
return MakeUnique<GrpcPolledFdFactoryLibuv>();
|
174
177
|
}
|
175
178
|
|