grpc 0.14.1 → 0.15.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.

Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1398 -817
  3. data/include/grpc/compression.h +2 -1
  4. data/include/grpc/grpc.h +10 -1
  5. data/include/grpc/grpc_cronet.h +51 -0
  6. data/include/grpc/grpc_posix.h +70 -0
  7. data/include/grpc/impl/codegen/atm.h +2 -2
  8. data/include/grpc/impl/codegen/{atm_win32.h → atm_windows.h} +3 -3
  9. data/include/grpc/impl/codegen/compression_types.h +39 -5
  10. data/include/grpc/impl/codegen/connectivity_state.h +1 -1
  11. data/include/grpc/impl/codegen/grpc_types.h +10 -0
  12. data/include/grpc/impl/codegen/log.h +2 -1
  13. data/include/grpc/impl/codegen/port_platform.h +30 -12
  14. data/include/grpc/impl/codegen/slice_buffer.h +2 -3
  15. data/include/grpc/impl/codegen/sync.h +2 -2
  16. data/include/grpc/impl/codegen/{sync_win32.h → sync_windows.h} +3 -3
  17. data/include/grpc/support/{sync_win32.h → atm_windows.h} +4 -4
  18. data/include/grpc/support/avl.h +5 -0
  19. data/include/grpc/support/{log_win32.h → log_windows.h} +3 -3
  20. data/include/grpc/support/string_util.h +2 -1
  21. data/include/grpc/support/{atm_win32.h → sync_windows.h} +4 -4
  22. data/src/core/ext/census/gen/census.pb.c +179 -0
  23. data/src/core/ext/census/gen/census.pb.h +294 -0
  24. data/src/core/ext/census/grpc_filter.c +11 -7
  25. data/src/core/ext/client_config/channel_connectivity.c +28 -14
  26. data/src/core/ext/client_config/client_channel.c +77 -53
  27. data/src/core/ext/client_config/connector.h +1 -1
  28. data/src/core/ext/client_config/lb_policy.c +9 -6
  29. data/src/core/ext/client_config/lb_policy.h +9 -5
  30. data/src/core/ext/client_config/subchannel.c +58 -39
  31. data/src/core/ext/client_config/subchannel.h +3 -2
  32. data/src/core/ext/client_config/subchannel_call_holder.c +34 -19
  33. data/src/core/ext/client_config/subchannel_call_holder.h +2 -1
  34. data/src/core/ext/client_config/subchannel_index.c +20 -9
  35. data/src/core/ext/lb_policy/grpclb/load_balancer_api.c +7 -7
  36. data/src/core/ext/lb_policy/grpclb/load_balancer_api.h +5 -5
  37. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/{v0 → v1}/load_balancer.pb.c +29 -30
  38. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +178 -0
  39. data/src/core/ext/lb_policy/pick_first/pick_first.c +65 -45
  40. data/src/core/ext/lb_policy/round_robin/round_robin.c +84 -43
  41. data/src/core/ext/load_reporting/load_reporting.c +133 -0
  42. data/src/core/ext/load_reporting/load_reporting.h +75 -0
  43. data/src/core/ext/load_reporting/load_reporting_filter.c +151 -0
  44. data/src/core/ext/load_reporting/load_reporting_filter.h +41 -0
  45. data/src/core/ext/resolver/dns/native/dns_resolver.c +22 -8
  46. data/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +2 -2
  47. data/src/core/ext/transport/chttp2/client/insecure/channel_create.c +4 -4
  48. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c +95 -0
  49. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +14 -18
  50. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +49 -24
  51. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c +82 -0
  52. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +104 -60
  53. data/src/core/ext/transport/chttp2/transport/bin_decoder.c +232 -0
  54. data/src/{ruby/ext/grpc/rb_signal.c → core/ext/transport/chttp2/transport/bin_decoder.h} +27 -31
  55. data/src/core/ext/transport/chttp2/transport/chttp2_transport.c +481 -260
  56. data/src/core/ext/transport/chttp2/transport/frame.h +1 -7
  57. data/src/core/ext/transport/chttp2/transport/frame_data.c +44 -27
  58. data/src/core/ext/transport/chttp2/transport/frame_data.h +6 -5
  59. data/src/core/ext/transport/chttp2/transport/frame_goaway.c +23 -17
  60. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -2
  61. data/src/core/ext/transport/chttp2/transport/frame_ping.c +12 -7
  62. data/src/core/ext/transport/chttp2/transport/frame_ping.h +3 -3
  63. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +25 -12
  64. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -2
  65. data/src/core/ext/transport/chttp2/transport/frame_settings.c +23 -21
  66. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -2
  67. data/src/core/ext/transport/chttp2/transport/frame_window_update.c +17 -9
  68. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -2
  69. data/src/core/ext/transport/chttp2/transport/hpack_parser.c +365 -287
  70. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +8 -6
  71. data/src/core/ext/transport/chttp2/transport/hpack_table.c +24 -20
  72. data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -4
  73. data/src/core/ext/transport/chttp2/transport/incoming_metadata.c +1 -0
  74. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +1 -0
  75. data/src/core/ext/transport/chttp2/transport/internal.h +34 -32
  76. data/src/core/ext/transport/chttp2/transport/parsing.c +296 -212
  77. data/src/core/ext/transport/chttp2/transport/writing.c +12 -9
  78. data/src/core/lib/channel/channel_args.c +26 -12
  79. data/src/core/lib/channel/channel_args.h +1 -1
  80. data/src/core/lib/channel/channel_stack.c +12 -8
  81. data/src/core/lib/channel/channel_stack.h +27 -11
  82. data/src/core/lib/channel/channel_stack_builder.c +2 -2
  83. data/src/core/lib/channel/compress_filter.c +26 -31
  84. data/src/core/lib/channel/compress_filter.h +4 -4
  85. data/src/core/lib/channel/connected_channel.c +7 -5
  86. data/src/core/lib/channel/http_client_filter.c +34 -8
  87. data/src/core/lib/channel/http_client_filter.h +1 -1
  88. data/src/core/lib/channel/http_server_filter.c +21 -12
  89. data/src/core/lib/compression/{compression_algorithm.c → compression.c} +22 -21
  90. data/src/core/lib/http/httpcli.c +81 -59
  91. data/src/core/lib/http/httpcli.h +11 -15
  92. data/src/core/lib/http/httpcli_security_connector.c +5 -3
  93. data/src/core/lib/http/parser.c +127 -118
  94. data/src/core/lib/http/parser.h +11 -6
  95. data/src/core/lib/iomgr/closure.c +20 -16
  96. data/src/core/lib/iomgr/closure.h +19 -15
  97. data/src/core/lib/iomgr/endpoint.h +1 -1
  98. data/src/core/lib/iomgr/endpoint_pair_posix.c +2 -2
  99. data/src/core/lib/iomgr/error.c +535 -0
  100. data/src/core/lib/iomgr/error.h +192 -0
  101. data/src/core/lib/iomgr/ev_poll_and_epoll_posix.c +190 -83
  102. data/src/core/lib/iomgr/ev_poll_posix.c +1267 -0
  103. data/src/{ruby/ext/grpc/rb_signal.h → core/lib/iomgr/ev_poll_posix.h} +7 -5
  104. data/src/core/lib/iomgr/ev_posix.c +104 -14
  105. data/src/core/lib/iomgr/ev_posix.h +17 -7
  106. data/src/core/lib/iomgr/exec_ctx.c +25 -7
  107. data/src/core/lib/iomgr/exec_ctx.h +27 -8
  108. data/src/core/lib/iomgr/executor.c +2 -2
  109. data/src/core/lib/iomgr/executor.h +1 -1
  110. data/src/core/lib/iomgr/iocp_windows.c +2 -41
  111. data/src/core/lib/iomgr/iocp_windows.h +0 -8
  112. data/src/core/lib/iomgr/iomgr.c +5 -4
  113. data/src/core/lib/iomgr/iomgr_posix.c +5 -1
  114. data/src/core/lib/iomgr/iomgr_windows.c +1 -1
  115. data/src/core/lib/{support → iomgr}/load_file.c +15 -17
  116. data/src/core/lib/{support → iomgr}/load_file.h +8 -7
  117. data/src/core/lib/iomgr/polling_entity.c +104 -0
  118. data/src/core/lib/iomgr/polling_entity.h +81 -0
  119. data/src/core/lib/iomgr/pollset.h +6 -5
  120. data/src/core/lib/iomgr/pollset_set_windows.c +4 -1
  121. data/src/core/lib/iomgr/pollset_windows.c +10 -6
  122. data/src/core/lib/iomgr/resolve_address.h +5 -9
  123. data/src/core/lib/iomgr/resolve_address_posix.c +55 -38
  124. data/src/core/lib/iomgr/resolve_address_windows.c +51 -37
  125. data/src/core/lib/iomgr/sockaddr.h +2 -2
  126. data/src/core/lib/iomgr/{sockaddr_win32.h → sockaddr_windows.h} +3 -3
  127. data/src/core/lib/iomgr/socket_utils_common_posix.c +92 -45
  128. data/src/core/lib/iomgr/socket_utils_posix.h +19 -12
  129. data/src/core/lib/iomgr/socket_windows.c +61 -2
  130. data/src/core/lib/iomgr/socket_windows.h +13 -0
  131. data/src/core/lib/iomgr/tcp_client_posix.c +54 -39
  132. data/src/core/lib/iomgr/tcp_client_windows.c +34 -34
  133. data/src/core/lib/iomgr/tcp_posix.c +43 -39
  134. data/src/core/lib/iomgr/tcp_server.h +5 -3
  135. data/src/core/lib/iomgr/tcp_server_posix.c +103 -64
  136. data/src/core/lib/iomgr/tcp_server_windows.c +114 -101
  137. data/src/core/lib/iomgr/tcp_windows.c +45 -50
  138. data/src/core/lib/iomgr/tcp_windows.h +1 -1
  139. data/src/core/lib/iomgr/timer.c +26 -13
  140. data/src/core/lib/iomgr/udp_server.c +28 -4
  141. data/src/core/lib/iomgr/udp_server.h +5 -1
  142. data/src/core/lib/iomgr/unix_sockets_posix.c +8 -7
  143. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -1
  144. data/src/core/lib/iomgr/unix_sockets_posix_noop.c +4 -2
  145. data/src/core/lib/iomgr/wakeup_fd_eventfd.c +15 -5
  146. data/src/core/lib/iomgr/wakeup_fd_pipe.c +13 -9
  147. data/src/core/lib/iomgr/wakeup_fd_posix.c +6 -6
  148. data/src/core/lib/iomgr/wakeup_fd_posix.h +9 -6
  149. data/src/core/lib/iomgr/workqueue.h +5 -4
  150. data/src/core/lib/iomgr/workqueue_posix.c +40 -26
  151. data/src/core/lib/iomgr/workqueue_windows.c +2 -2
  152. data/src/core/lib/profiling/basic_timers.c +2 -2
  153. data/src/core/lib/security/{security_context.c → context/security_context.c} +1 -1
  154. data/src/core/lib/security/{security_context.h → context/security_context.h} +4 -4
  155. data/src/core/lib/security/credentials/composite/composite_credentials.c +263 -0
  156. data/src/core/lib/security/credentials/composite/composite_credentials.h +72 -0
  157. data/src/core/lib/security/credentials/credentials.c +233 -0
  158. data/src/core/lib/security/{credentials.h → credentials/credentials.h} +19 -157
  159. data/src/core/lib/security/{credentials_metadata.c → credentials/credentials_metadata.c} +1 -1
  160. data/src/core/lib/security/credentials/fake/fake_credentials.c +139 -0
  161. data/src/core/lib/security/credentials/fake/fake_credentials.h +56 -0
  162. data/src/core/lib/security/{credentials_posix.c → credentials/google_default/credentials_posix.c} +1 -1
  163. data/src/core/lib/security/{credentials_win32.c → credentials/google_default/credentials_windows.c} +3 -3
  164. data/src/core/lib/security/{google_default_credentials.c → credentials/google_default/google_default_credentials.c} +93 -35
  165. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +46 -0
  166. data/src/core/lib/security/credentials/iam/iam_credentials.c +85 -0
  167. data/src/core/lib/security/credentials/iam/iam_credentials.h +44 -0
  168. data/src/core/lib/security/{json_token.c → credentials/jwt/json_token.c} +10 -101
  169. data/src/core/lib/security/{json_token.h → credentials/jwt/json_token.h} +3 -33
  170. data/src/core/lib/security/credentials/jwt/jwt_credentials.c +160 -0
  171. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +62 -0
  172. data/src/core/lib/security/{jwt_verifier.c → credentials/jwt/jwt_verifier.c} +35 -15
  173. data/src/core/lib/security/{jwt_verifier.h → credentials/jwt/jwt_verifier.h} +3 -3
  174. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.c +433 -0
  175. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +109 -0
  176. data/src/core/lib/security/credentials/plugin/plugin_credentials.c +129 -0
  177. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +45 -0
  178. data/src/core/lib/security/credentials/ssl/ssl_credentials.c +240 -0
  179. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +48 -0
  180. data/src/core/lib/security/{auth_filters.h → transport/auth_filters.h} +3 -3
  181. data/src/core/lib/security/{client_auth_filter.c → transport/client_auth_filter.c} +27 -20
  182. data/src/core/lib/security/{handshake.c → transport/handshake.c} +77 -45
  183. data/src/core/lib/security/{handshake.h → transport/handshake.h} +9 -11
  184. data/src/core/lib/security/{secure_endpoint.c → transport/secure_endpoint.c} +19 -12
  185. data/src/core/lib/security/{secure_endpoint.h → transport/secure_endpoint.h} +3 -3
  186. data/src/core/lib/security/{security_connector.c → transport/security_connector.c} +26 -17
  187. data/src/core/lib/security/{security_connector.h → transport/security_connector.h} +8 -8
  188. data/src/core/lib/security/{server_auth_filter.c → transport/server_auth_filter.c} +24 -16
  189. data/src/core/lib/security/transport/tsi_error.c +40 -0
  190. data/src/core/lib/security/transport/tsi_error.h +42 -0
  191. data/src/core/lib/security/{b64.c → util/b64.c} +1 -1
  192. data/src/core/lib/security/{b64.h → util/b64.h} +3 -3
  193. data/src/core/lib/security/util/json_util.c +61 -0
  194. data/src/core/lib/security/util/json_util.h +55 -0
  195. data/src/core/lib/support/avl.c +11 -0
  196. data/src/core/lib/support/cpu_windows.c +2 -2
  197. data/src/core/lib/support/{env_win32.c → env_windows.c} +3 -3
  198. data/src/core/lib/support/log.c +3 -1
  199. data/src/core/lib/support/log_linux.c +2 -2
  200. data/src/core/lib/support/{log_win32.c → log_windows.c} +4 -4
  201. data/src/core/lib/support/murmur_hash.c +3 -5
  202. data/src/core/lib/support/string.c +10 -0
  203. data/src/core/lib/support/string.h +4 -0
  204. data/src/core/lib/support/{string_util_win32.c → string_util_windows.c} +3 -3
  205. data/src/core/lib/support/{string_win32.c → string_windows.c} +2 -2
  206. data/src/core/lib/support/{string_win32.h → string_windows.h} +5 -5
  207. data/src/core/lib/support/subprocess_windows.c +1 -1
  208. data/src/core/lib/support/{sync_win32.c → sync_windows.c} +2 -2
  209. data/src/core/lib/support/{thd_win32.c → thd_windows.c} +2 -2
  210. data/src/core/lib/support/{time_win32.c → time_windows.c} +2 -2
  211. data/src/core/lib/support/tmpfile_msys.c +1 -1
  212. data/src/core/lib/support/{tmpfile_win32.c → tmpfile_windows.c} +3 -3
  213. data/src/core/lib/surface/alarm.c +2 -2
  214. data/src/core/lib/surface/byte_buffer_reader.c +13 -6
  215. data/src/core/lib/surface/call.c +323 -123
  216. data/src/core/lib/surface/call.h +2 -0
  217. data/src/core/lib/surface/call_log_batch.c +1 -1
  218. data/src/core/lib/surface/channel.c +64 -15
  219. data/src/core/lib/surface/channel.h +9 -0
  220. data/src/core/lib/surface/channel_ping.c +3 -3
  221. data/src/core/lib/surface/completion_queue.c +75 -19
  222. data/src/core/lib/surface/completion_queue.h +7 -2
  223. data/src/core/lib/surface/init.c +2 -1
  224. data/src/core/lib/surface/init_secure.c +4 -4
  225. data/src/core/lib/surface/lame_client.c +12 -8
  226. data/src/core/lib/surface/server.c +213 -120
  227. data/src/core/lib/surface/server.h +1 -0
  228. data/src/core/lib/surface/version.c +1 -1
  229. data/src/core/lib/transport/connectivity_state.c +40 -18
  230. data/src/core/lib/transport/connectivity_state.h +4 -1
  231. data/src/core/lib/transport/metadata.c +23 -23
  232. data/src/core/lib/transport/metadata.h +4 -0
  233. data/src/core/lib/transport/metadata_batch.c +9 -0
  234. data/src/core/lib/transport/metadata_batch.h +3 -0
  235. data/src/core/lib/transport/static_metadata.c +6 -5
  236. data/src/core/lib/transport/static_metadata.h +64 -60
  237. data/src/core/lib/transport/transport.c +24 -12
  238. data/src/core/lib/transport/transport.h +6 -5
  239. data/src/core/lib/transport/transport_impl.h +4 -0
  240. data/src/core/lib/transport/transport_op_string.c +2 -2
  241. data/src/core/plugin_registry/grpc_plugin_registry.c +4 -0
  242. data/src/ruby/bin/math_services.rb +41 -2
  243. data/src/ruby/ext/grpc/rb_call.c +42 -40
  244. data/src/ruby/ext/grpc/rb_channel.c +1 -1
  245. data/src/ruby/ext/grpc/rb_completion_queue.c +59 -6
  246. data/src/ruby/ext/grpc/rb_completion_queue.h +1 -1
  247. data/src/ruby/ext/grpc/rb_grpc.c +1 -3
  248. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +12 -2
  249. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +21 -5
  250. data/src/ruby/ext/grpc/rb_loader.c +1 -1
  251. data/src/ruby/ext/grpc/rb_server.c +5 -3
  252. data/src/ruby/lib/grpc.rb +0 -3
  253. data/src/ruby/lib/grpc/errors.rb +3 -2
  254. data/src/ruby/lib/grpc/generic/active_call.rb +32 -42
  255. data/src/ruby/lib/grpc/generic/bidi_call.rb +20 -0
  256. data/src/ruby/lib/grpc/generic/client_stub.rb +31 -54
  257. data/src/ruby/lib/grpc/generic/rpc_desc.rb +4 -4
  258. data/src/ruby/lib/grpc/generic/rpc_server.rb +12 -23
  259. data/src/ruby/lib/grpc/generic/service.rb +8 -8
  260. data/src/ruby/lib/grpc/version.rb +1 -1
  261. data/src/ruby/pb/grpc/health/v1/health_services.rb +30 -2
  262. data/src/ruby/pb/grpc/testing/duplicate/echo_duplicate_services.rb +34 -4
  263. data/src/ruby/pb/grpc/testing/metrics_services.rb +39 -2
  264. data/src/ruby/pb/src/proto/grpc/testing/empty.rb +15 -0
  265. data/src/ruby/pb/src/proto/grpc/testing/messages.rb +84 -0
  266. data/src/ruby/pb/src/proto/grpc/testing/test.rb +14 -0
  267. data/src/ruby/pb/src/proto/grpc/testing/test_services.rb +110 -0
  268. data/src/ruby/pb/test/client.rb +5 -2
  269. data/src/ruby/spec/generic/active_call_spec.rb +3 -2
  270. data/src/ruby/spec/generic/client_stub_spec.rb +27 -24
  271. data/src/ruby/spec/generic/rpc_desc_spec.rb +11 -11
  272. data/src/ruby/spec/generic/rpc_server_spec.rb +42 -61
  273. data/src/ruby/spec/pb/health/checker_spec.rb +3 -5
  274. metadata +86 -48
  275. data/src/core/ext/lb_policy/grpclb/proto/grpc/lb/v0/load_balancer.pb.h +0 -182
  276. data/src/core/lib/security/credentials.c +0 -1296
  277. data/src/ruby/lib/grpc/signals.rb +0 -69
