grpc 0.15.0-x86-linux → 1.0.0.pre1-x86-linux

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 (40) hide show
  1. checksums.yaml +4 -4
  2. data/etc/roots.pem +784 -509
  3. data/grpc_c.32.ruby +0 -0
  4. data/grpc_c.64.ruby +0 -0
  5. data/src/ruby/ext/grpc/rb_byte_buffer.c +4 -1
  6. data/src/ruby/ext/grpc/rb_call.c +87 -54
  7. data/src/ruby/ext/grpc/rb_call.h +1 -1
  8. data/src/ruby/ext/grpc/rb_call_credentials.c +1 -30
  9. data/src/ruby/ext/grpc/rb_channel.c +25 -50
  10. data/src/ruby/ext/grpc/rb_channel_credentials.c +1 -31
  11. data/src/ruby/ext/grpc/rb_completion_queue.c +15 -134
  12. data/src/ruby/ext/grpc/rb_completion_queue.h +3 -7
  13. data/src/ruby/ext/grpc/rb_grpc.c +2 -4
  14. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  15. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
  16. data/src/ruby/ext/grpc/rb_server.c +81 -133
  17. data/src/ruby/ext/grpc/rb_server_credentials.c +4 -33
  18. data/src/ruby/lib/grpc/2.0/grpc_c.so +0 -0
  19. data/src/ruby/lib/grpc/2.1/grpc_c.so +0 -0
  20. data/src/ruby/lib/grpc/2.2/grpc_c.so +0 -0
  21. data/src/ruby/lib/grpc/2.3/grpc_c.so +0 -0
  22. data/src/ruby/lib/grpc/generic/active_call.rb +40 -55
  23. data/src/ruby/lib/grpc/generic/bidi_call.rb +21 -23
  24. data/src/ruby/lib/grpc/generic/client_stub.rb +20 -15
  25. data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -37
  26. data/src/ruby/lib/grpc/generic/service.rb +1 -1
  27. data/src/ruby/lib/grpc/grpc_c.so +0 -0
  28. data/src/ruby/lib/grpc/version.rb +1 -1
  29. data/src/ruby/pb/test/client.rb +25 -7
  30. data/src/ruby/pb/test/server.rb +7 -5
  31. data/src/ruby/spec/call_spec.rb +1 -2
  32. data/src/ruby/spec/channel_spec.rb +2 -3
  33. data/src/ruby/spec/client_server_spec.rb +74 -59
  34. data/src/ruby/spec/generic/active_call_spec.rb +66 -86
  35. data/src/ruby/spec/generic/client_stub_spec.rb +27 -48
  36. data/src/ruby/spec/generic/rpc_server_spec.rb +4 -34
  37. data/src/ruby/spec/pb/health/checker_spec.rb +0 -2
  38. data/src/ruby/spec/server_spec.rb +20 -24
  39. metadata +4 -6
  40. data/src/ruby/spec/completion_queue_spec.rb +0 -42
@@ -159,16 +159,6 @@ module GRPC
159
159
  # Signal check period is 0.25s
160
160
  SIGNAL_CHECK_PERIOD = 0.25
161
161
 
162
- # setup_cq is used by #initialize to constuct a Core::CompletionQueue from
163
- # its arguments.
164
- def self.setup_cq(alt_cq)
165
- return Core::CompletionQueue.new if alt_cq.nil?
166
- unless alt_cq.is_a? Core::CompletionQueue
167
- fail(TypeError, '!CompletionQueue')
168
- end
169
- alt_cq
170
- end
171
-
172
162
  # setup_connect_md_proc is used by #initialize to validate the
173
163
  # connect_md_proc.
174
164
  def self.setup_connect_md_proc(a_proc)
@@ -182,26 +172,18 @@ module GRPC
182
172
  # The RPC server is configured using keyword arguments.
183
173
  #
184
174
  # There are some specific keyword args used to configure the RpcServer
185
- # instance, however other arbitrary are allowed and when present are used
186
- # to configure the listeninng connection set up by the RpcServer.
187
- #
188
- # * poll_period: when present, the server polls for new events with this
189
- # period
175
+ # instance.
190
176
  #
191
177
  # * pool_size: the size of the thread pool the server uses to run its
