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.

Files changed (327) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1434 -399
  3. data/etc/roots.pem +34 -150
  4. data/include/grpc/grpc.h +71 -0
  5. data/include/grpc/impl/codegen/atm.h +5 -0
  6. data/include/grpc/impl/codegen/atm_gcc_atomic.h +6 -0
  7. data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
  8. data/include/grpc/impl/codegen/atm_windows.h +11 -0
  9. data/include/grpc/impl/codegen/grpc_types.h +54 -13
  10. data/include/grpc/impl/codegen/port_platform.h +15 -1
  11. data/include/grpc/support/alloc.h +2 -1
  12. data/include/grpc/support/sync.h +4 -0
  13. data/include/grpc/support/tls.h +1 -1
  14. data/src/core/ext/census/gen/trace_context.pb.h +1 -1
  15. data/src/core/ext/census/grpc_filter.c +14 -10
  16. data/src/core/ext/census/grpc_plugin.c +3 -1
  17. data/src/core/ext/census/trace_label.h +1 -1
  18. data/src/core/ext/census/trace_propagation.h +1 -1
  19. data/src/core/ext/census/trace_status.h +1 -1
  20. data/src/core/ext/census/trace_string.h +1 -1
  21. data/src/core/ext/census/tracing.h +1 -1
  22. data/src/core/ext/{client_channel → filters/client_channel}/channel_connectivity.c +56 -27
  23. data/src/core/ext/{client_channel → filters/client_channel}/client_channel.c +407 -202
  24. data/src/core/ext/{client_channel → filters/client_channel}/client_channel.h +10 -6
  25. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.c +1 -1
  26. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_factory.h +4 -4
  27. data/src/core/ext/{client_channel → filters/client_channel}/client_channel_plugin.c +12 -7
  28. data/src/core/ext/{client_channel → filters/client_channel}/connector.c +1 -1
  29. data/src/core/ext/{client_channel → filters/client_channel}/connector.h +3 -5
  30. data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.c +6 -6
  31. data/src/core/ext/{client_channel → filters/client_channel}/http_connect_handshaker.h +3 -3
  32. data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.c +4 -4
  33. data/src/core/ext/{client_channel → filters/client_channel}/http_proxy.h +3 -3
  34. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.c +1 -1
  35. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy.h +4 -4
  36. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.c +22 -20
  37. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb.h +4 -4
  38. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel.h +5 -4
  39. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/grpclb_channel_secure.c +2 -2
  40. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.c +1 -1
  41. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/load_balancer_api.h +6 -5
  42. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +1 -1
  43. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +0 -0
  44. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/pick_first/pick_first.c +20 -15
  45. data/src/core/ext/{lb_policy → filters/client_channel/lb_policy}/round_robin/round_robin.c +21 -16
  46. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.c +1 -1
  47. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_factory.h +5 -5
  48. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.c +1 -1
  49. data/src/core/ext/{client_channel → filters/client_channel}/lb_policy_registry.h +4 -4
  50. data/src/core/ext/{client_channel → filters/client_channel}/parse_address.c +1 -1
  51. data/src/core/ext/{client_channel → filters/client_channel}/parse_address.h +4 -4
  52. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.c +1 -1
  53. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper.h +3 -3
  54. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.c +10 -4
  55. data/src/core/ext/{client_channel → filters/client_channel}/proxy_mapper_registry.h +4 -4
  56. data/src/core/ext/{client_channel → filters/client_channel}/resolver.c +1 -1
  57. data/src/core/ext/{client_channel → filters/client_channel}/resolver.h +4 -4
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c +350 -0
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +66 -0
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +319 -0
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c +289 -0
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +64 -0
  63. data/src/core/ext/{resolver → filters/client_channel/resolver}/dns/native/dns_resolver.c +21 -5
  64. data/src/core/ext/{resolver → filters/client_channel/resolver}/sockaddr/sockaddr_resolver.c +3 -3
  65. data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.c +1 -1
  66. data/src/core/ext/{client_channel → filters/client_channel}/resolver_factory.h +6 -6
  67. data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.c +1 -2
  68. data/src/core/ext/{client_channel → filters/client_channel}/resolver_registry.h +4 -4
  69. data/src/core/ext/filters/client_channel/retry_throttle.c +210 -0
  70. data/src/core/ext/filters/client_channel/retry_throttle.h +65 -0
  71. data/src/core/ext/{client_channel → filters/client_channel}/subchannel.c +49 -43
  72. data/src/core/ext/{client_channel → filters/client_channel}/subchannel.h +21 -7
  73. data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.c +1 -1
  74. data/src/core/ext/{client_channel → filters/client_channel}/subchannel_index.h +5 -5
  75. data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.c +1 -1
  76. data/src/core/ext/{client_channel → filters/client_channel}/uri_parser.h +3 -3
  77. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.c +4 -2
  78. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting.h +3 -3
  79. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.c +17 -14
  80. data/src/core/ext/{load_reporting → filters/load_reporting}/load_reporting_filter.h +4 -4
  81. data/src/core/ext/filters/max_age/max_age_filter.c +439 -0
  82. data/src/core/ext/filters/max_age/max_age_filter.h +39 -0
  83. data/src/core/ext/transport/chttp2/client/chttp2_connector.c +6 -41
  84. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
  85. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +2 -2
  86. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +3 -3
  87. data/src/core/ext/transport/chttp2/server/chttp2_server.c +2 -2
  88. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +2 -5
  89. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +2 -2
  90. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +449 -204
  91. data/src/core/ext/transport/chttp2/transport/frame_data.c +10 -7
  92. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +3 -2
  93. data/src/core/ext/transport/chttp2/transport/frame_ping.c +37 -7
  94. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -0
  95. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +4 -3
  96. data/src/core/ext/transport/chttp2/transport/frame_settings.c +18 -38
  97. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -29
  98. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +2 -2
  99. data/src/core/ext/transport/chttp2/transport/hpack_encoder.c +64 -37
  100. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +11 -4
  101. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +60 -39
  102. data/src/core/ext/transport/chttp2/transport/hpack_table.c +2 -2
  103. data/src/core/ext/transport/chttp2/transport/http2_settings.c +75 -0
  104. data/src/core/ext/transport/chttp2/transport/http2_settings.h +74 -0
  105. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +22 -43
  106. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +8 -10
  107. data/src/core/ext/transport/chttp2/transport/internal.h +24 -2
  108. data/src/core/ext/transport/chttp2/transport/parsing.c +33 -15
  109. data/src/core/ext/transport/chttp2/transport/writing.c +56 -10
  110. data/src/core/lib/channel/channel_args.c +7 -0
  111. data/src/core/lib/channel/channel_args.h +2 -0
  112. data/src/core/lib/channel/channel_stack.c +20 -27
  113. data/src/core/lib/channel/channel_stack.h +18 -16
  114. data/src/core/lib/channel/compress_filter.c +20 -18
  115. data/src/core/lib/channel/connected_channel.c +9 -8
  116. data/src/core/lib/channel/deadline_filter.c +28 -24
  117. data/src/core/lib/channel/deadline_filter.h +3 -3
  118. data/src/core/lib/channel/handshaker.c +3 -2
  119. data/src/core/lib/channel/http_client_filter.c +119 -61
  120. data/src/core/lib/channel/http_server_filter.c +124 -69
  121. data/src/core/lib/channel/message_size_filter.c +23 -19
  122. data/src/core/lib/http/httpcli.c +8 -6
  123. data/src/core/lib/http/httpcli_security_connector.c +5 -5
  124. data/src/core/lib/http/parser.c +57 -31
  125. data/src/core/lib/iomgr/closure.c +15 -0
  126. data/src/core/lib/iomgr/closure.h +4 -0
  127. data/src/core/lib/iomgr/combiner.c +8 -0
  128. data/src/core/lib/iomgr/endpoint_pair.h +2 -3
  129. data/src/core/lib/iomgr/endpoint_pair_posix.c +10 -7
  130. data/src/core/lib/iomgr/endpoint_pair_uv.c +2 -3
  131. data/src/core/lib/iomgr/endpoint_pair_windows.c +9 -6
  132. data/src/core/lib/iomgr/error.c +360 -177
  133. data/src/core/lib/iomgr/error.h +31 -33
  134. data/src/core/lib/iomgr/error_internal.h +30 -9
  135. data/src/core/lib/iomgr/ev_epoll_linux.c +25 -239
  136. data/src/core/lib/iomgr/ev_poll_posix.c +11 -7
  137. data/src/core/lib/iomgr/ev_posix.c +6 -0
  138. data/src/core/lib/iomgr/ev_posix.h +3 -0
  139. data/src/core/lib/iomgr/exec_ctx.c +6 -0
  140. data/src/core/lib/iomgr/executor.c +8 -2
  141. data/src/core/lib/iomgr/load_file.c +6 -3
  142. data/src/core/lib/iomgr/lockfree_event.c +238 -0
  143. data/src/core/{ext/client_channel/initial_connect_string.h → lib/iomgr/lockfree_event.h} +17 -13
  144. data/src/core/lib/iomgr/pollset.h +4 -0
  145. data/src/core/lib/iomgr/pollset_windows.c +2 -2
  146. data/src/core/lib/iomgr/port.h +9 -0
  147. data/src/core/lib/iomgr/resolve_address_posix.c +15 -9
  148. data/src/core/lib/iomgr/resolve_address_uv.c +8 -6
  149. data/src/core/lib/iomgr/resolve_address_windows.c +2 -2
  150. data/src/core/lib/iomgr/resource_quota.c +19 -4
  151. data/src/core/lib/iomgr/resource_quota.h +2 -0
  152. data/src/core/lib/iomgr/sockaddr_utils.c +3 -1
  153. data/src/core/lib/iomgr/socket_factory_posix.c +110 -0
  154. data/src/core/lib/iomgr/socket_factory_posix.h +90 -0
  155. data/src/core/lib/iomgr/socket_utils_common_posix.c +25 -9
  156. data/src/core/lib/iomgr/socket_utils_posix.h +7 -0
  157. data/src/core/lib/iomgr/tcp_client.h +0 -4
  158. data/src/core/lib/iomgr/tcp_client_posix.c +15 -31
  159. data/src/core/lib/iomgr/tcp_client_uv.c +10 -6
  160. data/src/core/lib/iomgr/tcp_client_windows.c +9 -19
  161. data/src/core/lib/iomgr/tcp_posix.c +111 -22
  162. data/src/core/lib/iomgr/tcp_posix.h +3 -4
  163. data/src/core/lib/iomgr/tcp_server_posix.c +39 -417
  164. data/src/core/lib/iomgr/tcp_server_utils_posix.h +135 -0
  165. data/src/core/lib/iomgr/tcp_server_utils_posix_common.c +221 -0
  166. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.c +196 -0
  167. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.c +49 -0
  168. data/src/core/lib/iomgr/tcp_server_uv.c +43 -16
  169. data/src/core/lib/iomgr/tcp_server_windows.c +10 -22
  170. data/src/core/lib/iomgr/tcp_uv.c +16 -13
  171. data/src/core/lib/iomgr/tcp_windows.c +24 -12
  172. data/src/core/lib/iomgr/tcp_windows.h +2 -2
  173. data/src/core/lib/iomgr/timer.h +3 -0
  174. data/src/core/lib/iomgr/timer_generic.c +257 -72
  175. data/src/core/lib/iomgr/timer_generic.h +1 -1
  176. data/src/core/lib/iomgr/timer_heap.c +8 -8
  177. data/src/core/lib/iomgr/udp_server.c +54 -24
  178. data/src/core/lib/iomgr/udp_server.h +7 -7
  179. data/src/core/lib/iomgr/unix_sockets_posix.c +1 -1
  180. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +2 -1
  181. data/src/core/lib/iomgr/wakeup_fd_posix.h +1 -1
  182. data/src/core/lib/profiling/basic_timers.c +1 -1
  183. data/src/core/lib/security/credentials/credentials.h +1 -1
  184. data/src/core/lib/security/credentials/google_default/google_default_credentials.c +10 -9
  185. data/src/core/lib/security/credentials/jwt/json_token.c +1 -1
  186. data/src/core/lib/security/credentials/jwt/jwt_verifier.c +2 -2
  187. data/src/core/lib/security/transport/client_auth_filter.c +33 -26
  188. data/src/core/lib/security/transport/secure_endpoint.c +8 -5
  189. data/src/core/lib/security/transport/security_connector.c +37 -37
  190. data/src/core/lib/security/transport/security_connector.h +1 -1
  191. data/src/core/lib/security/transport/security_handshaker.c +15 -12
  192. data/src/core/lib/security/transport/server_auth_filter.c +20 -18
  193. data/src/core/lib/security/transport/tsi_error.c +5 -3
  194. data/src/core/lib/security/transport/tsi_error.h +1 -1
  195. data/src/core/lib/{security/util → slice}/b64.c +21 -6
  196. data/src/core/lib/{security/util → slice}/b64.h +16 -4
  197. data/src/core/lib/slice/slice.c +4 -2
  198. data/src/core/lib/slice/slice_buffer.c +16 -14
  199. data/src/core/lib/support/arena.c +98 -0
  200. data/src/core/{ext/client_channel/initial_connect_string.c → lib/support/arena.h} +17 -15
  201. data/src/core/{ext/client_channel/default_initial_connect_string.c → lib/support/atm.c} +14 -5
  202. data/src/core/lib/support/cpu_linux.c +5 -0
  203. data/src/core/lib/support/sync.c +4 -0
  204. data/src/core/lib/support/time.c +4 -10
  205. data/src/core/lib/support/wrap_memcpy.c +3 -1
  206. data/src/core/lib/surface/call.c +252 -221
  207. data/src/core/lib/surface/channel.c +72 -21
  208. data/src/core/lib/surface/channel.h +8 -0
  209. data/src/core/lib/surface/completion_queue.c +2 -3
  210. data/src/core/lib/surface/completion_queue_factory.c +77 -0
  211. data/src/core/lib/surface/completion_queue_factory.h +51 -0
  212. data/src/core/lib/surface/init_secure.c +3 -1
  213. data/src/core/lib/surface/lame_client.c +18 -14
  214. data/src/core/lib/surface/server.c +43 -41
  215. data/src/core/lib/surface/validate_metadata.c +8 -4
  216. data/src/core/lib/surface/version.c +2 -2
  217. data/src/core/lib/transport/bdp_estimator.h +1 -1
  218. data/src/core/lib/transport/connectivity_state.c +2 -1
  219. data/src/core/lib/transport/error_utils.c +17 -17
  220. data/src/core/lib/transport/error_utils.h +1 -1
  221. data/src/core/lib/transport/metadata_batch.c +6 -7
  222. data/src/core/lib/transport/pid_controller.c +1 -0
  223. data/src/core/lib/transport/service_config.c +12 -0
  224. data/src/core/lib/transport/service_config.h +6 -0
  225. data/src/core/lib/transport/transport.c +29 -17
  226. data/src/core/lib/transport/transport.h +85 -42
  227. data/src/core/lib/transport/transport_impl.h +5 -3
  228. data/src/core/lib/transport/transport_op_string.c +20 -14
  229. data/src/core/plugin_registry/grpc_plugin_registry.c +8 -0
  230. data/src/core/{lib/tsi → tsi}/fake_transport_security.c +2 -2
  231. data/src/core/{lib/tsi → tsi}/fake_transport_security.h +4 -4
  232. data/src/core/{lib/tsi → tsi}/ssl_transport_security.c +40 -79
  233. data/src/core/{lib/tsi → tsi}/ssl_transport_security.h +44 -21
  234. data/src/core/{lib/tsi → tsi}/ssl_types.h +3 -3
  235. data/src/core/{lib/tsi → tsi}/transport_security.c +2 -2
  236. data/src/core/{lib/tsi → tsi}/transport_security.h +4 -4
  237. data/src/core/{lib/tsi → tsi}/transport_security_interface.h +3 -3
  238. data/src/ruby/ext/grpc/extconf.rb +1 -0
  239. data/src/ruby/ext/grpc/rb_call_credentials.c +2 -2
  240. data/src/ruby/ext/grpc/rb_channel.c +520 -93
  241. data/src/ruby/ext/grpc/rb_channel.h +2 -0
  242. data/src/ruby/ext/grpc/rb_channel_credentials.c +3 -0
  243. data/src/ruby/ext/grpc/rb_compression_options.c +5 -2
  244. data/src/ruby/ext/grpc/rb_event_thread.c +6 -6
  245. data/src/ruby/ext/grpc/rb_grpc.c +29 -7
  246. data/src/ruby/ext/grpc/rb_grpc.h +2 -0
  247. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
  249. data/src/ruby/ext/grpc/rb_server.c +5 -3
  250. data/src/ruby/lib/grpc/version.rb +1 -1
  251. data/src/ruby/spec/channel_connection_spec.rb +173 -0
  252. data/src/ruby/spec/channel_spec.rb +29 -0
  253. data/src/ruby/spec/generic/rpc_server_pool_spec.rb +27 -17
  254. data/third_party/cares/ares_build.h +264 -0
  255. data/third_party/cares/cares/ares.h +636 -0
  256. data/third_party/cares/cares/ares__close_sockets.c +61 -0
  257. data/third_party/cares/cares/ares__get_hostent.c +261 -0
  258. data/third_party/cares/cares/ares__read_line.c +73 -0
  259. data/third_party/cares/cares/ares__timeval.c +111 -0
  260. data/third_party/cares/cares/ares_cancel.c +63 -0
  261. data/third_party/cares/cares/ares_create_query.c +202 -0
  262. data/third_party/cares/cares/ares_data.c +221 -0
  263. data/third_party/cares/cares/ares_data.h +72 -0
  264. data/third_party/cares/cares/ares_destroy.c +108 -0
  265. data/third_party/cares/cares/ares_dns.h +103 -0
  266. data/third_party/cares/cares/ares_expand_name.c +205 -0
  267. data/third_party/cares/cares/ares_expand_string.c +70 -0
  268. data/third_party/cares/cares/ares_fds.c +59 -0
  269. data/third_party/cares/cares/ares_free_hostent.c +41 -0
  270. data/third_party/cares/cares/ares_free_string.c +25 -0
  271. data/third_party/cares/cares/ares_getenv.c +30 -0
  272. data/third_party/cares/cares/ares_getenv.h +26 -0
  273. data/third_party/cares/cares/ares_gethostbyaddr.c +294 -0
  274. data/third_party/cares/cares/ares_gethostbyname.c +518 -0
  275. data/third_party/cares/cares/ares_getnameinfo.c +422 -0
  276. data/third_party/cares/cares/ares_getopt.c +122 -0
  277. data/third_party/cares/cares/ares_getopt.h +53 -0
  278. data/third_party/cares/cares/ares_getsock.c +66 -0
  279. data/third_party/cares/cares/ares_inet_net_pton.h +25 -0
  280. data/third_party/cares/cares/ares_init.c +2146 -0
  281. data/third_party/cares/cares/ares_iphlpapi.h +221 -0
  282. data/third_party/cares/cares/ares_ipv6.h +78 -0
  283. data/third_party/cares/cares/ares_library_init.c +167 -0
  284. data/third_party/cares/cares/ares_library_init.h +42 -0
  285. data/third_party/cares/cares/ares_llist.c +63 -0
  286. data/third_party/cares/cares/ares_llist.h +39 -0
  287. data/third_party/cares/cares/ares_mkquery.c +24 -0
  288. data/third_party/cares/cares/ares_nowarn.c +260 -0
  289. data/third_party/cares/cares/ares_nowarn.h +61 -0
  290. data/third_party/cares/cares/ares_options.c +402 -0
  291. data/third_party/cares/cares/ares_parse_a_reply.c +264 -0
  292. data/third_party/cares/cares/ares_parse_aaaa_reply.c +264 -0
  293. data/third_party/cares/cares/ares_parse_mx_reply.c +170 -0
  294. data/third_party/cares/cares/ares_parse_naptr_reply.c +188 -0
  295. data/third_party/cares/cares/ares_parse_ns_reply.c +183 -0
  296. data/third_party/cares/cares/ares_parse_ptr_reply.c +219 -0
  297. data/third_party/cares/cares/ares_parse_soa_reply.c +133 -0
  298. data/third_party/cares/cares/ares_parse_srv_reply.c +179 -0
  299. data/third_party/cares/cares/ares_parse_txt_reply.c +220 -0
  300. data/third_party/cares/cares/ares_platform.c +11035 -0
  301. data/third_party/cares/cares/ares_platform.h +43 -0
  302. data/third_party/cares/cares/ares_private.h +363 -0
  303. data/third_party/cares/cares/ares_process.c +1359 -0
  304. data/third_party/cares/cares/ares_query.c +186 -0
  305. data/third_party/cares/cares/ares_rules.h +125 -0
  306. data/third_party/cares/cares/ares_search.c +316 -0
  307. data/third_party/cares/cares/ares_send.c +131 -0
  308. data/third_party/cares/cares/ares_setup.h +217 -0
  309. data/third_party/cares/cares/ares_strcasecmp.c +66 -0
  310. data/third_party/cares/cares/ares_strcasecmp.h +30 -0
  311. data/third_party/cares/cares/ares_strdup.c +49 -0
  312. data/third_party/cares/cares/ares_strdup.h +24 -0
  313. data/third_party/cares/cares/ares_strerror.c +56 -0
  314. data/third_party/cares/cares/ares_timeout.c +88 -0
  315. data/third_party/cares/cares/ares_version.c +11 -0
  316. data/third_party/cares/cares/ares_version.h +24 -0
  317. data/third_party/cares/cares/ares_writev.c +79 -0
  318. data/third_party/cares/cares/bitncmp.c +59 -0
  319. data/third_party/cares/cares/bitncmp.h +26 -0
  320. data/third_party/cares/cares/config-win32.h +377 -0
  321. data/third_party/cares/cares/inet_net_pton.c +450 -0
  322. data/third_party/cares/cares/inet_ntop.c +208 -0
  323. data/third_party/cares/cares/setup_once.h +554 -0
  324. data/third_party/cares/cares/windows_port.c +22 -0
  325. data/third_party/cares/config_darwin/ares_config.h +523 -0
  326. data/third_party/cares/config_linux/ares_config.h +524 -0
  327. metadata +164 -68