@@ -44,21 +44,21 @@ module GRPC
44
44
 
45
45
  # setup_channel is used by #initialize to constuct a channel from its
46
46
  # arguments.
47
- def self.setup_channel(alt_chan, host, creds, **kw)
47
+ def self.setup_channel(alt_chan, host, creds, channel_args = {})
48
48
  unless alt_chan.nil?
49
49
  fail(TypeError, '!Channel') unless alt_chan.is_a?(Core::Channel)
50
50
  return alt_chan
51
51
  end
52
- if kw['grpc.primary_user_agent'].nil?
53
- kw['grpc.primary_user_agent'] = ''
52
+ if channel_args['grpc.primary_user_agent'].nil?
53
+ channel_args['grpc.primary_user_agent'] = ''
54
54
  else
55
- kw['grpc.primary_user_agent'] += ' '
55
+ channel_args['grpc.primary_user_agent'] += ' '
56
56
  end
57
- kw['grpc.primary_user_agent'] += "grpc-ruby/#{VERSION}"
57
+ channel_args['grpc.primary_user_agent'] += "grpc-ruby/#{VERSION}"
58
58
  unless creds.is_a?(Core::ChannelCredentials) || creds.is_a?(Symbol)
59
59
  fail(TypeError, '!ChannelCredentials or Symbol')