192
178
  # threads
193
179
  #
194
- # * completion_queue_override: when supplied, this will be used as the
195
- # completion_queue that the server uses to receive network events,
196
- # otherwise its creates a new instance itself
197
- #
198
- # * creds: [GRPC::Core::ServerCredentials]
199
- # the credentials used to secure the server
200
- #
201
180
  # * max_waiting_requests: the maximum number of requests that are not
202
181
  # being handled to allow. When this limit is exceeded, the server responds
203
182
  # with not available to new requests
204
183
  #
184
+ # * poll_period: when present, the server polls for new events with this
185
+ # period
186
+ #
205
187
  # * connect_md_proc:
206
188
  # when non-nil is a proc for determining metadata to to send back the client
207
189
  # on receiving an invocation req. The proc signature is:
@@ -212,11 +194,9 @@ module GRPC
212
194
  def initialize(pool_size:DEFAULT_POOL_SIZE,
213
195
  max_waiting_requests:DEFAULT_MAX_WAITING_REQUESTS,
214
196
  poll_period:DEFAULT_POLL_PERIOD,
215
- completion_queue_override:nil,
216
197
  connect_md_proc:nil,
217
198
  server_args:{})
218
199
  @connect_md_proc = RpcServer.setup_connect_md_proc(connect_md_proc)
219
- @cq = RpcServer.setup_cq(completion_queue_override)
220
200
  @max_waiting_requests = max_waiting_requests
221
201
  @poll_period = poll_period
222
202
  @pool_size = pool_size
@@ -226,7 +206,7 @@ module GRPC
226
206
  # running_state can take 4 values: :not_started, :running, :stopping, and
227
207
  # :stopped. State transitions can only proceed in that order.
228
208
  @running_state = :not_started
229
- @server = Core::Server.new(@cq, server_args)
209
+ @server = Core::Server.new(server_args)
230
210
  end
231
211
 
232
212
  # stops a running server
@@ -240,7 +220,7 @@ module GRPC
240
220
  transition_running_state(:stopping)
241
221
  end
242
222
  deadline = from_relative_time(@poll_period)
243
- @server.close(@cq, deadline)
223
+ @server.close(deadline)
244
224
  @pool.stop
245
225
  end
246
226
 
@@ -355,7 +335,8 @@ module GRPC
355
335
  return an_rpc if @pool.jobs_waiting <= @max_waiting_requests
356
336
  GRPC.logger.warn("NOT AVAILABLE: too many jobs_waiting: #{an_rpc}")
357
337
  noop = proc { |x| x }
358
- c = ActiveCall.new(an_rpc.call, an_rpc.cq, noop, noop, an_rpc.deadline)
338
+ c = ActiveCall.new(an_rpc.call, noop, noop, an_rpc.deadline,
339
+ metadata_received: true)
359
340
  c.send_status(GRPC::Core::StatusCodes::RESOURCE_EXHAUSTED, '')
360
341
  nil
361
342
  end
@@ -366,7 +347,8 @@ module GRPC
366
347
  return an_rpc if rpc_descs.key?(mth)
367
348
  GRPC.logger.warn("UNIMPLEMENTED: #{an_rpc}")
368
349
  noop = proc { |x| x }
369
- c = ActiveCall.new(an_rpc.call, an_rpc.cq, noop, noop, an_rpc.deadline)
350
+ c = ActiveCall.new(an_rpc.call, noop, noop, an_rpc.deadline,
351
+ metadata_received: true)
370
352
  c.send_status(GRPC::Core::StatusCodes::UNIMPLEMENTED, '')
371
353
  nil
372
354
  end
@@ -374,11 +356,9 @@ module GRPC
374
356
  # handles calls to the server
375
357
  def loop_handle_server_calls
376
358
  fail 'not started' if running_state == :not_started
377
- loop_tag = Object.new
378
359
  while running_state == :running
379
360
  begin
380
- comp_queue = Core::CompletionQueue.new
381
- an_rpc = @server.request_call(comp_queue, loop_tag, INFINITE_FUTURE)
361
+ an_rpc = @server.request_call
382
362
  break if (!an_rpc.nil?) && an_rpc.call.nil?
383
363
  active_call = new_active_server_call(an_rpc)
