grpc 1.2.5 → 1.3.4
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 +1434 -399
- data/etc/roots.pem +34 -150
- data/include/grpc/grpc.h +71 -0
- data/include/grpc/impl/codegen/atm.h +5 -0
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +6 -0
- data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
- data/include/grpc/impl/codegen/atm_windows.h +11 -0
- data/include/grpc/impl/codegen/grpc_types.h +54 -13
- data/include/grpc/impl/codegen/port_platform.h +15 -1
- data/include/grpc/support/alloc.h +2 -1
- data/include/grpc/support/sync.h +4 -0
- data/include/grpc/support/tls.h +1 -1
- data/src/core/ext/census/gen/trace_context.pb.h +1 -1
- data/src/core/ext/census/grpc_filter.c +14 -10
- data/src/core/ext/census/grpc_plugin.c +3 -1
- data/src/core/ext/census/trace_label.h +1 -1
- data/src/core/ext/census/trace_propagation.h +1 -1
- data/src/core/ext/census/trace_status.h +1 -1
- data/src/core/ext/census/trace_string.h +1 -1
- data/src/core/ext/census/tracing.h +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/channel_connectivity.c +56 -27
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel.c +407 -202
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel.h +10 -6
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/client_channel_plugin.c +12 -7
- data/src/core/ext/{client_channel → filters/client_channel}/connector.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/connector.h +3 -5
- data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.c +6 -6
- data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.c +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.h +4 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.c +22 -20
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.h +4 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel.h +5 -4
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel_secure.c +2 -2
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.c +1 -1
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.h +6 -5
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +1 -1
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -0
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/pick_first/pick_first.c +20 -15
- data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/round_robin/round_robin.c +21 -16
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.h +5 -5
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/parse_address.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/parse_address.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.h +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.c +10 -4
- data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.h +4 -4
- data/src/core/ext/{client_channel → filters/client_channel}/resolver.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/resolver.h +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
- data/src/core/ext/{resolver → filters/client_channel/resolver}/dns/native/dns_resolver.c +21 -5
- data/src/core/ext/{resolver → filters/client_channel/resolver}/sockaddr/sockaddr_resolver.c +3 -3
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.h +6 -6
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.c +1 -2
- data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.h +4 -4
- data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
- data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel.c +49 -43
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel.h +21 -7
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.h +5 -5
- data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.c +1 -1
- data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.h +3 -3
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.c +4 -2
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.h +3 -3
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.c +17 -14
- data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.h +4 -4
- data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
- data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
- data/src/core/ext/transport/chttp2/client/chttp2_connector.c +6 -41
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +2 -2
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +3 -3
- data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
- data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +2 -5
- data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -2
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +449 -204
- data/src/core/ext/transport/chttp2/transport/frame_data.c +10 -7
- data/src/core/ext/transport/chttp2/transport/frame_goaway.c +3 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.c +37 -7
- data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +4 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.c +18 -38
- data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -29
- data/src/core/ext/transport/chttp2/transport/frame_window_update.c +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +64 -37
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +11 -4
- data/src/core/ext/transport/chttp2/transport/hpack_parser.c +60 -39
- data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
- data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
- data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +22 -43
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +8 -10
- data/src/core/ext/transport/chttp2/transport/internal.h +24 -2
- data/src/core/ext/transport/chttp2/transport/parsing.c +33 -15
- data/src/core/ext/transport/chttp2/transport/writing.c +56 -10
- data/src/core/lib/channel/channel_args.c +7 -0
- data/src/core/lib/channel/channel_args.h +2 -0
- data/src/core/lib/channel/channel_stack.c +20 -27
- data/src/core/lib/channel/channel_stack.h +18 -16
- data/src/core/lib/channel/compress_filter.c +20 -18
- data/src/core/lib/channel/connected_channel.c +9 -8
- data/src/core/lib/channel/deadline_filter.c +28 -24
- data/src/core/lib/channel/deadline_filter.h +3 -3
- data/src/core/lib/channel/handshaker.c +3 -2
- data/src/core/lib/channel/http_client_filter.c +119 -61
- data/src/core/lib/channel/http_server_filter.c +124 -69
- data/src/core/lib/channel/message_size_filter.c +23 -19
- data/src/core/lib/http/httpcli.c +8 -6
- data/src/core/lib/http/httpcli_security_connector.c +5 -5
- data/src/core/lib/http/parser.c +57 -31
- data/src/core/lib/iomgr/closure.c +15 -0
- data/src/core/lib/iomgr/closure.h +4 -0
- data/src/core/lib/iomgr/combiner.c +8 -0
- data/src/core/lib/iomgr/endpoint_pair.h +2 -3
- data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -7
- data/src/core/lib/iomgr/endpoint_pair_uv.c +2 -3
- data/src/core/lib/iomgr/endpoint_pair_windows.c +9 -6
- data/src/core/lib/iomgr/error.c +360 -177
- data/src/core/lib/iomgr/error.h +31 -33
- data/src/core/lib/iomgr/error_internal.h +30 -9
- data/src/core/lib/iomgr/ev_epoll_linux.c +25 -239
- data/src/core/lib/iomgr/ev_poll_posix.c +11 -7
- data/src/core/lib/iomgr/ev_posix.c +6 -0
- data/src/core/lib/iomgr/ev_posix.h +3 -0
- data/src/core/lib/iomgr/exec_ctx.c +6 -0
- data/src/core/lib/iomgr/executor.c +8 -2
- data/src/core/lib/iomgr/load_file.c +6 -3
- data/src/core/lib/iomgr/lockfree_event.c +238 -0
- data/src/core/{ext/client_channel/initial_connect_string.h → lib/iomgr/lockfree_event.h} +17 -13
- data/src/core/lib/iomgr/pollset.h +4 -0
- data/src/core/lib/iomgr/pollset_windows.c +2 -2
- data/src/core/lib/iomgr/port.h +9 -0
- data/src/core/lib/iomgr/resolve_address_posix.c +15 -9
- data/src/core/lib/iomgr/resolve_address_uv.c +8 -6
- data/src/core/lib/iomgr/resolve_address_windows.c +2 -2
- data/src/core/lib/iomgr/resource_quota.c +19 -4
- data/src/core/lib/iomgr/resource_quota.h +2 -0
- data/src/core/lib/iomgr/sockaddr_utils.c +3 -1
- data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
- data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.c +25 -9
- data/src/core/lib/iomgr/socket_utils_posix.h +7 -0
- data/src/core/lib/iomgr/tcp_client.h +0 -4
- data/src/core/lib/iomgr/tcp_client_posix.c +15 -31
- data/src/core/lib/iomgr/tcp_client_uv.c +10 -6
- data/src/core/lib/iomgr/tcp_client_windows.c +9 -19
- data/src/core/lib/iomgr/tcp_posix.c +111 -22
- data/src/core/lib/iomgr/tcp_posix.h +3 -4
- data/src/core/lib/iomgr/tcp_server_posix.c +39 -417
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
- data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
- data/src/core/lib/iomgr/tcp_server_uv.c +43 -16
- data/src/core/lib/iomgr/tcp_server_windows.c +10 -22
- data/src/core/lib/iomgr/tcp_uv.c +16 -13
- data/src/core/lib/iomgr/tcp_windows.c +24 -12
- data/src/core/lib/iomgr/tcp_windows.h +2 -2
- data/src/core/lib/iomgr/timer.h +3 -0
- data/src/core/lib/iomgr/timer_generic.c +257 -72
- data/src/core/lib/iomgr/timer_generic.h +1 -1
- data/src/core/lib/iomgr/timer_heap.c +8 -8
- data/src/core/lib/iomgr/udp_server.c +54 -24
- data/src/core/lib/iomgr/udp_server.h +7 -7
- data/src/core/lib/iomgr/unix_sockets_posix.c +1 -1
- data/src/core/lib/iomgr/unix_sockets_posix_noop.c +2 -1
- data/src/core/lib/iomgr/wakeup_fd_posix.h +1 -1
- data/src/core/lib/profiling/basic_timers.c +1 -1
- data/src/core/lib/security/credentials/credentials.h +1 -1
- data/src/core/lib/security/credentials/google_default/google_default_credentials.c +10 -9
- data/src/core/lib/security/credentials/jwt/json_token.c +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.c +2 -2
- data/src/core/lib/security/transport/client_auth_filter.c +33 -26
- data/src/core/lib/security/transport/secure_endpoint.c +8 -5
- data/src/core/lib/security/transport/security_connector.c +37 -37
- data/src/core/lib/security/transport/security_connector.h +1 -1
- data/src/core/lib/security/transport/security_handshaker.c +15 -12
- data/src/core/lib/security/transport/server_auth_filter.c +20 -18
- data/src/core/lib/security/transport/tsi_error.c +5 -3
- data/src/core/lib/security/transport/tsi_error.h +1 -1
- data/src/core/lib/{security/util → slice}/b64.c +21 -6
- data/src/core/lib/{security/util → slice}/b64.h +16 -4
- data/src/core/lib/slice/slice.c +4 -2
- data/src/core/lib/slice/slice_buffer.c +16 -14
- data/src/core/lib/support/arena.c +98 -0
- data/src/core/{ext/client_channel/initial_connect_string.c → lib/support/arena.h} +17 -15
- data/src/core/{ext/client_channel/default_initial_connect_string.c → lib/support/atm.c} +14 -5
- data/src/core/lib/support/cpu_linux.c +5 -0
- data/src/core/lib/support/sync.c +4 -0
- data/src/core/lib/support/time.c +4 -10
- data/src/core/lib/support/wrap_memcpy.c +3 -1
- data/src/core/lib/surface/call.c +252 -221
- data/src/core/lib/surface/channel.c +72 -21
- data/src/core/lib/surface/channel.h +8 -0
- data/src/core/lib/surface/completion_queue.c +2 -3
- data/src/core/lib/surface/completion_queue_factory.c +77 -0
- data/src/core/lib/surface/completion_queue_factory.h +51 -0
- data/src/core/lib/surface/init_secure.c +3 -1
- data/src/core/lib/surface/lame_client.c +18 -14
- data/src/core/lib/surface/server.c +43 -41
- data/src/core/lib/surface/validate_metadata.c +8 -4
- data/src/core/lib/surface/version.c +2 -2
- data/src/core/lib/transport/bdp_estimator.h +1 -1
- data/src/core/lib/transport/connectivity_state.c +2 -1
- data/src/core/lib/transport/error_utils.c +17 -17
- data/src/core/lib/transport/error_utils.h +1 -1
- data/src/core/lib/transport/metadata_batch.c +6 -7
- data/src/core/lib/transport/pid_controller.c +1 -0
- data/src/core/lib/transport/service_config.c +12 -0
- data/src/core/lib/transport/service_config.h +6 -0
- data/src/core/lib/transport/transport.c +29 -17
- data/src/core/lib/transport/transport.h +85 -42
- data/src/core/lib/transport/transport_impl.h +5 -3
- data/src/core/lib/transport/transport_op_string.c +20 -14
- data/src/core/plugin_registry/grpc_plugin_registry.c +8 -0
- data/src/core/{lib/tsi → tsi}/fake_transport_security.c +2 -2
- data/src/core/{lib/tsi → tsi}/fake_transport_security.h +4 -4
- data/src/core/{lib/tsi → tsi}/ssl_transport_security.c +40 -79
- data/src/core/{lib/tsi → tsi}/ssl_transport_security.h +44 -21
- data/src/core/{lib/tsi → tsi}/ssl_types.h +3 -3
- data/src/core/{lib/tsi → tsi}/transport_security.c +2 -2
- data/src/core/{lib/tsi → tsi}/transport_security.h +4 -4
- data/src/core/{lib/tsi → tsi}/transport_security_interface.h +3 -3
- data/src/ruby/ext/grpc/extconf.rb +1 -0
- data/src/ruby/ext/grpc/rb_call_credentials.c +2 -2
- data/src/ruby/ext/grpc/rb_channel.c +520 -93
- data/src/ruby/ext/grpc/rb_channel.h +2 -0
- data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -0
- data/src/ruby/ext/grpc/rb_compression_options.c +5 -2
- data/src/ruby/ext/grpc/rb_event_thread.c +6 -6
- data/src/ruby/ext/grpc/rb_grpc.c +29 -7
- data/src/ruby/ext/grpc/rb_grpc.h +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
- data/src/ruby/ext/grpc/rb_server.c +5 -3
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_connection_spec.rb +173 -0
- data/src/ruby/spec/channel_spec.rb +29 -0
- data/src/ruby/spec/generic/rpc_server_pool_spec.rb +27 -17
- data/third_party/cares/ares_build.h +264 -0
- data/third_party/cares/cares/ares.h +636 -0
- data/third_party/cares/cares/ares__close_sockets.c +61 -0
- data/third_party/cares/cares/ares__get_hostent.c +261 -0
- data/third_party/cares/cares/ares__read_line.c +73 -0
- data/third_party/cares/cares/ares__timeval.c +111 -0
- data/third_party/cares/cares/ares_cancel.c +63 -0
- data/third_party/cares/cares/ares_create_query.c +202 -0
- data/third_party/cares/cares/ares_data.c +221 -0
- data/third_party/cares/cares/ares_data.h +72 -0
- data/third_party/cares/cares/ares_destroy.c +108 -0
- data/third_party/cares/cares/ares_dns.h +103 -0
- data/third_party/cares/cares/ares_expand_name.c +205 -0
- data/third_party/cares/cares/ares_expand_string.c +70 -0
- data/third_party/cares/cares/ares_fds.c +59 -0
- data/third_party/cares/cares/ares_free_hostent.c +41 -0
- data/third_party/cares/cares/ares_free_string.c +25 -0
- data/third_party/cares/cares/ares_getenv.c +30 -0
- data/third_party/cares/cares/ares_getenv.h +26 -0
- data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
- data/third_party/cares/cares/ares_gethostbyname.c +518 -0
- data/third_party/cares/cares/ares_getnameinfo.c +422 -0
- data/third_party/cares/cares/ares_getopt.c +122 -0
- data/third_party/cares/cares/ares_getopt.h +53 -0
- data/third_party/cares/cares/ares_getsock.c +66 -0
- data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
- data/third_party/cares/cares/ares_init.c +2146 -0
- data/third_party/cares/cares/ares_iphlpapi.h +221 -0
- data/third_party/cares/cares/ares_ipv6.h +78 -0
- data/third_party/cares/cares/ares_library_init.c +167 -0
- data/third_party/cares/cares/ares_library_init.h +42 -0
- data/third_party/cares/cares/ares_llist.c +63 -0
- data/third_party/cares/cares/ares_llist.h +39 -0
- data/third_party/cares/cares/ares_mkquery.c +24 -0
- data/third_party/cares/cares/ares_nowarn.c +260 -0
- data/third_party/cares/cares/ares_nowarn.h +61 -0
- data/third_party/cares/cares/ares_options.c +402 -0
- data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
- data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
- data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
- data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
- data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
- data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
- data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
- data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
- data/third_party/cares/cares/ares_platform.c +11035 -0
- data/third_party/cares/cares/ares_platform.h +43 -0
- data/third_party/cares/cares/ares_private.h +363 -0
- data/third_party/cares/cares/ares_process.c +1359 -0
- data/third_party/cares/cares/ares_query.c +186 -0
- data/third_party/cares/cares/ares_rules.h +125 -0
- data/third_party/cares/cares/ares_search.c +316 -0
- data/third_party/cares/cares/ares_send.c +131 -0
- data/third_party/cares/cares/ares_setup.h +217 -0
- data/third_party/cares/cares/ares_strcasecmp.c +66 -0
- data/third_party/cares/cares/ares_strcasecmp.h +30 -0
- data/third_party/cares/cares/ares_strdup.c +49 -0
- data/third_party/cares/cares/ares_strdup.h +24 -0
- data/third_party/cares/cares/ares_strerror.c +56 -0
- data/third_party/cares/cares/ares_timeout.c +88 -0
- data/third_party/cares/cares/ares_version.c +11 -0
- data/third_party/cares/cares/ares_version.h +24 -0
- data/third_party/cares/cares/ares_writev.c +79 -0
- data/third_party/cares/cares/bitncmp.c +59 -0
- data/third_party/cares/cares/bitncmp.h +26 -0
- data/third_party/cares/cares/config-win32.h +377 -0
- data/third_party/cares/cares/inet_net_pton.c +450 -0
- data/third_party/cares/cares/inet_ntop.c +208 -0
- data/third_party/cares/cares/setup_once.h +554 -0
- data/third_party/cares/cares/windows_port.c +22 -0
- data/third_party/cares/config_darwin/ares_config.h +523 -0
- data/third_party/cares/config_linux/ares_config.h +524 -0
- metadata +164 -68
@@ -156,6 +156,9 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE *argv, VALUE self)
|
|
156
156
|
grpc_ssl_pem_key_cert_pair key_cert_pair;
|
157
157
|
const char *pem_root_certs_cstr = NULL;
|
158
158
|
MEMZERO(&key_cert_pair, grpc_ssl_pem_key_cert_pair, 1);
|
159
|
+
|
160
|
+
grpc_ruby_once_init();
|
161
|
+
|
159
162
|
/* "03" == no mandatory arg, 3 optional */
|
160
163
|
rb_scan_args(argc, argv, "03", &pem_root_certs, &pem_private_key,
|
161
164
|
&pem_cert_chain);
|
@@ -100,8 +100,11 @@ static rb_data_type_t grpc_rb_compression_options_data_type = {
|
|
100
100
|
Allocate the wrapped grpc compression options and
|
101
101
|
initialize it here too. */
|
102
102
|
static VALUE grpc_rb_compression_options_alloc(VALUE cls) {
|
103
|
-
grpc_rb_compression_options *wrapper =
|
104
|
-
|
103
|
+
grpc_rb_compression_options *wrapper = NULL;
|
104
|
+
|
105
|
+
grpc_ruby_once_init();
|
106
|
+
|
107
|
+
wrapper = gpr_malloc(sizeof(grpc_rb_compression_options));
|
105
108
|
wrapper->wrapped = NULL;
|
106
109
|
wrapper->wrapped = gpr_malloc(sizeof(grpc_compression_options));
|
107
110
|
grpc_compression_options_init(wrapper->wrapped);
|
@@ -106,17 +106,17 @@ static void *grpc_rb_wait_for_event_no_gil(void *param) {
|
|
106
106
|
grpc_rb_event *event = NULL;
|
107
107
|
(void)param;
|
108
108
|
gpr_mu_lock(&event_queue.mu);
|
109
|
-
while (
|
109
|
+
while (!event_queue.abort) {
|
110
|
+
if ((event = grpc_rb_event_queue_dequeue()) != NULL) {
|
111
|
+
gpr_mu_unlock(&event_queue.mu);
|
112
|
+
return event;
|
113
|
+
}
|
110
114
|
gpr_cv_wait(&event_queue.cv,
|
111
115
|
&event_queue.mu,
|
112
116
|
gpr_inf_future(GPR_CLOCK_REALTIME));
|
113
|
-
if (event_queue.abort) {
|
114
|
-
gpr_mu_unlock(&event_queue.mu);
|
115
|
-
return NULL;
|
116
|
-
}
|
117
117
|
}
|
118
118
|
gpr_mu_unlock(&event_queue.mu);
|
119
|
-
return
|
119
|
+
return NULL;
|
120
120
|
}
|
121
121
|
|
122
122
|
static void grpc_rb_event_unblocking_func(void *arg) {
|
data/src/ruby/ext/grpc/rb_grpc.c
CHANGED
@@ -50,6 +50,8 @@
|
|
50
50
|
#include "rb_server.h"
|
51
51
|
#include "rb_server_credentials.h"
|
52
52
|
#include "rb_compression_options.h"
|
53
|
+
#include "rb_event_thread.h"
|
54
|
+
#include "rb_channel.h"
|
53
55
|
|
54
56
|
static VALUE grpc_rb_cTimeVal = Qnil;
|
55
57
|
|
@@ -291,17 +293,15 @@ VALUE sym_metadata = Qundef;
|
|
291
293
|
|
292
294
|
static gpr_once g_once_init = GPR_ONCE_INIT;
|
293
295
|
|
294
|
-
static void
|
296
|
+
static void grpc_ruby_once_init_internal() {
|
295
297
|
grpc_init();
|
296
298
|
atexit(grpc_rb_shutdown);
|
297
299
|
}
|
298
300
|
|
299
|
-
|
300
|
-
|
301
|
-
rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core");
|
302
|
-
return;
|
303
|
-
}
|
301
|
+
static VALUE bg_thread_init_rb_mu = Qundef;
|
302
|
+
static int bg_thread_init_done = 0;
|
304
303
|
|
304
|
+
void grpc_ruby_once_init() {
|
305
305
|
/* ruby_vm_at_exit doesn't seem to be working. It would crash once every
|
306
306
|
* blue moon, and some users are getting it repeatedly. See the discussions
|
307
307
|
* - https://github.com/grpc/grpc/pull/5337
|
@@ -312,7 +312,29 @@ void Init_grpc_c() {
|
|
312
312
|
* then loaded again by another VM within the same process, we need to
|
313
313
|
* schedule our initialization and destruction only once.
|
314
314
|
*/
|
315
|
-
gpr_once_init(&g_once_init,
|
315
|
+
gpr_once_init(&g_once_init, grpc_ruby_once_init_internal);
|
316
|
+
|
317
|
+
// Avoid calling calling into ruby library (when creating threads here)
|
318
|
+
// in gpr_once_init. In general, it appears to be unsafe to call
|
319
|
+
// into the ruby library while holding a non-ruby mutex, because a gil yield
|
320
|
+
// could end up trying to lock onto that same mutex and deadlocking.
|
321
|
+
rb_mutex_lock(bg_thread_init_rb_mu);
|
322
|
+
if (!bg_thread_init_done) {
|
323
|
+
grpc_rb_event_queue_thread_start();
|
324
|
+
grpc_rb_channel_polling_thread_start();
|
325
|
+
bg_thread_init_done = 1;
|
326
|
+
}
|
327
|
+
rb_mutex_unlock(bg_thread_init_rb_mu);
|
328
|
+
}
|
329
|
+
|
330
|
+
void Init_grpc_c() {
|
331
|
+
if (!grpc_rb_load_core()) {
|
332
|
+
rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core");
|
333
|
+
return;
|
334
|
+
}
|
335
|
+
|
336
|
+
bg_thread_init_rb_mu = rb_mutex_new();
|
337
|
+
rb_global_variable(&bg_thread_init_rb_mu);
|
316
338
|
|
317
339
|
grpc_rb_mGRPC = rb_define_module("GRPC");
|
318
340
|
grpc_rb_mGrpcCore = rb_define_module_under(grpc_rb_mGRPC, "Core");
|
data/src/ruby/ext/grpc/rb_grpc.h
CHANGED
@@ -91,6 +91,9 @@ grpc_init_type grpc_init_import;
|
|
91
91
|
grpc_shutdown_type grpc_shutdown_import;
|
92
92
|
grpc_version_string_type grpc_version_string_import;
|
93
93
|
grpc_g_stands_for_type grpc_g_stands_for_import;
|
94
|
+
grpc_completion_queue_factory_lookup_type grpc_completion_queue_factory_lookup_import;
|
95
|
+
grpc_completion_queue_create_for_next_type grpc_completion_queue_create_for_next_import;
|
96
|
+
grpc_completion_queue_create_for_pluck_type grpc_completion_queue_create_for_pluck_import;
|
94
97
|
grpc_completion_queue_create_type grpc_completion_queue_create_import;
|
95
98
|
grpc_completion_queue_next_type grpc_completion_queue_next_import;
|
96
99
|
grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import;
|
@@ -100,6 +103,7 @@ grpc_alarm_create_type grpc_alarm_create_import;
|
|
100
103
|
grpc_alarm_cancel_type grpc_alarm_cancel_import;
|
101
104
|
grpc_alarm_destroy_type grpc_alarm_destroy_import;
|
102
105
|
grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import;
|
106
|
+
grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_external_connectivity_watchers_import;
|
103
107
|
grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
|
104
108
|
grpc_channel_create_call_type grpc_channel_create_call_import;
|
105
109
|
grpc_channel_ping_type grpc_channel_ping_import;
|
@@ -296,6 +300,7 @@ gpr_ref_type gpr_ref_import;
|
|
296
300
|
gpr_ref_non_zero_type gpr_ref_non_zero_import;
|
297
301
|
gpr_refn_type gpr_refn_import;
|
298
302
|
gpr_unref_type gpr_unref_import;
|
303
|
+
gpr_ref_is_unique_type gpr_ref_is_unique_import;
|
299
304
|
gpr_stats_init_type gpr_stats_init_import;
|
300
305
|
gpr_stats_inc_type gpr_stats_inc_import;
|
301
306
|
gpr_stats_read_type gpr_stats_read_import;
|
@@ -384,6 +389,9 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
384
389
|
grpc_shutdown_import = (grpc_shutdown_type) GetProcAddress(library, "grpc_shutdown");
|
385
390
|
grpc_version_string_import = (grpc_version_string_type) GetProcAddress(library, "grpc_version_string");
|
386
391
|
grpc_g_stands_for_import = (grpc_g_stands_for_type) GetProcAddress(library, "grpc_g_stands_for");
|
392
|
+
grpc_completion_queue_factory_lookup_import = (grpc_completion_queue_factory_lookup_type) GetProcAddress(library, "grpc_completion_queue_factory_lookup");
|
393
|
+
grpc_completion_queue_create_for_next_import = (grpc_completion_queue_create_for_next_type) GetProcAddress(library, "grpc_completion_queue_create_for_next");
|
394
|
+
grpc_completion_queue_create_for_pluck_import = (grpc_completion_queue_create_for_pluck_type) GetProcAddress(library, "grpc_completion_queue_create_for_pluck");
|
387
395
|
grpc_completion_queue_create_import = (grpc_completion_queue_create_type) GetProcAddress(library, "grpc_completion_queue_create");
|
388
396
|
grpc_completion_queue_next_import = (grpc_completion_queue_next_type) GetProcAddress(library, "grpc_completion_queue_next");
|
389
397
|
grpc_completion_queue_pluck_import = (grpc_completion_queue_pluck_type) GetProcAddress(library, "grpc_completion_queue_pluck");
|
@@ -393,6 +401,7 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
393
401
|
grpc_alarm_cancel_import = (grpc_alarm_cancel_type) GetProcAddress(library, "grpc_alarm_cancel");
|
394
402
|
grpc_alarm_destroy_import = (grpc_alarm_destroy_type) GetProcAddress(library, "grpc_alarm_destroy");
|
395
403
|
grpc_channel_check_connectivity_state_import = (grpc_channel_check_connectivity_state_type) GetProcAddress(library, "grpc_channel_check_connectivity_state");
|
404
|
+
grpc_channel_num_external_connectivity_watchers_import = (grpc_channel_num_external_connectivity_watchers_type) GetProcAddress(library, "grpc_channel_num_external_connectivity_watchers");
|
396
405
|
grpc_channel_watch_connectivity_state_import = (grpc_channel_watch_connectivity_state_type) GetProcAddress(library, "grpc_channel_watch_connectivity_state");
|
397
406
|
grpc_channel_create_call_import = (grpc_channel_create_call_type) GetProcAddress(library, "grpc_channel_create_call");
|
398
407
|
grpc_channel_ping_import = (grpc_channel_ping_type) GetProcAddress(library, "grpc_channel_ping");
|
@@ -589,6 +598,7 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
589
598
|
gpr_ref_non_zero_import = (gpr_ref_non_zero_type) GetProcAddress(library, "gpr_ref_non_zero");
|
590
599
|
gpr_refn_import = (gpr_refn_type) GetProcAddress(library, "gpr_refn");
|
591
600
|
gpr_unref_import = (gpr_unref_type) GetProcAddress(library, "gpr_unref");
|
601
|
+
gpr_ref_is_unique_import = (gpr_ref_is_unique_type) GetProcAddress(library, "gpr_ref_is_unique");
|
592
602
|
gpr_stats_init_import = (gpr_stats_init_type) GetProcAddress(library, "gpr_stats_init");
|
593
603
|
gpr_stats_inc_import = (gpr_stats_inc_type) GetProcAddress(library, "gpr_stats_inc");
|
594
604
|
gpr_stats_read_import = (gpr_stats_read_type) GetProcAddress(library, "gpr_stats_read");
|
@@ -224,6 +224,15 @@ extern grpc_version_string_type grpc_version_string_import;
|
|
224
224
|
typedef const char *(*grpc_g_stands_for_type)(void);
|
225
225
|
extern grpc_g_stands_for_type grpc_g_stands_for_import;
|
226
226
|
#define grpc_g_stands_for grpc_g_stands_for_import
|
227
|
+
typedef const grpc_completion_queue_factory *(*grpc_completion_queue_factory_lookup_type)(const grpc_completion_queue_attributes *attributes);
|
228
|
+
extern grpc_completion_queue_factory_lookup_type grpc_completion_queue_factory_lookup_import;
|
229
|
+
#define grpc_completion_queue_factory_lookup grpc_completion_queue_factory_lookup_import
|
230
|
+
typedef grpc_completion_queue *(*grpc_completion_queue_create_for_next_type)(void *reserved);
|
231
|
+
extern grpc_completion_queue_create_for_next_type grpc_completion_queue_create_for_next_import;
|
232
|
+
#define grpc_completion_queue_create_for_next grpc_completion_queue_create_for_next_import
|
233
|
+
typedef grpc_completion_queue *(*grpc_completion_queue_create_for_pluck_type)(void *reserved);
|
234
|
+
extern grpc_completion_queue_create_for_pluck_type grpc_completion_queue_create_for_pluck_import;
|
235
|
+
#define grpc_completion_queue_create_for_pluck grpc_completion_queue_create_for_pluck_import
|
227
236
|
typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(void *reserved);
|
228
237
|
extern grpc_completion_queue_create_type grpc_completion_queue_create_import;
|
229
238
|
#define grpc_completion_queue_create grpc_completion_queue_create_import
|
@@ -251,6 +260,9 @@ extern grpc_alarm_destroy_type grpc_alarm_destroy_import;
|
|
251
260
|
typedef grpc_connectivity_state(*grpc_channel_check_connectivity_state_type)(grpc_channel *channel, int try_to_connect);
|
252
261
|
extern grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import;
|
253
262
|
#define grpc_channel_check_connectivity_state grpc_channel_check_connectivity_state_import
|
263
|
+
typedef int(*grpc_channel_num_external_connectivity_watchers_type)(grpc_channel *channel);
|
264
|
+
extern grpc_channel_num_external_connectivity_watchers_type grpc_channel_num_external_connectivity_watchers_import;
|
265
|
+
#define grpc_channel_num_external_connectivity_watchers grpc_channel_num_external_connectivity_watchers_import
|
254
266
|
typedef void(*grpc_channel_watch_connectivity_state_type)(grpc_channel *channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue *cq, void *tag);
|
255
267
|
extern grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import;
|
256
268
|
#define grpc_channel_watch_connectivity_state grpc_channel_watch_connectivity_state_import
|
@@ -839,6 +851,9 @@ extern gpr_refn_type gpr_refn_import;
|
|
839
851
|
typedef int(*gpr_unref_type)(gpr_refcount *r);
|
840
852
|
extern gpr_unref_type gpr_unref_import;
|
841
853
|
#define gpr_unref gpr_unref_import
|
854
|
+
typedef int(*gpr_ref_is_unique_type)(gpr_refcount *r);
|
855
|
+
extern gpr_ref_is_unique_type gpr_ref_is_unique_import;
|
856
|
+
#define gpr_ref_is_unique gpr_ref_is_unique_import
|
842
857
|
typedef void(*gpr_stats_init_type)(gpr_stats_counter *c, intptr_t n);
|
843
858
|
extern gpr_stats_init_type gpr_stats_init_import;
|
844
859
|
#define gpr_stats_init gpr_stats_init_import
|
@@ -131,11 +131,15 @@ static VALUE grpc_rb_server_alloc(VALUE cls) {
|
|
131
131
|
|
132
132
|
Initializes server instances. */
|
133
133
|
static VALUE grpc_rb_server_init(VALUE self, VALUE channel_args) {
|
134
|
-
grpc_completion_queue *cq =
|
134
|
+
grpc_completion_queue *cq = NULL;
|
135
135
|
grpc_rb_server *wrapper = NULL;
|
136
136
|
grpc_server *srv = NULL;
|
137
137
|
grpc_channel_args args;
|
138
138
|
MEMZERO(&args, grpc_channel_args, 1);
|
139
|
+
|
140
|
+
grpc_ruby_once_init();
|
141
|
+
|
142
|
+
cq = grpc_completion_queue_create(NULL);
|
139
143
|
TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type,
|
140
144
|
wrapper);
|
141
145
|
grpc_rb_hash_convert_to_channel_args(channel_args, &args);
|
@@ -218,8 +222,6 @@ static VALUE grpc_rb_server_request_call(VALUE self) {
|
|
218
222
|
return Qnil;
|
219
223
|
}
|
220
224
|
|
221
|
-
|
222
|
-
|
223
225
|
/* build the NewServerRpc struct result */
|
224
226
|
deadline = gpr_convert_clock_type(st.details.deadline, GPR_CLOCK_REALTIME);
|
225
227
|
result = rb_struct_new(
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# Copyright 2015, Google Inc.
|
2
|
+
# All rights reserved.
|
3
|
+
#
|
4
|
+
# Redistribution and use in source and binary forms, with or without
|
5
|
+
# modification, are permitted provided that the following conditions are
|
6
|
+
# met:
|
7
|
+
#
|
8
|
+
# * Redistributions of source code must retain the above copyright
|
9
|
+
# notice, this list of conditions and the following disclaimer.
|
10
|
+
# * Redistributions in binary form must reproduce the above
|
11
|
+
# copyright notice, this list of conditions and the following disclaimer
|
12
|
+
# in the documentation and/or other materials provided with the
|
13
|
+
# distribution.
|
14
|
+
# * Neither the name of Google Inc. nor the names of its
|
15
|
+
# contributors may be used to endorse or promote products derived from
|
16
|
+
# this software without specific prior written permission.
|
17
|
+
#
|
18
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
19
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
20
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
21
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
22
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
23
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
|
+
|
30
|
+
require 'grpc'
|
31
|
+
require 'timeout'
|
32
|
+
|
33
|
+
include Timeout
|
34
|
+
include GRPC::Core
|
35
|
+
|
36
|
+
# A test message
|
37
|
+
class EchoMsg
|
38
|
+
def self.marshal(_o)
|
39
|
+
''
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.unmarshal(_o)
|
43
|
+
EchoMsg.new
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# A test service with an echo implementation.
|
48
|
+
class EchoService
|
49
|
+
include GRPC::GenericService
|
50
|
+
rpc :an_rpc, EchoMsg, EchoMsg
|
51
|
+
attr_reader :received_md
|
52
|
+
|
53
|
+
def initialize(**kw)
|
54
|
+
@trailing_metadata = kw
|
55
|
+
@received_md = []
|
56
|
+
end
|
57
|
+
|
58
|
+
def an_rpc(req, call)
|
59
|
+
GRPC.logger.info('echo service received a request')
|
60
|
+
call.output_metadata.update(@trailing_metadata)
|
61
|
+
@received_md << call.metadata unless call.metadata.nil?
|
62
|
+
req
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
EchoStub = EchoService.rpc_stub_class
|
67
|
+
|
68
|
+
def start_server(port = 0)
|
69
|
+
@srv = GRPC::RpcServer.new(pool_size: 1)
|
70
|
+
server_port = @srv.add_http2_port("localhost:#{port}", :this_port_is_insecure)
|
71
|
+
@srv.handle(EchoService)
|
72
|
+
@server_thd = Thread.new { @srv.run }
|
73
|
+
@srv.wait_till_running
|
74
|
+
server_port
|
75
|
+
end
|
76
|
+
|
77
|
+
def stop_server
|
78
|
+
expect(@srv.stopped?).to be(false)
|
79
|
+
@srv.stop
|
80
|
+
@server_thd.join
|
81
|
+
expect(@srv.stopped?).to be(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'channel connection behavior' do
|
85
|
+
it 'the client channel handles temporary loss of a transport' do
|
86
|
+
port = start_server
|
87
|
+
stub = EchoStub.new("localhost:#{port}", :this_channel_is_insecure)
|
88
|
+
req = EchoMsg.new
|
89
|
+
expect(stub.an_rpc(req)).to be_a(EchoMsg)
|
90
|
+
stop_server
|
91
|
+
sleep 1
|
92
|
+
# TODO(apolcyn) grabbing the same port might fail, is this stable enough?
|
93
|
+
start_server(port)
|
94
|
+
expect(stub.an_rpc(req)).to be_a(EchoMsg)
|
95
|
+
stop_server
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'observably connects and reconnects to transient server' \
|
99
|
+
' when using the channel state API' do
|
100
|
+
port = start_server
|
101
|
+
ch = GRPC::Core::Channel.new("localhost:#{port}", {},
|
102
|
+
:this_channel_is_insecure)
|
103
|
+
|
104
|
+
expect(ch.connectivity_state).to be(GRPC::Core::ConnectivityStates::IDLE)
|
105
|
+
|
106
|
+
state = ch.connectivity_state(true)
|
107
|
+
|
108
|
+
count = 0
|
109
|
+
while count < 20 && state != GRPC::Core::ConnectivityStates::READY
|
110
|
+
ch.watch_connectivity_state(state, Time.now + 60)
|
111
|
+
state = ch.connectivity_state(true)
|
112
|
+
count += 1
|
113
|
+
end
|
114
|
+
|
115
|
+
expect(state).to be(GRPC::Core::ConnectivityStates::READY)
|
116
|
+
|
117
|
+
stop_server
|
118
|
+
|
119
|
+
state = ch.connectivity_state
|
120
|
+
|
121
|
+
count = 0
|
122
|
+
while count < 20 && state == GRPC::Core::ConnectivityStates::READY
|
123
|
+
ch.watch_connectivity_state(state, Time.now + 60)
|
124
|
+
state = ch.connectivity_state
|
125
|
+
count += 1
|
126
|
+
end
|
127
|
+
|
128
|
+
expect(state).to_not be(GRPC::Core::ConnectivityStates::READY)
|
129
|
+
|
130
|
+
start_server(port)
|
131
|
+
|
132
|
+
state = ch.connectivity_state(true)
|
133
|
+
|
134
|
+
count = 0
|
135
|
+
while count < 20 && state != GRPC::Core::ConnectivityStates::READY
|
136
|
+
ch.watch_connectivity_state(state, Time.now + 60)
|
137
|
+
state = ch.connectivity_state(true)
|
138
|
+
count += 1
|
139
|
+
end
|
140
|
+
|
141
|
+
expect(state).to be(GRPC::Core::ConnectivityStates::READY)
|
142
|
+
|
143
|
+
stop_server
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'concurrent watches on the same channel' do
|
147
|
+
timeout(180) do
|
148
|
+
port = start_server
|
149
|
+
ch = GRPC::Core::Channel.new("localhost:#{port}", {},
|
150
|
+
:this_channel_is_insecure)
|
151
|
+
stop_server
|
152
|
+
|
153
|
+
thds = []
|
154
|
+
50.times do
|
155
|
+
thds << Thread.new do
|
156
|
+
while ch.connectivity_state(true) != ConnectivityStates::READY
|
157
|
+
ch.watch_connectivity_state(
|
158
|
+
ConnectivityStates::READY, Time.now + 60)
|
159
|
+
break
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
sleep 0.01
|
165
|
+
|
166
|
+
start_server(port)
|
167
|
+
|
168
|
+
thds.each(&:join)
|
169
|
+
|
170
|
+
stop_server
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -153,6 +153,35 @@ describe GRPC::Core::Channel do
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
+
describe '#connectivity_state' do
|
157
|
+
it 'returns an enum' do
|
158
|
+
ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
|
159
|
+
valid_states = [
|
160
|
+
GRPC::Core::ConnectivityStates::IDLE,
|
161
|
+
GRPC::Core::ConnectivityStates::CONNECTING,
|
162
|
+
GRPC::Core::ConnectivityStates::READY,
|
163
|
+
GRPC::Core::ConnectivityStates::TRANSIENT_FAILURE,
|
164
|
+
GRPC::Core::ConnectivityStates::FATAL_FAILURE
|
165
|
+
]
|
166
|
+
|
167
|
+
expect(valid_states).to include(ch.connectivity_state)
|
168
|
+
end
|
169
|
+
|
170
|
+
it 'returns an enum when trying to connect' do
|
171
|
+
ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
|
172
|
+
ch.connectivity_state(true)
|
173
|
+
valid_states = [
|
174
|
+
GRPC::Core::ConnectivityStates::IDLE,
|
175
|
+
GRPC::Core::ConnectivityStates::CONNECTING,
|
176
|
+
GRPC::Core::ConnectivityStates::READY,
|
177
|
+
GRPC::Core::ConnectivityStates::TRANSIENT_FAILURE,
|
178
|
+
GRPC::Core::ConnectivityStates::FATAL_FAILURE
|
179
|
+
]
|
180
|
+
|
181
|
+
expect(valid_states).to include(ch.connectivity_state)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
156
185
|
describe '::SSL_TARGET' do
|
157
186
|
it 'is a symbol' do
|
158
187
|
expect(GRPC::Core::Channel::SSL_TARGET).to be_a(Symbol)
|