60
60
  end
61
- Core::Channel.new(host, kw, creds)
61
+ Core::Channel.new(host, channel_args, creds)
62
62
  end
63
63
 
64
64
  # Allows users of the stub to modify the propagate mask.
@@ -96,15 +96,16 @@ module GRPC
96
96
  # :this_channel_is_insecure
97
97
  # @param channel_override [Core::Channel] a pre-created channel
98
98
  # @param timeout [Number] the default timeout to use in requests
99
- # @param kw [KeywordArgs]the channel arguments
99
+ # @param channel_args [Hash] the channel arguments
100
100
  def initialize(host, q, creds,
101
101
  channel_override: nil,
102
102
  timeout: nil,
103
103
  propagate_mask: nil,
104
- **kw)
104
+ channel_args: {})
105
105
  fail(TypeError, '!CompletionQueue') unless q.is_a?(Core::CompletionQueue)
106
- @ch = ClientStub.setup_channel(channel_override, host, creds, **kw)
107
- alt_host = kw[Core::Channel::SSL_TARGET]
106
+ @ch = ClientStub.setup_channel(channel_override, host, creds,
107
+ channel_args)
108
+ alt_host = channel_args[Core::Channel::SSL_TARGET]
108
109
  @host = alt_host.nil? ? host : alt_host
