grpc 1.15.0-universal-darwin → 1.16.0.pre1-universal-darwin

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61c907ae957a690995ac283ded3c5cebedc1b5fc4f1ac6e225d0d2e124b5af43
4
- data.tar.gz: a147a4023192ee1284301ce6bc4b481e7d5e8b3acec87d7d3ed8928f6b7c5d98
3
+ metadata.gz: dff9c31874e701fc9bb56c8fbad242c5945f0440ef57a5b81d96d35acf6f410f
4
+ data.tar.gz: a66df395b35e53c15b48dbb104c76dfa0f59171b75bc8ece14060f3d99df3d1b
5
5
  SHA512:
6
- metadata.gz: 0dd948095cb0d13a4709caa2a21f4021b6dc8ee8d080a3758230fdfb8d425393120a54935c41686e0ed457ca227a244f52135bf2ca9f72ef5e720e87e7dae621
7
- data.tar.gz: 8d3f8220e7f7abd8a0ed70eab0f40803712507242d3c7a60798737404b4b3d8ac8d9e47dfb1e19ff67b8a9bde0a375d47ccd364bb2931572ccc8d9775c5724e0
6
+ metadata.gz: c6157d587fa1186ba32ab0a1c444089e0d7292c4095b1501a0899b826182e17cfc397aacfd049e19e72297fbc3354c48d3658f7cad5b4a45ff94facf934e4813
7
+ data.tar.gz: 4c744dd2f3f6f6b761122e6b82d9c260122ee14f25fb3cdfd6468de93a64c34c72310234bcde1666ad7f3558bd315ffe58c809cdb5c44a3ced45fc140a12c367
@@ -4317,3 +4317,26 @@ JJUEeKgDu+6B5dpffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R
4317
4317
  8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4
4318
4318
  5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
4319
4319
  -----END CERTIFICATE-----
4320
+
4321
+ # Issuer: CN=OISTE WISeKey Global Root GC CA O=WISeKey OU=OISTE Foundation Endorsed
4322
+ # Subject: CN=OISTE WISeKey Global Root GC CA O=WISeKey OU=OISTE Foundation Endorsed
4323
+ # Label: "OISTE WISeKey Global Root GC CA"
4324
+ # Serial: 44084345621038548146064804565436152554
4325
+ # MD5 Fingerprint: a9:d6:b9:2d:2f:93:64:f8:a5:69:ca:91:e9:68:07:23
4326
+ # SHA1 Fingerprint: e0:11:84:5e:34:de:be:88:81:b9:9c:f6:16:26:d1:96:1f:c3:b9:31
4327
+ # SHA256 Fingerprint: 85:60:f9:1c:36:24:da:ba:95:70:b5:fe:a0:db:e3:6f:f1:1a:83:23:be:94:86:85:4f:b3:f3:4a:55:71:19:8d
4328
+ -----BEGIN CERTIFICATE-----
4329
+ MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQsw
4330
+ CQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91
4331
+ bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwg
4332
+ Um9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRaFw00MjA1MDkwOTU4MzNaMG0xCzAJ
4333
+ BgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBGb3Vu
4334
+ ZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2JhbCBS
4335
+ b290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4ni
4336
+ eUqjFqdrVCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4W
4337
+ p2OQ0jnUsYd4XxiWD1AbNTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8E
4338
+ BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7T
4339
+ rYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0EAwMDaAAwZQIwJsdpW9zV
4340
+ 57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtkAjEA2zQg
4341
+ Mgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
4342
+ -----END CERTIFICATE-----
@@ -819,6 +819,7 @@ static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
819
819
  unsigned write_flag = 0;
820
820
  void* tag = (void*)&st;
821
821
 
