grpc 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Rakefile +4 -2
- data/bin/{interop/test/cpp/interop/test.rb → grpc_ruby_interop_client} +4 -14
- data/bin/{interop/test/cpp/interop/empty.rb → grpc_ruby_interop_server} +4 -15
- data/bin/interop/interop_client.rb +9 -335
- data/bin/interop/interop_server.rb +9 -153
- data/bin/math_client.rb +3 -3
- data/bin/math_server.rb +18 -1
- data/bin/noproto_server.rb +2 -1
- data/ext/grpc/rb_call.c +82 -15
- data/ext/grpc/rb_channel.c +141 -11
- data/ext/grpc/rb_channel_args.c +2 -1
- data/ext/grpc/rb_completion_queue.c +8 -7
- data/ext/grpc/rb_credentials.c +7 -6
- data/ext/grpc/rb_grpc.c +23 -8
- data/ext/grpc/rb_server.c +31 -45
- data/ext/grpc/rb_server_credentials.c +91 -34
- data/lib/grpc/generic/active_call.rb +7 -7
- data/lib/grpc/generic/bidi_call.rb +17 -12
- data/lib/grpc/generic/client_stub.rb +88 -22
- data/lib/grpc/generic/rpc_server.rb +19 -18
- data/lib/grpc/generic/service.rb +8 -10
- data/lib/grpc/grpc.so +0 -0
- data/lib/grpc/logconfig.rb +26 -10
- data/lib/grpc/version.rb +1 -1
- data/spec/call_spec.rb +9 -1
- data/spec/channel_spec.rb +2 -2
- data/spec/client_server_spec.rb +28 -11
- data/spec/credentials_spec.rb +7 -7
- data/spec/generic/active_call_spec.rb +43 -18
- data/spec/generic/client_stub_spec.rb +21 -1
- data/spec/generic/rpc_server_spec.rb +20 -9
- data/spec/pb/health/checker_spec.rb +232 -0
- data/spec/server_credentials_spec.rb +32 -7
- data/spec/server_spec.rb +8 -4
- data/spec/spec_helper.rb +13 -1
- metadata +31 -51
- data/.gitignore +0 -15
- data/.rspec +0 -4
- data/.rubocop.yml +0 -10
- data/.rubocop_todo.yml +0 -44
- data/CHANGELOG.md +0 -11
- data/Gemfile +0 -4
- data/README.md +0 -84
- data/bin/interop/README.md +0 -8
- data/bin/interop/test/cpp/interop/messages.rb +0 -89
- data/bin/interop/test/cpp/interop/test_services.rb +0 -60
- data/grpc.gemspec +0 -40
@@ -59,7 +59,7 @@ module GRPC
|
|
59
59
|
include Core::CallOps
|
60
60
|
extend Forwardable
|
61
61
|
attr_reader(:deadline)
|
62
|
-
def_delegators :@call, :cancel, :metadata
|
62
|
+
def_delegators :@call, :cancel, :metadata, :write_flag, :write_flag=
|
63
63
|
|
64
64
|
# client_invoke begins a client invocation.
|
65
65
|
#
|
@@ -74,8 +74,7 @@ module GRPC
|
|
74
74
|
#
|
75
75
|
# @param call [Call] a call on which to start and invocation
|
76
76
|
# @param q [CompletionQueue] the completion queue
|
77
|
-
|
78
|
-
def self.client_invoke(call, q, _deadline, **kw)
|
77
|
+
def self.client_invoke(call, q, **kw)
|
79
78
|
fail(TypeError, '!Core::Call') unless call.is_a? Core::Call
|
80
79
|
unless q.is_a? Core::CompletionQueue
|
81
80
|
fail(TypeError, '!Core::CompletionQueue')
|
@@ -418,7 +417,7 @@ module GRPC
|
|
418
417
|
# @return [Enumerator, nil] a response Enumerator
|
419
418
|
def bidi_streamer(requests, **kw, &blk)
|
420
419
|
start_call(**kw) unless @started
|
421
|
-
bd = BidiCall.new(@call, @cq, @marshal, @unmarshal
|
420
|
+
bd = BidiCall.new(@call, @cq, @marshal, @unmarshal)
|
422
421
|
bd.run_on_client(requests, @op_notifier, &blk)
|
423
422
|
end
|
424
423
|
|
@@ -434,7 +433,7 @@ module GRPC
|
|
434
433
|
#
|
435
434
|
# @param gen_each_reply [Proc] generates the BiDi stream replies
|
436
435
|
def run_server_bidi(gen_each_reply)
|
437
|
-
bd = BidiCall.new(@call, @cq, @marshal, @unmarshal
|
436
|
+
bd = BidiCall.new(@call, @cq, @marshal, @unmarshal)
|
438
437
|
bd.run_on_server(gen_each_reply)
|
439
438
|
end
|
440
439
|
|
@@ -456,7 +455,7 @@ module GRPC
|
|
456
455
|
# Starts the call if not already started
|
457
456
|
def start_call(**kw)
|
458
457
|
return if @started
|
459
|
-
@metadata_tag = ActiveCall.client_invoke(@call, @cq,
|
458
|
+
@metadata_tag = ActiveCall.client_invoke(@call, @cq, **kw)
|
460
459
|
@started = true
|
461
460
|
end
|
462
461
|
|
@@ -485,6 +484,7 @@ module GRPC
|
|
485
484
|
# Operation limits access to an ActiveCall's methods for use as
|
486
485
|
# a Operation on the client.
|
487
486
|
Operation = view_class(:cancel, :cancelled, :deadline, :execute,
|
488
|
-
:metadata, :status, :start_call, :wait
|
487
|
+
:metadata, :status, :start_call, :wait, :write_flag,
|
488
|
+
:write_flag=)
|
489
489
|
end
|
490
490
|
end
|
@@ -56,15 +56,13 @@ module GRPC
|
|
56
56
|
# the call
|
57
57
|
# @param marshal [Function] f(obj)->string that marshal requests
|
58
58
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
59
|
-
|
60
|
-
def initialize(call, q, marshal, unmarshal, deadline)
|
59
|
+
def initialize(call, q, marshal, unmarshal)
|
61
60
|
fail(ArgumentError, 'not a call') unless call.is_a? Core::Call
|
62
61
|
unless q.is_a? Core::CompletionQueue
|
63
62
|
fail(ArgumentError, 'not a CompletionQueue')
|
64
63
|
end
|
65
64
|
@call = call
|
66
65
|
@cq = q
|
67
|
-
@deadline = deadline
|
68
66
|
@marshal = marshal
|
69
67
|
@op_notifier = nil # signals completion on clients
|
70
68
|
@readq = Queue.new
|
@@ -99,7 +97,7 @@ module GRPC
|
|
99
97
|
# @param gen_each_reply [Proc] generates the BiDi stream replies.
|
100
98
|
def run_on_server(gen_each_reply)
|
101
99
|
replys = gen_each_reply.call(each_queued_msg)
|
102
|
-
@loop_th = start_read_loop
|
100
|
+
@loop_th = start_read_loop(is_client: false)
|
103
101
|
write_loop(replys, is_client: false)
|
104
102
|
end
|
105
103
|
|
@@ -127,7 +125,7 @@ module GRPC
|
|
127
125
|
count += 1
|
128
126
|
req = @readq.pop
|
129
127
|
GRPC.logger.debug("each_queued_msg: req = #{req}")
|
130
|
-
|
128
|
+
fail req if req.is_a? StandardError
|
131
129
|
break if req.equal?(END_OF_READS)
|
132
130
|
yield req
|
133
131
|
end
|
@@ -147,12 +145,9 @@ module GRPC
|
|
147
145
|
GRPC.logger.debug("bidi-write-loop: #{count} writes done")
|
148
146
|
if is_client
|
149
147
|
GRPC.logger.debug("bidi-write-loop: client sent #{count}, waiting")
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
@call.status = batch_result.status
|
154
|
-
batch_result.check_status
|
155
|
-
GRPC.logger.debug("bidi-write-loop: done status #{@call.status}")
|
148
|
+
@call.run_batch(@cq, write_tag, INFINITE_FUTURE,
|
149
|
+
SEND_CLOSE_FROM_CLIENT => nil)
|
150
|
+
GRPC.logger.debug('bidi-write-loop: done')
|
156
151
|
notify_done
|
157
152
|
end
|
158
153
|
GRPC.logger.debug('bidi-write-loop: finished')
|
@@ -164,7 +159,7 @@ module GRPC
|
|
164
159
|
end
|
165
160
|
|
166
161
|
# starts the read loop
|
167
|
-
def start_read_loop
|
162
|
+
def start_read_loop(is_client: true)
|
168
163
|
Thread.new do
|
169
164
|
GRPC.logger.debug('bidi-read-loop: starting')
|
170
165
|
begin
|
@@ -177,9 +172,19 @@ module GRPC
|
|
177
172
|
# TODO: ensure metadata is read if available, currently it's not
|
178
173
|
batch_result = @call.run_batch(@cq, read_tag, INFINITE_FUTURE,
|
179
174
|
RECV_MESSAGE => nil)
|
175
|
+
|
180
176
|
# handle the next message
|
181
177
|
if batch_result.message.nil?
|
182
178
|
GRPC.logger.debug("bidi-read-loop: null batch #{batch_result}")
|
179
|
+
|
180
|
+
if is_client
|
181
|
+
batch_result = @call.run_batch(@cq, read_tag, INFINITE_FUTURE,
|
182
|
+
RECV_STATUS_ON_CLIENT => nil)
|
183
|
+
@call.status = batch_result.status
|
184
|
+
batch_result.check_status
|
185
|
+
GRPC.logger.debug("bidi-read-loop: done status #{@call.status}")
|
186
|
+
end
|
187
|
+
|
183
188
|
@readq.push(END_OF_READS)
|
184
189
|
GRPC.logger.debug('bidi-read-loop: done reading!')
|
185
190
|
break
|
@@ -28,16 +28,19 @@
|
|
28
28
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
29
29
|
|
30
30
|
require 'grpc/generic/active_call'
|
31
|
+
require 'grpc/version'
|
31
32
|
|
32
33
|
# GRPC contains the General RPC module.
|
33
34
|
module GRPC
|
35
|
+
# rubocop:disable Metrics/ParameterLists
|
36
|
+
|
34
37
|
# ClientStub represents an endpoint used to send requests to GRPC servers.
|
35
38
|
class ClientStub
|
36
39
|
include Core::StatusCodes
|
37
40
|
include Core::TimeConsts
|
38
41
|
|
39
|
-
# Default timeout is
|
40
|
-
DEFAULT_TIMEOUT =
|
42
|
+
# Default timeout is infinity.
|
43
|
+
DEFAULT_TIMEOUT = INFINITE_FUTURE
|
41
44
|
|
42
45
|
# setup_channel is used by #initialize to constuct a channel from its
|
43
46
|
# arguments.
|
@@ -46,6 +49,7 @@ module GRPC
|
|
46
49
|
fail(TypeError, '!Channel') unless alt_chan.is_a?(Core::Channel)
|
47
50
|
return alt_chan
|
48
51
|
end
|
52
|
+
kw['grpc.primary_user_agent'] = "grpc-ruby/#{VERSION}"
|
49
53
|
return Core::Channel.new(host, kw) if creds.nil?
|
50
54
|
fail(TypeError, '!Credentials') unless creds.is_a?(Core::Credentials)
|
51
55
|
Core::Channel.new(host, kw, creds)
|
@@ -66,6 +70,12 @@ module GRPC
|
|
66
70
|
update_metadata
|
67
71
|
end
|
68
72
|
|
73
|
+
# Allows users of the stub to modify the propagate mask.
|
74
|
+
#
|
75
|
+
# This is an advanced feature for use when making calls to another gRPC
|
76
|
+
# server whilst running in the handler of an existing one.
|
77
|
+
attr_writer :propagate_mask
|
78
|
+
|
69
79
|
# Creates a new ClientStub.
|
70
80
|
#
|
71
81
|
# Minimally, a stub is created with the just the host of the gRPC service
|
@@ -89,8 +99,8 @@ module GRPC
|
|
89
99
|
#
|
90
100
|
# - :update_metadata
|
91
101
|
# when present, this a func that takes a hash and returns a hash
|
92
|
-
# it can be used to update metadata, i.e, remove,
|
93
|
-
#
|
102
|
+
# it can be used to update metadata, i.e, remove, or amend
|
103
|
+
# metadata values.
|
94
104
|
#
|
95
105
|
# @param host [String] the host the stub connects to
|
96
106
|
# @param q [Core::CompletionQueue] used to wait for events
|
@@ -103,6 +113,7 @@ module GRPC
|
|
103
113
|
channel_override: nil,
|
104
114
|
timeout: nil,
|
105
115
|
creds: nil,
|
116
|
+
propagate_mask: nil,
|
106
117
|
update_metadata: nil,
|
107
118
|
**kw)
|
108
119
|
fail(TypeError, '!CompletionQueue') unless q.is_a?(Core::CompletionQueue)
|
@@ -111,6 +122,7 @@ module GRPC
|
|
111
122
|
@update_metadata = ClientStub.check_update_metadata(update_metadata)
|
112
123
|
alt_host = kw[Core::Channel::SSL_TARGET]
|
113
124
|
@host = alt_host.nil? ? host : alt_host
|
125
|
+
@propagate_mask = propagate_mask
|
114
126
|
@timeout = timeout.nil? ? DEFAULT_TIMEOUT : timeout
|
115
127
|
end
|
116
128
|
|
@@ -149,11 +161,21 @@ module GRPC
|
|
149
161
|
# @param marshal [Function] f(obj)->string that marshals requests
|
150
162
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
151
163
|
# @param timeout [Numeric] (optional) the max completion time in seconds
|
164
|
+
# @param deadline [Time] (optional) the time the request should complete
|
165
|
+
# @param parent [Core::Call] a prior call whose reserved metadata
|
166
|
+
# will be propagated by this one.
|
152
167
|
# @param return_op [true|false] return an Operation if true
|
153
168
|
# @return [Object] the response received from the server
|
154
|
-
def request_response(method, req, marshal, unmarshal,
|
155
|
-
|
156
|
-
|
169
|
+
def request_response(method, req, marshal, unmarshal,
|
170
|
+
deadline: nil,
|
171
|
+
timeout: nil,
|
172
|
+
return_op: false,
|
173
|
+
parent: parent,
|
174
|
+
**kw)
|
175
|
+
c = new_active_call(method, marshal, unmarshal,
|
176
|
+
deadline: deadline,
|
177
|
+
timeout: timeout,
|
178
|
+
parent: parent)
|
157
179
|
kw_with_jwt_uri = self.class.update_with_jwt_aud_uri(kw, @host, method)
|
158
180
|
md = @update_metadata.nil? ? kw : @update_metadata.call(kw_with_jwt_uri)
|
159
181
|
return c.request_response(req, **md) unless return_op
|
@@ -206,12 +228,22 @@ module GRPC
|
|
206
228
|
# @param requests [Object] an Enumerable of requests to send
|
207
229
|
# @param marshal [Function] f(obj)->string that marshals requests
|
208
230
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
209
|
-
# @param timeout [Numeric] the max completion time in seconds
|
231
|
+
# @param timeout [Numeric] (optional) the max completion time in seconds
|
232
|
+
# @param deadline [Time] (optional) the time the request should complete
|
210
233
|
# @param return_op [true|false] return an Operation if true
|
234
|
+
# @param parent [Core::Call] a prior call whose reserved metadata
|
235
|
+
# will be propagated by this one.
|
211
236
|
# @return [Object|Operation] the response received from the server
|
212
|
-
def client_streamer(method, requests, marshal, unmarshal,
|
213
|
-
|
214
|
-
|
237
|
+
def client_streamer(method, requests, marshal, unmarshal,
|
238
|
+
deadline: nil,
|
239
|
+
timeout: nil,
|
240
|
+
return_op: false,
|
241
|
+
parent: nil,
|
242
|
+
**kw)
|
243
|
+
c = new_active_call(method, marshal, unmarshal,
|
244
|
+
deadline: deadline,
|
245
|
+
timeout: timeout,
|
246
|
+
parent: parent)
|
215
247
|
kw_with_jwt_uri = self.class.update_with_jwt_aud_uri(kw, @host, method)
|
216
248
|
md = @update_metadata.nil? ? kw : @update_metadata.call(kw_with_jwt_uri)
|
217
249
|
return c.client_streamer(requests, **md) unless return_op
|
@@ -272,13 +304,24 @@ module GRPC
|
|
272
304
|
# @param req [Object] the request sent to the server
|
273
305
|
# @param marshal [Function] f(obj)->string that marshals requests
|
274
306
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
275
|
-
# @param timeout [Numeric] the max completion time in seconds
|
307
|
+
# @param timeout [Numeric] (optional) the max completion time in seconds
|
308
|
+
# @param deadline [Time] (optional) the time the request should complete
|
276
309
|
# @param return_op [true|false]return an Operation if true
|
310
|
+
# @param parent [Core::Call] a prior call whose reserved metadata
|
311
|
+
# will be propagated by this one.
|
277
312
|
# @param blk [Block] when provided, is executed for each response
|
278
313
|
# @return [Enumerator|Operation|nil] as discussed above
|
279
|
-
def server_streamer(method, req, marshal, unmarshal,
|
280
|
-
|
281
|
-
|
314
|
+
def server_streamer(method, req, marshal, unmarshal,
|
315
|
+
deadline: nil,
|
316
|
+
timeout: nil,
|
317
|
+
return_op: false,
|
318
|
+
parent: nil,
|
319
|
+
**kw,
|
320
|
+
&blk)
|
321
|
+
c = new_active_call(method, marshal, unmarshal,
|
322
|
+
deadline: deadline,
|
323
|
+
timeout: timeout,
|
324
|
+
parent: parent)
|
282
325
|
kw_with_jwt_uri = self.class.update_with_jwt_aud_uri(kw, @host, method)
|
283
326
|
md = @update_metadata.nil? ? kw : @update_metadata.call(kw_with_jwt_uri)
|
284
327
|
return c.server_streamer(req, **md, &blk) unless return_op
|
@@ -379,12 +422,23 @@ module GRPC
|
|
379
422
|
# @param marshal [Function] f(obj)->string that marshals requests
|
380
423
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
381
424
|
# @param timeout [Numeric] (optional) the max completion time in seconds
|
382
|
-
# @param
|
425
|
+
# @param deadline [Time] (optional) the time the request should complete
|
426
|
+
# @param parent [Core::Call] a prior call whose reserved metadata
|
427
|
+
# will be propagated by this one.
|
383
428
|
# @param return_op [true|false] return an Operation if true
|
429
|
+
# @param blk [Block] when provided, is executed for each response
|
384
430
|
# @return [Enumerator|nil|Operation] as discussed above
|
385
|
-
def bidi_streamer(method, requests, marshal, unmarshal,
|
386
|
-
|
387
|
-
|
431
|
+
def bidi_streamer(method, requests, marshal, unmarshal,
|
432
|
+
deadline: nil,
|
433
|
+
timeout: nil,
|
434
|
+
return_op: false,
|
435
|
+
parent: nil,
|
436
|
+
**kw,
|
437
|
+
&blk)
|
438
|
+
c = new_active_call(method, marshal, unmarshal,
|
439
|
+
deadline: deadline,
|
440
|
+
timeout: timeout,
|
441
|
+
parent: parent)
|
388
442
|
kw_with_jwt_uri = self.class.update_with_jwt_aud_uri(kw, @host, method)
|
389
443
|
md = @update_metadata.nil? ? kw : @update_metadata.call(kw_with_jwt_uri)
|
390
444
|
return c.bidi_streamer(requests, **md, &blk) unless return_op
|
@@ -405,10 +459,22 @@ module GRPC
|
|
405
459
|
# @param method [string] the method being called.
|
406
460
|
# @param marshal [Function] f(obj)->string that marshals requests
|
407
461
|
# @param unmarshal [Function] f(string)->obj that unmarshals responses
|
462
|
+
# @param parent [Grpc::Call] a parent call, available when calls are
|
463
|
+
# made from server
|
408
464
|
# @param timeout [TimeConst]
|
409
|
-
def new_active_call(method, marshal, unmarshal,
|
410
|
-
|
411
|
-
|
465
|
+
def new_active_call(method, marshal, unmarshal,
|
466
|
+
deadline: nil,
|
467
|
+
timeout: nil,
|
468
|
+
parent: nil)
|
469
|
+
if deadline.nil?
|
470
|
+
deadline = from_relative_time(timeout.nil? ? @timeout : timeout)
|
471
|
+
end
|
472
|
+
call = @ch.create_call(@queue,
|
473
|
+
parent, # parent call
|
474
|
+
@propagate_mask, # propagation options
|
475
|
+
method,
|
476
|
+
nil, # host use nil,
|
477
|
+
deadline)
|
412
478
|
ActiveCall.new(call, @queue, marshal, unmarshal, deadline, started: false)
|
413
479
|
end
|
414
480
|
end
|
@@ -277,10 +277,11 @@ module GRPC
|
|
277
277
|
@stop_mutex.synchronize do
|
278
278
|
@stopped = true
|
279
279
|
end
|
280
|
-
@pool.stop
|
281
280
|
deadline = from_relative_time(@poll_period)
|
282
|
-
|
281
|
+
return if @server.close(@cq, deadline)
|
282
|
+
deadline = from_relative_time(@poll_period)
|
283
283
|
@server.close(@cq, deadline)
|
284
|
+
@pool.stop
|
284
285
|
end
|
285
286
|
|
286
287
|
# determines if the server has been stopped
|
@@ -383,7 +384,6 @@ module GRPC
|
|
383
384
|
@pool.start
|
384
385
|
@server.start
|
385
386
|
loop_handle_server_calls
|
386
|
-
@running = false
|
387
387
|
end
|
388
388
|
|
389
389
|
# Sends UNAVAILABLE if there are too many unprocessed jobs
|
@@ -398,14 +398,14 @@ module GRPC
|
|
398
398
|
nil
|
399
399
|
end
|
400
400
|
|
401
|
-
# Sends
|
402
|
-
def
|
401
|
+
# Sends UNIMPLEMENTED if the method is not implemented by this server
|
402
|
+
def implemented?(an_rpc)
|
403
403
|
mth = an_rpc.method.to_sym
|
404
404
|
return an_rpc if rpc_descs.key?(mth)
|
405
|
-
GRPC.logger.warn("
|
405
|
+
GRPC.logger.warn("UNIMPLEMENTED: #{an_rpc}")
|
406
406
|
noop = proc { |x| x }
|
407
407
|
c = ActiveCall.new(an_rpc.call, @cq, noop, noop, an_rpc.deadline)
|
408
|
-
c.send_status(StatusCodes::
|
408
|
+
c.send_status(StatusCodes::UNIMPLEMENTED, '')
|
409
409
|
nil
|
410
410
|
end
|
411
411
|
|
@@ -414,23 +414,24 @@ module GRPC
|
|
414
414
|
fail 'not running' unless @running
|
415
415
|
loop_tag = Object.new
|
416
416
|
until stopped?
|
417
|
-
deadline = from_relative_time(@poll_period)
|
418
417
|
begin
|
419
|
-
an_rpc = @server.request_call(@cq, loop_tag,
|
418
|
+
an_rpc = @server.request_call(@cq, loop_tag, INFINITE_FUTURE)
|
420
419
|
c = new_active_server_call(an_rpc)
|
420
|
+
unless c.nil?
|
421
|
+
mth = an_rpc.method.to_sym
|
422
|
+
@pool.schedule(c) do |call|
|
423
|
+
rpc_descs[mth].run_server_method(call, rpc_handlers[mth])
|
424
|
+
end
|
425
|
+
end
|
421
426
|
rescue Core::CallError, RuntimeError => e
|
422
427
|
# these might happen for various reasonse. The correct behaviour of
|
423
|
-
# the server is to log them and continue.
|
424
|
-
GRPC.logger.warn("server call failed: #{e}")
|
428
|
+
# the server is to log them and continue, if it's not shutting down.
|
429
|
+
GRPC.logger.warn("server call failed: #{e}") unless stopped?
|
425
430
|
next
|
426
431
|
end
|
427
|
-
unless c.nil?
|
428
|
-
mth = an_rpc.method.to_sym
|
429
|
-
@pool.schedule(c) do |call|
|
430
|
-
rpc_descs[mth].run_server_method(call, rpc_handlers[mth])
|
431
|
-
end
|
432
|
-
end
|
433
432
|
end
|
433
|
+
@running = false
|
434
|
+
GRPC.logger.info("stopped: #{self}")
|
434
435
|
end
|
435
436
|
|
436
437
|
def new_active_server_call(an_rpc)
|
@@ -446,7 +447,7 @@ module GRPC
|
|
446
447
|
an_rpc.call.run_batch(@cq, handle_call_tag, INFINITE_FUTURE,
|
447
448
|
SEND_INITIAL_METADATA => connect_md)
|
448
449
|
return nil unless available?(an_rpc)
|
449
|
-
return nil unless
|
450
|
+
return nil unless implemented?(an_rpc)
|
450
451
|
|
451
452
|
# Create the ActiveCall
|
452
453
|
GRPC.logger.info("deadline is #{an_rpc.deadline}; (now=#{Time.now})")
|
data/lib/grpc/generic/service.rb
CHANGED
@@ -174,26 +174,24 @@ module GRPC
|
|
174
174
|
unmarshal = desc.unmarshal_proc(:output)
|
175
175
|
route = "/#{route_prefix}/#{name}"
|
176
176
|
if desc.request_response?
|
177
|
-
define_method(mth_name) do |req,
|
177
|
+
define_method(mth_name) do |req, **kw|
|
178
178
|
GRPC.logger.debug("calling #{@host}:#{route}")
|
179
|
-
request_response(route, req, marshal, unmarshal,
|
179
|
+
request_response(route, req, marshal, unmarshal, **kw)
|
180
180
|
end
|
181
181
|
elsif desc.client_streamer?
|
182
|
-
define_method(mth_name) do |reqs,
|
182
|
+
define_method(mth_name) do |reqs, **kw|
|
183
183
|
GRPC.logger.debug("calling #{@host}:#{route}")
|
184
|
-
client_streamer(route, reqs, marshal, unmarshal,
|
184
|
+
client_streamer(route, reqs, marshal, unmarshal, **kw)
|
185
185
|
end
|
186
186
|
elsif desc.server_streamer?
|
187
|
-
define_method(mth_name) do |req,
|
187
|
+
define_method(mth_name) do |req, **kw, &blk|
|
188
188
|
GRPC.logger.debug("calling #{@host}:#{route}")
|
189
|
-
server_streamer(route, req, marshal, unmarshal,
|
190
|
-
&blk)
|
189
|
+
server_streamer(route, req, marshal, unmarshal, **kw, &blk)
|
191
190
|
end
|
192
191
|
else # is a bidi_stream
|
193
|
-
define_method(mth_name) do |reqs,
|
192
|
+
define_method(mth_name) do |reqs, **kw, &blk|
|
194
193
|
GRPC.logger.debug("calling #{@host}:#{route}")
|
195
|
-
bidi_streamer(route, reqs, marshal, unmarshal,
|
196
|
-
&blk)
|
194
|
+
bidi_streamer(route, reqs, marshal, unmarshal, **kw, &blk)
|
197
195
|
end
|
198
196
|
end
|
199
197
|
end
|