109
110
  @propagate_mask = propagate_mask
110
111
  @timeout = timeout.nil? ? DEFAULT_TIMEOUT : timeout
@@ -135,42 +136,35 @@ module GRPC
135
136
  # If return_op is true, the call returns an Operation, calling execute
136
137
  # on the Operation returns the response.
137
138
  #
138
- # == Keyword Args ==
139
- #
140
- # Unspecified keyword arguments are treated as metadata to be sent to the
141
- # server.
142
- #
143
139
  # @param method [String] the RPC method to call on the GRPC server
144
140
  # @param req [Object] the request sent to the server
145
141
  # @param marshal [Function] f(obj)->string that marshals requests
146
142
  # @param unmarshal [Function] f(string)->obj that unmarshals responses
147
- # @param timeout [Numeric] (optional) the max completion time in seconds
148
143
  # @param deadline [Time] (optional) the time the request should complete
144
+ # @param return_op [true|false] return an Operation if true
149
145
  # @param parent [Core::Call] a prior call whose reserved metadata
150
146
  # will be propagated by this one.
151
147
  # @param credentials [Core::CallCredentials] credentials to use when making
152
148
  # the call
153
- # @param return_op [true|false] return an Operation if true
149
+ # @param metadata [Hash] metadata to be sent to the server
154
150
  # @return [Object] the response received from the server
