grpc 1.10.0-universal-darwin → 1.11.0.pre2-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 +4 -4
- data/src/ruby/ext/grpc/extconf.rb +1 -2
- data/src/ruby/ext/grpc/rb_call.c +1 -13
- data/src/ruby/ext/grpc/rb_channel.c +6 -6
- data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +10 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +15 -0
- data/src/ruby/lib/grpc/2.0/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.1/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.2/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.3/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.4/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/2.5/grpc_c.bundle +0 -0
- data/src/ruby/lib/grpc/core/time_consts.rb +1 -1
- data/src/ruby/lib/grpc/generic/bidi_call.rb +19 -8
- data/src/ruby/lib/grpc/generic/client_stub.rb +6 -10
- data/src/ruby/lib/grpc/generic/interceptors.rb +1 -1
- data/src/ruby/lib/grpc/generic/rpc_server.rb +2 -2
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/generic/client_stub_spec.rb +133 -0
- data/src/ruby/spec/pb/package_with_underscore/checker_spec.rb +54 -0
- data/src/ruby/spec/pb/package_with_underscore/data.proto +23 -0
- data/src/ruby/spec/pb/package_with_underscore/service.proto +23 -0
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22e056f828a68fc13afce00042ebedab5481ee4780ed089e91749e048f30ede4
|
4
|
+
data.tar.gz: cf32d6c67d5eb7917ca1f87a57855e7b8dd4d1de5a07d62e7b0b78acd91eb8de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a771eea58ee1bbbb5584970705d7adafbcd6531f58b7ba58b0759c320357c8aab0b9c26290eea2365b5f3a399987de8c7cb69bd7f17e3578593722d703e13ff
|
7
|
+
data.tar.gz: 77dc9908f6706428e80a49f23afd656daf6b5254d6dca4b0f3ad419ab2a2f7d6031405e74c1724733a1e594c4065d62f7d18e239420e4e25aca9fce4def7f88e
|
@@ -84,7 +84,7 @@ if grpc_config == 'gcov'
|
|
84
84
|
end
|
85
85
|
|
86
86
|
if grpc_config == 'dbg'
|
87
|
-
$CFLAGS << ' -O0'
|
87
|
+
$CFLAGS << ' -O0 -ggdb3'
|
88
88
|
end
|
89
89
|
|
90
90
|
$LDFLAGS << ' -Wl,-wrap,memcpy' if RUBY_PLATFORM =~ /linux/
|
@@ -94,7 +94,6 @@ $CFLAGS << ' -std=c99 '
|
|
94
94
|
$CFLAGS << ' -Wall '
|
95
95
|
$CFLAGS << ' -Wextra '
|
96
96
|
$CFLAGS << ' -pedantic '
|
97
|
-
$CFLAGS << ' -Wno-format '
|
98
97
|
|
99
98
|
output = File.join('grpc', 'grpc_c')
|
100
99
|
puts 'Generating Makefile for ' + output
|
data/src/ruby/ext/grpc/rb_call.c
CHANGED
@@ -103,23 +103,11 @@ static void grpc_rb_call_destroy(void* p) {
|
|
103
103
|
xfree(p);
|
104
104
|
}
|
105
105
|
|
106
|
-
static size_t md_ary_datasize(const void* p) {
|
107
|
-
const grpc_metadata_array* const ary = (grpc_metadata_array*)p;
|
108
|
-
size_t i, datasize = sizeof(grpc_metadata_array);
|
109
|
-
for (i = 0; i < ary->count; ++i) {
|
110
|
-
const grpc_metadata* const md = &ary->metadata[i];
|
111
|
-
datasize += GRPC_SLICE_LENGTH(md->key);
|
112
|
-
datasize += GRPC_SLICE_LENGTH(md->value);
|
113
|
-
}
|
114
|
-
datasize += ary->capacity * sizeof(grpc_metadata);
|
115
|
-
return datasize;
|
116
|
-
}
|
117
|
-
|
118
106
|
static const rb_data_type_t grpc_rb_md_ary_data_type = {
|
119
107
|
"grpc_metadata_array",
|
120
108
|
{GRPC_RB_GC_NOT_MARKED,
|
121
109
|
GRPC_RB_GC_DONT_FREE,
|
122
|
-
|
110
|
+
GRPC_RB_MEMSIZE_UNAVAILABLE,
|
123
111
|
{NULL, NULL}},
|
124
112
|
NULL,
|
125
113
|
NULL,
|
@@ -315,7 +315,7 @@ static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE* argv,
|
|
315
315
|
}
|
316
316
|
|
317
317
|
typedef struct watch_state_stack {
|
318
|
-
|
318
|
+
bg_watched_channel* bg_wrapped;
|
319
319
|
gpr_timespec deadline;
|
320
320
|
int last_state;
|
321
321
|
} watch_state_stack;
|
@@ -328,15 +328,15 @@ static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
|
|
328
328
|
gpr_mu_lock(&global_connection_polling_mu);
|
329
329
|
// its unsafe to do a "watch" after "channel polling abort" because the cq has
|
330
330
|
// been shut down.
|
331
|
-
if (abort_channel_polling) {
|
331
|
+
if (abort_channel_polling || stack->bg_wrapped->channel_destroyed) {
|
332
332
|
gpr_mu_unlock(&global_connection_polling_mu);
|
333
333
|
return (void*)0;
|
334
334
|
}
|
335
335
|
op = gpr_zalloc(sizeof(watch_state_op));
|
336
336
|
op->op_type = WATCH_STATE_API;
|
337
|
-
grpc_channel_watch_connectivity_state(stack->channel,
|
338
|
-
stack->
|
339
|
-
op);
|
337
|
+
grpc_channel_watch_connectivity_state(stack->bg_wrapped->channel,
|
338
|
+
stack->last_state, stack->deadline,
|
339
|
+
channel_polling_cq, op);
|
340
340
|
|
341
341
|
while (!op->op.api_callback_args.called_back) {
|
342
342
|
gpr_cv_wait(&global_connection_polling_cv, &global_connection_polling_mu,
|
@@ -388,7 +388,7 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
|
|
388
388
|
return Qnil;
|
389
389
|
}
|
390
390
|
|
391
|
-
stack.
|
391
|
+
stack.bg_wrapped = wrapper->bg_wrapped;
|
392
392
|
stack.deadline = grpc_rb_time_timeval(deadline, 0),
|
393
393
|
stack.last_state = NUM2LONG(last_state);
|
394
394
|
|
@@ -186,7 +186,7 @@ void grpc_rb_compression_options_algorithm_name_to_value_internal(
|
|
186
186
|
error_message_ruby_str =
|
187
187
|
rb_str_new(error_message_str, strlen(error_message_str));
|
188
188
|
gpr_free(error_message_str);
|
189
|
-
rb_raise(rb_eNameError, StringValueCStr(error_message_ruby_str));
|
189
|
+
rb_raise(rb_eNameError, "%s", StringValueCStr(error_message_ruby_str));
|
190
190
|
}
|
191
191
|
|
192
192
|
grpc_slice_unref(name_slice);
|
@@ -68,6 +68,8 @@ grpc_channel_get_info_type grpc_channel_get_info_import;
|
|
68
68
|
grpc_insecure_channel_create_type grpc_insecure_channel_create_import;
|
69
69
|
grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import;
|
70
70
|
grpc_channel_destroy_type grpc_channel_destroy_import;
|
71
|
+
grpc_channel_get_trace_type grpc_channel_get_trace_import;
|
72
|
+
grpc_channel_get_uuid_type grpc_channel_get_uuid_import;
|
71
73
|
grpc_call_cancel_type grpc_call_cancel_import;
|
72
74
|
grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import;
|
73
75
|
grpc_call_ref_type grpc_call_ref_import;
|
@@ -106,6 +108,9 @@ grpc_auth_context_release_type grpc_auth_context_release_import;
|
|
106
108
|
grpc_auth_context_add_property_type grpc_auth_context_add_property_import;
|
107
109
|
grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring_property_import;
|
108
110
|
grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import;
|
111
|
+
grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import;
|
112
|
+
grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import;
|
113
|
+
grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import;
|
109
114
|
grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
|
110
115
|
grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import;
|
111
116
|
grpc_set_ssl_roots_override_callback_type grpc_set_ssl_roots_override_callback_import;
|
@@ -304,6 +309,8 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
304
309
|
grpc_insecure_channel_create_import = (grpc_insecure_channel_create_type) GetProcAddress(library, "grpc_insecure_channel_create");
|
305
310
|
grpc_lame_client_channel_create_import = (grpc_lame_client_channel_create_type) GetProcAddress(library, "grpc_lame_client_channel_create");
|
306
311
|
grpc_channel_destroy_import = (grpc_channel_destroy_type) GetProcAddress(library, "grpc_channel_destroy");
|
312
|
+
grpc_channel_get_trace_import = (grpc_channel_get_trace_type) GetProcAddress(library, "grpc_channel_get_trace");
|
313
|
+
grpc_channel_get_uuid_import = (grpc_channel_get_uuid_type) GetProcAddress(library, "grpc_channel_get_uuid");
|
307
314
|
grpc_call_cancel_import = (grpc_call_cancel_type) GetProcAddress(library, "grpc_call_cancel");
|
308
315
|
grpc_call_cancel_with_status_import = (grpc_call_cancel_with_status_type) GetProcAddress(library, "grpc_call_cancel_with_status");
|
309
316
|
grpc_call_ref_import = (grpc_call_ref_type) GetProcAddress(library, "grpc_call_ref");
|
@@ -342,6 +349,9 @@ void grpc_rb_load_imports(HMODULE library) {
|
|
342
349
|
grpc_auth_context_add_property_import = (grpc_auth_context_add_property_type) GetProcAddress(library, "grpc_auth_context_add_property");
|
343
350
|
grpc_auth_context_add_cstring_property_import = (grpc_auth_context_add_cstring_property_type) GetProcAddress(library, "grpc_auth_context_add_cstring_property");
|
344
351
|
grpc_auth_context_set_peer_identity_property_name_import = (grpc_auth_context_set_peer_identity_property_name_type) GetProcAddress(library, "grpc_auth_context_set_peer_identity_property_name");
|
352
|
+
grpc_ssl_session_cache_create_lru_import = (grpc_ssl_session_cache_create_lru_type) GetProcAddress(library, "grpc_ssl_session_cache_create_lru");
|
353
|
+
grpc_ssl_session_cache_destroy_import = (grpc_ssl_session_cache_destroy_type) GetProcAddress(library, "grpc_ssl_session_cache_destroy");
|
354
|
+
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");
|
345
355
|
grpc_channel_credentials_release_import = (grpc_channel_credentials_release_type) GetProcAddress(library, "grpc_channel_credentials_release");
|
346
356
|
grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create");
|
347
357
|
grpc_set_ssl_roots_override_callback_import = (grpc_set_ssl_roots_override_callback_type) GetProcAddress(library, "grpc_set_ssl_roots_override_callback");
|
@@ -179,6 +179,12 @@ extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_impo
|
|
179
179
|
typedef void(*grpc_channel_destroy_type)(grpc_channel* channel);
|
180
180
|
extern grpc_channel_destroy_type grpc_channel_destroy_import;
|
181
181
|
#define grpc_channel_destroy grpc_channel_destroy_import
|
182
|
+
typedef char*(*grpc_channel_get_trace_type)(grpc_channel* channel);
|
183
|
+
extern grpc_channel_get_trace_type grpc_channel_get_trace_import;
|
184
|
+
#define grpc_channel_get_trace grpc_channel_get_trace_import
|
185
|
+
typedef intptr_t(*grpc_channel_get_uuid_type)(grpc_channel* channel);
|
186
|
+
extern grpc_channel_get_uuid_type grpc_channel_get_uuid_import;
|
187
|
+
#define grpc_channel_get_uuid grpc_channel_get_uuid_import
|
182
188
|
typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call* call, void* reserved);
|
183
189
|
extern grpc_call_cancel_type grpc_call_cancel_import;
|
184
190
|
#define grpc_call_cancel grpc_call_cancel_import
|
@@ -293,6 +299,15 @@ extern grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring
|
|
293
299
|
typedef int(*grpc_auth_context_set_peer_identity_property_name_type)(grpc_auth_context* ctx, const char* name);
|
294
300
|
extern grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import;
|
295
301
|
#define grpc_auth_context_set_peer_identity_property_name grpc_auth_context_set_peer_identity_property_name_import
|
302
|
+
typedef grpc_ssl_session_cache*(*grpc_ssl_session_cache_create_lru_type)(size_t capacity);
|
303
|
+
extern grpc_ssl_session_cache_create_lru_type grpc_ssl_session_cache_create_lru_import;
|
304
|
+
#define grpc_ssl_session_cache_create_lru grpc_ssl_session_cache_create_lru_import
|
305
|
+
typedef void(*grpc_ssl_session_cache_destroy_type)(grpc_ssl_session_cache* cache);
|
306
|
+
extern grpc_ssl_session_cache_destroy_type grpc_ssl_session_cache_destroy_import;
|
307
|
+
#define grpc_ssl_session_cache_destroy grpc_ssl_session_cache_destroy_import
|
308
|
+
typedef grpc_arg(*grpc_ssl_session_cache_create_channel_arg_type)(grpc_ssl_session_cache* cache);
|
309
|
+
extern grpc_ssl_session_cache_create_channel_arg_type grpc_ssl_session_cache_create_channel_arg_import;
|
310
|
+
#define grpc_ssl_session_cache_create_channel_arg grpc_ssl_session_cache_create_channel_arg_import
|
296
311
|
typedef void(*grpc_channel_credentials_release_type)(grpc_channel_credentials* creds);
|
297
312
|
extern grpc_channel_credentials_release_type grpc_channel_credentials_release_import;
|
298
313
|
#define grpc_channel_credentials_release grpc_channel_credentials_release_import
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -64,7 +64,7 @@ module GRPC
|
|
64
64
|
# @param requests the Enumerable of requests to send
|
65
65
|
# @param set_input_stream_done [Proc] called back when we're done
|
66
66
|
# reading the input stream
|
67
|
-
# @param
|
67
|
+
# @param set_output_stream_done [Proc] called back when we're done
|
68
68
|
# sending data on the output stream
|
69
69
|
# @return an Enumerator of requests to yield
|
70
70
|
def run_on_client(requests,
|
@@ -124,12 +124,18 @@ module GRPC
|
|
124
124
|
def read_using_run_batch
|
125
125
|
ops = { RECV_MESSAGE => nil }
|
126
126
|
ops[RECV_INITIAL_METADATA] = nil unless @metadata_received
|
127
|
-
|
128
|
-
|
129
|
-
@
|
130
|
-
|
127
|
+
begin
|
128
|
+
batch_result = @call.run_batch(ops)
|
129
|
+
unless @metadata_received
|
130
|
+
@call.metadata = batch_result.metadata
|
131
|
+
@metadata_received = true
|
132
|
+
end
|
133
|
+
batch_result
|
134
|
+
rescue GRPC::Core::CallError => e
|
135
|
+
GRPC.logger.warn('bidi call: read_using_run_batch failed')
|
136
|
+
GRPC.logger.warn(e)
|
137
|
+
nil
|
131
138
|
end
|
132
|
-
batch_result
|
133
139
|
end
|
134
140
|
|
135
141
|
# set_output_stream_done is relevant on client-side
|
@@ -155,7 +161,12 @@ module GRPC
|
|
155
161
|
GRPC.logger.debug("bidi-write-loop: #{count} writes done")
|
156
162
|
if is_client
|
157
163
|
GRPC.logger.debug("bidi-write-loop: client sent #{count}, waiting")
|
158
|
-
|
164
|
+
begin
|
165
|
+
@call.run_batch(SEND_CLOSE_FROM_CLIENT => nil)
|
166
|
+
rescue GRPC::Core::CallError => e
|
167
|
+
GRPC.logger.warn('bidi-write-loop: send close failed')
|
168
|
+
GRPC.logger.warn(e)
|
169
|
+
end
|
159
170
|
GRPC.logger.debug('bidi-write-loop: done')
|
160
171
|
end
|
161
172
|
GRPC.logger.debug('bidi-write-loop: finished')
|
@@ -187,7 +198,7 @@ module GRPC
|
|
187
198
|
batch_result = read_using_run_batch
|
188
199
|
|
189
200
|
# handle the next message
|
190
|
-
if batch_result.message.nil?
|
201
|
+
if batch_result.nil? || batch_result.message.nil?
|
191
202
|
GRPC.logger.debug("bidi-read-loop: null batch #{batch_result}")
|
192
203
|
|
193
204
|
if is_client
|
@@ -58,8 +58,8 @@ module GRPC
|
|
58
58
|
# Minimally, a stub is created with the just the host of the gRPC service
|
59
59
|
# it wishes to access, e.g.,
|
60
60
|
#
|
61
|
-
#
|
62
|
-
#
|
61
|
+
# my_stub = ClientStub.new(example.host.com:50505,
|
62
|
+
# :this_channel_is_insecure)
|
63
63
|
#
|
64
64
|
# If a channel_override argument is passed, it will be used as the
|
65
65
|
# underlying channel. Otherwise, the channel_args argument will be used
|
@@ -376,7 +376,7 @@ module GRPC
|
|
376
376
|
# This is a blocking call.
|
377
377
|
#
|
378
378
|
# * the call completes when the next call to provided block returns
|
379
|
-
#
|
379
|
+
# false
|
380
380
|
#
|
381
381
|
# * the execution block parameters are two objects for sending and
|
382
382
|
# receiving responses, each of which blocks waiting for flow control.
|
@@ -398,13 +398,9 @@ module GRPC
|
|
398
398
|
# responses by throwing StopIteration, but can only happen either
|
399
399
|
# if bidi_call#writes_done is called.
|
400
400
|
#
|
401
|
-
# To terminate the RPC
|
402
|
-
#
|
403
|
-
#
|
404
|
-
#
|
405
|
-
# * either return false as soon as there is no need for other responses
|
406
|
-
#
|
407
|
-
# * loop on responses#next until no further responses are available
|
401
|
+
# To properly terminate the RPC, the responses should be completely iterated
|
402
|
+
# through; one way to do this is to loop on responses#next until no further
|
403
|
+
# responses are available.
|
408
404
|
#
|
409
405
|
# == Errors ==
|
410
406
|
# An RuntimeError is raised if
|
@@ -204,7 +204,7 @@ module GRPC
|
|
204
204
|
# * connect_md_proc:
|
205
205
|
# when non-nil is a proc for determining metadata to to send back the client
|
206
206
|
# on receiving an invocation req. The proc signature is:
|
207
|
-
#
|
207
|
+
# {key: val, ..} func(method_name, {key: val, ...})
|
208
208
|
#
|
209
209
|
# * server_args:
|
210
210
|
# A server arguments hash to be passed down to the underlying core server
|
@@ -283,7 +283,7 @@ module GRPC
|
|
283
283
|
# If run has not been called, this returns immediately.
|
284
284
|
#
|
285
285
|
# @param timeout [Numeric] number of seconds to wait
|
286
|
-
# @
|
286
|
+
# @return [true, false] true if the server is running, false otherwise
|
287
287
|
def wait_till_running(timeout = nil)
|
288
288
|
@run_mutex.synchronize do
|
289
289
|
@run_cond.wait(@run_mutex, timeout) if @running_state == :not_started
|
@@ -750,6 +750,90 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
|
|
750
750
|
expected_error_message)
|
751
751
|
end
|
752
752
|
end
|
753
|
+
|
754
|
+
# Prompted by grpc/github #14853
|
755
|
+
describe 'client-side error handling on bidi streams' do
|
756
|
+
class EnumeratorQueue
|
757
|
+
def initialize(queue)
|
758
|
+
@queue = queue
|
759
|
+
end
|
760
|
+
|
761
|
+
def each
|
762
|
+
loop do
|
763
|
+
msg = @queue.pop
|
764
|
+
break if msg.nil?
|
765
|
+
yield msg
|
766
|
+
end
|
767
|
+
end
|
768
|
+
end
|
769
|
+
|
770
|
+
def run_server_bidi_shutdown_after_one_read
|
771
|
+
@server.start
|
772
|
+
recvd_rpc = @server.request_call
|
773
|
+
recvd_call = recvd_rpc.call
|
774
|
+
server_call = GRPC::ActiveCall.new(
|
775
|
+
recvd_call, noop, noop, INFINITE_FUTURE,
|
776
|
+
metadata_received: true, started: false)
|
777
|
+
expect(server_call.remote_read).to eq('first message')
|
778
|
+
@server.shutdown_and_notify(from_relative_time(0))
|
779
|
+
@server.close
|
780
|
+
end
|
781
|
+
|
782
|
+
it 'receives a grpc status code when writes to a bidi stream fail' do
|
783
|
+
# This test tries to trigger the case when a 'SEND_MESSAGE' op
|
784
|
+
# and subseqeunt 'SEND_CLOSE_FROM_CLIENT' op of a bidi stream fails.
|
785
|
+
# In this case, iteration through the response stream should result
|
786
|
+
# in a grpc status code, and the writer thread should not raise an
|
787
|
+
# exception.
|
788
|
+
server_thread = Thread.new do
|
789
|
+
run_server_bidi_shutdown_after_one_read
|
790
|
+
end
|
791
|
+
stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
|
792
|
+
request_queue = Queue.new
|
793
|
+
@sent_msgs = EnumeratorQueue.new(request_queue)
|
794
|
+
responses = get_responses(stub)
|
795
|
+
request_queue.push('first message')
|
796
|
+
# Now wait for the server to shut down.
|
797
|
+
server_thread.join
|
798
|
+
# Sanity check. This test is not interesting if
|
799
|
+
# Thread.abort_on_exception is not set.
|
800
|
+
expect(Thread.abort_on_exception).to be(true)
|
801
|
+
# An attempt to send a second message should fail now that the
|
802
|
+
# server is down.
|
803
|
+
request_queue.push('second message')
|
804
|
+
request_queue.push(nil)
|
805
|
+
expect { responses.next }.to raise_error(GRPC::BadStatus)
|
806
|
+
end
|
807
|
+
|
808
|
+
def run_server_bidi_shutdown_after_one_write
|
809
|
+
@server.start
|
810
|
+
recvd_rpc = @server.request_call
|
811
|
+
recvd_call = recvd_rpc.call
|
812
|
+
server_call = GRPC::ActiveCall.new(
|
813
|
+
recvd_call, noop, noop, INFINITE_FUTURE,
|
814
|
+
metadata_received: true, started: false)
|
815
|
+
server_call.send_initial_metadata
|
816
|
+
server_call.remote_send('message')
|
817
|
+
@server.shutdown_and_notify(from_relative_time(0))
|
818
|
+
@server.close
|
819
|
+
end
|
820
|
+
|
821
|
+
it 'receives a grpc status code when reading from a failed bidi call' do
|
822
|
+
server_thread = Thread.new do
|
823
|
+
run_server_bidi_shutdown_after_one_write
|
824
|
+
end
|
825
|
+
stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
|
826
|
+
request_queue = Queue.new
|
827
|
+
@sent_msgs = EnumeratorQueue.new(request_queue)
|
828
|
+
responses = get_responses(stub)
|
829
|
+
expect(responses.next).to eq('message')
|
830
|
+
# Wait for the server to shut down
|
831
|
+
server_thread.join
|
832
|
+
expect { responses.next }.to raise_error(GRPC::BadStatus)
|
833
|
+
# Push a sentinel to allow the writer thread to finish
|
834
|
+
request_queue.push(nil)
|
835
|
+
end
|
836
|
+
end
|
753
837
|
end
|
754
838
|
|
755
839
|
describe 'without a call operation' do
|
@@ -810,6 +894,55 @@ describe 'ClientStub' do # rubocop:disable Metrics/BlockLength
|
|
810
894
|
responses.each { |r| p r }
|
811
895
|
end
|
812
896
|
end
|
897
|
+
|
898
|
+
def run_server_bidi_expect_client_to_cancel(wait_for_shutdown_ok_callback)
|
899
|
+
@server.start
|
900
|
+
recvd_rpc = @server.request_call
|
901
|
+
recvd_call = recvd_rpc.call
|
902
|
+
server_call = GRPC::ActiveCall.new(
|
903
|
+
recvd_call, noop, noop, INFINITE_FUTURE,
|
904
|
+
metadata_received: true, started: false)
|
905
|
+
server_call.send_initial_metadata
|
906
|
+
server_call.remote_send('server call received')
|
907
|
+
wait_for_shutdown_ok_callback.call
|
908
|
+
# since the client is cancelling the call,
|
909
|
+
# we should be able to shut down cleanly
|
910
|
+
@server.shutdown_and_notify(nil)
|
911
|
+
@server.close
|
912
|
+
end
|
913
|
+
|
914
|
+
it 'receives a grpc status code when reading from a cancelled bidi call' do
|
915
|
+
# This test tries to trigger a 'RECV_INITIAL_METADATA' and/or
|
916
|
+
# 'RECV_MESSAGE' op failure.
|
917
|
+
# An attempt to read a message might fail; in that case, iteration
|
918
|
+
# through the response stream should still result in a grpc status.
|
919
|
+
server_can_shutdown = false
|
920
|
+
server_can_shutdown_mu = Mutex.new
|
921
|
+
server_can_shutdown_cv = ConditionVariable.new
|
922
|
+
wait_for_shutdown_ok_callback = proc do
|
923
|
+
server_can_shutdown_mu.synchronize do
|
924
|
+
server_can_shutdown_cv.wait(server_can_shutdown_mu) until server_can_shutdown
|
925
|
+
end
|
926
|
+
end
|
927
|
+
server_thread = Thread.new do
|
928
|
+
run_server_bidi_expect_client_to_cancel(wait_for_shutdown_ok_callback)
|
929
|
+
end
|
930
|
+
stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
|
931
|
+
request_queue = Queue.new
|
932
|
+
@sent_msgs = EnumeratorQueue.new(request_queue)
|
933
|
+
responses = get_responses(stub)
|
934
|
+
expect(responses.next).to eq('server call received')
|
935
|
+
@op.cancel
|
936
|
+
expect { responses.next }.to raise_error(GRPC::Cancelled)
|
937
|
+
# Now let the server proceed to shut down.
|
938
|
+
server_can_shutdown_mu.synchronize do
|
939
|
+
server_can_shutdown = true
|
940
|
+
server_can_shutdown_cv.broadcast
|
941
|
+
end
|
942
|
+
server_thread.join
|
943
|
+
# Push a sentinel to allow the writer thread to finish
|
944
|
+
request_queue.push(nil)
|
945
|
+
end
|
813
946
|
end
|
814
947
|
end
|
815
948
|
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright 2016 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 'open3'
|
16
|
+
require 'tmpdir'
|
17
|
+
|
18
|
+
def debug_mode?
|
19
|
+
!ENV['CONFIG'].nil? && ENV['CONFIG'] == 'dbg'
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'Package with underscore protobuf code generation' do
|
23
|
+
it 'should have the same content as created by code generation' do
|
24
|
+
root_dir = File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..')
|
25
|
+
pb_dir = File.join(root_dir, 'src', 'ruby', 'spec', 'pb')
|
26
|
+
|
27
|
+
bins_sub_dir = debug_mode? ? 'dbg' : 'opt'
|
28
|
+
bins_dir = File.join(root_dir, 'bins', bins_sub_dir)
|
29
|
+
|
30
|
+
plugin = File.join(bins_dir, 'grpc_ruby_plugin')
|
31
|
+
protoc = File.join(bins_dir, 'protobuf', 'protoc')
|
32
|
+
|
33
|
+
got = nil
|
34
|
+
|
35
|
+
Dir.mktmpdir do |tmp_dir|
|
36
|
+
gen_out = File.join(tmp_dir, 'package_with_underscore', 'service_services_pb.rb')
|
37
|
+
|
38
|
+
pid = spawn(
|
39
|
+
protoc,
|
40
|
+
'-I.',
|
41
|
+
'package_with_underscore/service.proto',
|
42
|
+
"--grpc_out=#{tmp_dir}",
|
43
|
+
"--plugin=protoc-gen-grpc=#{plugin}",
|
44
|
+
chdir: pb_dir)
|
45
|
+
Process.waitpid2(pid)
|
46
|
+
File.open(gen_out) { |f| got = f.read }
|
47
|
+
end
|
48
|
+
|
49
|
+
correct_modularized_rpc = 'rpc :TestOne, ' \
|
50
|
+
'Grpc::Testing::PackageWithUnderscore::Data::Request, ' \
|
51
|
+
'Grpc::Testing::PackageWithUnderscore::Data::Response'
|
52
|
+
expect(got).to include(correct_modularized_rpc)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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
|
+
syntax = "proto3";
|
16
|
+
|
17
|
+
package grpc.testing.package_with_underscore.data;
|
18
|
+
|
19
|
+
message Request {
|
20
|
+
}
|
21
|
+
|
22
|
+
message Response {
|
23
|
+
}
|
@@ -0,0 +1,23 @@
|
|
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
|
+
syntax = "proto3";
|
16
|
+
|
17
|
+
package grpc.testing.package_with_underscore.service;
|
18
|
+
|
19
|
+
import "package_with_underscore/data.proto";
|
20
|
+
|
21
|
+
service MyService {
|
22
|
+
rpc TestOne(data.Request) returns (data.Response) {}
|
23
|
+
}
|
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.
|
4
|
+
version: 1.11.0.pre2
|
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-
|
11
|
+
date: 2018-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -303,6 +303,9 @@ files:
|
|
303
303
|
- src/ruby/spec/google_rpc_status_utils_spec.rb
|
304
304
|
- src/ruby/spec/pb/duplicate/codegen_spec.rb
|
305
305
|
- src/ruby/spec/pb/health/checker_spec.rb
|
306
|
+
- src/ruby/spec/pb/package_with_underscore/checker_spec.rb
|
307
|
+
- src/ruby/spec/pb/package_with_underscore/data.proto
|
308
|
+
- src/ruby/spec/pb/package_with_underscore/service.proto
|
306
309
|
- src/ruby/spec/server_credentials_spec.rb
|
307
310
|
- src/ruby/spec/server_spec.rb
|
308
311
|
- src/ruby/spec/spec_helper.rb
|
@@ -335,12 +338,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
335
338
|
version: '2.6'
|
336
339
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
337
340
|
requirements:
|
338
|
-
- - "
|
341
|
+
- - ">"
|
339
342
|
- !ruby/object:Gem::Version
|
340
|
-
version:
|
343
|
+
version: 1.3.1
|
341
344
|
requirements: []
|
342
345
|
rubyforge_project:
|
343
|
-
rubygems_version: 2.7.
|
346
|
+
rubygems_version: 2.7.6
|
344
347
|
signing_key:
|
345
348
|
specification_version: 4
|
346
349
|
summary: GRPC system in Ruby
|
@@ -366,6 +369,9 @@ test_files:
|
|
366
369
|
- src/ruby/spec/google_rpc_status_utils_spec.rb
|
367
370
|
- src/ruby/spec/pb/duplicate/codegen_spec.rb
|
368
371
|
- src/ruby/spec/pb/health/checker_spec.rb
|
372
|
+
- src/ruby/spec/pb/package_with_underscore/checker_spec.rb
|
373
|
+
- src/ruby/spec/pb/package_with_underscore/data.proto
|
374
|
+
- src/ruby/spec/pb/package_with_underscore/service.proto
|
369
375
|
- src/ruby/spec/server_credentials_spec.rb
|
370
376
|
- src/ruby/spec/server_spec.rb
|
371
377
|
- src/ruby/spec/spec_helper.rb
|