384
364
  unless active_call.nil?
@@ -410,15 +390,13 @@ module GRPC
410
390
  return nil if an_rpc.nil? || an_rpc.call.nil?
411
391
 
412
392
  # allow the metadata to be accessed from the call
413
- handle_call_tag = Object.new
414
393
  an_rpc.call.metadata = an_rpc.metadata # attaches md to call for handlers
415
394
  GRPC.logger.debug("call md is #{an_rpc.metadata}")
416
395
  connect_md = nil
417
396
  unless @connect_md_proc.nil?
418
397
  connect_md = @connect_md_proc.call(an_rpc.method, an_rpc.metadata)
419
398
  end
420
- an_rpc.call.run_batch(an_rpc.cq, handle_call_tag, INFINITE_FUTURE,
421
- SEND_INITIAL_METADATA => connect_md)
399
+ an_rpc.call.run_batch(SEND_INITIAL_METADATA => connect_md)
422
400
 
423
401
  return nil unless available?(an_rpc)
424
402
  return nil unless implemented?(an_rpc)
@@ -426,9 +404,9 @@ module GRPC
426
404
  # Create the ActiveCall
427
405
  GRPC.logger.info("deadline is #{an_rpc.deadline}; (now=#{Time.now})")
428
406
  rpc_desc = rpc_descs[an_rpc.method.to_sym]
429
- c = ActiveCall.new(an_rpc.call, an_rpc.cq,
430
- rpc_desc.marshal_proc, rpc_desc.unmarshal_proc(:input),
431
- an_rpc.deadline)
407
+ c = ActiveCall.new(an_rpc.call, rpc_desc.marshal_proc,
408
+ rpc_desc.unmarshal_proc(:input), an_rpc.deadline,
409
+ metadata_received: true)
432
410
  mth = an_rpc.method.to_sym
433
411
  [c, mth]
434
412
  end
@@ -168,7 +168,7 @@ module GRPC
168
168
  # @param kw [KeywordArgs] the channel arguments, plus any optional
169
169
  # args for configuring the client's channel
170
170
  def initialize(host, creds, **kw)
171
- super(host, Core::CompletionQueue.new, creds, **kw)
171
+ super(host, creds, **kw)
172
172
  end
173
173
 
174
174
  # Used define_method to add a method for each rpc_desc. Each method
Binary file
@@ -29,5 +29,5 @@
29
29
 
30
30
  # GRPC contains the General RPC module.
31
31
  module GRPC
32
- VERSION = '0.15.0'
32
+ VERSION = '1.0.0.pre1'
33
33
  end
@@ -197,6 +197,25 @@ class PingPongPlayer
197
197
  end
198
198
  end
199
199
 
200
+ class BlockingEnumerator
201
+ include Grpc::Testing
202
+ include Grpc::Testing::PayloadType
203
+
204
+ def initialize(req_size, sleep_time)
205
+ @req_size = req_size
206
+ @sleep_time = sleep_time
207
+ end
208
+
209
+ def each_item
210
+ return enum_for(:each_item) unless block_given?
211
+ req_cls = StreamingOutputCallRequest
212
+ req = req_cls.new(payload: Payload.new(body: nulls(@req_size)))
213
+ yield req
214
+ # Sleep until after the deadline should have passed
215
+ sleep(@sleep_time)
216
+ end
217
+ end
218
+
200
219
  # defines methods corresponding to each interop test case.
201
220
  class NamedTests
202
221
  include Grpc::Testing
@@ -315,11 +334,10 @@ class NamedTests
315
334
  end
316
335
 
317
336
  def timeout_on_sleeping_server
318
- msg_sizes = [[27_182, 31_415]]
319
- ppp = PingPongPlayer.new(msg_sizes)
320
- deadline = GRPC::Core::TimeConsts::from_relative_time(0.001)
321
- resps = @stub.full_duplex_call(ppp.each_item, deadline: deadline)
322
- resps.each { |r| ppp.queue.push(r) }
337
+ enum = BlockingEnumerator.new(27_182, 2)
338
+ deadline = GRPC::Core::TimeConsts::from_relative_time(1)
339
+ resps = @stub.full_duplex_call(enum.each_item, deadline: deadline)
340
+ resps.each { } # wait to receive each request (or timeout)
323
341
  fail 'Should have raised GRPC::BadStatus(DEADLINE_EXCEEDED)'
