grpc 1.18.0 → 1.22.0
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 +4731 -7404
- data/etc/roots.pem +146 -0
- data/include/grpc/grpc.h +11 -6
- data/include/grpc/grpc_security.h +297 -4
- data/include/grpc/grpc_security_constants.h +1 -1
- data/include/grpc/impl/codegen/byte_buffer.h +13 -0
- data/include/grpc/impl/codegen/gpr_types.h +1 -1
- data/include/grpc/impl/codegen/grpc_types.h +30 -7
- data/include/grpc/impl/codegen/port_platform.h +88 -7
- data/include/grpc/impl/codegen/slice.h +2 -22
- data/include/grpc/impl/codegen/status.h +2 -1
- data/include/grpc/impl/codegen/sync_posix.h +18 -0
- data/include/grpc/slice.h +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +21 -16
- data/src/core/ext/filters/client_channel/backup_poller.h +8 -2
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +3 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +2435 -1557
- data/src/core/ext/filters/client_channel/client_channel.h +2 -10
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +6 -89
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +8 -33
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +22 -34
- data/src/core/ext/filters/client_channel/client_channel_factory.h +19 -38
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +9 -11
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +179 -0
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +68 -0
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +59 -55
- data/src/core/ext/filters/client_channel/health/health_check_client.h +20 -9
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +146 -157
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +29 -32
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +844 -859
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +3 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +2 -6
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +14 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +16 -12
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +185 -312
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +143 -375
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +192 -245
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +1554 -955
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_secure.cc +0 -43
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc +14 -10
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h +2 -2
- data/src/core/ext/filters/client_channel/lb_policy.cc +115 -22
- data/src/core/ext/filters/client_channel/lb_policy.h +260 -129
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +5 -2
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +107 -4
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +10 -3
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +96 -0
- data/src/core/ext/filters/client_channel/local_subchannel_pool.h +56 -0
- data/src/core/ext/filters/client_channel/parse_address.cc +24 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +121 -122
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +84 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +3 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +179 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +24 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +111 -47
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +7 -13
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +39 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_posix.cc +0 -6
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +2 -64
- data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_selection.cc +28 -0
- data/src/core/{lib/iomgr/network_status_tracker.cc → ext/filters/client_channel/resolver/dns/dns_resolver_selection.h} +8 -15
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +36 -82
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +111 -72
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +13 -8
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +28 -63
- data/src/core/ext/filters/client_channel/resolver.cc +54 -1
- data/src/core/ext/filters/client_channel/resolver.h +52 -23
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -1
- data/src/core/ext/filters/client_channel/resolver_registry.cc +5 -2
- data/src/core/ext/filters/client_channel/resolver_registry.h +5 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +368 -241
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +58 -76
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +543 -0
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +139 -0
- data/src/core/ext/filters/client_channel/server_address.cc +4 -54
- data/src/core/ext/filters/client_channel/server_address.h +1 -13
- data/src/core/ext/filters/client_channel/service_config.cc +329 -0
- data/src/core/ext/filters/client_channel/service_config.h +205 -0
- data/src/core/ext/filters/client_channel/subchannel.cc +803 -838
- data/src/core/ext/filters/client_channel/subchannel.h +295 -128
- data/src/core/ext/filters/client_channel/subchannel_interface.h +113 -0
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +97 -0
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +94 -0
- data/src/core/ext/filters/deadline/deadline_filter.cc +3 -4
- data/src/core/ext/filters/deadline/deadline_filter.h +3 -2
- data/src/core/ext/filters/http/client/http_client_filter.cc +7 -5
- data/src/core/ext/filters/http/client/http_client_filter.h +1 -1
- data/src/core/ext/filters/http/client_authority_filter.cc +6 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +4 -3
- data/src/core/ext/filters/http/server/http_server_filter.cc +18 -12
- data/src/core/ext/filters/max_age/max_age_filter.cc +5 -2
- data/src/core/ext/filters/message_size/message_size_filter.cc +119 -77
- data/src/core/ext/filters/message_size/message_size_filter.h +33 -0
- data/src/core/ext/transport/chttp2/alpn/alpn.h +1 -1
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +13 -12
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +45 -47
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +134 -143
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +68 -21
- data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_decoder.h +4 -4
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/bin_encoder.h +4 -3
- data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +9 -7
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +156 -94
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +33 -37
- data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -5
- data/src/core/ext/transport/chttp2/transport/frame_goaway.h +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -4
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +8 -6
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +6 -4
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +7 -6
- data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +74 -55
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +33 -11
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -2
- data/src/core/ext/transport/chttp2/transport/hpack_table.cc +7 -14
- data/src/core/ext/transport/chttp2/transport/hpack_table.h +10 -1
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +9 -5
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +9 -3
- data/src/core/ext/transport/chttp2/transport/internal.h +43 -30
- data/src/core/ext/transport/chttp2/transport/parsing.cc +52 -70
- data/src/core/ext/transport/chttp2/transport/stream_lists.cc +3 -3
- data/src/core/ext/transport/chttp2/transport/writing.cc +70 -33
- data/src/core/ext/transport/inproc/inproc_transport.cc +26 -18
- data/src/core/lib/channel/channel_args.cc +2 -101
- data/src/core/lib/channel/channel_args.h +3 -37
- data/src/core/lib/channel/channel_stack.h +10 -6
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channel_trace.h +4 -4
- data/src/core/lib/channel/channelz.cc +168 -38
- data/src/core/lib/channel/channelz.h +40 -44
- data/src/core/lib/channel/channelz_registry.cc +75 -107
- data/src/core/lib/channel/channelz_registry.h +10 -28
- data/src/core/lib/channel/connected_channel.cc +2 -2
- data/src/core/lib/channel/context.h +2 -2
- data/src/core/lib/channel/handshaker.cc +151 -218
- data/src/core/lib/channel/handshaker.h +110 -101
- data/src/core/lib/channel/handshaker_factory.h +11 -19
- data/src/core/lib/channel/handshaker_registry.cc +67 -51
- data/src/core/lib/channel/handshaker_registry.h +21 -16
- data/src/core/lib/compression/algorithm_metadata.h +3 -3
- data/src/core/lib/compression/compression.cc +14 -9
- data/src/core/lib/compression/compression_args.cc +127 -0
- data/src/core/lib/compression/compression_args.h +55 -0
- data/src/core/lib/compression/compression_internal.cc +16 -12
- data/src/core/lib/compression/compression_internal.h +1 -1
- data/src/core/lib/compression/stream_compression.cc +3 -2
- data/src/core/lib/compression/stream_compression.h +2 -2
- data/src/core/lib/compression/stream_compression_gzip.cc +9 -9
- data/src/core/lib/debug/trace.cc +13 -7
- data/src/core/lib/debug/trace.h +14 -1
- data/src/core/lib/gpr/arena.h +13 -9
- data/src/core/lib/gpr/cpu_posix.cc +5 -3
- data/src/core/lib/gpr/env.h +3 -6
- data/src/core/lib/gpr/env_linux.cc +6 -1
- data/src/core/lib/gpr/env_posix.cc +5 -0
- data/src/core/lib/gpr/env_windows.cc +7 -5
- data/src/core/lib/gpr/log.cc +9 -13
- data/src/core/lib/gpr/log_posix.cc +2 -1
- data/src/core/lib/gpr/string.cc +20 -7
- data/src/core/lib/gpr/string.h +10 -3
- data/src/core/lib/gpr/sync_posix.cc +65 -4
- data/src/core/lib/gpr/time.cc +8 -0
- data/src/core/lib/gpr/time_posix.cc +21 -2
- data/src/core/lib/gprpp/arena.cc +103 -0
- data/src/core/lib/gprpp/arena.h +121 -0
- data/src/core/lib/gprpp/atomic.h +75 -5
- data/src/core/lib/gprpp/fork.cc +13 -32
- data/src/core/lib/gprpp/fork.h +5 -1
- data/src/core/lib/gprpp/global_config.h +96 -0
- data/src/core/lib/gprpp/global_config_custom.h +29 -0
- data/src/core/lib/gprpp/global_config_env.cc +135 -0
- data/src/core/lib/gprpp/global_config_env.h +131 -0
- data/src/core/lib/gprpp/global_config_generic.h +44 -0
- data/src/core/lib/gprpp/inlined_vector.h +8 -0
- data/src/core/lib/gprpp/map.h +436 -0
- data/src/core/lib/gprpp/memory.h +2 -2
- data/src/core/lib/gprpp/optional.h +48 -0
- data/src/core/lib/gprpp/orphanable.h +6 -5
- data/src/core/lib/gprpp/{mutex_lock.h → pair.h} +15 -19
- data/src/core/lib/gprpp/ref_counted.h +36 -17
- data/src/core/lib/gprpp/sync.h +126 -0
- data/src/core/lib/gprpp/thd.h +42 -7
- data/src/core/lib/gprpp/thd_posix.cc +31 -13
- data/src/core/lib/gprpp/thd_windows.cc +47 -34
- data/src/core/lib/http/httpcli.cc +6 -5
- data/src/core/lib/http/httpcli_security_connector.cc +13 -15
- data/src/core/lib/http/parser.cc +3 -2
- data/src/core/lib/http/parser.h +2 -1
- data/src/core/lib/iomgr/buffer_list.cc +182 -24
- data/src/core/lib/iomgr/buffer_list.h +72 -10
- data/src/core/lib/iomgr/call_combiner.cc +84 -90
- data/src/core/lib/iomgr/call_combiner.h +75 -82
- data/src/core/lib/iomgr/cfstream_handle.cc +203 -0
- data/src/core/lib/iomgr/cfstream_handle.h +86 -0
- data/src/core/lib/iomgr/combiner.cc +11 -3
- data/src/core/lib/iomgr/combiner.h +1 -1
- data/src/core/lib/iomgr/endpoint.cc +2 -2
- data/src/core/lib/iomgr/endpoint.h +3 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +375 -0
- data/src/core/lib/iomgr/endpoint_cfstream.h +49 -0
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/error.cc +21 -17
- data/src/core/lib/iomgr/error.h +36 -6
- data/src/core/lib/iomgr/error_cfstream.cc +52 -0
- data/src/core/lib/iomgr/error_cfstream.h +31 -0
- data/src/core/lib/iomgr/error_internal.h +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +44 -28
- data/src/core/lib/iomgr/ev_epollex_linux.cc +173 -194
- data/src/core/lib/iomgr/ev_poll_posix.cc +16 -487
- data/src/core/lib/iomgr/ev_posix.cc +29 -19
- data/src/core/lib/iomgr/ev_posix.h +19 -3
- data/src/core/lib/iomgr/ev_windows.cc +2 -2
- data/src/core/lib/iomgr/exec_ctx.cc +1 -0
- data/src/core/lib/iomgr/exec_ctx.h +137 -8
- data/src/core/lib/iomgr/executor.cc +147 -95
- data/src/core/lib/iomgr/executor.h +55 -49
- data/src/core/lib/iomgr/fork_posix.cc +6 -5
- data/src/core/lib/{gprpp/atomic_with_std.h → iomgr/grpc_if_nametoindex.h} +8 -13
- data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +42 -0
- data/src/core/lib/iomgr/{network_status_tracker.h → grpc_if_nametoindex_unsupported.cc} +15 -9
- data/src/core/lib/iomgr/internal_errqueue.cc +3 -5
- data/src/core/lib/iomgr/internal_errqueue.h +105 -3
- data/src/core/lib/iomgr/iomgr.cc +20 -13
- data/src/core/lib/iomgr/iomgr.h +15 -0
- data/src/core/lib/iomgr/iomgr_custom.cc +17 -3
- data/src/core/lib/iomgr/iomgr_custom.h +2 -0
- data/src/core/lib/iomgr/iomgr_internal.cc +10 -0
- data/src/core/lib/iomgr/iomgr_internal.h +12 -0
- data/src/core/lib/iomgr/iomgr_posix.cc +19 -2
- data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +93 -0
- data/src/core/lib/iomgr/iomgr_windows.cc +18 -2
- data/src/core/lib/iomgr/lockfree_event.cc +4 -4
- data/src/core/lib/iomgr/port.h +35 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +4 -3
- data/src/core/lib/iomgr/resolve_address_windows.cc +2 -1
- data/src/core/lib/iomgr/resource_quota.cc +40 -37
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +6 -2
- data/src/core/lib/iomgr/socket_windows.cc +19 -0
- data/src/core/lib/iomgr/socket_windows.h +8 -0
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +216 -0
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +3 -3
- data/src/core/lib/iomgr/tcp_client_windows.cc +7 -5
- data/src/core/lib/iomgr/tcp_custom.cc +10 -14
- data/src/core/lib/iomgr/tcp_posix.cc +256 -140
- data/src/core/lib/iomgr/tcp_server.cc +5 -0
- data/src/core/lib/iomgr/tcp_server.h +24 -0
- data/src/core/lib/iomgr/tcp_server_custom.cc +14 -12
- data/src/core/lib/iomgr/tcp_server_posix.cc +86 -12
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
- data/src/core/lib/iomgr/tcp_server_windows.cc +13 -11
- data/src/core/lib/iomgr/tcp_uv.cc +5 -7
- data/src/core/lib/iomgr/tcp_windows.cc +8 -14
- data/src/core/lib/iomgr/timer.h +2 -1
- data/src/core/lib/iomgr/timer_generic.cc +16 -16
- data/src/core/lib/iomgr/timer_manager.cc +20 -11
- data/src/core/lib/iomgr/udp_server.cc +8 -6
- data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -19
- data/src/core/lib/json/json.cc +1 -4
- data/src/core/lib/profiling/basic_timers.cc +10 -4
- data/src/core/lib/security/context/security_context.cc +6 -7
- data/src/core/lib/security/context/security_context.h +3 -4
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +1 -1
- data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
- data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -0
- data/src/core/lib/security/credentials/credentials.h +9 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +15 -3
- data/src/core/lib/security/credentials/google_default/google_default_credentials.h +2 -0
- data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +2 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +10 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +3 -3
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +9 -8
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +20 -2
- data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +192 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +210 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +129 -0
- data/src/core/lib/security/credentials/tls/spiffe_credentials.h +62 -0
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +10 -8
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +13 -12
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +7 -5
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +10 -8
- data/src/core/lib/security/security_connector/security_connector.cc +0 -1
- data/src/core/lib/security/security_connector/security_connector.h +3 -3
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +39 -38
- data/src/core/lib/security/security_connector/ssl_utils.cc +164 -26
- data/src/core/lib/security/security_connector/ssl_utils.h +70 -1
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +426 -0
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.h +122 -0
- data/src/core/lib/security/transport/auth_filters.h +5 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +55 -50
- data/src/core/lib/security/transport/secure_endpoint.cc +6 -6
- data/src/core/lib/security/transport/security_handshaker.cc +271 -303
- data/src/core/lib/security/transport/security_handshaker.h +11 -2
- data/src/core/lib/security/transport/server_auth_filter.cc +3 -3
- data/src/core/lib/slice/b64.h +2 -2
- data/src/core/lib/slice/percent_encoding.cc +3 -3
- data/src/core/lib/slice/percent_encoding.h +3 -3
- data/src/core/lib/slice/slice.cc +174 -122
- data/src/core/lib/slice/slice_buffer.cc +54 -21
- data/src/core/lib/slice/slice_hash_table.h +4 -4
- data/src/core/lib/slice/slice_intern.cc +49 -107
- data/src/core/lib/slice/slice_internal.h +264 -3
- data/src/core/lib/slice/slice_string_helpers.cc +10 -1
- data/src/core/lib/slice/slice_string_helpers.h +3 -1
- data/src/core/lib/slice/slice_utils.h +50 -0
- data/src/core/lib/slice/slice_weak_hash_table.h +6 -6
- data/src/core/lib/surface/api_trace.h +1 -1
- data/src/core/lib/surface/byte_buffer_reader.cc +17 -0
- data/src/core/lib/surface/call.cc +67 -46
- data/src/core/lib/surface/call.h +7 -2
- data/src/core/lib/surface/call_details.cc +0 -1
- data/src/core/lib/surface/channel.cc +89 -97
- data/src/core/lib/surface/channel.h +60 -6
- data/src/core/lib/surface/channel_init.h +5 -0
- data/src/core/lib/surface/completion_queue.cc +221 -216
- data/src/core/lib/surface/completion_queue.h +2 -1
- data/src/core/lib/surface/init.cc +82 -33
- data/src/core/lib/surface/init.h +1 -0
- data/src/core/lib/surface/init_secure.cc +1 -1
- data/src/core/lib/surface/lame_client.cc +5 -7
- data/src/core/lib/surface/server.cc +42 -47
- data/src/core/lib/surface/validate_metadata.cc +14 -8
- data/src/core/lib/surface/validate_metadata.h +13 -2
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/lib/transport/bdp_estimator.cc +3 -3
- data/src/core/lib/transport/bdp_estimator.h +2 -2
- data/src/core/lib/transport/connectivity_state.cc +10 -40
- data/src/core/lib/transport/connectivity_state.h +0 -8
- data/src/core/lib/transport/error_utils.cc +12 -0
- data/src/core/lib/transport/metadata.cc +258 -267
- data/src/core/lib/transport/metadata.h +227 -16
- data/src/core/lib/transport/metadata_batch.cc +1 -1
- data/src/core/lib/transport/metadata_batch.h +1 -1
- data/src/core/lib/transport/static_metadata.cc +477 -399
- data/src/core/lib/transport/static_metadata.h +273 -182
- data/src/core/lib/transport/status_metadata.cc +3 -3
- data/src/core/lib/transport/timeout_encoding.cc +1 -1
- data/src/core/lib/transport/timeout_encoding.h +1 -1
- data/src/core/lib/transport/transport.cc +39 -72
- data/src/core/lib/transport/transport.h +59 -24
- data/src/core/lib/transport/transport_impl.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -3
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +1 -1
- data/src/core/tsi/alts/handshaker/alts_shared_resource.h +1 -1
- data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +4 -3
- data/src/core/tsi/alts/handshaker/transport_security_common_api.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +1 -1
- data/src/core/tsi/fake_transport_security.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +12 -10
- data/src/core/tsi/ssl_transport_security.h +24 -4
- data/src/ruby/bin/math_pb.rb +18 -16
- data/src/ruby/ext/grpc/extconf.rb +12 -4
- data/src/ruby/ext/grpc/rb_call_credentials.c +8 -5
- data/src/ruby/ext/grpc/rb_channel.c +14 -10
- data/src/ruby/ext/grpc/rb_channel_credentials.c +8 -4
- data/src/ruby/ext/grpc/rb_compression_options.c +9 -7
- data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc.c +23 -24
- data/src/ruby/ext/grpc/rb_grpc.h +4 -2
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +24 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +36 -0
- data/src/ruby/ext/grpc/rb_server.c +8 -4
- data/src/ruby/lib/grpc/errors.rb +22 -3
- data/src/ruby/lib/grpc/generic/bidi_call.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/README.md +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +13 -10
- data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +18 -0
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +3 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +58 -56
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -0
- data/src/ruby/spec/errors_spec.rb +141 -0
- data/third_party/cares/cares/ares.h +12 -0
- data/third_party/cares/cares/ares_create_query.c +5 -1
- data/third_party/cares/cares/ares_data.c +74 -73
- data/third_party/cares/cares/ares_destroy.c +6 -1
- data/third_party/cares/cares/ares_gethostbyaddr.c +5 -5
- data/third_party/cares/cares/ares_gethostbyname.c +15 -4
- data/third_party/cares/cares/ares_getnameinfo.c +11 -0
- data/third_party/cares/cares/ares_init.c +274 -173
- data/third_party/cares/cares/ares_library_init.c +21 -3
- data/third_party/cares/cares/ares_options.c +6 -2
- data/third_party/cares/cares/ares_parse_naptr_reply.c +7 -6
- data/third_party/cares/cares/ares_parse_ptr_reply.c +4 -2
- data/third_party/cares/cares/ares_platform.c +7 -0
- data/third_party/cares/cares/ares_private.h +19 -11
- data/third_party/cares/cares/ares_process.c +27 -2
- data/third_party/cares/cares/ares_rules.h +1 -1
- data/third_party/cares/cares/ares_search.c +7 -0
- data/third_party/cares/cares/ares_send.c +6 -0
- data/third_party/cares/cares/ares_strsplit.c +174 -0
- data/third_party/cares/cares/ares_strsplit.h +43 -0
- data/third_party/cares/cares/ares_version.h +4 -4
- data/third_party/cares/cares/config-win32.h +1 -1
- data/third_party/cares/cares/inet_ntop.c +2 -3
- data/third_party/cares/config_darwin/ares_config.h +3 -0
- data/third_party/cares/config_freebsd/ares_config.h +3 -0
- data/third_party/cares/config_linux/ares_config.h +3 -0
- data/third_party/cares/config_openbsd/ares_config.h +3 -0
- metadata +83 -48
- data/src/core/ext/filters/client_channel/request_routing.cc +0 -936
- data/src/core/ext/filters/client_channel/request_routing.h +0 -177
- data/src/core/ext/filters/client_channel/subchannel_index.cc +0 -248
- data/src/core/ext/filters/client_channel/subchannel_index.h +0 -76
- data/src/core/lib/channel/handshaker_factory.cc +0 -42
- data/src/core/lib/gpr/arena.cc +0 -192
- data/src/core/lib/gprpp/atomic_with_atm.h +0 -57
- data/src/core/lib/iomgr/wakeup_fd_cv.cc +0 -107
- data/src/core/lib/iomgr/wakeup_fd_cv.h +0 -69
- data/src/core/lib/transport/service_config.cc +0 -106
- data/src/core/lib/transport/service_config.h +0 -249
@@ -27,7 +27,10 @@
|
|
27
27
|
|
28
28
|
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
|
29
29
|
#include "src/core/ext/filters/client_channel/server_address.h"
|
30
|
+
// TODO(roth): Should not need the include of subchannel.h here, since
|
31
|
+
// that implementation should be hidden from the LB policy API.
|
30
32
|
#include "src/core/ext/filters/client_channel/subchannel.h"
|
33
|
+
#include "src/core/ext/filters/client_channel/subchannel_interface.h"
|
31
34
|
#include "src/core/lib/channel/channel_args.h"
|
32
35
|
#include "src/core/lib/debug/trace.h"
|
33
36
|
#include "src/core/lib/gprpp/abstract.h"
|
@@ -51,7 +54,7 @@ class MySubchannelData
|
|
51
54
|
: public SubchannelData<MySubchannelList, MySubchannelData> {
|
52
55
|
public:
|
53
56
|
void ProcessConnectivityChangeLocked(
|
54
|
-
grpc_connectivity_state connectivity_state
|
57
|
+
grpc_connectivity_state connectivity_state) override {
|
55
58
|
// ...code to handle connectivity changes...
|
56
59
|
}
|
57
60
|
};
|
@@ -88,25 +91,23 @@ class SubchannelData {
|
|
88
91
|
}
|
89
92
|
|
90
93
|
// Returns a pointer to the subchannel.
|
91
|
-
|
94
|
+
SubchannelInterface* subchannel() const { return subchannel_.get(); }
|
92
95
|
|
93
96
|
// Returns the connected subchannel. Will be null if the subchannel
|
94
97
|
// is not connected.
|
95
|
-
|
98
|
+
ConnectedSubchannelInterface* connected_subchannel() const {
|
96
99
|
return connected_subchannel_.get();
|
97
100
|
}
|
98
101
|
|
99
102
|
// Synchronously checks the subchannel's connectivity state.
|
100
103
|
// Must not be called while there is a connectivity notification
|
101
|
-
// pending (i.e., between calling StartConnectivityWatchLocked()
|
102
|
-
//
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
UpdateConnectedSubchannelLocked();
|
109
|
-
return pending_connectivity_state_unsafe_;
|
104
|
+
// pending (i.e., between calling StartConnectivityWatchLocked() and
|
105
|
+
// calling CancelConnectivityWatchLocked()).
|
106
|
+
grpc_connectivity_state CheckConnectivityStateLocked() {
|
107
|
+
GPR_ASSERT(pending_watcher_ == nullptr);
|
108
|
+
connectivity_state_ =
|
109
|
+
subchannel()->CheckConnectivityState(&connected_subchannel_);
|
110
|
+
return connectivity_state_;
|
110
111
|
}
|
111
112
|
|
112
113
|
// Resets the connection backoff.
|
@@ -115,23 +116,11 @@ class SubchannelData {
|
|
115
116
|
void ResetBackoffLocked();
|
116
117
|
|
117
118
|
// Starts watching the connectivity state of the subchannel.
|
118
|
-
// ProcessConnectivityChangeLocked() will be called
|
119
|
+
// ProcessConnectivityChangeLocked() will be called whenever the
|
119
120
|
// connectivity state changes.
|
120
121
|
void StartConnectivityWatchLocked();
|
121
122
|
|
122
|
-
// Renews watching the connectivity state of the subchannel.
|
123
|
-
void RenewConnectivityWatchLocked();
|
124
|
-
|
125
|
-
// Stops watching the connectivity state of the subchannel.
|
126
|
-
void StopConnectivityWatchLocked();
|
127
|
-
|
128
123
|
// Cancels watching the connectivity state of the subchannel.
|
129
|
-
// Must be called only while there is a connectivity notification
|
130
|
-
// pending (i.e., between calling StartConnectivityWatchLocked() or
|
131
|
-
// RenewConnectivityWatchLocked() and the resulting invocation of
|
132
|
-
// ProcessConnectivityChangeLocked()).
|
133
|
-
// From within ProcessConnectivityChangeLocked(), use
|
134
|
-
// StopConnectivityWatchLocked() instead.
|
135
124
|
void CancelConnectivityWatchLocked(const char* reason);
|
136
125
|
|
137
126
|
// Cancels any pending connectivity watch and unrefs the subchannel.
|
@@ -142,45 +131,81 @@ class SubchannelData {
|
|
142
131
|
protected:
|
143
132
|
SubchannelData(
|
144
133
|
SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list,
|
145
|
-
const ServerAddress& address,
|
146
|
-
|
134
|
+
const ServerAddress& address,
|
135
|
+
RefCountedPtr<SubchannelInterface> subchannel);
|
147
136
|
|
148
137
|
virtual ~SubchannelData();
|
149
138
|
|
150
|
-
// After StartConnectivityWatchLocked()
|
151
|
-
//
|
152
|
-
//
|
153
|
-
// Implementations must invoke either RenewConnectivityWatchLocked() or
|
154
|
-
// StopConnectivityWatchLocked() before returning.
|
139
|
+
// After StartConnectivityWatchLocked() is called, this method will be
|
140
|
+
// invoked whenever the subchannel's connectivity state changes.
|
141
|
+
// To stop watching, use CancelConnectivityWatchLocked().
|
155
142
|
virtual void ProcessConnectivityChangeLocked(
|
156
|
-
grpc_connectivity_state connectivity_state
|
157
|
-
grpc_error* error) GRPC_ABSTRACT;
|
158
|
-
|
159
|
-
// Unrefs the subchannel.
|
160
|
-
void UnrefSubchannelLocked(const char* reason);
|
143
|
+
grpc_connectivity_state connectivity_state) GRPC_ABSTRACT;
|
161
144
|
|
162
145
|
private:
|
163
|
-
//
|
164
|
-
|
165
|
-
|
146
|
+
// Watcher for subchannel connectivity state.
|
147
|
+
class Watcher : public SubchannelInterface::ConnectivityStateWatcher {
|
148
|
+
public:
|
149
|
+
Watcher(
|
150
|
+
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data,
|
151
|
+
RefCountedPtr<SubchannelListType> subchannel_list)
|
152
|
+
: subchannel_data_(subchannel_data),
|
153
|
+
subchannel_list_(std::move(subchannel_list)) {}
|
154
|
+
|
155
|
+
~Watcher() { subchannel_list_.reset(DEBUG_LOCATION, "Watcher dtor"); }
|
156
|
+
|
157
|
+
void OnConnectivityStateChange(grpc_connectivity_state new_state,
|
158
|
+
RefCountedPtr<ConnectedSubchannelInterface>
|
159
|
+
connected_subchannel) override;
|
160
|
+
|
161
|
+
grpc_pollset_set* interested_parties() override {
|
162
|
+
return subchannel_list_->policy()->interested_parties();
|
163
|
+
}
|
164
|
+
|
165
|
+
private:
|
166
|
+
// A fire-and-forget class that bounces into the combiner to process
|
167
|
+
// a connectivity state update.
|
168
|
+
class Updater {
|
169
|
+
public:
|
170
|
+
Updater(
|
171
|
+
SubchannelData<SubchannelListType, SubchannelDataType>*
|
172
|
+
subchannel_data,
|
173
|
+
RefCountedPtr<SubchannelList<SubchannelListType, SubchannelDataType>>
|
174
|
+
subchannel_list,
|
175
|
+
grpc_connectivity_state state,
|
176
|
+
RefCountedPtr<ConnectedSubchannelInterface> connected_subchannel);
|
177
|
+
|
178
|
+
~Updater() {
|
179
|
+
subchannel_list_.reset(DEBUG_LOCATION, "Watcher::Updater dtor");
|
180
|
+
}
|
181
|
+
|
182
|
+
private:
|
183
|
+
static void OnUpdateLocked(void* arg, grpc_error* error);
|
166
184
|
|
167
|
-
|
185
|
+
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data_;
|
186
|
+
RefCountedPtr<SubchannelList<SubchannelListType, SubchannelDataType>>
|
187
|
+
subchannel_list_;
|
188
|
+
const grpc_connectivity_state state_;
|
189
|
+
RefCountedPtr<ConnectedSubchannelInterface> connected_subchannel_;
|
190
|
+
grpc_closure closure_;
|
191
|
+
};
|
192
|
+
|
193
|
+
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data_;
|
194
|
+
RefCountedPtr<SubchannelListType> subchannel_list_;
|
195
|
+
};
|
196
|
+
|
197
|
+
// Unrefs the subchannel.
|
198
|
+
void UnrefSubchannelLocked(const char* reason);
|
168
199
|
|
169
200
|
// Backpointer to owning subchannel list. Not owned.
|
170
201
|
SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list_;
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
// Is a connectivity notification pending?
|
179
|
-
bool connectivity_notification_pending_ = false;
|
180
|
-
// Connectivity state to be updated by
|
181
|
-
// grpc_subchannel_notify_on_state_change(), not guarded by
|
182
|
-
// the combiner.
|
183
|
-
grpc_connectivity_state pending_connectivity_state_unsafe_;
|
202
|
+
// The subchannel.
|
203
|
+
RefCountedPtr<SubchannelInterface> subchannel_;
|
204
|
+
// Will be non-null when the subchannel's state is being watched.
|
205
|
+
SubchannelInterface::ConnectivityStateWatcher* pending_watcher_ = nullptr;
|
206
|
+
// Data updated by the watcher.
|
207
|
+
grpc_connectivity_state connectivity_state_;
|
208
|
+
RefCountedPtr<ConnectedSubchannelInterface> connected_subchannel_;
|
184
209
|
};
|
185
210
|
|
186
211
|
// A list of subchannels.
|
@@ -198,23 +223,9 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|
198
223
|
// Returns true if the subchannel list is shutting down.
|
199
224
|
bool shutting_down() const { return shutting_down_; }
|
200
225
|
|
201
|
-
// Populates refs_list with the uuids of this SubchannelLists's subchannels.
|
202
|
-
void PopulateChildRefsList(channelz::ChildRefsList* refs_list) {
|
203
|
-
for (size_t i = 0; i < subchannels_.size(); ++i) {
|
204
|
-
if (subchannels_[i].subchannel() != nullptr) {
|
205
|
-
grpc_core::channelz::SubchannelNode* subchannel_node =
|
206
|
-
grpc_subchannel_get_channelz_node(subchannels_[i].subchannel());
|
207
|
-
if (subchannel_node != nullptr) {
|
208
|
-
refs_list->push_back(subchannel_node->uuid());
|
209
|
-
}
|
210
|
-
}
|
211
|
-
}
|
212
|
-
}
|
213
|
-
|
214
226
|
// Accessors.
|
215
227
|
LoadBalancingPolicy* policy() const { return policy_; }
|
216
228
|
TraceFlag* tracer() const { return tracer_; }
|
217
|
-
bool inhibit_health_checking() const { return inhibit_health_checking_; }
|
218
229
|
|
219
230
|
// Resets connection backoff of all subchannels.
|
220
231
|
// TODO(roth): We will probably need to rethink this as part of moving
|
@@ -232,7 +243,7 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|
232
243
|
protected:
|
233
244
|
SubchannelList(LoadBalancingPolicy* policy, TraceFlag* tracer,
|
234
245
|
const ServerAddressList& addresses, grpc_combiner* combiner,
|
235
|
-
|
246
|
+
LoadBalancingPolicy::ChannelControlHelper* helper,
|
236
247
|
const grpc_channel_args& args);
|
237
248
|
|
238
249
|
virtual ~SubchannelList();
|
@@ -252,8 +263,6 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|
252
263
|
|
253
264
|
TraceFlag* tracer_;
|
254
265
|
|
255
|
-
bool inhibit_health_checking_;
|
256
|
-
|
257
266
|
grpc_combiner* combiner_;
|
258
267
|
|
259
268
|
// The list of subchannels.
|
@@ -269,6 +278,67 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|
269
278
|
// implementation -- no user-servicable parts below
|
270
279
|
//
|
271
280
|
|
281
|
+
//
|
282
|
+
// SubchannelData::Watcher
|
283
|
+
//
|
284
|
+
|
285
|
+
template <typename SubchannelListType, typename SubchannelDataType>
|
286
|
+
void SubchannelData<SubchannelListType, SubchannelDataType>::Watcher::
|
287
|
+
OnConnectivityStateChange(
|
288
|
+
grpc_connectivity_state new_state,
|
289
|
+
RefCountedPtr<ConnectedSubchannelInterface> connected_subchannel) {
|
290
|
+
// Will delete itself.
|
291
|
+
New<Updater>(subchannel_data_,
|
292
|
+
subchannel_list_->Ref(DEBUG_LOCATION, "Watcher::Updater"),
|
293
|
+
new_state, std::move(connected_subchannel));
|
294
|
+
}
|
295
|
+
|
296
|
+
template <typename SubchannelListType, typename SubchannelDataType>
|
297
|
+
SubchannelData<SubchannelListType, SubchannelDataType>::Watcher::Updater::
|
298
|
+
Updater(
|
299
|
+
SubchannelData<SubchannelListType, SubchannelDataType>* subchannel_data,
|
300
|
+
RefCountedPtr<SubchannelList<SubchannelListType, SubchannelDataType>>
|
301
|
+
subchannel_list,
|
302
|
+
grpc_connectivity_state state,
|
303
|
+
RefCountedPtr<ConnectedSubchannelInterface> connected_subchannel)
|
304
|
+
: subchannel_data_(subchannel_data),
|
305
|
+
subchannel_list_(std::move(subchannel_list)),
|
306
|
+
state_(state),
|
307
|
+
connected_subchannel_(std::move(connected_subchannel)) {
|
308
|
+
GRPC_CLOSURE_INIT(&closure_, &OnUpdateLocked, this,
|
309
|
+
grpc_combiner_scheduler(subchannel_list_->combiner_));
|
310
|
+
GRPC_CLOSURE_SCHED(&closure_, GRPC_ERROR_NONE);
|
311
|
+
}
|
312
|
+
|
313
|
+
template <typename SubchannelListType, typename SubchannelDataType>
|
314
|
+
void SubchannelData<SubchannelListType, SubchannelDataType>::Watcher::Updater::
|
315
|
+
OnUpdateLocked(void* arg, grpc_error* error) {
|
316
|
+
Updater* self = static_cast<Updater*>(arg);
|
317
|
+
SubchannelData* sd = self->subchannel_data_;
|
318
|
+
if (GRPC_TRACE_FLAG_ENABLED(*sd->subchannel_list_->tracer())) {
|
319
|
+
gpr_log(GPR_INFO,
|
320
|
+
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
321
|
+
" (subchannel %p): connectivity changed: state=%s, "
|
322
|
+
"connected_subchannel=%p, shutting_down=%d, pending_watcher=%p",
|
323
|
+
sd->subchannel_list_->tracer()->name(),
|
324
|
+
sd->subchannel_list_->policy(), sd->subchannel_list_, sd->Index(),
|
325
|
+
sd->subchannel_list_->num_subchannels(), sd->subchannel_.get(),
|
326
|
+
grpc_connectivity_state_name(self->state_),
|
327
|
+
self->connected_subchannel_.get(),
|
328
|
+
sd->subchannel_list_->shutting_down(), sd->pending_watcher_);
|
329
|
+
}
|
330
|
+
if (!sd->subchannel_list_->shutting_down() &&
|
331
|
+
sd->pending_watcher_ != nullptr) {
|
332
|
+
sd->connectivity_state_ = self->state_;
|
333
|
+
// Get or release ref to connected subchannel.
|
334
|
+
sd->connected_subchannel_ = std::move(self->connected_subchannel_);
|
335
|
+
// Call the subclass's ProcessConnectivityChangeLocked() method.
|
336
|
+
sd->ProcessConnectivityChangeLocked(sd->connectivity_state_);
|
337
|
+
}
|
338
|
+
// Clean up.
|
339
|
+
Delete(self);
|
340
|
+
}
|
341
|
+
|
272
342
|
//
|
273
343
|
// SubchannelData
|
274
344
|
//
|
@@ -276,39 +346,31 @@ class SubchannelList : public InternallyRefCounted<SubchannelListType> {
|
|
276
346
|
template <typename SubchannelListType, typename SubchannelDataType>
|
277
347
|
SubchannelData<SubchannelListType, SubchannelDataType>::SubchannelData(
|
278
348
|
SubchannelList<SubchannelListType, SubchannelDataType>* subchannel_list,
|
279
|
-
const ServerAddress& address,
|
280
|
-
grpc_combiner* combiner)
|
349
|
+
const ServerAddress& address, RefCountedPtr<SubchannelInterface> subchannel)
|
281
350
|
: subchannel_list_(subchannel_list),
|
282
|
-
subchannel_(subchannel),
|
351
|
+
subchannel_(std::move(subchannel)),
|
283
352
|
// We assume that the current state is IDLE. If not, we'll get a
|
284
353
|
// callback telling us that.
|
285
|
-
|
286
|
-
GRPC_CLOSURE_INIT(
|
287
|
-
&connectivity_changed_closure_,
|
288
|
-
(&SubchannelData<SubchannelListType,
|
289
|
-
SubchannelDataType>::OnConnectivityChangedLocked),
|
290
|
-
this, grpc_combiner_scheduler(combiner));
|
291
|
-
}
|
354
|
+
connectivity_state_(GRPC_CHANNEL_IDLE) {}
|
292
355
|
|
293
356
|
template <typename SubchannelListType, typename SubchannelDataType>
|
294
357
|
SubchannelData<SubchannelListType, SubchannelDataType>::~SubchannelData() {
|
295
|
-
|
358
|
+
GPR_ASSERT(subchannel_ == nullptr);
|
296
359
|
}
|
297
360
|
|
298
361
|
template <typename SubchannelListType, typename SubchannelDataType>
|
299
362
|
void SubchannelData<SubchannelListType, SubchannelDataType>::
|
300
363
|
UnrefSubchannelLocked(const char* reason) {
|
301
364
|
if (subchannel_ != nullptr) {
|
302
|
-
if (subchannel_list_->tracer()
|
365
|
+
if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) {
|
303
366
|
gpr_log(GPR_INFO,
|
304
367
|
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
305
368
|
" (subchannel %p): unreffing subchannel",
|
306
369
|
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
307
370
|
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
308
|
-
subchannel_);
|
371
|
+
subchannel_.get());
|
309
372
|
}
|
310
|
-
|
311
|
-
subchannel_ = nullptr;
|
373
|
+
subchannel_.reset();
|
312
374
|
connected_subchannel_.reset();
|
313
375
|
}
|
314
376
|
}
|
@@ -317,166 +379,52 @@ template <typename SubchannelListType, typename SubchannelDataType>
|
|
317
379
|
void SubchannelData<SubchannelListType,
|
318
380
|
SubchannelDataType>::ResetBackoffLocked() {
|
319
381
|
if (subchannel_ != nullptr) {
|
320
|
-
|
382
|
+
subchannel_->ResetBackoff();
|
321
383
|
}
|
322
384
|
}
|
323
385
|
|
324
386
|
template <typename SubchannelListType, typename SubchannelDataType>
|
325
387
|
void SubchannelData<SubchannelListType,
|
326
388
|
SubchannelDataType>::StartConnectivityWatchLocked() {
|
327
|
-
if (subchannel_list_->tracer()
|
389
|
+
if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) {
|
328
390
|
gpr_log(GPR_INFO,
|
329
391
|
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
330
|
-
" (subchannel %p): starting watch
|
331
|
-
"notification (from %s)",
|
392
|
+
" (subchannel %p): starting watch (from %s)",
|
332
393
|
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
333
394
|
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
334
|
-
subchannel_,
|
335
|
-
grpc_connectivity_state_name(
|
395
|
+
subchannel_.get(),
|
396
|
+
grpc_connectivity_state_name(connectivity_state_));
|
336
397
|
}
|
337
|
-
GPR_ASSERT(
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
}
|
345
|
-
|
346
|
-
template <typename SubchannelListType, typename SubchannelDataType>
|
347
|
-
void SubchannelData<SubchannelListType,
|
348
|
-
SubchannelDataType>::RenewConnectivityWatchLocked() {
|
349
|
-
if (subchannel_list_->tracer()->enabled()) {
|
350
|
-
gpr_log(GPR_INFO,
|
351
|
-
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
352
|
-
" (subchannel %p): renewing watch: requesting connectivity change "
|
353
|
-
"notification (from %s)",
|
354
|
-
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
355
|
-
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
356
|
-
subchannel_,
|
357
|
-
grpc_connectivity_state_name(pending_connectivity_state_unsafe_));
|
358
|
-
}
|
359
|
-
GPR_ASSERT(connectivity_notification_pending_);
|
360
|
-
grpc_subchannel_notify_on_state_change(
|
361
|
-
subchannel_, subchannel_list_->policy()->interested_parties(),
|
362
|
-
&pending_connectivity_state_unsafe_, &connectivity_changed_closure_,
|
363
|
-
subchannel_list_->inhibit_health_checking());
|
364
|
-
}
|
365
|
-
|
366
|
-
template <typename SubchannelListType, typename SubchannelDataType>
|
367
|
-
void SubchannelData<SubchannelListType,
|
368
|
-
SubchannelDataType>::StopConnectivityWatchLocked() {
|
369
|
-
if (subchannel_list_->tracer()->enabled()) {
|
370
|
-
gpr_log(GPR_INFO,
|
371
|
-
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
372
|
-
" (subchannel %p): stopping connectivity watch",
|
373
|
-
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
374
|
-
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
375
|
-
subchannel_);
|
376
|
-
}
|
377
|
-
GPR_ASSERT(connectivity_notification_pending_);
|
378
|
-
connectivity_notification_pending_ = false;
|
379
|
-
subchannel_list()->Unref(DEBUG_LOCATION, "connectivity_watch");
|
398
|
+
GPR_ASSERT(pending_watcher_ == nullptr);
|
399
|
+
pending_watcher_ =
|
400
|
+
New<Watcher>(this, subchannel_list()->Ref(DEBUG_LOCATION, "Watcher"));
|
401
|
+
subchannel_->WatchConnectivityState(
|
402
|
+
connectivity_state_,
|
403
|
+
UniquePtr<SubchannelInterface::ConnectivityStateWatcher>(
|
404
|
+
pending_watcher_));
|
380
405
|
}
|
381
406
|
|
382
407
|
template <typename SubchannelListType, typename SubchannelDataType>
|
383
408
|
void SubchannelData<SubchannelListType, SubchannelDataType>::
|
384
409
|
CancelConnectivityWatchLocked(const char* reason) {
|
385
|
-
if (subchannel_list_->tracer()
|
410
|
+
if (GRPC_TRACE_FLAG_ENABLED(*subchannel_list_->tracer())) {
|
386
411
|
gpr_log(GPR_INFO,
|
387
412
|
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
388
413
|
" (subchannel %p): canceling connectivity watch (%s)",
|
389
414
|
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
390
415
|
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
391
|
-
subchannel_, reason);
|
416
|
+
subchannel_.get(), reason);
|
392
417
|
}
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
subchannel_list_->inhibit_health_checking());
|
397
|
-
}
|
398
|
-
|
399
|
-
template <typename SubchannelListType, typename SubchannelDataType>
|
400
|
-
bool SubchannelData<SubchannelListType,
|
401
|
-
SubchannelDataType>::UpdateConnectedSubchannelLocked() {
|
402
|
-
// If the subchannel is READY, take a ref to the connected subchannel.
|
403
|
-
if (pending_connectivity_state_unsafe_ == GRPC_CHANNEL_READY) {
|
404
|
-
connected_subchannel_ =
|
405
|
-
grpc_subchannel_get_connected_subchannel(subchannel_);
|
406
|
-
// If the subchannel became disconnected between the time that READY
|
407
|
-
// was reported and the time we got here (e.g., between when a
|
408
|
-
// notification callback is scheduled and when it was actually run in
|
409
|
-
// the combiner), then the connected subchannel may have disappeared out
|
410
|
-
// from under us. In that case, we don't actually want to consider the
|
411
|
-
// subchannel to be in state READY. Instead, we use IDLE as the
|
412
|
-
// basis for any future connectivity watch; this is the one state that
|
413
|
-
// the subchannel will never transition back into, so this ensures
|
414
|
-
// that we will get a notification for the next state, even if that state
|
415
|
-
// is READY again (e.g., if the subchannel has transitioned back to
|
416
|
-
// READY before the next watch gets requested).
|
417
|
-
if (connected_subchannel_ == nullptr) {
|
418
|
-
if (subchannel_list_->tracer()->enabled()) {
|
419
|
-
gpr_log(GPR_INFO,
|
420
|
-
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
421
|
-
" (subchannel %p): state is READY but connected subchannel is "
|
422
|
-
"null; moving to state IDLE",
|
423
|
-
subchannel_list_->tracer()->name(), subchannel_list_->policy(),
|
424
|
-
subchannel_list_, Index(), subchannel_list_->num_subchannels(),
|
425
|
-
subchannel_);
|
426
|
-
}
|
427
|
-
pending_connectivity_state_unsafe_ = GRPC_CHANNEL_IDLE;
|
428
|
-
return false;
|
429
|
-
}
|
430
|
-
} else {
|
431
|
-
// For any state other than READY, unref the connected subchannel.
|
432
|
-
connected_subchannel_.reset();
|
418
|
+
if (pending_watcher_ != nullptr) {
|
419
|
+
subchannel_->CancelConnectivityStateWatch(pending_watcher_);
|
420
|
+
pending_watcher_ = nullptr;
|
433
421
|
}
|
434
|
-
return true;
|
435
|
-
}
|
436
|
-
|
437
|
-
template <typename SubchannelListType, typename SubchannelDataType>
|
438
|
-
void SubchannelData<SubchannelListType, SubchannelDataType>::
|
439
|
-
OnConnectivityChangedLocked(void* arg, grpc_error* error) {
|
440
|
-
SubchannelData* sd = static_cast<SubchannelData*>(arg);
|
441
|
-
if (sd->subchannel_list_->tracer()->enabled()) {
|
442
|
-
gpr_log(
|
443
|
-
GPR_INFO,
|
444
|
-
"[%s %p] subchannel list %p index %" PRIuPTR " of %" PRIuPTR
|
445
|
-
" (subchannel %p): connectivity changed: state=%s, error=%s, "
|
446
|
-
"shutting_down=%d",
|
447
|
-
sd->subchannel_list_->tracer()->name(), sd->subchannel_list_->policy(),
|
448
|
-
sd->subchannel_list_, sd->Index(),
|
449
|
-
sd->subchannel_list_->num_subchannels(), sd->subchannel_,
|
450
|
-
grpc_connectivity_state_name(sd->pending_connectivity_state_unsafe_),
|
451
|
-
grpc_error_string(error), sd->subchannel_list_->shutting_down());
|
452
|
-
}
|
453
|
-
// If shutting down, unref subchannel and stop watching.
|
454
|
-
if (sd->subchannel_list_->shutting_down() || error == GRPC_ERROR_CANCELLED) {
|
455
|
-
sd->UnrefSubchannelLocked("connectivity_shutdown");
|
456
|
-
sd->StopConnectivityWatchLocked();
|
457
|
-
return;
|
458
|
-
}
|
459
|
-
// Get or release ref to connected subchannel.
|
460
|
-
if (!sd->UpdateConnectedSubchannelLocked()) {
|
461
|
-
// We don't want to report this connectivity state, so renew the watch.
|
462
|
-
sd->RenewConnectivityWatchLocked();
|
463
|
-
return;
|
464
|
-
}
|
465
|
-
// Call the subclass's ProcessConnectivityChangeLocked() method.
|
466
|
-
sd->ProcessConnectivityChangeLocked(sd->pending_connectivity_state_unsafe_,
|
467
|
-
GRPC_ERROR_REF(error));
|
468
422
|
}
|
469
423
|
|
470
424
|
template <typename SubchannelListType, typename SubchannelDataType>
|
471
425
|
void SubchannelData<SubchannelListType, SubchannelDataType>::ShutdownLocked() {
|
472
|
-
|
473
|
-
|
474
|
-
// Otherwise, unref the subchannel directly.
|
475
|
-
if (connectivity_notification_pending_) {
|
476
|
-
CancelConnectivityWatchLocked("shutdown");
|
477
|
-
} else if (subchannel_ != nullptr) {
|
478
|
-
UnrefSubchannelLocked("shutdown");
|
479
|
-
}
|
426
|
+
if (pending_watcher_ != nullptr) CancelConnectivityWatchLocked("shutdown");
|
427
|
+
UnrefSubchannelLocked("shutdown");
|
480
428
|
}
|
481
429
|
|
482
430
|
//
|
@@ -487,13 +435,13 @@ template <typename SubchannelListType, typename SubchannelDataType>
|
|
487
435
|
SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
488
436
|
LoadBalancingPolicy* policy, TraceFlag* tracer,
|
489
437
|
const ServerAddressList& addresses, grpc_combiner* combiner,
|
490
|
-
|
438
|
+
LoadBalancingPolicy::ChannelControlHelper* helper,
|
491
439
|
const grpc_channel_args& args)
|
492
440
|
: InternallyRefCounted<SubchannelListType>(tracer),
|
493
441
|
policy_(policy),
|
494
442
|
tracer_(tracer),
|
495
443
|
combiner_(GRPC_COMBINER_REF(combiner, "subchannel_list")) {
|
496
|
-
if (tracer_
|
444
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
497
445
|
gpr_log(GPR_INFO,
|
498
446
|
"[%s %p] Creating subchannel list %p for %" PRIuPTR " subchannels",
|
499
447
|
tracer_->name(), policy, this, addresses.size());
|
@@ -501,23 +449,23 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
|
501
449
|
subchannels_.reserve(addresses.size());
|
502
450
|
// We need to remove the LB addresses in order to be able to compare the
|
503
451
|
// subchannel keys of subchannels from a different batch of addresses.
|
504
|
-
// We
|
505
|
-
//
|
506
|
-
inhibit_health_checking_ = grpc_channel_arg_get_bool(
|
507
|
-
grpc_channel_args_find(&args, GRPC_ARG_INHIBIT_HEALTH_CHECKING), false);
|
452
|
+
// We remove the service config, since it will be passed into the
|
453
|
+
// subchannel via call context.
|
508
454
|
static const char* keys_to_remove[] = {GRPC_ARG_SUBCHANNEL_ADDRESS,
|
509
|
-
|
510
|
-
GRPC_ARG_INHIBIT_HEALTH_CHECKING};
|
455
|
+
GRPC_ARG_SERVICE_CONFIG};
|
511
456
|
// Create a subchannel for each address.
|
512
|
-
grpc_subchannel_args sc_args;
|
513
457
|
for (size_t i = 0; i < addresses.size(); i++) {
|
514
|
-
//
|
515
|
-
//
|
516
|
-
|
517
|
-
|
518
|
-
|
458
|
+
// TODO(roth): we should ideally hide this from the LB policy code. In
|
459
|
+
// principle, if we're dealing with this special case in the client_channel
|
460
|
+
// code for selecting grpclb, then we should also strip out these addresses
|
461
|
+
// there if we're not using grpclb.
|
462
|
+
if (addresses[i].IsBalancer()) {
|
463
|
+
continue;
|
464
|
+
}
|
465
|
+
InlinedVector<grpc_arg, 3> args_to_add;
|
466
|
+
const size_t subchannel_address_arg_index = args_to_add.size();
|
519
467
|
args_to_add.emplace_back(
|
520
|
-
|
468
|
+
Subchannel::CreateSubchannelAddressArg(&addresses[i].address()));
|
521
469
|
if (addresses[i].args() != nullptr) {
|
522
470
|
for (size_t j = 0; j < addresses[i].args()->num_args; ++j) {
|
523
471
|
args_to_add.emplace_back(addresses[i].args()->args[j]);
|
@@ -526,14 +474,13 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
|
526
474
|
grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
|
527
475
|
&args, keys_to_remove, GPR_ARRAY_SIZE(keys_to_remove),
|
528
476
|
args_to_add.data(), args_to_add.size());
|
529
|
-
gpr_free(args_to_add[
|
530
|
-
|
531
|
-
|
532
|
-
client_channel_factory, &sc_args);
|
477
|
+
gpr_free(args_to_add[subchannel_address_arg_index].value.string);
|
478
|
+
RefCountedPtr<SubchannelInterface> subchannel =
|
479
|
+
helper->CreateSubchannel(*new_args);
|
533
480
|
grpc_channel_args_destroy(new_args);
|
534
481
|
if (subchannel == nullptr) {
|
535
482
|
// Subchannel could not be created.
|
536
|
-
if (tracer_
|
483
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
537
484
|
char* address_uri = grpc_sockaddr_to_uri(&addresses[i].address());
|
538
485
|
gpr_log(GPR_INFO,
|
539
486
|
"[%s %p] could not create subchannel for address uri %s, "
|
@@ -543,22 +490,22 @@ SubchannelList<SubchannelListType, SubchannelDataType>::SubchannelList(
|
|
543
490
|
}
|
544
491
|
continue;
|
545
492
|
}
|
546
|
-
if (tracer_
|
493
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
547
494
|
char* address_uri = grpc_sockaddr_to_uri(&addresses[i].address());
|
548
495
|
gpr_log(GPR_INFO,
|
549
496
|
"[%s %p] subchannel list %p index %" PRIuPTR
|
550
497
|
": Created subchannel %p for address uri %s",
|
551
|
-
tracer_->name(), policy_, this, subchannels_.size(),
|
552
|
-
address_uri);
|
498
|
+
tracer_->name(), policy_, this, subchannels_.size(),
|
499
|
+
subchannel.get(), address_uri);
|
553
500
|
gpr_free(address_uri);
|
554
501
|
}
|
555
|
-
subchannels_.emplace_back(this, addresses[i], subchannel
|
502
|
+
subchannels_.emplace_back(this, addresses[i], std::move(subchannel));
|
556
503
|
}
|
557
504
|
}
|
558
505
|
|
559
506
|
template <typename SubchannelListType, typename SubchannelDataType>
|
560
507
|
SubchannelList<SubchannelListType, SubchannelDataType>::~SubchannelList() {
|
561
|
-
if (tracer_
|
508
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
562
509
|
gpr_log(GPR_INFO, "[%s %p] Destroying subchannel_list %p", tracer_->name(),
|
563
510
|
policy_, this);
|
564
511
|
}
|
@@ -567,7 +514,7 @@ SubchannelList<SubchannelListType, SubchannelDataType>::~SubchannelList() {
|
|
567
514
|
|
568
515
|
template <typename SubchannelListType, typename SubchannelDataType>
|
569
516
|
void SubchannelList<SubchannelListType, SubchannelDataType>::ShutdownLocked() {
|
570
|
-
if (tracer_
|
517
|
+
if (GRPC_TRACE_FLAG_ENABLED(*tracer_)) {
|
571
518
|
gpr_log(GPR_INFO, "[%s %p] Shutting down subchannel_list %p",
|
572
519
|
tracer_->name(), policy_, this);
|
573
520
|
}
|