155
151
  def request_response(method, req, marshal, unmarshal,
156
152
  deadline: nil,
157
- timeout: nil,
158
153
  return_op: false,
159
154
  parent: nil,
160
155
  credentials: nil,
161
- **kw)
156
+ metadata: {})
162
157
  c = new_active_call(method, marshal, unmarshal,
163
158
  deadline: deadline,
164
- timeout: timeout,
165
159
  parent: parent,
166
160
  credentials: credentials)
167
- return c.request_response(req, **kw) unless return_op
161
+ return c.request_response(req, metadata: metadata) unless return_op
168
162
 
169
163
  # return the operation view of the active_call; define #execute as a
170
164
  # new method for this instance that invokes #request_response.
171
165
  op = c.operation
172
166
  op.define_singleton_method(:execute) do
173
- c.request_response(req, **kw)
167
+ c.request_response(req, metadata: metadata)
174
168
  end
175
169
  op
176
170
  end
@@ -205,42 +199,35 @@ module GRPC
205
199
  #
206
200
  # If return_op is true, the call returns the response.
207
201
  #
208
- # == Keyword Args ==
209
- #
210
- # Unspecified keyword arguments are treated as metadata to be sent to the
211
- # server.
212
- #
213
202
  # @param method [String] the RPC method to call on the GRPC server
214
203
  # @param requests [Object] an Enumerable of requests to send
215
204
  # @param marshal [Function] f(obj)->string that marshals requests
216
205
  # @param unmarshal [Function] f(string)->obj that unmarshals responses
217
- # @param timeout [Numeric] (optional) the max completion time in seconds
218
206
  # @param deadline [Time] (optional) the time the request should complete
219
207
  # @param return_op [true|false] return an Operation if true
220
208
  # @param parent [Core::Call] a prior call whose reserved metadata
221
209
  # will be propagated by this one.
222
210
  # @param credentials [Core::CallCredentials] credentials to use when making
223
211
  # the call
212
+ # @param metadata [Hash] metadata to be sent to the server
224
213
  # @return [Object|Operation] the response received from the server
225
214
  def client_streamer(method, requests, marshal, unmarshal,
226
215
  deadline: nil,
227
- timeout: nil,
228
216
  return_op: false,
229
217
  parent: nil,
230
218
  credentials: nil,
231
- **kw)
219
+ metadata: {})
232
220
  c = new_active_call(method, marshal, unmarshal,
233
221
  deadline: deadline,
234
- timeout: timeout,
235
222
  parent: parent,
236
223
  credentials: credentials)
237
- return c.client_streamer(requests, **kw) unless return_op
224
+ return c.client_streamer(requests, metadata: metadata) unless return_op
238
225
 
239
226
  # return the operation view of the active_call; define #execute as a
