grpc 1.30.1-x64-mingw32 → 1.32.0.pre1-x64-mingw32

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 (32) hide show
  1. checksums.yaml +4 -4
  2. data/grpc_c.32.ruby +0 -0
  3. data/grpc_c.64.ruby +0 -0
  4. data/src/ruby/bin/math_services_pb.rb +4 -4
  5. data/src/ruby/ext/grpc/extconf.rb +5 -2
  6. data/src/ruby/ext/grpc/rb_call.c +3 -2
  7. data/src/ruby/ext/grpc/rb_call.h +4 -0
  8. data/src/ruby/ext/grpc/rb_call_credentials.c +54 -10
  9. data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
  10. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -2
  11. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -4
  12. data/src/ruby/lib/grpc/2.3/grpc_c.so +0 -0
  13. data/src/ruby/lib/grpc/2.4/grpc_c.so +0 -0
  14. data/src/ruby/lib/grpc/2.5/grpc_c.so +0 -0
  15. data/src/ruby/lib/grpc/2.6/grpc_c.so +0 -0
  16. data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
  17. data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
  18. data/src/ruby/lib/grpc/generic/interceptors.rb +1 -1
  19. data/src/ruby/lib/grpc/version.rb +1 -1
  20. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +2 -2
  21. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +5 -0
  22. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +28 -12
  23. data/src/ruby/pb/test/xds_client.rb +101 -17
  24. data/src/ruby/spec/channel_credentials_spec.rb +10 -0
  25. data/src/ruby/spec/generic/active_call_spec.rb +19 -8
  26. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
  27. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +2 -0
  28. data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
  29. data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
  30. data/src/ruby/spec/pb/codegen/package_option_spec.rb +25 -1
  31. data/src/ruby/spec/user_agent_spec.rb +74 -0
  32. metadata +38 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 642c6616455013275005f619a09ff045ee7b7c6366cd550ab1dbd0e1be8c084b
4
- data.tar.gz: 5f7362bfea74a552eeb4b1bb07025efc29af39e36b26e595ced36236e59d741a
3
+ metadata.gz: bd359895a718fe64d146b46f607d62964de6219205ed49f456a35c663bd71ece
4
+ data.tar.gz: 97f5a026e545912b0c65a20d72a76ea277bb4a51375f344a5d6b67255caa9a56
5
5
  SHA512:
6
- metadata.gz: 0b2c84631050a181a5679bfaec5eb8abda70bba96aa325ff7e26f8f2f79ccc7eac0f8f0b902523b8271d746da4ea176351570a841b1980a43cfa792560e9b386
7
- data.tar.gz: '094d8b7e2fb81ab2c500d173d0fd6036541115336f57f53d13d743d1f600c1d85e7ece342356fbc28d1af53ede849cd917bbbb5a1daf8c51f3e76eed2d7f538b'
6
+ metadata.gz: 8a6507a860a36e0634b16485213e44147082bf23cbca3b13a256000f1ae76764b41f2941da011d6e675e0c04025a03a02be4568660013e1de768170af7a7c972
7
+ data.tar.gz: 5cecbecb4c4e10b0ec7797a7ac3a0f5522cb99b4afb4ad5e5a8048c6b2592ba7da023fed6bb83c8258bd479b924577777018130c641e5a287a59eff7fec06e07
Binary file
Binary file
@@ -31,19 +31,19 @@ module Math
31
31
 
32
32
  # Div divides DivArgs.dividend by DivArgs.divisor and returns the quotient
33
33
  # and remainder.
34
- rpc :Div, DivArgs, DivReply
34
+ rpc :Div, ::Math::DivArgs, ::Math::DivReply
35
35
  # DivMany accepts an arbitrary number of division args from the client stream
36
36
  # and sends back the results in the reply stream. The stream continues until
37
37
  # the client closes its end; the server does the same after sending all the
38
38
  # replies. The stream ends immediately if either end aborts.
39
- rpc :DivMany, stream(DivArgs), stream(DivReply)
39
+ rpc :DivMany, stream(::Math::DivArgs), stream(::Math::DivReply)
40
40
  # Fib generates numbers in the Fibonacci sequence. If FibArgs.limit > 0, Fib
41
41
  # generates up to limit numbers; otherwise it continues until the call is
42
42
  # canceled. Unlike Fib above, Fib has no final FibReply.
43
- rpc :Fib, FibArgs, stream(Num)
43
+ rpc :Fib, ::Math::FibArgs, stream(::Math::Num)
44
44
  # Sum sums a stream of numbers, returning the final result once the stream
45
45
  # is closed.
46
- rpc :Sum, stream(Num), Num
46
+ rpc :Sum, stream(::Math::Num), ::Math::Num
47
47
  end
48
48
 
49
49
  Stub = Service.rpc_stub_class
@@ -25,7 +25,7 @@ grpc_config = ENV['GRPC_CONFIG'] || 'opt'
25
25
  ENV['MACOSX_DEPLOYMENT_TARGET'] = '10.7'
26
26
 
27
27
  if ENV['AR'].nil? || ENV['AR'].size == 0
28
- ENV['AR'] = RbConfig::CONFIG['AR'] + ' rcs'
28
+ ENV['AR'] = RbConfig::CONFIG['AR']
29
29
  end
30
30
  if ENV['CC'].nil? || ENV['CC'].size == 0
31
31
  ENV['CC'] = RbConfig::CONFIG['CC']
@@ -37,7 +37,10 @@ if ENV['LD'].nil? || ENV['LD'].size == 0
37
37
  ENV['LD'] = ENV['CC']
38
38
  end
39
39
 
40
- ENV['AR'] = 'libtool -o' if RUBY_PLATFORM =~ /darwin/
40
+ if RUBY_PLATFORM =~ /darwin/
41
+ ENV['AR'] = 'libtool'
42
+ ENV['ARFLAGS'] = '-o'
43
+ end
41
44
 
42
45
  ENV['EMBED_OPENSSL'] = 'true'
43
46
  ENV['EMBED_ZLIB'] = 'true'
@@ -48,7 +48,7 @@ static VALUE grpc_rb_sBatchResult;
48
48
 
49
49
  /* grpc_rb_cMdAry is the MetadataArray class whose instances proxy
50
50
  * grpc_metadata_array. */
51
- static VALUE grpc_rb_cMdAry;
51
+ VALUE grpc_rb_cMdAry;
52
52
 
53
53
  /* id_credentials is the name of the hidden ivar that preserves the value
54
54
  * of the credentials added to the call */
@@ -103,7 +103,7 @@ static void grpc_rb_call_destroy(void* p) {
103
103
  xfree(p);
104
104
  }
105
105
 