324
342
  rescue GRPC::BadStatus => e
325
343
  assert("#{__callee__}: status was wrong") do
@@ -351,7 +369,7 @@ class NamedTests
351
369
  op.execute
352
370
  fail 'Should have raised GRPC:Cancelled'
353
371
  rescue GRPC::Cancelled
354
- assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled }
372
+ assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled? }
355
373
  end
356
374
 
357
375
  def cancel_after_first_response
@@ -362,7 +380,7 @@ class NamedTests
362
380
  op.execute.each { |r| ppp.queue.push(r) }
363
381
  fail 'Should have raised GRPC:Cancelled'
364
382
  rescue GRPC::Cancelled
365
- assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled }
383
+ assert("#{__callee__}: call operation should be CANCELLED") { op.cancelled? }
366
384
  op.wait
367
385
  end
368
386
 
@@ -188,11 +188,13 @@ class TestTarget < Grpc::Testing::TestService::Service
188
188
  begin
189
189
  GRPC.logger.info('interop-server: started receiving')
190
190
  reqs.each do |req|
191
- resp_size = req.response_parameters[0].size
192
- GRPC.logger.info("read a req, response size is #{resp_size}")
193
- resp = cls.new(payload: Payload.new(type: req.response_type,
194
- body: nulls(resp_size)))
195
- q.push(resp)
191
+ req.response_parameters.each do |params|
192
+ resp_size = params.size
193
+ GRPC.logger.info("read a req, response size is #{resp_size}")
194
+ resp = cls.new(payload: Payload.new(type: req.response_type,
195
+ body: nulls(resp_size)))
196
+ q.push(resp)
197
+ end
196
198
  end
197
199
  GRPC.logger.info('interop-server: finished receiving')
198
200
  q.push(self)
@@ -96,7 +96,6 @@ describe GRPC::Core::CallOps do
96
96
  end
97
97
 
98
98
  describe GRPC::Core::Call do
99
- let(:client_queue) { GRPC::Core::CompletionQueue.new }
100
99
  let(:test_tag) { Object.new }
101
100
  let(:fake_host) { 'localhost:10101' }
102
101
 
@@ -154,7 +153,7 @@ describe GRPC::Core::Call do
154
153
  end
155
154
 
156
155
  def make_test_call
157
- @ch.create_call(client_queue, nil, nil, 'dummy_method', nil, deadline)
156
+ @ch.create_call(nil, nil, 'dummy_method', nil, deadline)
158
157
  end
159
158
 
160
159
  def deadline
@@ -37,7 +37,6 @@ end
37
37
 
38
38
  describe GRPC::Core::Channel do
39
39
  let(:fake_host) { 'localhost:0' }
40
- let(:cq) { GRPC::Core::CompletionQueue.new }
41
40
 
42
41
  def create_test_cert
43
42
  GRPC::Core::ChannelCredentials.new(load_test_certs[0])
@@ -122,7 +121,7 @@ describe GRPC::Core::Channel do
122
121
  deadline = Time.now + 5
123
122
 
124
123
  blk = proc do
125
- ch.create_call(cq, nil, nil, 'dummy_method', nil, deadline)
124
+ ch.create_call(nil, nil, 'dummy_method', nil, deadline)
126
125
  end
127
126
  expect(&blk).to_not raise_error
128
127
  end
@@ -133,7 +132,7 @@ describe GRPC::Core::Channel do
133
132
 
134
133
  deadline = Time.now + 5
135
134
  blk = proc do
136
- ch.create_call(cq, nil, nil, 'dummy_method', nil, deadline)
135
+ ch.create_call(nil, nil, 'dummy_method', nil, deadline)
137
136
  end
138
137
  expect(&blk).to raise_error(RuntimeError)
139
138
  end
@@ -34,27 +34,23 @@ include GRPC::Core
34
34
  shared_context 'setup: tags' do
35
35
  let(:sent_message) { 'sent message' }
36
36
  let(:reply_text) { 'the reply' }
37
- before(:example) do
38
- @client_tag = Object.new
39
- @server_tag = Object.new
40
- end
41
37
 