240
227
  # new method for this instance that invokes #client_streamer.
241
228
  op = c.operation
242
229
  op.define_singleton_method(:execute) do
243
- c.client_streamer(requests, **kw)
230
+ c.client_streamer(requests, metadata: metadata)
244
231
  end
245
232
  op
246
233
  end
@@ -292,35 +279,33 @@ module GRPC
292
279
  # @param req [Object] the request sent to the server
293
280
  # @param marshal [Function] f(obj)->string that marshals requests
294
281
  # @param unmarshal [Function] f(string)->obj that unmarshals responses
295
- # @param timeout [Numeric] (optional) the max completion time in seconds
296
282
  # @param deadline [Time] (optional) the time the request should complete
297
283
  # @param return_op [true|false]return an Operation if true
298
284
  # @param parent [Core::Call] a prior call whose reserved metadata
299
285
  # will be propagated by this one.
300
286
  # @param credentials [Core::CallCredentials] credentials to use when making
301
287
  # the call
288
+ # @param metadata [Hash] metadata to be sent to the server
302
289
  # @param blk [Block] when provided, is executed for each response
303
290
  # @return [Enumerator|Operation|nil] as discussed above
304
291
  def server_streamer(method, req, marshal, unmarshal,
305
292
  deadline: nil,
306
- timeout: nil,
307
293
  return_op: false,
308
294
  parent: nil,
309
295
  credentials: nil,
310
- **kw,
296
+ metadata: {},
311
297
  &blk)
312
298
  c = new_active_call(method, marshal, unmarshal,
313
299
  deadline: deadline,
314
- timeout: timeout,
315
300
  parent: parent,
316
301
  credentials: credentials)
317
- return c.server_streamer(req, **kw, &blk) unless return_op
302
+ return c.server_streamer(req, metadata: metadata, &blk) unless return_op
318
303
 
319
304
  # return the operation view of the active_call; define #execute
320
305
  # as a new method for this instance that invokes #server_streamer
321
306
  op = c.operation
322
307
  op.define_singleton_method(:execute) do
323
- c.server_streamer(req, **kw, &blk)
308
+ c.server_streamer(req, metadata: metadata, &blk)
324
309
  end
325
310
  op
326
311
  end
@@ -391,11 +376,6 @@ module GRPC
391
376
  # * the deadline is exceeded
392
377
  #
393
378
  #
394
- # == Keyword Args ==
395
- #
396
- # Unspecified keyword arguments are treated as metadata to be sent to the
397
- # server.
398
- #
399
379
  # == Return Value ==
400
380
  #
401
381
  # if the return_op is false, the return value is an Enumerator of the
@@ -411,36 +391,35 @@ module GRPC
411
391
  # @param requests [Object] an Enumerable of requests to send
412
392
  # @param marshal [Function] f(obj)->string that marshals requests
413
393
  # @param unmarshal [Function] f(string)->obj that unmarshals responses
414
- # @param timeout [Numeric] (optional) the max completion time in seconds
415
394
  # @param deadline [Time] (optional) the time the request should complete
416
395
  # @param parent [Core::Call] a prior call whose reserved metadata
417
396
  # will be propagated by this one.
418
397
  # @param credentials [Core::CallCredentials] credentials to use when making
419
398
  # the call
420
399
  # @param return_op [true|false] return an Operation if true
400
+ # @param metadata [Hash] metadata to be sent to the server
421
401
  # @param blk [Block] when provided, is executed for each response
422
402
  # @return [Enumerator|nil|Operation] as discussed above
423
403
  def bidi_streamer(method, requests, marshal, unmarshal,
424
404
  deadline: nil,
425
- timeout: nil,
426
405
  return_op: false,
427
406
  parent: nil,
428
407
  credentials: nil,
429
- **kw,
408
+ metadata: {},
430
409
  &blk)
431
410
  c = new_active_call(method, marshal, unmarshal,
432
411
  deadline: deadline,
433
- timeout: timeout,
434
412
  parent: parent,
435
413
  credentials: credentials)
436
414
 
437
- return c.bidi_streamer(requests, **kw, &blk) unless return_op
415
+ return c.bidi_streamer(requests, metadata: metadata,
416
+ &blk) unless return_op
438
417
 
439
418
  # return the operation view of the active_call; define #execute
440
419
  # as a new method for this instance that invokes #bidi_streamer
441
420
  op = c.operation
442
421
  op.define_singleton_method(:execute) do
443
- c.bidi_streamer(requests, **kw, &blk)
422
+ c.bidi_streamer(requests, metadata: metadata, &blk)
444
423
  end
445
424
  op
446
425
  end
@@ -457,12 +436,10 @@ module GRPC
457
436
  # @param timeout [TimeConst]
458
437
  def new_active_call(method, marshal, unmarshal,
459
438
  deadline: nil,
460
- timeout: nil,
461
439
  parent: nil,
462
440
  credentials: nil)
463
- if deadline.nil?
464
- deadline = from_relative_time(timeout.nil? ? @timeout : timeout)
465
- end
441
+
442
+ deadline = from_relative_time(@timeout) if deadline.nil?
466
443
  # Provide each new client call with its own completion queue
467
444
  call_queue = Core::CompletionQueue.new