@@ -41,6 +41,8 @@
41
41
  /* Initializes the Channel class. */
42
42
  void Init_grpc_channel();
43
43
 
44
+ void grpc_rb_channel_polling_thread_start();
45
+
44
46
  /* Gets the wrapped channel from the ruby wrapper */
45
47
  grpc_channel* grpc_rb_get_wrapped_channel(VALUE v);
46
48
 
@@ -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
- gpr_malloc(sizeof(grpc_rb_compression_options));
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 ((event = grpc_rb_event_queue_dequeue()) == NULL) {
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 event;
119
+ return NULL;
120
120
  }
121
121
 
122
122
  static void grpc_rb_event_unblocking_func(void *arg) {
@@ -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 grpc_ruby_once_init() {
296
+ static void grpc_ruby_once_init_internal() {
295
297
  grpc_init();
296
298
  atexit(grpc_rb_shutdown);
297
299
  }
298
300
 
299
- void Init_grpc_c() {
300
- if (!grpc_rb_load_core()) {
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, grpc_ruby_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");
@@ -82,4 +82,6 @@ VALUE grpc_rb_cannot_init_copy(VALUE copy, VALUE self);
82
82
  /* grpc_rb_time_timeval creates a gpr_timespec from a ruby time object. */
83
83
  gpr_timespec grpc_rb_time_timeval(VALUE time, int interval);
84
84
 
85
+ void grpc_ruby_once_init();
86
+
85
87
  #endif /* GRPC_RB_H_ */
@@ -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 = grpc_completion_queue_create(NULL);
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(
@@ -29,5 +29,5 @@
29
29
 
30
30
  # GRPC contains the General RPC module.
31
31
  module GRPC
32
- VERSION = '1.2.5'
32
+ VERSION = '1.3.4'
33
33
  end
@@ -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)