42
38
  def deadline
43
39
  Time.now + 5
44
40
  end
45
41
 
46
- def server_allows_client_to_proceed
47
- recvd_rpc = @server.request_call(@server_queue, @server_tag, deadline)
42
+ def server_allows_client_to_proceed(metadata = {})
43
+ recvd_rpc = @server.request_call
48
44
  expect(recvd_rpc).to_not eq nil
49
45
  server_call = recvd_rpc.call
50
- ops = { CallOps::SEND_INITIAL_METADATA => {} }
51
- svr_batch = server_call.run_batch(@server_queue, @server_tag, deadline, ops)
46
+ ops = { CallOps::SEND_INITIAL_METADATA => metadata }
47
+ svr_batch = server_call.run_batch(ops)
52
48
  expect(svr_batch.send_metadata).to be true
53
49
  server_call
54
50
  end
55
51
 
56
52
  def new_client_call
57
- @ch.create_call(@client_queue, nil, nil, '/method', nil, deadline)
53
+ @ch.create_call(nil, nil, '/method', nil, deadline)
58
54
  end
59
55
  end
60
56
 
@@ -91,8 +87,7 @@ shared_examples 'basic GRPC message delivery is OK' do
91
87
  CallOps::SEND_INITIAL_METADATA => {},
92
88
  CallOps::SEND_MESSAGE => sent_message
93
89
  }
94
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
95
- client_ops)
90
+ batch_result = call.run_batch(client_ops)
96
91
  expect(batch_result.send_metadata).to be true
97
92
  expect(batch_result.send_message).to be true
98
93
 
@@ -101,8 +96,7 @@ shared_examples 'basic GRPC message delivery is OK' do
101
96
  server_ops = {
102
97
  CallOps::RECV_MESSAGE => nil
103
98
  }
104
- svr_batch = server_call.run_batch(@server_queue, @server_tag, deadline,
105
- server_ops)
99
+ svr_batch = server_call.run_batch(server_ops)
106
100
  expect(svr_batch.message).to eq(sent_message)
107
101
  end
108
102
 
@@ -118,8 +112,7 @@ shared_examples 'basic GRPC message delivery is OK' do
118
112
  CallOps::SEND_INITIAL_METADATA => {},
119
113
  CallOps::SEND_MESSAGE => sent_message
120
114
  }
121
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
122
- client_ops)
115
+ batch_result = call.run_batch(client_ops)
123
116
  expect(batch_result.send_metadata).to be true
124
117
  expect(batch_result.send_message).to be true
125
118
 
@@ -129,12 +122,50 @@ shared_examples 'basic GRPC message delivery is OK' do
129
122
  CallOps::RECV_MESSAGE => nil,
130
123
  CallOps::SEND_MESSAGE => reply_text
131
124
  }
132
- svr_batch = server_call.run_batch(@server_queue, @server_tag, deadline,
133
- server_ops)
125
+ svr_batch = server_call.run_batch(server_ops)
134
126
  expect(svr_batch.message).to eq(sent_message)
135
127
  expect(svr_batch.send_message).to be true
136
128
  end
137
129
 
130
+ it 'compressed messages can be sent and received' do
131
+ call = new_client_call
132
+ server_call = nil
133
+ long_request_str = '0' * 2000
134
+ long_response_str = '1' * 2000
135
+ md = { 'grpc-internal-encoding-request' => 'gzip' }
136
+
137
+ server_thread = Thread.new do
138
+ server_call = server_allows_client_to_proceed(md)
139
+ end
140
+
141
+ client_ops = {
142
+ CallOps::SEND_INITIAL_METADATA => md,
143
+ CallOps::SEND_MESSAGE => long_request_str
144
+ }
145
+ batch_result = call.run_batch(client_ops)
146
+ expect(batch_result.send_metadata).to be true
147
+ expect(batch_result.send_message).to be true
148
+
149
+ # confirm the server can read the inbound message
150
+ server_thread.join
151
+ server_ops = {
152
+ CallOps::RECV_MESSAGE => nil,
153
+ CallOps::SEND_MESSAGE => long_response_str
154
+ }
155
+ svr_batch = server_call.run_batch(server_ops)
156
+ expect(svr_batch.message).to eq(long_request_str)
157
+ expect(svr_batch.send_message).to be true
158
+
159
+ client_ops = {
160
+ CallOps::SEND_CLOSE_FROM_CLIENT => nil,
161
+ CallOps::RECV_INITIAL_METADATA => nil,
162
+ CallOps::RECV_MESSAGE => nil
163
+ }
164
+ batch_result = call.run_batch(client_ops)
165
+ expect(batch_result.send_close).to be true
166
+ expect(batch_result.message).to eq long_response_str
167
+ end
168
+
138
169
  it 'servers can ignore a client write and send a status' do