468
445
  call = @ch.create_call(call_queue,
@@ -80,12 +80,12 @@ module GRPC
80
80
  else # is a bidi_stream
81
81
  active_call.run_server_bidi(mth)
82
82
  end
83
- send_status(active_call, OK, 'OK', **active_call.output_metadata)
83
+ send_status(active_call, OK, 'OK', active_call.output_metadata)
84
84
  rescue BadStatus => e
85
85
  # this is raised by handlers that want GRPC to send an application error
86
86
  # code and detail message and some additional app-specific metadata.
87
87
  GRPC.logger.debug("app err:#{active_call}, status:#{e.code}:#{e.details}")
88
- send_status(active_call, e.code, e.details, **e.metadata)
88
+ send_status(active_call, e.code, e.details, e.metadata)
89
89
  rescue Core::CallError => e
90
90
  # This is raised by GRPC internals but should rarely, if ever happen.
91
91
  # Log it, but don't notify the other endpoint..
@@ -135,10 +135,10 @@ module GRPC
135
135
  "##{mth.name}: bad arg count; got:#{mth.arity}, want:#{want}, #{msg}"
136
136
  end
137
137
 
138
- def send_status(active_client, code, details, **kw)
138
+ def send_status(active_client, code, details, metadata = {})
139
139
  details = 'Not sure why' if details.nil?
140
140
  GRPC.logger.debug("Sending status #{code}:#{details}")
141
- active_client.send_status(code, details, code == OK, **kw)
141
+ active_client.send_status(code, details, code == OK, metadata: metadata)
142
142
  rescue StandardError => e
143
143
  GRPC.logger.warn("Could not send status #{code}:#{details}")
144
144
  GRPC.logger.warn(e)
@@ -28,7 +28,6 @@
28
28
  # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
 
30
30
  require_relative '../grpc'
31
- require_relative '../signals'
32
31
  require_relative 'active_call'
33
32
  require_relative 'service'
34
33
  require 'thread'
@@ -170,14 +169,6 @@ module GRPC
170
169
  alt_cq
171
170
  end
172
171
 
173
- # setup_srv is used by #initialize to constuct a Core::Server from its
174
- # arguments.
175
- def self.setup_srv(alt_srv, cq, **kw)
176
- return Core::Server.new(cq, kw) if alt_srv.nil?
177
- fail(TypeError, '!Server') unless alt_srv.is_a? Core::Server
178
- alt_srv
179
- end
180
-
181
172
  # setup_connect_md_proc is used by #initialize to validate the
182
173
  # connect_md_proc.
183
174
  def self.setup_connect_md_proc(a_proc)
@@ -194,9 +185,6 @@ module GRPC
194
185
  # instance, however other arbitrary are allowed and when present are used
195
186
  # to configure the listeninng connection set up by the RpcServer.
196
187
  #
197
- # * server_override: which if passed must be a [GRPC::Core::Server]. When
198
- # present.
199
- #
200
188
  # * poll_period: when present, the server polls for new events with this
201
189
  # period
202
190
  #
@@ -218,13 +206,15 @@ module GRPC
218
206
  # when non-nil is a proc for determining metadata to to send back the client
219
207
  # on receiving an invocation req. The proc signature is:
220
208
  # {key: val, ..} func(method_name, {key: val, ...})
209
+ #
210
+ # * server_args:
211
+ # A server arguments hash to be passed down to the underlying core server
221
212
  def initialize(pool_size:DEFAULT_POOL_SIZE,
222
213
  max_waiting_requests:DEFAULT_MAX_WAITING_REQUESTS,
223
214
  poll_period:DEFAULT_POLL_PERIOD,
224
215
  completion_queue_override:nil,
225
- server_override:nil,
226
216
  connect_md_proc:nil,
227
- **kw)
217
+ server_args:{})
228
218
  @connect_md_proc = RpcServer.setup_connect_md_proc(connect_md_proc)
229
219
  @cq = RpcServer.setup_cq(completion_queue_override)
230
220
  @max_waiting_requests = max_waiting_requests
@@ -236,7 +226,7 @@ module GRPC
236
226
  # running_state can take 4 values: :not_started, :running, :stopping, and
237
227
  # :stopped. State transitions can only proceed in that order.
238
228
  @running_state = :not_started
239
- @server = RpcServer.setup_srv(server_override, @cq, **kw)
229
+ @server = Core::Server.new(@cq, server_args)
240
230
  end
241
231
 
242
232
  # stops a running server
@@ -353,10 +343,7 @@ module GRPC
353
343
  transition_running_state(:running)
354
344
  @run_cond.broadcast
355
345
  end
356
- remove_signal_handler = GRPC::Signals.register_handler { stop }
357
346
  loop_handle_server_calls
358
- # Remove signal handler when server stops
359
- remove_signal_handler.call
360
347
  end
361
348
 
362
349
  alias_method :run_till_terminated, :run
@@ -368,7 +355,7 @@ module GRPC
368
355
  return an_rpc if @pool.jobs_waiting <= @max_waiting_requests
369
356
  GRPC.logger.warn("NOT AVAILABLE: too many jobs_waiting: #{an_rpc}")
370
357
  noop = proc { |x| x }
371
- c = ActiveCall.new(an_rpc.call, @cq, noop, noop, an_rpc.deadline)
358
+ c = ActiveCall.new(an_rpc.call, an_rpc.cq, noop, noop, an_rpc.deadline)
372
359
  c.send_status(GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED, '')
373
360
  nil
374
361
  end
@@ -379,7 +366,7 @@ module GRPC
379
366
  return an_rpc if rpc_descs.key?(mth)
380
367
  GRPC.logger.warn("UNIMPLEMENTED: #{an_rpc}")
381
368
  noop = proc { |x| x }