822
+ grpc_ruby_fork_guard();
822
823
  if (RTYPEDDATA_DATA(self) == NULL) {
823
824
  rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
824
825
  return Qnil;
@@ -217,6 +217,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
217
217
  MEMZERO(&args, grpc_channel_args, 1);
218
218
 
219
219
  grpc_ruby_once_init();
220
+ grpc_ruby_fork_guard();
220
221
  rb_thread_call_without_gvl(
221
222
  wait_until_channel_polling_thread_started_no_gil,
222
223
  &stop_waiting_for_thread_start,
@@ -374,6 +375,7 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
374
375
  watch_state_stack stack;
375
376
  void* op_success = 0;
376
377
 
378
+ grpc_ruby_fork_guard();
377
379
  TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
378
380
 
379
381
  if (wrapper->bg_wrapped == NULL) {
@@ -415,6 +417,7 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask,
415
417
  grpc_slice* host_slice_ptr = NULL;
416
418
  char* tmp_str = NULL;
417
419
 
420
+ grpc_ruby_fork_guard();
418
421
  if (host != Qnil) {
419
422
  host_slice =
420
423
  grpc_slice_from_copied_buffer(RSTRING_PTR(host), RSTRING_LEN(host));
@@ -23,9 +23,13 @@
23
23
 
24
24
  #include <math.h>
25
25
  #include <ruby/vm.h>
26
+ #include <stdbool.h>
26
27
  #include <sys/time.h>
28
+ #include <sys/types.h>
29
+ #include <unistd.h>
27
30
 
28
31
  #include <grpc/grpc.h>
32
+ #include <grpc/support/log.h>
29
33
  #include <grpc/support/time.h>
30
34
  #include "rb_call.h"
31
35
  #include "rb_call_credentials.h"
@@ -255,7 +259,26 @@ static void Init_grpc_time_consts() {
255
259
  id_tv_nsec = rb_intern("tv_nsec");
256
260
  }
257
261
 
258
- static void grpc_rb_shutdown(void) { grpc_shutdown(); }
262
+ #if GPR_WINDOWS
263
+ static void grpc_ruby_set_init_pid(void) {}
264
+ static bool grpc_ruby_forked_after_init(void) { return false; }
265
+ #else
266
+ static pid_t grpc_init_pid;
267
+
268
+ static void grpc_ruby_set_init_pid(void) {
269
+ GPR_ASSERT(grpc_init_pid == 0);
270
+ grpc_init_pid = getpid();
271
+ }
272
+
273
+ static bool grpc_ruby_forked_after_init(void) {
274
+ GPR_ASSERT(grpc_init_pid != 0);
275
+ return grpc_init_pid != getpid();
276
+ }
277
+ #endif
278
+
279
+ static void grpc_rb_shutdown(void) {
280
+ if (!grpc_ruby_forked_after_init()) grpc_shutdown();
281
+ }
259
282
 
260
283
  /* Initialize the GRPC module structs */
261
284
 
@@ -276,10 +299,17 @@ VALUE sym_metadata = Qundef;
276
299
  static gpr_once g_once_init = GPR_ONCE_INIT;
277
300
 
278
301
  static void grpc_ruby_once_init_internal() {
302
+ grpc_ruby_set_init_pid();
279
303
  grpc_init();
280
304
  atexit(grpc_rb_shutdown);
281
305
  }
282
306
 
307
+ void grpc_ruby_fork_guard() {
308
+ if (grpc_ruby_forked_after_init()) {
309
+ rb_raise(rb_eRuntimeError, "grpc cannot be used before and after forking");
310
+ }
311
+ }
312
+
283
313
  static VALUE bg_thread_init_rb_mu = Qundef;
284
314
  static int bg_thread_init_done = 0;
285
315
 
@@ -69,4 +69,6 @@ gpr_timespec grpc_rb_time_timeval(VALUE time, int interval);
69
69
 
70
70
  void grpc_ruby_once_init();
71
71
 
72
+ void grpc_ruby_fork_guard();
73
+
72
74
  #endif /* GRPC_RB_H_ */
@@ -97,7 +97,10 @@ grpc_resource_quota_resize_type grpc_resource_quota_resize_import;
97
97
  grpc_resource_quota_set_max_threads_type grpc_resource_quota_set_max_threads_import;
98
98
  grpc_resource_quota_arg_vtable_type grpc_resource_quota_arg_vtable_import;
99
99
  grpc_channelz_get_top_channels_type grpc_channelz_get_top_channels_import;
100
+ grpc_channelz_get_servers_type grpc_channelz_get_servers_import;
100
101
  grpc_channelz_get_channel_type grpc_channelz_get_channel_import;
102
+ grpc_channelz_get_subchannel_type grpc_channelz_get_subchannel_import;
103
+ grpc_channelz_get_socket_type grpc_channelz_get_socket_import;
101
104
  grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import;
102
105
  grpc_server_add_insecure_channel_from_fd_type grpc_server_add_insecure_channel_from_fd_import;
103
106
  grpc_use_signal_type grpc_use_signal_import;
@@ -351,7 +354,10 @@ void grpc_rb_load_imports(HMODULE library) {
351
354
  grpc_resource_quota_set_max_threads_import = (grpc_resource_quota_set_max_threads_type) GetProcAddress(library, "grpc_resource_quota_set_max_threads");
352
355
  grpc_resource_quota_arg_vtable_import = (grpc_resource_quota_arg_vtable_type) GetProcAddress(library, "grpc_resource_quota_arg_vtable");
353
356
  grpc_channelz_get_top_channels_import = (grpc_channelz_get_top_channels_type) GetProcAddress(library, "grpc_channelz_get_top_channels");
357
+ grpc_channelz_get_servers_import = (grpc_channelz_get_servers_type) GetProcAddress(library, "grpc_channelz_get_servers");
354
358
  grpc_channelz_get_channel_import = (grpc_channelz_get_channel_type) GetProcAddress(library, "grpc_channelz_get_channel");
359
+ grpc_channelz_get_subchannel_import = (grpc_channelz_get_subchannel_type) GetProcAddress(library, "grpc_channelz_get_subchannel");
360
+ grpc_channelz_get_socket_import = (grpc_channelz_get_socket_type) GetProcAddress(library, "grpc_channelz_get_socket");
355
361
  grpc_insecure_channel_create_from_fd_import = (grpc_insecure_channel_create_from_fd_type) GetProcAddress(library, "grpc_insecure_channel_create_from_fd");
356
362
  grpc_server_add_insecure_channel_from_fd_import = (grpc_server_add_insecure_channel_from_fd_type) GetProcAddress(library, "grpc_server_add_insecure_channel_from_fd");
357
363
  grpc_use_signal_import = (grpc_use_signal_type) GetProcAddress(library, "grpc_use_signal");
@@ -107,7 +107,7 @@ extern grpc_completion_queue_create_for_next_type grpc_completion_queue_create_f
107
107
  typedef grpc_completion_queue*(*grpc_completion_queue_create_for_pluck_type)(void* reserved);
108
108
  extern grpc_completion_queue_create_for_pluck_type grpc_completion_queue_create_for_pluck_import;
109
109
  #define grpc_completion_queue_create_for_pluck grpc_completion_queue_create_for_pluck_import
110
- typedef grpc_completion_queue*(*grpc_completion_queue_create_for_callback_type)(void* shutdown_callback, void* reserved);
110
+ typedef grpc_completion_queue*(*grpc_completion_queue_create_for_callback_type)(grpc_experimental_completion_queue_functor* shutdown_callback, void* reserved);
111
111
  extern grpc_completion_queue_create_for_callback_type grpc_completion_queue_create_for_callback_import;
112
112
  #define grpc_completion_queue_create_for_callback grpc_completion_queue_create_for_callback_import
113
113
  typedef grpc_completion_queue*(*grpc_completion_queue_create_type)(const grpc_completion_queue_factory* factory, const grpc_completion_queue_attributes* attributes, void* reserved);
@@ -266,9 +266,18 @@ extern grpc_resource_quota_arg_vtable_type grpc_resource_quota_arg_vtable_import
266
266
  typedef char*(*grpc_channelz_get_top_channels_type)(intptr_t start_channel_id);
267
267
  extern grpc_channelz_get_top_channels_type grpc_channelz_get_top_channels_import;
268
268
  #define grpc_channelz_get_top_channels grpc_channelz_get_top_channels_import
269
+ typedef char*(*grpc_channelz_get_servers_type)(intptr_t start_server_id);
270
+ extern grpc_channelz_get_servers_type grpc_channelz_get_servers_import;
271
+ #define grpc_channelz_get_servers grpc_channelz_get_servers_import
269
272
  typedef char*(*grpc_channelz_get_channel_type)(intptr_t channel_id);
270
273
  extern grpc_channelz_get_channel_type grpc_channelz_get_channel_import;
271
274
  #define grpc_channelz_get_channel grpc_channelz_get_channel_import
275
+ typedef char*(*grpc_channelz_get_subchannel_type)(intptr_t subchannel_id);
276
+ extern grpc_channelz_get_subchannel_type grpc_channelz_get_subchannel_import;
277
+ #define grpc_channelz_get_subchannel grpc_channelz_get_subchannel_import
278
+ typedef char*(*grpc_channelz_get_socket_type)(intptr_t socket_id);
279
+ extern grpc_channelz_get_socket_type grpc_channelz_get_socket_import;
280
+ #define grpc_channelz_get_socket grpc_channelz_get_socket_import
272
281
  typedef grpc_channel*(*grpc_insecure_channel_create_from_fd_type)(const char* target, int fd, const grpc_channel_args* args);
273
282
  extern grpc_insecure_channel_create_from_fd_type grpc_insecure_channel_create_from_fd_import;
274
283
  #define grpc_insecure_channel_create_from_fd grpc_insecure_channel_create_from_fd_import
@@ -401,10 +410,10 @@ extern grpc_call_set_credentials_type grpc_call_set_credentials_import;
401
410
  typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials* creds, grpc_auth_metadata_processor processor);
402
411
  extern grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import;
403
412
  #define grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor_import
404
- typedef grpc_alts_credentials_options*(*grpc_alts_credentials_client_options_create_type)();
413
+ typedef grpc_alts_credentials_options*(*grpc_alts_credentials_client_options_create_type)(void);
405
414
  extern grpc_alts_credentials_client_options_create_type grpc_alts_credentials_client_options_create_import;
406
415
  #define grpc_alts_credentials_client_options_create grpc_alts_credentials_client_options_create_import
407
- typedef grpc_alts_credentials_options*(*grpc_alts_credentials_server_options_create_type)();
416
+ typedef grpc_alts_credentials_options*(*grpc_alts_credentials_server_options_create_type)(void);
408
417
  extern grpc_alts_credentials_server_options_create_type grpc_alts_credentials_server_options_create_import;
409
418
  #define grpc_alts_credentials_server_options_create grpc_alts_credentials_server_options_create_import
410
419
  typedef void(*grpc_alts_credentials_client_options_add_target_service_account_type)(grpc_alts_credentials_options* options, const char* service_account);
@@ -243,6 +243,8 @@ static VALUE grpc_rb_server_request_call(VALUE self) {
243
243
  static VALUE grpc_rb_server_start(VALUE self) {
244
244
  grpc_rb_server* s = NULL;
245
245
  TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s);
246
+
247
+ grpc_ruby_fork_guard();
246
248
  if (s->wrapped == NULL) {
247
249
  rb_raise(rb_eRuntimeError, "destroyed!");
248
250
  } else {
@@ -68,7 +68,6 @@ module GRPC
68
68
  codes[OUT_OF_RANGE] = OutOfRange
69
69
  codes[UNIMPLEMENTED] = Unimplemented
70
70
  codes[INTERNAL] = Internal
71
- codes[UNIMPLEMENTED] = Unimplemented
72
71
  codes[UNAVAILABLE] = Unavailable
73
72
  codes[DATA_LOSS] = DataLoss
74
73
 
@@ -32,7 +32,7 @@ module GRPC
32
32
 
33
33
  # @return [Proc] { |instance| marshalled(instance) }
34
34
  def marshal_proc
35
- proc { |o| o.class.method(marshal_method).call(o).to_s }
35
+ proc { |o| o.class.send(marshal_method, o).to_s }
36
36
  end
37
37
 
38
38
  # @param [:input, :output] target determines whether to produce the an
@@ -42,9 +42,9 @@ module GRPC
42
42
  # @return [Proc] An unmarshal proc { |marshalled(instance)| instance }
43
43
  def unmarshal_proc(target)
44
44
  fail ArgumentError unless [:input, :output].include?(target)
45
- unmarshal_class = method(target).call
45
+ unmarshal_class = send(target)
46
46
  unmarshal_class = unmarshal_class.type if unmarshal_class.is_a? Stream
47
- proc { |o| unmarshal_class.method(unmarshal_method).call(o) }
47
+ proc { |o| unmarshal_class.send(unmarshal_method, o) }
48
48
  end
49
49
 
50
50
  def handle_request_response(active_call, mth, inter_ctx)
@@ -136,7 +136,7 @@ module GRPC
136
136
  begin
137
137
  blk, args = worker_queue.pop
138
138
  blk.call(*args)
139
- rescue StandardError => e
139
+ rescue StandardError, GRPC::Core::CallError => e
140
140
  GRPC.logger.warn('Error in worker thread')
141
141
  GRPC.logger.warn(e)
142
142
  end
@@ -14,5 +14,5 @@
14
14
 
15
15
  # GRPC contains the General RPC module.
16
16
  module GRPC
17
- VERSION = '1.15.0'
17
+ VERSION = '1.16.0.pre1'
18
18
  end
@@ -95,7 +95,7 @@ end
95
95
 
96
96
  # creates a test stub that accesses host:port securely.
97
97
  def create_stub(opts)
98
- address = "#{opts.host}:#{opts.port}"
98
+ address = "#{opts.server_host}:#{opts.server_port}"
99
99
 
100
100
  # Provide channel args that request compression by default
101
101
  # for compression interop tests
@@ -112,7 +112,7 @@ def create_stub(opts)
112
112
  creds = ssl_creds(opts.use_test_ca)
113
113
  stub_opts = {
114
114
  channel_args: {
115
- GRPC::Core::Channel::SSL_TARGET => opts.host_override
115
+ GRPC::Core::Channel::SSL_TARGET => opts.server_host_override
116
116
  }
117
117
  }
118
118
 
@@ -703,19 +703,19 @@ class NamedTests
703
703
  end
704
704
 
705
705
  # Args is used to hold the command line info.
706
- Args = Struct.new(:default_service_account, :host, :host_override,
707
- :oauth_scope, :port, :secure, :test_case,
706
+ Args = Struct.new(:default_service_account, :server_host, :server_host_override,
707
+ :oauth_scope, :server_port, :secure, :test_case,
708
708
  :use_test_ca)
709
709
 
710
710
  # validates the command line options, returning them as a Hash.
711
711
  def parse_args
712
712
  args = Args.new
713
- args.host_override = 'foo.test.google.fr'
713
+ args.server_host_override = 'foo.test.google.fr'
714
714
  OptionParser.new do |opts|
715
715
  opts.on('--oauth_scope scope',
716
716
  'Scope for OAuth tokens') { |v| args['oauth_scope'] = v }
717
717
  opts.on('--server_host SERVER_HOST', 'server hostname') do |v|
718
- args['host'] = v
718
+ args['server_host'] = v
719
719
  end
720
720
  opts.on('--default_service_account email_address',
721
721
  'email address of the default service account') do |v|
@@ -723,9 +723,11 @@ def parse_args
723
723
  end
724
724
  opts.on('--server_host_override HOST_OVERRIDE',
725
725
  'override host via a HTTP header') do |v|
726
- args['host_override'] = v
726
+ args['server_host_override'] = v
727
+ end
728
+ opts.on('--server_port SERVER_PORT', 'server port') do |v|
729
+ args['server_port'] = v
727
730
  end
728
- opts.on('--server_port SERVER_PORT', 'server port') { |v| args['port'] = v }
729
731
  # instance_methods(false) gives only the methods defined in that class
730
732
  test_cases = NamedTests.instance_methods(false).map(&:to_s)
731
733
  test_case_list = test_cases.join(',')
@@ -744,7 +746,7 @@ def parse_args
744
746
  end
745
747
 
746
748
  def _check_args(args)
747
- %w(host port test_case).each do |a|
749
+ %w(server_host server_port test_case).each do |a|
748
750
  if args[a].nil?
749
751
  fail(OptionParser::MissingArgument, "please specify --#{a}")
750
752
  end
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'spec_helper'
16
+ require 'English'
16
17
 
17
18
  def load_test_certs
18
19
  test_root = File.join(File.dirname(__FILE__), 'testdata')
@@ -27,6 +28,28 @@ describe GRPC::Core::Channel do
27
28
  GRPC::Core::ChannelCredentials.new(load_test_certs[0])
28
29
  end
29
30
 
31
+ def fork_with_propagated_error_message
32
+ pipe_read, pipe_write = IO.pipe
33
+ pid = fork do
34
+ pipe_read.close
35
+ begin
36
+ yield
37
+ rescue => exc
38
+ pipe_write.syswrite(exc.message)
39
+ end
40
+ pipe_write.close
41
+ end
42
+ pipe_write.close
43
+
44
+ exc_message = pipe_read.read
45
+ Process.wait(pid)
46
+
47
+ unless $CHILD_STATUS.success?
48
+ raise "forked process failed with #{$CHILD_STATUS}"
49
+ end
50
+ raise exc_message unless exc_message.empty?
51
+ end
52
+
30
53
  shared_examples '#new' do
31
54
  it 'take a host name without channel args' do
32
55
  blk = proc do
@@ -79,6 +102,14 @@ describe GRPC::Core::Channel do
79
102
  blk = construct_with_args(args)
80
103
  expect(&blk).to_not raise_error
81
104
  end
105
+
106
+ it 'raises if grpc was initialized in another process' do
107
+ blk = construct_with_args({})
108
+ expect(&blk).not_to raise_error
109
+ expect do
110
+ fork_with_propagated_error_message(&blk)
111
+ end.to raise_error(RuntimeError, 'grpc cannot be used before and after forking')
112
+ end
82
113
  end
83
114
 
84
115
  describe '#new for secure channels' do
@@ -121,6 +152,19 @@ describe GRPC::Core::Channel do
121
152
  end
122
153
  expect(&blk).to raise_error(RuntimeError)
123
154
  end
155
+
156
+ it 'raises if grpc was initialized in another process' do
157
+ ch = GRPC::Core::Channel.new(fake_host, nil, :this_channel_is_insecure)
158
+
159
+ deadline = Time.now + 5
160
+
161
+ blk = proc do
162
+ fork_with_propagated_error_message do
163
+ ch.create_call(nil, nil, 'dummy_method', nil, deadline)
164
+ end
165
+ end
166
+ expect(&blk).to raise_error(RuntimeError, 'grpc cannot be used before and after forking')
167
+ end
124
168
  end
125
169
 
126
170
  describe '#destroy' do
@@ -30,7 +30,7 @@ end
30
30
 
31
31
  def create_server_creds
32
32
  test_root = File.join(File.dirname(__FILE__), 'testdata')
33
- p "test root: #{test_root}"
33
+ GRPC.logger.info("test root: #{test_root}")
34
34
  files = ['ca.pem', 'server1.key', 'server1.pem']
35
35
  creds = files.map { |f| File.open(File.join(test_root, f)).read }
36
36
  GRPC::Core::ServerCredentials.new(
@@ -59,7 +59,7 @@ class SslTestService
59
59
 
60
60
  def a_client_streaming_rpc(call)
61
61
  check_peer_cert(call)
62
- call.each_remote_read.each { |r| p r }
62
+ call.each_remote_read.each { |r| GRPC.logger.info(r) }
63
63
  EchoMsg.new
64
64
  end
65
65
 
@@ -70,7 +70,7 @@ class SslTestService
70
70
 
71
71
  def a_bidi_rpc(requests, call)
72
72
  check_peer_cert(call)
73
- requests.each { |r| p r }
73
+ requests.each { |r| GRPC.logger.info(r) }
74
74
  [EchoMsg.new, EchoMsg.new]
75
75
  end
76
76
  end
@@ -116,11 +116,11 @@ describe 'client-server auth' do
116
116
 
117
117
  it 'client-server auth with server streaming RPCs' do
118
118
  responses = @stub.a_server_streaming_rpc(EchoMsg.new)
119
- responses.each { |r| p r }
119
+ responses.each { |r| GRPC.logger.info(r) }
120
120
  end
121
121
 
122
122
  it 'client-server auth with bidi RPCs' do
123
123
  responses = @stub.a_bidi_rpc([EchoMsg.new, EchoMsg.new])
124
- responses.each { |r| p r }
124
+ responses.each { |r| GRPC.logger.info(r) }
125
125
  end
126
126
  end
@@ -293,7 +293,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
293
293
 
294
294
  describe 'without a call operation' do
295
295
  def get_response(stub, credentials: nil)
296
- puts credentials.inspect
296
+ GRPC.logger.info(credentials.inspect)
297
297
  stub.request_response(@method, @sent_msg, noop, noop,
298
298
  metadata: @metadata,
299
299
  credentials: credentials)
@@ -342,13 +342,15 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
342
342
  it 'sends metadata to the server ok when running start_call first' do
343
343
  run_op_view_metadata_test(true)
344
344
  check_op_view_of_finished_client_call(
345
- @op, @server_initial_md, @server_trailing_md) { |r| p r }
345
+ @op, @server_initial_md, @server_trailing_md
346
+ ) { |r| GRPC.logger.info(r) }
346
347
  end
347
348
 
348
349
  it 'does not crash when used after the call has been finished' do
349
350
  run_op_view_metadata_test(false)
350
351
  check_op_view_of_finished_client_call(
351
- @op, @server_initial_md, @server_trailing_md) { |r| p r }
352
+ @op, @server_initial_md, @server_trailing_md
353
+ ) { |r| GRPC.logger.info(r) }
352
354
  end
353
355
  end
354
356
  end
@@ -435,13 +437,15 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
435
437
  it 'sends metadata to the server ok when running start_call first' do
436
438
  run_op_view_metadata_test(true)
437
439
  check_op_view_of_finished_client_call(
438
- @op, @server_initial_md, @server_trailing_md) { |r| p r }
440
+ @op, @server_initial_md, @server_trailing_md
441
+ ) { |r| GRPC.logger.info(r) }
439
442
  end
440
443
 
441
444
  it 'does not crash when used after the call has been finished' do
442
445
  run_op_view_metadata_test(false)
443
446
  check_op_view_of_finished_client_call(
444
- @op, @server_initial_md, @server_trailing_md) { |r| p r }
447
+ @op, @server_initial_md, @server_trailing_md
448
+ ) { |r| GRPC.logger.info(r) }
445
449
  end
446
450
  end
447
451
  end
@@ -578,7 +582,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
578
582
  run_op_view_metadata_test(true)
579
583
  check_op_view_of_finished_client_call(
580
584
  @op, @server_initial_md, @server_trailing_md) do |responses|
581
- responses.each { |r| p r }
585
+ responses.each { |r| GRPC.logger.info(r) }
582
586
  end
583
587
  end
584
588
 
@@ -586,7 +590,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
586
590
  run_op_view_metadata_test(false)
587
591
  check_op_view_of_finished_client_call(
588
592
  @op, @server_initial_md, @server_trailing_md) do |responses|
589
- responses.each { |r| p r }
593
+ responses.each { |r| GRPC.logger.info(r) }
590
594
  end
591
595
  end
592
596
 
@@ -895,7 +899,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
895
899
  run_op_view_metadata_test(true)
896
900
  check_op_view_of_finished_client_call(
897
901
  @op, @server_initial_md, @server_trailing_md) do |responses|
898
- responses.each { |r| p r }
902
+ responses.each { |r| GRPC.logger.info(r) }
899
903
  end
900
904
  end
901
905
 
@@ -903,7 +907,7 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
903
907
  run_op_view_metadata_test(false)
904
908
  check_op_view_of_finished_client_call(
905
909
  @op, @server_initial_md, @server_trailing_md) do |responses|
906
- responses.each { |r| p r }
910
+ responses.each { |r| GRPC.logger.info(r) }
907
911
  end
908
912
  end
909
913
 
@@ -125,7 +125,7 @@ class CheckCallAfterFinishedService
125
125
  fail 'shouldnt reuse service' unless @server_side_call.nil?
126
126
  @server_side_call = call
127
127
  # iterate through requests so call can complete
128
- call.each_remote_read.each { |r| p r }
128
+ call.each_remote_read.each { |r| GRPC.logger.info(r) }
129
129
  EchoMsg.new
130
130
  end
131
131
 
@@ -138,7 +138,7 @@ class CheckCallAfterFinishedService
138
138
  def a_bidi_rpc(requests, call)
139
139
  fail 'shouldnt reuse service' unless @server_side_call.nil?
140
140
  @server_side_call = call
141
- requests.each { |r| p r }
141
+ requests.each { |r| GRPC.logger.info(r) }
142
142
  [EchoMsg.new, EchoMsg.new]
143
143
  end
144
144
  end
@@ -560,7 +560,7 @@ describe GRPC::RpcServer do
560
560
  'connect_k1' => 'connect_v1'
561
561
  }
562
562
  wanted_md.each do |key, value|
563
- puts "key: #{key}"
563
+ GRPC.logger.info("key: #{key}")
564
564
  expect(op.metadata[key]).to eq(value)
565
565
  end
566
566
  @srv.stop
@@ -0,0 +1,53 @@
1
+ # Copyright 2018 gRPC authors.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'spec_helper'
16
+ require 'open3'
17
+ require 'tmpdir'
18
+
19
+ describe 'Code Generation Options' do
20
+ it 'should generate and respect package options' do
21
+ fail 'CONFIG env variable unexpectedly unset' unless ENV['CONFIG']
22
+ bins_sub_dir = ENV['CONFIG']
23
+
24
+ src_dir = File.join(File.dirname(__FILE__), '..', '..', '..', '..')
25
+ pb_dir = File.join(src_dir, 'proto')
26
+ bins_dir = File.join(src_dir, '..', 'bins', bins_sub_dir)
27
+
28
+ plugin = File.join(bins_dir, 'grpc_ruby_plugin')
29
+ protoc = File.join(bins_dir, 'protobuf', 'protoc')
30
+
31
+ # Generate the service from the proto
32
+ Dir.mktmpdir(nil, File.dirname(__FILE__)) do |tmp_dir|
33
+ gen_file = system(protoc,
34
+ '-I.',
35
+ 'grpc/testing/package_options.proto',
36
+ "--grpc_out=#{tmp_dir}", # generate the service
37
+ "--ruby_out=#{tmp_dir}", # generate the definitions
38
+ "--plugin=protoc-gen-grpc=#{plugin}",
39
+ chdir: pb_dir,
40
+ out: File::NULL)
41
+
42
+ expect(gen_file).to be_truthy
43
+ begin
44
+ $LOAD_PATH.push(tmp_dir)
45
+ expect { Grpc::Testing::Package::Options::TestService::Service }.to raise_error(NameError)
46
+ expect(require('grpc/testing/package_options_services_pb')).to be_truthy
47
+ expect { Grpc::Testing::Package::Options::TestService::Service }.to_not raise_error
48
+ ensure
49
+ $LOAD_PATH.delete(tmp_dir)
50
+ end
51
+ end
52
+ end
53
+ end
@@ -50,7 +50,9 @@ class EchoService
50
50
  def a_client_streaming_rpc(call)
51
51
  # iterate through requests so call can complete
52
52
  call.output_metadata.update(@trailing_metadata)
53
- call.each_remote_read.each { |r| p r }
53
+ call.each_remote_read.each do |r|
54
+ GRPC.logger.info(r)
55
+ end
54
56
  EchoMsg.new
55
57
  end
56
58
 
@@ -61,7 +63,9 @@ class EchoService
61
63
 
62
64
  def a_bidi_rpc(requests, call)
63
65
  call.output_metadata.update(@trailing_metadata)
64
- requests.each { |r| p r }
66
+ requests.each do |r|
67
+ GRPC.logger.info(r)
68
+ end
65
69
  [EchoMsg.new, EchoMsg.new]
66
70
  end
67
71
  end
@@ -71,35 +75,37 @@ EchoStub = EchoService.rpc_stub_class
71
75
  # For testing server interceptors
72
76
  class TestServerInterceptor < GRPC::ServerInterceptor
73
77
  def request_response(request:, call:, method:)
74
- p "Received request/response call at method #{method}" \
75
- " with request #{request} for call #{call}"
78
+ GRPC.logger.info("Received request/response call at method #{method}" \
79
+ " with request #{request} for call #{call}")
76
80
  call.output_metadata[:interc] = 'from_request_response'
77
- p "[GRPC::Ok] (#{method.owner.name}.#{method.name})"
81
+ GRPC.logger.info("[GRPC::Ok] (#{method.owner.name}.#{method.name})")
78
82
  yield
79
83
  end
80
84
 
81
85
  def client_streamer(call:, method:)
82
86
  call.output_metadata[:interc] = 'from_client_streamer'
83
87
  call.each_remote_read.each do |r|
84
- p "In interceptor: #{r}"
88
+ GRPC.logger.info("In interceptor: #{r}")
85
89
  end
86
- p "Received client streamer call at method #{method} for call #{call}"
90
+ GRPC.logger.info(
91
+ "Received client streamer call at method #{method} for call #{call}"
92
+ )
87
93
  yield
88
94
  end
89
95
 
90
96
  def server_streamer(request:, call:, method:)
91
- p "Received server streamer call at method #{method} with request" \
92
- " #{request} for call #{call}"
97
+ GRPC.logger.info("Received server streamer call at method #{method} with request" \
98
+ " #{request} for call #{call}")
93
99
  call.output_metadata[:interc] = 'from_server_streamer'
94
100
  yield
95
101
  end
96
102
 
97
103
  def bidi_streamer(requests:, call:, method:)
98
104
  requests.each do |r|
99
- p "Bidi request: #{r}"
105
+ GRPC.logger.info("Bidi request: #{r}")
100
106
  end
101
- p "Received bidi streamer call at method #{method} with requests" \
102
- " #{requests} for call #{call}"
107
+ GRPC.logger.info("Received bidi streamer call at method #{method} with requests" \
108
+ " #{requests} for call #{call}")
103
109
  call.output_metadata[:interc] = 'from_bidi_streamer'
104
110
  yield
105
111
  end
@@ -108,38 +114,38 @@ end
108
114
  # For testing client interceptors
109
115
  class TestClientInterceptor < GRPC::ClientInterceptor
110
116
  def request_response(request:, call:, method:, metadata: {})
111
- p "Intercepted request/response call at method #{method}" \
117
+ GRPC.logger.info("Intercepted request/response call at method #{method}" \
112
118
  " with request #{request} for call #{call}" \
113
- " and metadata: #{metadata}"
119
+ " and metadata: #{metadata}")
114
120
  metadata['foo'] = 'bar_from_request_response'
115
121
  yield
116
122
  end
117
123
 
118
124
  def client_streamer(requests:, call:, method:, metadata: {})
119
- p "Received client streamer call at method #{method}" \
125
+ GRPC.logger.info("Received client streamer call at method #{method}" \
120
126
  " with requests #{requests} for call #{call}" \
121
- " and metadata: #{metadata}"
127
+ " and metadata: #{metadata}")
122
128
  requests.each do |r|
123
- p "In client interceptor: #{r}"
129
+ GRPC.logger.info("In client interceptor: #{r}")
124
130
  end
125
131
  metadata['foo'] = 'bar_from_client_streamer'
126
132
  yield
127
133
  end
128
134
 
129
135
  def server_streamer(request:, call:, method:, metadata: {})
130
- p "Received server streamer call at method #{method}" \
136
+ GRPC.logger.info("Received server streamer call at method #{method}" \
131
137
  " with request #{request} for call #{call}" \
132
- " and metadata: #{metadata}"
138
+ " and metadata: #{metadata}")
133
139
  metadata['foo'] = 'bar_from_server_streamer'
134
140
  yield
135
141
  end
136
142
 
137
143
  def bidi_streamer(requests:, call:, method:, metadata: {})
138
- p "Received bidi streamer call at method #{method}" \
144
+ GRPC.logger.info("Received bidi streamer call at method #{method}" \
139
145
  "with requests #{requests} for call #{call}" \
140
- " and metadata: #{metadata}"
146
+ " and metadata: #{metadata}")
141
147
  requests.each do |r|
142
- p "In client interceptor: #{r}"
148
+ GRPC.logger.info("In client interceptor: #{r}")
143
149
  end
144
150
  metadata['foo'] = 'bar_from_bidi_streamer'
145
151
  yield
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.16.0.pre1
5
5
  platform: universal-darwin
6
6
  authors:
7
7
  - gRPC Authors
8
8
  autorequire:
9
9
  bindir: src/ruby/bin
10
10
  cert_chain: []
11
- date: 2018-09-11 00:00:00.000000000 Z
11
+ date: 2018-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -297,6 +297,7 @@ files:
297
297
  - src/ruby/spec/generic/server_interceptors_spec.rb
298
298
  - src/ruby/spec/generic/service_spec.rb
299
299
  - src/ruby/spec/google_rpc_status_utils_spec.rb
300
+ - src/ruby/spec/pb/codegen/package_option_spec.rb
300
301
  - src/ruby/spec/pb/duplicate/codegen_spec.rb
301
302
  - src/ruby/spec/pb/health/checker_spec.rb
302
303
  - src/ruby/spec/server_credentials_spec.rb
@@ -331,9 +332,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
331
332
  version: '2.6'
332
333
  required_rubygems_version: !ruby/object:Gem::Requirement
333
334
  requirements:
334
- - - ">="
335
+ - - ">"
335
336
  - !ruby/object:Gem::Version
336
- version: '0'
337
+ version: 1.3.1
337
338
  requirements: []
338
339
  rubyforge_project:
339
340
  rubygems_version: 2.7.7
@@ -360,6 +361,7 @@ test_files:
360
361
  - src/ruby/spec/generic/server_interceptors_spec.rb
361
362
  - src/ruby/spec/generic/service_spec.rb
362
363
  - src/ruby/spec/google_rpc_status_utils_spec.rb
364
+ - src/ruby/spec/pb/codegen/package_option_spec.rb
363
365
  - src/ruby/spec/pb/duplicate/codegen_spec.rb
364
366
  - src/ruby/spec/pb/health/checker_spec.rb
365
367
  - src/ruby/spec/server_credentials_spec.rb