139
170
  call = new_client_call
140
171
  server_call = nil
@@ -147,8 +178,7 @@ shared_examples 'basic GRPC message delivery is OK' do
147
178
  CallOps::SEND_INITIAL_METADATA => {},
148
179
  CallOps::SEND_MESSAGE => sent_message
149
180
  }
150
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
151
- client_ops)
181
+ batch_result = call.run_batch(client_ops)
152
182
  expect(batch_result.send_metadata).to be true
153
183
  expect(batch_result.send_message).to be true
154
184
 
@@ -158,8 +188,7 @@ shared_examples 'basic GRPC message delivery is OK' do
158
188
  server_ops = {
159
189
  CallOps::SEND_STATUS_FROM_SERVER => the_status
160
190
  }
161
- svr_batch = server_call.run_batch(@server_queue, @server_tag, deadline,
162
- server_ops)
191
+ svr_batch = server_call.run_batch(server_ops)
163
192
  expect(svr_batch.message).to eq nil
164
193
  expect(svr_batch.send_status).to be true
165
194
  end
@@ -176,8 +205,7 @@ shared_examples 'basic GRPC message delivery is OK' do
176
205
  CallOps::SEND_INITIAL_METADATA => {},
177
206
  CallOps::SEND_MESSAGE => sent_message
178
207
  }
179
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
180
- client_ops)
208
+ batch_result = call.run_batch(client_ops)
181
209
  expect(batch_result.send_metadata).to be true
182
210
  expect(batch_result.send_message).to be true
183
211
 
@@ -189,8 +217,7 @@ shared_examples 'basic GRPC message delivery is OK' do
189
217
  CallOps::SEND_MESSAGE => reply_text,
190
218
  CallOps::SEND_STATUS_FROM_SERVER => the_status
191
219
  }
192
- svr_batch = server_call.run_batch(@server_queue, @server_tag, deadline,
193
- server_ops)
220
+ svr_batch = server_call.run_batch(server_ops)
194
221
  expect(svr_batch.message).to eq sent_message
195
222
  expect(svr_batch.send_status).to be true
196
223
  expect(svr_batch.send_message).to be true
@@ -202,8 +229,7 @@ shared_examples 'basic GRPC message delivery is OK' do
202
229
  CallOps::RECV_MESSAGE => nil,
203
230
  CallOps::RECV_STATUS_ON_CLIENT => nil
204
231
  }
205
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
206
- client_ops)
232
+ batch_result = call.run_batch(client_ops)
207
233
  expect(batch_result.send_close).to be true
208
234
  expect(batch_result.message).to eq reply_text
209
235
  expect(batch_result.status).to eq the_status
@@ -212,8 +238,7 @@ shared_examples 'basic GRPC message delivery is OK' do
212
238
  server_ops = {
213
239
  CallOps::RECV_CLOSE_ON_SERVER => nil
214
240
  }
215
- svr_batch = server_call.run_batch(@server_queue, @server_tag, deadline,
216
- server_ops)
241
+ svr_batch = server_call.run_batch(server_ops)
217
242
  expect(svr_batch.send_close).to be true
218
243
  end
219
244
  end
@@ -244,8 +269,7 @@ shared_examples 'GRPC metadata delivery works OK' do
244
269
  CallOps::SEND_INITIAL_METADATA => md
245
270
  }
246
271
  blk = proc do
247
- call.run_batch(@client_queue, @client_tag, deadline,
248
- client_ops)
272
+ call.run_batch(client_ops)
249
273
  end
250
274
  expect(&blk).to raise_error
251
275
  end