106
- static const rb_data_type_t grpc_rb_md_ary_data_type = {
106
+ const rb_data_type_t grpc_rb_md_ary_data_type = {
107
107
  "grpc_metadata_array",
108
108
  {GRPC_RB_GC_NOT_MARKED,
109
109
  GRPC_RB_GC_DONT_FREE,
@@ -489,6 +489,7 @@ static int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val,
489
489
 
490
490
  /* grpc_rb_md_ary_convert converts a ruby metadata hash into
491
491
  a grpc_metadata_array.
492
+ Note that this function may throw exceptions.
492
493
  */
493
494
  void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array* md_ary) {
494
495
  VALUE md_ary_obj = Qnil;
@@ -23,6 +23,10 @@
23
23
 
24
24
  #include <grpc/grpc.h>
25
25
 
26
+ extern const rb_data_type_t grpc_rb_md_ary_data_type;
27
+
28
+ extern VALUE grpc_rb_cMdAry;
29
+
26
30
  /* Gets the wrapped call from a VALUE. */
27
31
  grpc_call* grpc_rb_get_wrapped_call(VALUE v);
28
32
 
@@ -54,10 +54,41 @@ typedef struct callback_params {
54
54
  grpc_credentials_plugin_metadata_cb callback;
55
55
  } callback_params;
56
56
 
57
- static VALUE grpc_rb_call_credentials_callback(VALUE callback_args) {
57
+ static VALUE grpc_rb_call_credentials_callback(VALUE args) {
58
58
  VALUE result = rb_hash_new();
59
- VALUE metadata = rb_funcall(rb_ary_entry(callback_args, 0), rb_intern("call"),
60
- 1, rb_ary_entry(callback_args, 1));
59
+ VALUE callback_func = rb_ary_entry(args, 0);
60
+ VALUE callback_args = rb_ary_entry(args, 1);
61
+ VALUE md_ary_obj = rb_ary_entry(args, 2);
62
+ if (gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
63
+ VALUE callback_func_str = rb_funcall(callback_func, rb_intern("to_s"), 0);
64
+ VALUE callback_args_str = rb_funcall(callback_args, rb_intern("to_s"), 0);
65
+ VALUE callback_source_info =
66
+ rb_funcall(callback_func, rb_intern("source_location"), 0);
67
+ if (callback_source_info != Qnil) {
68
+ VALUE source_filename = rb_ary_entry(callback_source_info, 0);
69
+ VALUE source_line_number = rb_funcall(
70
+ rb_ary_entry(callback_source_info, 1), rb_intern("to_s"), 0);
71
+ gpr_log(GPR_DEBUG,
72
+ "GRPC_RUBY: grpc_rb_call_credentials invoking user callback:|%s| "
73
+ "source_filename:%s line_number:%s with arguments:|%s|",
74
+ StringValueCStr(callback_func_str),
75
+ StringValueCStr(source_filename),
76
+ StringValueCStr(source_line_number),
77
+ StringValueCStr(callback_args_str));
78
+ } else {
79
+ gpr_log(GPR_DEBUG,
80
+ "GRPC_RUBY: grpc_rb_call_credentials invoking user callback:|%s| "
81
+ "(failed to get source filename and line) with arguments:|%s|",
82
+ StringValueCStr(callback_func_str),
83
+ StringValueCStr(callback_args_str));
84
+ }
85
+ }
86
+ VALUE metadata =
87
+ rb_funcall(callback_func, rb_intern("call"), 1, callback_args);
88
+ grpc_metadata_array* md_ary = NULL;
89
+ TypedData_Get_Struct(md_ary_obj, grpc_metadata_array,
90
+ &grpc_rb_md_ary_data_type, md_ary);
91
+ grpc_rb_md_ary_convert(metadata, md_ary);
61
92
  rb_hash_aset(result, rb_str_new2("metadata"), metadata);
62
93
  rb_hash_aset(result, rb_str_new2("status"), INT2NUM(GRPC_STATUS_OK));
63
94
  rb_hash_aset(result, rb_str_new2("details"), rb_str_new2(""));
@@ -67,14 +98,23 @@ static VALUE grpc_rb_call_credentials_callback(VALUE callback_args) {
67
98
  static VALUE grpc_rb_call_credentials_callback_rescue(VALUE args,
68
99
  VALUE exception_object) {
69
100
  VALUE result = rb_hash_new();
70
- VALUE backtrace =
71
- rb_funcall(rb_funcall(exception_object, rb_intern("backtrace"), 0),
72
- rb_intern("join"), 1, rb_str_new2("\n\tfrom "));
101
+ VALUE backtrace = rb_funcall(exception_object, rb_intern("backtrace"), 0);
102
+ VALUE backtrace_str;
103
+ if (backtrace != Qnil) {
104
+ backtrace_str =
105
+ rb_funcall(backtrace, rb_intern("join"), 1, rb_str_new2("\n\tfrom "));
106
+ } else {
107
+ backtrace_str = rb_str_new2(
108
+ "failed to get backtrace, this exception was likely thrown from native "
109
+ "code");
110
+ }
73
111
  VALUE rb_exception_info =
74
112
  rb_funcall(exception_object, rb_intern("inspect"), 0);
75
113
  (void)args;
76
- gpr_log(GPR_INFO, "Call credentials callback failed: %s\n%s",
77
- StringValueCStr(rb_exception_info), StringValueCStr(backtrace));
114
+ gpr_log(GPR_INFO,
115
+ "GRPC_RUBY call credentials callback failed, exception inspect:|%s| "
116
+ "backtrace:|%s|",
117
+ StringValueCStr(rb_exception_info), StringValueCStr(backtrace_str));
78
118
  rb_hash_aset(result, rb_str_new2("metadata"), Qnil);
79
119
  rb_hash_aset(result, rb_str_new2("status"),
80
120
  INT2NUM(GRPC_STATUS_UNAUTHENTICATED));
@@ -98,11 +138,15 @@ static void grpc_rb_call_credentials_callback_with_gil(void* param) {
98
138
  rb_hash_aset(args, ID2SYM(rb_intern("jwt_aud_uri")), auth_uri);
99
139
  rb_ary_push(callback_args, params->get_metadata);
100
140
  rb_ary_push(callback_args, args);
141
+ // Wrap up the grpc_metadata_array into a ruby object and do the conversion
142
+ // from hash to grpc_metadata_array within the rescue block, because the
143
+ // conversion can throw exceptions.
144
+ rb_ary_push(callback_args,
145
+ TypedData_Wrap_Struct(grpc_rb_cMdAry, &grpc_rb_md_ary_data_type,
146
+ &md_ary));
101
147
  result = rb_rescue(grpc_rb_call_credentials_callback, callback_args,
102
148
  grpc_rb_call_credentials_callback_rescue, Qnil);
103
149
  // Both callbacks return a hash, so result should be a hash
104
- grpc_rb_md_ary_convert(rb_hash_aref(result, rb_str_new2("metadata")),
105
- &md_ary);
106
150
  status = NUM2INT(rb_hash_aref(result, rb_str_new2("status")));
107
151
  details = rb_hash_aref(result, rb_str_new2("details"));
108
152
  error_details = StringValueCStr(details);
@@ -165,6 +165,15 @@ static VALUE grpc_rb_channel_credentials_init(int argc, VALUE* argv,
165
165
  if (pem_private_key == Qnil && pem_cert_chain == Qnil) {
166
166
  creds = grpc_ssl_credentials_create(pem_root_certs_cstr, NULL, NULL, NULL);
167
167
  } else {
168
+ if (pem_private_key == Qnil) {
169
+ rb_raise(
170
+ rb_eRuntimeError,
171
+ "could not create a credentials because pem_private_key is NULL");
172
+ }
173
+ if (pem_cert_chain == Qnil) {
174
+ rb_raise(rb_eRuntimeError,
175
+ "could not create a credentials because pem_cert_chain is NULL");
176
+ }
168
177
  key_cert_pair.private_key = RSTRING_PTR(pem_private_key);
169
178
  key_cert_pair.cert_chain = RSTRING_PTR(pem_cert_chain);
170
179
  creds = grpc_ssl_credentials_create(pem_root_certs_cstr, &key_cert_pair,
@@ -120,12 +120,12 @@ grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_pee
120
120
  grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import;
121
121
  grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import;
122
122
  grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import;
123
+ grpc_call_credentials_release_type grpc_call_credentials_release_import;
123
124
  grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
124
125
  grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
125
126
  grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
126
127
  grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
127
128
  grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import;
128
- grpc_call_credentials_release_type grpc_call_credentials_release_import;
129
129
  grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
130
130
  grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import;
131
131
  grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import;
@@ -394,12 +394,12 @@ void grpc_rb_load_imports(HMODULE library) {
394
394
  grpc_ssl_session_cache_create_lru_import = (grpc_ssl_session_cache_create_lru_type) GetProcAddress(library, "grpc_ssl_session_cache_create_lru");
395
395
  grpc_ssl_session_cache_destroy_import = (grpc_ssl_session_cache_destroy_type) GetProcAddress(library, "grpc_ssl_session_cache_destroy");
396
396
  grpc_ssl_session_cache_create_channel_arg_import = (grpc_ssl_session_cache_create_channel_arg_type) GetProcAddress(library, "grpc_ssl_session_cache_create_channel_arg");
397
+ grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release");
397
398
  grpc_channel_credentials_release_import = (grpc_channel_credentials_release_type) GetProcAddress(library, "grpc_channel_credentials_release");
398
399
  grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create");
399
400
  grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback");
400
401
  grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create");
401
402
  grpc_ssl_credentials_create_ex_import = (grpc_ssl_credentials_create_ex_type) GetProcAddress(library, "grpc_ssl_credentials_create_ex");
402
- grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release");
403
403
  grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create");
404
404
  grpc_composite_call_credentials_create_import = (grpc_composite_call_credentials_create_type) GetProcAddress(library, "grpc_composite_call_credentials_create");
405
405
  grpc_google_compute_engine_credentials_create_import = (grpc_google_compute_engine_credentials_create_type) GetProcAddress(library, "grpc_google_compute_engine_credentials_create");
@@ -335,10 +335,13 @@ extern grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import
335
335
  typedef grpc_arg(*grpc_ssl_session_cache_create_channel_arg_type)(grpc_ssl_session_cache* cache);
336
336
  extern grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import;
337
337
  #define grpc_ssl_session_cache_create_channel_arg grpc_ssl_session_cache_create_channel_arg_import
338
+ typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds);
339
+ extern grpc_call_credentials_release_type grpc_call_credentials_release_import;
340
+ #define grpc_call_credentials_release grpc_call_credentials_release_import
338
341
  typedef void(*grpc_channel_credentials_release_type)(grpc_channel_credentials* creds);
339
342
  extern grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
340
343
  #define grpc_channel_credentials_release grpc_channel_credentials_release_import
341
- typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(void);
344
+ typedef grpc_channel_credentials*(*grpc_google_default_credentials_create_type)(grpc_call_credentials* call_credentials);
342
345
  extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
343
346
  #define grpc_google_default_credentials_create grpc_google_default_credentials_create_import
344
347
  typedef void(*grpc_set_ssl_roots_override_callback_type)(grpc_ssl_roots_override_callback cb);
@@ -350,9 +353,6 @@ extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import;
350
353
  typedef grpc_channel_credentials*(*grpc_ssl_credentials_create_ex_type)(const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const grpc_ssl_verify_peer_options* verify_options, void* reserved);
351
354
  extern grpc_ssl_credentials_create_ex_type grpc_ssl_credentials_create_ex_import;
352
355
  #define grpc_ssl_credentials_create_ex grpc_ssl_credentials_create_ex_import
353
- typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials* creds);
354
- extern grpc_call_credentials_release_type grpc_call_credentials_release_import;
355
- #define grpc_call_credentials_release grpc_call_credentials_release_import
356
356
  typedef grpc_channel_credentials*(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, void* reserved);
357
357
  extern grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import;
358
358
  #define grpc_composite_channel_credentials_create grpc_composite_channel_credentials_create_import
@@ -100,7 +100,7 @@ module GRPC
100
100
  channel_args: {},
101
101
  interceptors: [])
102
102
  @ch = ClientStub.setup_channel(channel_override, host, creds,
103
- channel_args)
103
+ channel_args.dup)
104
104
  alt_host = channel_args[Core::Channel::SSL_TARGET]
105
105
  @host = alt_host.nil? ? host : alt_host
106
106
  @propagate_mask = propagate_mask
@@ -172,7 +172,7 @@ module GRPC
172
172
  i = @interceptors.pop
173
173
  return yield unless i
174
174
 
175
- i.send(type, args) do
175
+ i.send(type, **args) do
176
176
  if @interceptors.any?
177
177
  intercept!(type, args) do
178
178
  yield
@@ -14,5 +14,5 @@
14
14
 
15
15
  # GRPC contains the General RPC module.
16
16
  module GRPC
17
- VERSION = '1.30.1'
17
+ VERSION = '1.32.0.pre1'
18
18
  end
@@ -36,7 +36,7 @@ module Grpc
36
36
 
37
37
  # If the requested service is unknown, the call will fail with status
38
38
  # NOT_FOUND.
39
- rpc :Check, HealthCheckRequest, HealthCheckResponse
39
+ rpc :Check, ::Grpc::Health::V1::HealthCheckRequest, ::Grpc::Health::V1::HealthCheckResponse
40
40
  # Performs a watch for the serving status of the requested service.
41
41
  # The server will immediately send back a message indicating the current
42
42
  # serving status. It will then subsequently send a new message whenever
@@ -52,7 +52,7 @@ module Grpc
52
52
  # should assume this method is not supported and should not retry the
53
53
  # call. If the call terminates with any other status (including OK),
54
54
  # clients should retry the call with appropriate exponential backoff.
55
- rpc :Watch, HealthCheckRequest, stream(HealthCheckResponse)
55
+ rpc :Watch, ::Grpc::Health::V1::HealthCheckRequest, stream(::Grpc::Health::V1::HealthCheckResponse)
56
56
  end
57
57
 
58
58
  Stub = Service.rpc_stub_class
@@ -71,6 +71,10 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
71
71
  add_message "grpc.testing.LoadBalancerStatsResponse" do
72
72
  map :rpcs_by_peer, :string, :int32, 1
73
73
  optional :num_failures, :int32, 2
74
+ map :rpcs_by_method, :string, :message, 3, "grpc.testing.LoadBalancerStatsResponse.RpcsByPeer"
75
+ end
76
+ add_message "grpc.testing.LoadBalancerStatsResponse.RpcsByPeer" do
77
+ map :rpcs_by_peer, :string, :int32, 1
74
78
  end
75
79
  add_enum "grpc.testing.PayloadType" do
76
80
  value :COMPRESSABLE, 0
@@ -99,6 +103,7 @@ module Grpc
99
103
  ReconnectInfo = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.ReconnectInfo").msgclass
100
104
  LoadBalancerStatsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.LoadBalancerStatsRequest").msgclass
101
105
  LoadBalancerStatsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.LoadBalancerStatsResponse").msgclass
106
+ LoadBalancerStatsResponse::RpcsByPeer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.LoadBalancerStatsResponse.RpcsByPeer").msgclass
102
107
  PayloadType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.PayloadType").enummodule
103
108
  GrpclbRouteType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("grpc.testing.GrpclbRouteType").enummodule
104
109
  end
@@ -36,31 +36,31 @@ module Grpc
36
36
  self.service_name = 'grpc.testing.TestService'
37
37
 
38
38
  # One empty request followed by one empty response.
39
- rpc :EmptyCall, Empty, Empty
39
+ rpc :EmptyCall, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
40
40
  # One request followed by one response.
41
- rpc :UnaryCall, SimpleRequest, SimpleResponse
41
+ rpc :UnaryCall, ::Grpc::Testing::SimpleRequest, ::Grpc::Testing::SimpleResponse
42
42
  # One request followed by one response. Response has cache control
43
43
  # headers set such that a caching HTTP proxy (such as GFE) can
44
44
  # satisfy subsequent requests.
45
- rpc :CacheableUnaryCall, SimpleRequest, SimpleResponse
45
+ rpc :CacheableUnaryCall, ::Grpc::Testing::SimpleRequest, ::Grpc::Testing::SimpleResponse
46
46
  # One request followed by a sequence of responses (streamed download).
47
47
  # The server returns the payload with client desired type and sizes.
48
- rpc :StreamingOutputCall, StreamingOutputCallRequest, stream(StreamingOutputCallResponse)
48
+ rpc :StreamingOutputCall, ::Grpc::Testing::StreamingOutputCallRequest, stream(::Grpc::Testing::StreamingOutputCallResponse)
49
49
  # A sequence of requests followed by one response (streamed upload).
50
50
  # The server returns the aggregated size of client payload as the result.
51
- rpc :StreamingInputCall, stream(StreamingInputCallRequest), StreamingInputCallResponse
51
+ rpc :StreamingInputCall, stream(::Grpc::Testing::StreamingInputCallRequest), ::Grpc::Testing::StreamingInputCallResponse
52
52
  # A sequence of requests with each request served by the server immediately.
53
53
  # As one request could lead to multiple responses, this interface
54
54
  # demonstrates the idea of full duplexing.
55
- rpc :FullDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse)
55
+ rpc :FullDuplexCall, stream(::Grpc::Testing::StreamingOutputCallRequest), stream(::Grpc::Testing::StreamingOutputCallResponse)
56
56
  # A sequence of requests followed by a sequence of responses.
57
57
  # The server buffers all the client requests and then serves them in order. A
58
58
  # stream of responses are returned to the client when the server starts with
59
59
  # first request.
60
- rpc :HalfDuplexCall, stream(StreamingOutputCallRequest), stream(StreamingOutputCallResponse)
60
+ rpc :HalfDuplexCall, stream(::Grpc::Testing::StreamingOutputCallRequest), stream(::Grpc::Testing::StreamingOutputCallResponse)
61
61
  # The test server will not implement this method. It will be used
62
62
  # to test the behavior when clients call unimplemented methods.
63
- rpc :UnimplementedCall, Empty, Empty
63
+ rpc :UnimplementedCall, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
64
64
  end
65
65
 
66
66
  Stub = Service.rpc_stub_class
@@ -77,7 +77,7 @@ module Grpc
77
77
  self.service_name = 'grpc.testing.UnimplementedService'
78
78
 
79
79
  # A call that no server should implement
80
- rpc :UnimplementedCall, Empty, Empty
80
+ rpc :UnimplementedCall, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
81
81
  end
82
82
 
83
83
  Stub = Service.rpc_stub_class
@@ -92,8 +92,8 @@ module Grpc
92
92
  self.unmarshal_class_method = :decode
93
93
  self.service_name = 'grpc.testing.ReconnectService'
94
94
 
95
- rpc :Start, ReconnectParams, Empty
96
- rpc :Stop, Empty, ReconnectInfo
95
+ rpc :Start, ::Grpc::Testing::ReconnectParams, ::Grpc::Testing::Empty
96
+ rpc :Stop, ::Grpc::Testing::Empty, ::Grpc::Testing::ReconnectInfo
97
97
  end
98
98
 
99
99
  Stub = Service.rpc_stub_class
@@ -109,7 +109,23 @@ module Grpc
109
109
  self.service_name = 'grpc.testing.LoadBalancerStatsService'
110
110
 
111
111
  # Gets the backend distribution for RPCs sent by a test client.
112
- rpc :GetClientStats, LoadBalancerStatsRequest, LoadBalancerStatsResponse
112
+ rpc :GetClientStats, ::Grpc::Testing::LoadBalancerStatsRequest, ::Grpc::Testing::LoadBalancerStatsResponse
113
+ end
114
+
115
+ Stub = Service.rpc_stub_class
116
+ end
117
+ module XdsUpdateHealthService
118
+ # A service to remotely control health status of an xDS test server.
119
+ class Service
120
+
121
+ include GRPC::GenericService
122
+
123
+ self.marshal_class_method = :encode
124
+ self.unmarshal_class_method = :decode
125
+ self.service_name = 'grpc.testing.XdsUpdateHealthService'
126
+
127
+ rpc :SetServing, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
128
+ rpc :SetNotServing, ::Grpc::Testing::Empty, ::Grpc::Testing::Empty
113
129
  end
114
130
 
115
131
  Stub = Service.rpc_stub_class
@@ -81,6 +81,7 @@ class TestTarget < Grpc::Testing::LoadBalancerStatsService::Service
81
81
  watcher = {}
82
82
  $watchers_mutex.synchronize do
83
83
  watcher = {
84
+ "rpcs_by_method" => Hash.new(),
84
85
  "rpcs_by_peer" => Hash.new(0),
85
86
  "rpcs_needed" => req['num_rpcs'],
86
87
  "no_remote_peer" => 0
@@ -95,17 +96,45 @@ class TestTarget < Grpc::Testing::LoadBalancerStatsService::Service
95
96
  end
96
97
  $watchers.delete_at($watchers.index(watcher))
97
98
  end
99
+ # convert results into proper proto object
100
+ rpcs_by_method = {}
101
+ watcher['rpcs_by_method'].each do |rpc_name, rpcs_by_peer|
102
+ rpcs_by_method[rpc_name] = LoadBalancerStatsResponse::RpcsByPeer.new(
103
+ rpcs_by_peer: rpcs_by_peer
104
+ )
105
+ end
98
106
  LoadBalancerStatsResponse.new(
107
+ rpcs_by_method: rpcs_by_method,
99
108
  rpcs_by_peer: watcher['rpcs_by_peer'],
100
109
  num_failures: watcher['no_remote_peer'] + watcher['rpcs_needed']
101
110
  );
102
111
  end
103
112
  end
104
113
 
114
+ # execute 1 RPC and return remote hostname
115
+ def execute_rpc(op, fail_on_failed_rpcs)
116
+ remote_peer = ""
117
+ begin
118
+ op.execute
119
+ if op.metadata.key?('hostname')
120
+ remote_peer = op.metadata['hostname']
121
+ end
122
+ rescue GRPC::BadStatus => e
123
+ GRPC.logger.info("ruby xds: rpc failed:|#{e.message}|, " \
124
+ "this may or may not be expected")
125
+ if fail_on_failed_rpcs
126
+ raise e
127
+ end
128
+ end
129
+ remote_peer
130
+ end
131
+
105
132
  # send 1 rpc every 1/qps second
106
- def run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs)
133
+ def run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs,
134
+ rpcs_to_send, metadata_to_send)
107
135
  include Grpc::Testing
108
- req = SimpleRequest.new()
136
+ simple_req = SimpleRequest.new()
137
+ empty_req = Empty.new()
109
138
  target_next_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
110
139
  while !$shutdown
111
140
  now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@@ -121,25 +150,42 @@ def run_test_loop(stub, target_seconds_between_rpcs, fail_on_failed_rpcs)
121
150
  target_next_start += target_seconds_between_rpcs
122
151
  sleep(sleep_seconds)
123
152
  end
124
- begin
125
- deadline = GRPC::Core::TimeConsts::from_relative_time(30) # 30 seconds
126
- resp = stub.unary_call(req, deadline: deadline)
127
- remote_peer = resp.hostname
128
- rescue GRPC::BadStatus => e
129
- remote_peer = ""
130
- GRPC.logger.info("ruby xds: rpc failed:|#{e.message}|, " \
131
- "this may or may not be expected")
132
- if fail_on_failed_rpcs
133
- raise e
153
+ deadline = GRPC::Core::TimeConsts::from_relative_time(30) # 30 seconds
154
+ results = {}
155
+ rpcs_to_send.each do |rpc|
156
+ metadata = metadata_to_send.key?(rpc) ? metadata_to_send[rpc] : {}
157
+ if rpc == 'UnaryCall'
158
+ op = stub.unary_call(simple_req,
159
+ metadata: metadata,
160
+ deadline: deadline,
161
+ return_op: true)
162
+ elsif rpc == 'EmptyCall'
163
+ op = stub.empty_call(empty_req,
164
+ metadata: metadata,
165
+ deadline: deadline,
166
+ return_op: true)
167
+ else
168
+ raise "Unsupported rpc %s" % [rpc]
134
169
  end
170
+ results[rpc] = execute_rpc(op, fail_on_failed_rpcs)
135
171
  end
136
172
  $watchers_mutex.synchronize do
137
173
  $watchers.each do |watcher|
174
+ # this is counted once when each group of all rpcs_to_send were done
138
175
  watcher['rpcs_needed'] -= 1
139
- if remote_peer.strip.empty?
140
- watcher['no_remote_peer'] += 1
141
- else
142
- watcher['rpcs_by_peer'][remote_peer] += 1
176
+ results.each do |rpc_name, remote_peer|
177
+ if remote_peer.strip.empty?
178
+ # error is counted per individual RPC
179
+ watcher['no_remote_peer'] += 1
180
+ else
181
+ if not watcher['rpcs_by_method'].key?(rpc_name)
182
+ watcher['rpcs_by_method'][rpc_name] = Hash.new(0)
183
+ end
184
+ # increment the remote hostname distribution histogram
185
+ # both by overall, and broken down per RPC
186
+ watcher['rpcs_by_method'][rpc_name][remote_peer] += 1
187
+ watcher['rpcs_by_peer'][remote_peer] += 1
188
+ end
143
189
  end
144
190
  end
145
191
  $watchers_cv.broadcast
@@ -149,6 +195,7 @@ end
149
195
 
150
196
  # Args is used to hold the command line info.
151
197
  Args = Struct.new(:fail_on_failed_rpcs, :num_channels,
198
+ :rpc, :metadata,
152
199
  :server, :stats_port, :qps)
153
200
 
154
201
  # validates the command line options, returning them as a Hash.
@@ -156,6 +203,8 @@ def parse_args
156
203
  args = Args.new
157
204
  args['fail_on_failed_rpcs'] = false
158
205
  args['num_channels'] = 1
206
+ args['rpc'] = 'UnaryCall'
207
+ args['metadata'] = ''
159
208
  OptionParser.new do |opts|
160
209
  opts.on('--fail_on_failed_rpcs BOOL', ['false', 'true']) do |v|
161
210
  args['fail_on_failed_rpcs'] = v == 'true'
@@ -163,6 +212,12 @@ def parse_args
163
212
  opts.on('--num_channels CHANNELS', 'number of channels') do |v|
164
213
  args['num_channels'] = v.to_i
165
214
  end
215
+ opts.on('--rpc RPCS_TO_SEND', 'list of RPCs to send') do |v|
216
+ args['rpc'] = v
217
+ end
218
+ opts.on('--metadata METADATA_TO_SEND', 'metadata to send per RPC') do |v|
219
+ args['metadata'] = v
220
+ end
166
221
  opts.on('--server SERVER_HOST', 'server hostname') do |v|
167
222
  GRPC.logger.info("ruby xds: server address is #{v}")
168
223
  args['server'] = v
@@ -195,11 +250,40 @@ def main
195
250
  # The client just sends unary rpcs continuously in a regular interval
196
251
  stub = create_stub(opts)
197
252
  target_seconds_between_rpcs = (1.0 / opts['qps'].to_f)
253
+ rpcs_to_send = []
254
+ if opts['rpc']
255
+ rpcs_to_send = opts['rpc'].split(',')
256
+ end
257
+ # Convert 'metadata' input in the form of
258
+ # rpc1:k1:v1,rpc2:k2:v2,rpc1:k3:v3
259
+ # into
260
+ # {
261
+ # 'rpc1' => {
262
+ # 'k1' => 'v1',
263
+ # 'k3' => 'v3',
264
+ # },
265
+ # 'rpc2' => {
266
+ # 'k2' => 'v2'
267
+ # },
268
+ # }
269
+ metadata_to_send = {}
270
+ if opts['metadata']
271
+ metadata_entries = opts['metadata'].split(',')
272
+ metadata_entries.each do |e|
273
+ (rpc_name, metadata_key, metadata_value) = e.split(':')
274
+ # initialize if we haven't seen this rpc_name yet
275
+ if !metadata_to_send.key?(rpc_name)
276
+ metadata_to_send[rpc_name] = {}
277
+ end
278
+ metadata_to_send[rpc_name][metadata_key] = metadata_value
279
+ end
280
+ end
198
281
  client_threads = Array.new
199
282
  opts['num_channels'].times {
200
283
  client_threads << Thread.new {
201
284
  run_test_loop(stub, target_seconds_between_rpcs,
202
- opts['fail_on_failed_rpcs'])
285
+ opts['fail_on_failed_rpcs'],
286
+ rpcs_to_send, metadata_to_send)
203
287
  }
204
288
  }
205
289
 
@@ -50,6 +50,16 @@ describe GRPC::Core::ChannelCredentials do
50
50
  blk = proc { ChannelCredentials.new(nil) }
51
51
  expect(&blk).not_to raise_error
52
52
  end
53
+
54
+ it 'fails gracefully with constructed with a nil private key' do
55
+ blk = proc { GRPC::Core::ChannelCredentials.new(nil, nil, '') }
56
+ expect(&blk).to raise_error
57
+ end
58
+
59
+ it 'fails gracefully with constructed with a nil cert chain' do
60
+ blk = proc { GRPC::Core::ChannelCredentials.new(nil, '', nil) }
61
+ expect(&blk).to raise_error
62
+ end
53
63
  end
54
64
 
55
65
  describe '#compose' do
@@ -43,6 +43,16 @@ describe GRPC::ActiveCall do
43
43
  @server = new_core_server_for_testing(nil)
44
44
  server_port = @server.add_http2_port(host, :this_port_is_insecure)
45
45
  @server.start
46
+ @received_rpcs_queue = Queue.new
47
+ @server_thread = Thread.new do
48
+ begin
49
+ received_rpc = @server.request_call
50
+ rescue GRPC::Core::CallError, StandardError => e
51
+ # enqueue the exception in this case as a way to indicate the error
52
+ received_rpc = e
53
+ end
54
+ @received_rpcs_queue.push(received_rpc)
55
+ end
46
56
  @ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil,
47
57
  :this_channel_is_insecure)
48
58
  end
@@ -50,6 +60,7 @@ describe GRPC::ActiveCall do
50
60
  after(:each) do
51
61
  @server.shutdown_and_notify(deadline)
52
62
  @server.close
63
+ @server_thread.join
53
64
  end
54
65
 
55
66
  describe 'restricted view methods' do
@@ -105,7 +116,7 @@ describe GRPC::ActiveCall do
105
116
  client_call.remote_send(msg)
106
117
 
107
118
  # check that server rpc new was received
108
- recvd_rpc = @server.request_call
119
+ recvd_rpc = @received_rpcs_queue.pop
109
120
  expect(recvd_rpc).to_not eq nil
110
121
  recvd_call = recvd_rpc.call
111
122
 
@@ -130,7 +141,7 @@ describe GRPC::ActiveCall do
130
141
  client_call.remote_send(msg)
131
142
 
132
143
  # confirm that the message was marshalled
133
- recvd_rpc = @server.request_call
144
+ recvd_rpc = @received_rpcs_queue.pop
134
145
  recvd_call = recvd_rpc.call
135
146
  server_ops = {
136
147
  CallOps::SEND_INITIAL_METADATA => nil
@@ -160,7 +171,7 @@ describe GRPC::ActiveCall do
160
171
  call.run_batch(CallOps::SEND_CLOSE_FROM_CLIENT => nil) if f == 1
161
172
 
162
173
  # confirm that the message was marshalled
163
- recvd_rpc = @server.request_call
174
+ recvd_rpc = @received_rpcs_queue.pop
164
175
  recvd_call = recvd_rpc.call
165
176
  server_ops = {
166
177
  CallOps::SEND_INITIAL_METADATA => nil
@@ -321,7 +332,7 @@ describe GRPC::ActiveCall do
321
332
  call = make_test_call
322
333
  metadata = { k1: 'v1', k2: 'v2' }
323
334
  ActiveCall.client_invoke(call, metadata)
324
- recvd_rpc = @server.request_call
335
+ recvd_rpc = @received_rpcs_queue.pop
325
336
  recvd_call = recvd_rpc.call
326
337
  expect(recvd_call).to_not be_nil
327
338
  expect(recvd_rpc.metadata).to_not be_nil
@@ -339,7 +350,7 @@ describe GRPC::ActiveCall do
339
350
  call = make_test_call
340
351
  ActiveCall.client_invoke(call)
341
352
 
342
- recvd_rpc = @server.request_call
353
+ recvd_rpc = @received_rpcs_queue.pop
343
354
  server_call = ActiveCall.new(
344
355
  recvd_rpc.call,
345
356
  @pass_through,
@@ -405,7 +416,7 @@ describe GRPC::ActiveCall do
405
416
  client_call = make_test_call
406
417
  ActiveCall.client_invoke(client_call)
407
418
 
408
- recvd_rpc = @server.request_call
419
+ recvd_rpc = @received_rpcs_queue.pop
409
420
  recvd_call = recvd_rpc.call
410
421
 
411
422
  server_call = ActiveCall.new(
@@ -575,7 +586,7 @@ describe GRPC::ActiveCall do
575
586
  @client_call = make_test_call
576
587
  @client_call.run_batch(CallOps::SEND_INITIAL_METADATA => {})
577
588
 
578
- recvd_rpc = @server.request_call
589
+ recvd_rpc = @received_rpcs_queue.pop
579
590
  recvd_call = recvd_rpc.call
580
591
  @server_call = ActiveCall.new(
581
592
  recvd_call,
@@ -654,7 +665,7 @@ describe GRPC::ActiveCall do
654
665
  end
655
666
 
656
667
  def expect_server_to_be_invoked(**kw)
657
- recvd_rpc = @server.request_call
668
+ recvd_rpc = @received_rpcs_queue.pop
658
669
  expect(recvd_rpc).to_not eq nil
659
670
  recvd_call = recvd_rpc.call
660
671
  recvd_call.run_batch(CallOps::SEND_INITIAL_METADATA => kw)
@@ -0,0 +1,23 @@
1
+ // Copyright 2020 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
+ syntax = "proto3";
16
+
17
+ package grpc.foo;
18
+
19
+ option ruby_package = "B::Other";
20
+
21
+ message Foo {
22
+ message Bar { }
23
+ }
@@ -17,6 +17,7 @@ syntax = "proto3";
17
17
  package grpc.testing;
18
18
 
19
19
  import "grpc/testing/package_options_import.proto";
20
+ import "grpc/testing/package_options_import2.proto";
20
21
 
21
22
  // For sanity checking package definitions
22
23
  option ruby_package = "RPC::Test::New::Package::Options";
@@ -34,6 +35,7 @@ message Bar {
34
35
  service AnotherTestService {
35
36
  rpc GetTest(AnotherTestRequest) returns (AnotherTestResponse) { }
36
37
  rpc OtherTest(Thing) returns (Thing) { }
38
+ rpc PackageTest(grpc.testing.Thing) returns (grpc.foo.Foo.Bar) { }
37
39
  rpc FooTest(Foo) returns (Foo) { }
38
40
  rpc NestedMessageTest(Foo) returns (Bar.Baz) { }
39
41
  }
@@ -0,0 +1,27 @@
1
+ // Copyright 2020 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
+ syntax = "proto3";
16
+
17
+ package same_name;
18
+
19
+ service SameName {
20
+ rpc Health(Request) returns (Status);
21
+ }
22
+
23
+ message Status {
24
+ string msg = 1;
25
+ }
26
+
27
+ message Request {}
@@ -0,0 +1,29 @@
1
+ // Copyright 2020 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
+ syntax = "proto3";
16
+
17
+ package other_name;
18
+
19
+ option ruby_package = "SameName2";
20
+
21
+ service SameName2 {
22
+ rpc Health(Request) returns (Status);
23
+ }
24
+
25
+ message Status {
26
+ string msg = 1;
27
+ }
28
+
29
+ message Request {}
@@ -27,7 +27,9 @@ describe 'Code Generation Options' do
27
27
  end
28
28
 
29
29
  it 'should generate and respect Ruby style package options' do
30
- with_protos(%w[grpc/testing/package_options_ruby_style.proto grpc/testing/package_options_import.proto]) do
30
+ with_protos(['grpc/testing/package_options_ruby_style.proto',
31
+ 'grpc/testing/package_options_import.proto',
32
+ 'grpc/testing/package_options_import2.proto']) do
31
33
  expect { RPC::Test::New::Package::Options::AnotherTestService::Service }.to raise_error(NameError)
32
34
  expect(require('grpc/testing/package_options_ruby_style_services_pb')).to be_truthy
33
35
  expect { RPC::Test::New::Package::Options::AnotherTestService::Service }.to_not raise_error
@@ -38,12 +40,34 @@ describe 'Code Generation Options' do
38
40
  expect(services[:GetTest].output).to eq(RPC::Test::New::Package::Options::AnotherTestResponse)
39
41
  expect(services[:OtherTest].input).to eq(A::Other::Thing)
40
42
  expect(services[:OtherTest].output).to eq(A::Other::Thing)
43
+ expect(services[:PackageTest].input).to eq(A::Other::Thing)
44
+ expect(services[:PackageTest].output).to eq(B::Other::Foo::Bar)
41
45
  expect(services[:FooTest].input).to eq(RPC::Test::New::Package::Options::Foo)
42
46
  expect(services[:FooTest].output).to eq(RPC::Test::New::Package::Options::Foo)
43
47
  expect(services[:NestedMessageTest].input).to eq(RPC::Test::New::Package::Options::Foo)
44
48
  expect(services[:NestedMessageTest].output).to eq(RPC::Test::New::Package::Options::Bar::Baz)
45
49
  end
46
50
  end
51
+
52
+ it 'should generate when package and service has same name' do
53
+ with_protos(['grpc/testing/same_package_service_name.proto']) do
54
+ expect { SameName::SameName::Service }.to raise_error(NameError)
55
+ expect(require('grpc/testing/same_package_service_name_services_pb')).to be_truthy
56
+ expect { SameName::SameName::Service }.to_not raise_error
57
+ expect { SameName::Request }.to_not raise_error
58
+ expect { SameName::Status }.to_not raise_error
59
+ end
60
+ end
61
+
62
+ it 'should generate when ruby_package and service has same name' do
63
+ with_protos(['grpc/testing/same_ruby_package_service_name.proto']) do
64
+ expect { SameName2::SameName2::Service }.to raise_error(NameError)
65
+ expect(require('grpc/testing/same_ruby_package_service_name_services_pb')).to be_truthy
66
+ expect { SameName2::SameName2::Service }.to_not raise_error
67
+ expect { SameName2::Request }.to_not raise_error
68
+ expect { SameName2::Status }.to_not raise_error
69
+ end
70
+ end
47
71
  end
48
72
 
49
73
  def with_protos(file_paths)
@@ -0,0 +1,74 @@
1
+ # Copyright 2020 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
+
17
+ # a test service that checks the cert of its peer
18
+ class UserAgentEchoService
19
+ include GRPC::GenericService
20
+ rpc :an_rpc, EchoMsg, EchoMsg
21
+
22
+ def an_rpc(_req, call)
23
+ EchoMsg.new(msg: call.metadata['user-agent'])
24
+ end
25
+ end
26
+
27
+ UserAgentEchoServiceStub = UserAgentEchoService.rpc_stub_class
28
+
29
+ describe 'user agent' do
30
+ RpcServer = GRPC::RpcServer
31
+
32
+ before(:all) do
33
+ server_opts = {
34
+ poll_period: 1
35
+ }
36
+ @srv = new_rpc_server_for_testing(**server_opts)
37
+ @port = @srv.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
38
+ @srv.handle(UserAgentEchoService)
39
+ @srv_thd = Thread.new { @srv.run }
40
+ @srv.wait_till_running
41
+ end
42
+
43
+ after(:all) do
44
+ expect(@srv.stopped?).to be(false)
45
+ @srv.stop
46
+ @srv_thd.join
47
+ end
48
+
49
+ it 'client sends expected user agent' do
50
+ stub = UserAgentEchoServiceStub.new("localhost:#{@port}",
51
+ :this_channel_is_insecure,
52
+ {})
53
+ response = stub.an_rpc(EchoMsg.new)
54
+ expected_user_agent_prefix = "grpc-ruby/#{GRPC::VERSION}"
55
+ expect(response.msg.start_with?(expected_user_agent_prefix)).to be true
56
+ # check that the expected user agent prefix occurs in the real user agent exactly once
57
+ expect(response.msg.split(expected_user_agent_prefix).size).to eq 2
58
+ end
59
+
60
+ it 'user agent header does not grow when the same channel args hash is used across multiple stubs' do
61
+ shared_channel_args_hash = {}
62
+ 10.times do
63
+ stub = UserAgentEchoServiceStub.new("localhost:#{@port}",
64
+ :this_channel_is_insecure,
65
+ channel_args: shared_channel_args_hash)
66
+ response = stub.an_rpc(EchoMsg.new)
67
+ puts "got echo response: #{response.msg}"
68
+ expected_user_agent_prefix = "grpc-ruby/#{GRPC::VERSION}"
69
+ expect(response.msg.start_with?(expected_user_agent_prefix)).to be true
70
+ # check that the expected user agent prefix occurs in the real user agent exactly once
71
+ expect(response.msg.split(expected_user_agent_prefix).size).to eq 2
72
+ end
73
+ end
74
+ end
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.30.1
4
+ version: 1.32.0.pre1
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - gRPC Authors
8
8
  autorequire:
9
9
  bindir: src/ruby/bin
10
10
  cert_chain: []
11
- date: 2020-07-08 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.12'
19
+ version: '3.13'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.12'
26
+ version: '3.13'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: googleapis-common-protos-types
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -306,7 +306,10 @@ files:
306
306
  - src/ruby/spec/google_rpc_status_utils_spec.rb
307
307
  - src/ruby/spec/pb/codegen/grpc/testing/package_options.proto
308
308
  - src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto
309
+ - src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto
309
310
  - src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto
311
+ - src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto
312
+ - src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto
310
313
  - src/ruby/spec/pb/codegen/package_option_spec.rb
311
314
  - src/ruby/spec/pb/duplicate/codegen_spec.rb
312
315
  - src/ruby/spec/pb/health/checker_spec.rb
@@ -322,6 +325,7 @@ files:
322
325
  - src/ruby/spec/testdata/server1.key
323
326
  - src/ruby/spec/testdata/server1.pem
324
327
  - src/ruby/spec/time_consts_spec.rb
328
+ - src/ruby/spec/user_agent_spec.rb
325
329
  homepage: https://github.com/google/grpc/tree/master/src/ruby
326
330
  licenses:
327
331
  - Apache-2.0
@@ -342,51 +346,55 @@ required_ruby_version: !ruby/object:Gem::Requirement
342
346
  version: 2.8.dev
343
347
  required_rubygems_version: !ruby/object:Gem::Requirement
344
348
  requirements:
345
- - - ">="
349
+ - - ">"
346
350
  - !ruby/object:Gem::Version
347
- version: '0'
351
+ version: 1.3.1
348
352
  requirements: []
349
353
  rubygems_version: 3.1.4
350
354
  signing_key:
351
355
  specification_version: 4
352
356
  summary: GRPC system in Ruby
353
357
  test_files:
354
- - src/ruby/spec/spec_helper.rb
355
- - src/ruby/spec/pb/health/checker_spec.rb
356
- - src/ruby/spec/pb/duplicate/codegen_spec.rb
358
+ - src/ruby/spec/server_credentials_spec.rb
357
359
  - src/ruby/spec/pb/codegen/package_option_spec.rb
360
+ - src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto
361
+ - src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto
358
362
  - src/ruby/spec/pb/codegen/grpc/testing/package_options_import.proto
359
- - src/ruby/spec/pb/codegen/grpc/testing/package_options.proto
360
363
  - src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto
361
- - src/ruby/spec/errors_spec.rb
364
+ - src/ruby/spec/pb/codegen/grpc/testing/package_options.proto
365
+ - src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto
366
+ - src/ruby/spec/pb/health/checker_spec.rb
367
+ - src/ruby/spec/pb/duplicate/codegen_spec.rb
362
368
  - src/ruby/spec/call_spec.rb
369
+ - src/ruby/spec/user_agent_spec.rb
370
+ - src/ruby/spec/support/helpers.rb
371
+ - src/ruby/spec/support/services.rb
372
+ - src/ruby/spec/errors_spec.rb
363
373
  - src/ruby/spec/compression_options_spec.rb
364
- - src/ruby/spec/server_credentials_spec.rb
365
- - src/ruby/spec/call_credentials_spec.rb
366
- - src/ruby/spec/client_server_spec.rb
367
- - src/ruby/spec/error_sanity_spec.rb
374
+ - src/ruby/spec/google_rpc_status_utils_spec.rb
375
+ - src/ruby/spec/client_auth_spec.rb
368
376
  - src/ruby/spec/channel_spec.rb
369
- - src/ruby/spec/server_spec.rb
370
377
  - src/ruby/spec/generic/client_stub_spec.rb
371
- - src/ruby/spec/generic/rpc_server_spec.rb
372
- - src/ruby/spec/generic/active_call_spec.rb
373
- - src/ruby/spec/generic/rpc_server_pool_spec.rb
374
- - src/ruby/spec/generic/client_interceptors_spec.rb
375
378
  - src/ruby/spec/generic/rpc_desc_spec.rb
376
- - src/ruby/spec/generic/interceptor_registry_spec.rb
377
379
  - src/ruby/spec/generic/service_spec.rb
378
380
  - src/ruby/spec/generic/server_interceptors_spec.rb
379
- - src/ruby/spec/testdata/client.key
380
- - src/ruby/spec/testdata/client.pem
381
+ - src/ruby/spec/generic/client_interceptors_spec.rb
382
+ - src/ruby/spec/generic/active_call_spec.rb
383
+ - src/ruby/spec/generic/rpc_server_pool_spec.rb
384
+ - src/ruby/spec/generic/rpc_server_spec.rb
385
+ - src/ruby/spec/generic/interceptor_registry_spec.rb
386
+ - src/ruby/spec/testdata/README
381
387
  - src/ruby/spec/testdata/ca.pem
388
+ - src/ruby/spec/testdata/client.key
382
389
  - src/ruby/spec/testdata/server1.key
390
+ - src/ruby/spec/testdata/client.pem
383
391
  - src/ruby/spec/testdata/server1.pem
384
- - src/ruby/spec/testdata/README
385
- - src/ruby/spec/support/helpers.rb
386
- - src/ruby/spec/support/services.rb
387
- - src/ruby/spec/debug_message_spec.rb
388
- - src/ruby/spec/google_rpc_status_utils_spec.rb
392
+ - src/ruby/spec/client_server_spec.rb
389
393
  - src/ruby/spec/time_consts_spec.rb
390
- - src/ruby/spec/channel_credentials_spec.rb
394
+ - src/ruby/spec/server_spec.rb
395
+ - src/ruby/spec/error_sanity_spec.rb
391
396
  - src/ruby/spec/channel_connection_spec.rb
392
- - src/ruby/spec/client_auth_spec.rb
397
+ - src/ruby/spec/call_credentials_spec.rb
398
+ - src/ruby/spec/spec_helper.rb
399
+ - src/ruby/spec/debug_message_spec.rb
400
+ - src/ruby/spec/channel_credentials_spec.rb