382
- c = ActiveCall.new(an_rpc.call, @cq, noop, noop, an_rpc.deadline)
369
+ c = ActiveCall.new(an_rpc.call, an_rpc.cq, noop, noop, an_rpc.deadline)
383
370
  c.send_status(GRPC::Core::StatusCodes::UNIMPLEMENTED, '')
384
371
  nil
385
372
  end
@@ -390,7 +377,8 @@ module GRPC
390
377
  loop_tag = Object.new
391
378
  while running_state == :running
392
379
  begin
393
- an_rpc = @server.request_call(@cq, loop_tag, INFINITE_FUTURE)
380
+ comp_queue = Core::CompletionQueue.new
381
+ an_rpc = @server.request_call(comp_queue, loop_tag, INFINITE_FUTURE)
394
382
  break if (!an_rpc.nil?) && an_rpc.call.nil?
395
383
  active_call = new_active_server_call(an_rpc)
396
384
  unless active_call.nil?
@@ -429,15 +417,16 @@ module GRPC
429
417
  unless @connect_md_proc.nil?
430
418
  connect_md = @connect_md_proc.call(an_rpc.method, an_rpc.metadata)
431
419
  end
432
- an_rpc.call.run_batch(@cq, handle_call_tag, INFINITE_FUTURE,
420
+ an_rpc.call.run_batch(an_rpc.cq, handle_call_tag, INFINITE_FUTURE,
433
421
  SEND_INITIAL_METADATA => connect_md)
422
+
434
423
  return nil unless available?(an_rpc)
435
424
  return nil unless implemented?(an_rpc)
436
425
 
437
426
  # Create the ActiveCall
438
427
  GRPC.logger.info("deadline is #{an_rpc.deadline}; (now=#{Time.now})")
439
428
  rpc_desc = rpc_descs[an_rpc.method.to_sym]
440
- c = ActiveCall.new(an_rpc.call, @cq,
429
+ c = ActiveCall.new(an_rpc.call, an_rpc.cq,
441
430
  rpc_desc.marshal_proc, rpc_desc.unmarshal_proc(:input),
442
431
  an_rpc.deadline)
443
432
  mth = an_rpc.method.to_sym
@@ -179,24 +179,24 @@ module GRPC
179
179
  unmarshal = desc.unmarshal_proc(:output)
180
180
  route = "/#{route_prefix}/#{name}"
181
181
  if desc.request_response?
182
- define_method(mth_name) do |req, **kw|
182
+ define_method(mth_name) do |req, metadata = {}|
183
183
  GRPC.logger.debug("calling #{@host}:#{route}")
184
- request_response(route, req, marshal, unmarshal, **kw)
184
+ request_response(route, req, marshal, unmarshal, metadata)
185
185
  end
186
186
  elsif desc.client_streamer?
187
- define_method(mth_name) do |reqs, **kw|
187
+ define_method(mth_name) do |reqs, metadata = {}|
188
188
  GRPC.logger.debug("calling #{@host}:#{route}")
189
- client_streamer(route, reqs, marshal, unmarshal, **kw)
189
+ client_streamer(route, reqs, marshal, unmarshal, metadata)
190
190
  end
191
191
  elsif desc.server_streamer?
192
- define_method(mth_name) do |req, **kw, &blk|
192
+ define_method(mth_name) do |req, metadata = {}, &blk|
193
193
  GRPC.logger.debug("calling #{@host}:#{route}")
194
- server_streamer(route, req, marshal, unmarshal, **kw, &blk)
194
+ server_streamer(route, req, marshal, unmarshal, metadata, &blk)
195
195
  end
196
196
  else # is a bidi_stream
197
- define_method(mth_name) do |reqs, **kw, &blk|
197
+ define_method(mth_name) do |reqs, metadata = {}, &blk|
198
198
  GRPC.logger.debug("calling #{@host}:#{route}")
199
- bidi_streamer(route, reqs, marshal, unmarshal, **kw, &blk)
199
+ bidi_streamer(route, reqs, marshal, unmarshal, metadata, &blk)
200
200
  end
201
201
  end
202
202
  end
@@ -29,5 +29,5 @@
29
29
 
30
30
  # GRPC contains the General RPC module.
31
31
  module GRPC
32
- VERSION = '0.14.1'
32
+ VERSION = '0.15.0'
33
33
  end
@@ -1,5 +1,35 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # Source: grpc/health/v1/health.proto for package 'grpc.health.v1'
3
+ # Original file comments:
4
+ # Copyright 2015, Google Inc.
5
+ # All rights reserved.
6
+ #
7
+ # Redistribution and use in source and binary forms, with or without
8
+ # modification, are permitted provided that the following conditions are
9
+ # met:
10
+ #
11
+ # * Redistributions of source code must retain the above copyright
12
+ # notice, this list of conditions and the following disclaimer.
13
+ # * Redistributions in binary form must reproduce the above
14
+ # copyright notice, this list of conditions and the following disclaimer
15
+ # in the documentation and/or other materials provided with the
16
+ # distribution.
17
+ # * Neither the name of Google Inc. nor the names of its
18
+ # contributors may be used to endorse or promote products derived from
19
+ # this software without specific prior written permission.
20
+ #
21
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ #
3
33
 
4
34
  require 'grpc'
5
35
  require 'grpc/health/v1/health'
@@ -8,8 +38,6 @@ module Grpc
8
38
  module Health
9
39
  module V1
10
40
  module Health
11
-
12
- # TODO: add proto service documentation here
13
41
  class Service
14
42
 
15
43
  include GRPC::GenericService