@@ -255,15 +279,14 @@ shared_examples 'GRPC metadata delivery works OK' do
255
279
  @valid_metadata.each do |md|
256
280
  recvd_rpc = nil
257
281
  rcv_thread = Thread.new do
258
- recvd_rpc = @server.request_call(@server_queue, @server_tag, deadline)
282
+ recvd_rpc = @server.request_call
259
283
  end
260
284
 
261
285
  call = new_client_call
262
286
  client_ops = {
263
287
  CallOps::SEND_INITIAL_METADATA => md
264
288
  }
265
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
266
- client_ops)
289
+ batch_result = call.run_batch(client_ops)
267
290
  expect(batch_result.send_metadata).to be true
268
291
 
269
292
  # confirm the server can receive the client metadata
@@ -296,7 +319,7 @@ shared_examples 'GRPC metadata delivery works OK' do
296
319
  @bad_keys.each do |md|
297
320
  recvd_rpc = nil
298
321
  rcv_thread = Thread.new do
299
- recvd_rpc = @server.request_call(@server_queue, @server_tag, deadline)
322
+ recvd_rpc = @server.request_call
300
323
  end
301
324
 
302
325
  call = new_client_call
@@ -305,7 +328,7 @@ shared_examples 'GRPC metadata delivery works OK' do
305
328
  client_ops = {
306
329
  CallOps::SEND_INITIAL_METADATA => nil
307
330
  }
308
- call.run_batch(@client_queue, @client_tag, deadline, client_ops)
331
+ call.run_batch(client_ops)
309
332
 
310
333
  # server gets the invocation
311
334
  rcv_thread.join
@@ -314,8 +337,7 @@ shared_examples 'GRPC metadata delivery works OK' do
314
337
  CallOps::SEND_INITIAL_METADATA => md
315
338
  }
316
339
  blk = proc do
317
- recvd_rpc.call.run_batch(@server_queue, @server_tag, deadline,
318
- server_ops)
340
+ recvd_rpc.call.run_batch(server_ops)
319
341
  end
320
342
  expect(&blk).to raise_error
321
343
  end
@@ -324,7 +346,7 @@ shared_examples 'GRPC metadata delivery works OK' do
324
346
  it 'sends an empty hash if no metadata is added' do
325
347
  recvd_rpc = nil
326
348
  rcv_thread = Thread.new do
327
- recvd_rpc = @server.request_call(@server_queue, @server_tag, deadline)
349
+ recvd_rpc = @server.request_call
328
350
  end
329
351
 
330
352
  call = new_client_call
@@ -333,7 +355,7 @@ shared_examples 'GRPC metadata delivery works OK' do
333
355
  client_ops = {
334
356
  CallOps::SEND_INITIAL_METADATA => nil
335
357
  }
336
- call.run_batch(@client_queue, @client_tag, deadline, client_ops)
358
+ call.run_batch(client_ops)
337
359
 
338
360
  # server gets the invocation but sends no metadata back
339
361
  rcv_thread.join
@@ -342,14 +364,13 @@ shared_examples 'GRPC metadata delivery works OK' do
342
364
  server_ops = {
343
365
  CallOps::SEND_INITIAL_METADATA => nil
344
366
  }
345
- server_call.run_batch(@server_queue, @server_tag, deadline, server_ops)
367
+ server_call.run_batch(server_ops)
346
368
 
347
369
  # client receives nothing as expected
348
370
  client_ops = {
349
371
  CallOps::RECV_INITIAL_METADATA => nil
350
372
  }
351
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
352
- client_ops)
373
+ batch_result = call.run_batch(client_ops)
353
374
  expect(batch_result.metadata).to eq({})
354
375
  end
355
376
 
@@ -357,7 +378,7 @@ shared_examples 'GRPC metadata delivery works OK' do
357
378
  @valid_metadata.each do |md|
358
379
  recvd_rpc = nil
359
380
  rcv_thread = Thread.new do
360
- recvd_rpc = @server.request_call(@server_queue, @server_tag, deadline)
381
+ recvd_rpc = @server.request_call
361
382
  end
362
383
 
363
384
  call = new_client_call
@@ -366,7 +387,7 @@ shared_examples 'GRPC metadata delivery works OK' do
366
387
  client_ops = {
367
388
  CallOps::SEND_INITIAL_METADATA => nil
368
389
  }
369
- call.run_batch(@client_queue, @client_tag, deadline, client_ops)
390
+ call.run_batch(client_ops)
370
391
 
371
392
  # server gets the invocation but sends no metadata back
372
393
  rcv_thread.join
@@ -375,14 +396,13 @@ shared_examples 'GRPC metadata delivery works OK' do
375
396
  server_ops = {
376
397
  CallOps::SEND_INITIAL_METADATA => md
377
398
  }
378
- server_call.run_batch(@server_queue, @server_tag, deadline, server_ops)
399
+ server_call.run_batch(server_ops)
379
400
 
380
401
  # client receives nothing as expected
381
402
  client_ops = {
382
403
  CallOps::RECV_INITIAL_METADATA => nil
383
404
  }
384
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
385
- client_ops)
405
+ batch_result = call.run_batch(client_ops)
386
406
  replace_symbols = Hash[md.each_pair.collect { |x, y| [x.to_s, y] }]
387
407
  expect(batch_result.metadata).to eq(replace_symbols)
388
408
  end
@@ -393,9 +413,7 @@ end
393
413
  describe 'the http client/server' do
394
414
  before(:example) do
395
415
  server_host = '0.0.0.0:0'
396
- @client_queue = GRPC::Core::CompletionQueue.new
397
- @server_queue = GRPC::Core::CompletionQueue.new
398
- @server = GRPC::Core::Server.new(@server_queue, nil)
416
+ @server = GRPC::Core::Server.new(nil)
399
417
  server_port = @server.add_http2_port(server_host, :this_port_is_insecure)
400
418
  @server.start
401
419
  @ch = Channel.new("0.0.0.0:#{server_port}", nil, :this_channel_is_insecure)
@@ -403,7 +421,7 @@ describe 'the http client/server' do
403
421
 
404
422
  after(:example) do
405
423
  @ch.close
406
- @server.close(@server_queue, deadline)
424
+ @server.close(deadline)
407
425
  end
408
426
 
409
427
  it_behaves_like 'basic GRPC message delivery is OK' do
@@ -425,11 +443,9 @@ describe 'the secure http client/server' do
425
443
  before(:example) do
426
444
  certs = load_test_certs
427
445
  server_host = '0.0.0.0:0'
428
- @client_queue = GRPC::Core::CompletionQueue.new
429
- @server_queue = GRPC::Core::CompletionQueue.new
430
446
  server_creds = GRPC::Core::ServerCredentials.new(
431
447
  nil, [{ private_key: certs[1], cert_chain: certs[2] }], false)
432
- @server = GRPC::Core::Server.new(@server_queue, nil)
448
+ @server = GRPC::Core::Server.new(nil)
433
449
  server_port = @server.add_http2_port(server_host, server_creds)
434
450
  @server.start
435
451
  args = { Channel::SSL_TARGET => 'foo.test.google.fr' }
@@ -438,7 +454,7 @@ describe 'the secure http client/server' do
438
454
  end
439
455
 
440
456
  after(:example) do
441
- @server.close(@server_queue, deadline)
457
+ @server.close(deadline)
442
458
  end
443
459
 
444
460
  it_behaves_like 'basic GRPC message delivery is OK' do
@@ -454,7 +470,7 @@ describe 'the secure http client/server' do
454
470
  expected_md = { 'k1' => 'updated-v1', 'k2' => 'v2' }
455
471
  recvd_rpc = nil
456
472
  rcv_thread = Thread.new do
457
- recvd_rpc = @server.request_call(@server_queue, @server_tag, deadline)
473
+ recvd_rpc = @server.request_call
458
474
  end
459
475
 
460
476
  call = new_client_call
@@ -462,8 +478,7 @@ describe 'the secure http client/server' do
462
478
  client_ops = {
463
479
  CallOps::SEND_INITIAL_METADATA => md
464
480
  }
465
- batch_result = call.run_batch(@client_queue, @client_tag, deadline,
466
- client_ops)
481
+ batch_result = call.run_batch(client_ops)
467
482
  expect(batch_result.send_metadata).to be true
468
483
 
469
484
  # confirm the server can receive the client metadata