grpc 0.15.0-universal-darwin → 1.0.0.pre1-universal-darwin
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/etc/roots.pem +784 -509
- data/src/ruby/ext/grpc/rb_byte_buffer.c +4 -1
- data/src/ruby/ext/grpc/rb_call.c +87 -54
- data/src/ruby/ext/grpc/rb_call.h +1 -1
- data/src/ruby/ext/grpc/rb_call_credentials.c +1 -30
- data/src/ruby/ext/grpc/rb_channel.c +25 -50
- data/src/ruby/ext/grpc/rb_channel_credentials.c +1 -31
- data/src/ruby/ext/grpc/rb_completion_queue.c +15 -134
- data/src/ruby/ext/grpc/rb_completion_queue.h +3 -7
- data/src/ruby/ext/grpc/rb_grpc.c +2 -4
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
- data/src/ruby/ext/grpc/rb_server.c +81 -133
- data/src/ruby/ext/grpc/rb_server_credentials.c +4 -33
- 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/generic/active_call.rb +40 -55
- data/src/ruby/lib/grpc/generic/bidi_call.rb +21 -23
- data/src/ruby/lib/grpc/generic/client_stub.rb +20 -15
- data/src/ruby/lib/grpc/generic/rpc_server.rb +15 -37
- data/src/ruby/lib/grpc/generic/service.rb +1 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/test/client.rb +25 -7
- data/src/ruby/pb/test/server.rb +7 -5
- data/src/ruby/spec/call_spec.rb +1 -2
- data/src/ruby/spec/channel_spec.rb +2 -3
- data/src/ruby/spec/client_server_spec.rb +74 -59
- data/src/ruby/spec/generic/active_call_spec.rb +66 -86
- data/src/ruby/spec/generic/client_stub_spec.rb +27 -48
- data/src/ruby/spec/generic/rpc_server_spec.rb +4 -34
- data/src/ruby/spec/pb/health/checker_spec.rb +0 -2
- data/src/ruby/spec/server_spec.rb +20 -24
- metadata +4 -6
- data/src/ruby/spec/completion_queue_spec.rb +0 -42
| @@ -39,13 +39,8 @@ describe GRPC::ActiveCall do | |
| 39 39 |  | 
| 40 40 | 
             
              before(:each) do
         | 
| 41 41 | 
             
                @pass_through = proc { |x| x }
         | 
| 42 | 
            -
                @server_tag = Object.new
         | 
| 43 | 
            -
                @tag = Object.new
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                @client_queue = GRPC::Core::CompletionQueue.new
         | 
| 46 | 
            -
                @server_queue = GRPC::Core::CompletionQueue.new
         | 
| 47 42 | 
             
                host = '0.0.0.0:0'
         | 
| 48 | 
            -
                @server = GRPC::Core::Server.new( | 
| 43 | 
            +
                @server = GRPC::Core::Server.new(nil)
         | 
| 49 44 | 
             
                server_port = @server.add_http2_port(host, :this_port_is_insecure)
         | 
| 50 45 | 
             
                @server.start
         | 
| 51 46 | 
             
                @ch = GRPC::Core::Channel.new("0.0.0.0:#{server_port}", nil,
         | 
| @@ -53,21 +48,20 @@ describe GRPC::ActiveCall do | |
| 53 48 | 
             
              end
         | 
| 54 49 |  | 
| 55 50 | 
             
              after(:each) do
         | 
| 56 | 
            -
                @server.close( | 
| 51 | 
            +
                @server.close(deadline)
         | 
| 57 52 | 
             
              end
         | 
| 58 53 |  | 
| 59 54 | 
             
              describe 'restricted view methods' do
         | 
| 60 55 | 
             
                before(:each) do
         | 
| 61 56 | 
             
                  call = make_test_call
         | 
| 62 | 
            -
                   | 
| 63 | 
            -
                  @client_call = ActiveCall.new(call, @ | 
| 64 | 
            -
                                                @pass_through, deadline | 
| 65 | 
            -
                                                metadata_tag: md_tag)
         | 
| 57 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 58 | 
            +
                  @client_call = ActiveCall.new(call, @pass_through,
         | 
| 59 | 
            +
                                                @pass_through, deadline)
         | 
| 66 60 | 
             
                end
         | 
| 67 61 |  | 
| 68 62 | 
             
                describe '#multi_req_view' do
         | 
| 69 63 | 
             
                  it 'exposes a fixed subset of the ActiveCall methods' do
         | 
| 70 | 
            -
                    want = %w(cancelled | 
| 64 | 
            +
                    want = %w(cancelled?, deadline, each_remote_read, metadata, shutdown)
         | 
| 71 65 | 
             
                    v = @client_call.multi_req_view
         | 
| 72 66 | 
             
                    want.each do |w|
         | 
| 73 67 | 
             
                      expect(v.methods.include?(w))
         | 
| @@ -77,7 +71,7 @@ describe GRPC::ActiveCall do | |
| 77 71 |  | 
| 78 72 | 
             
                describe '#single_req_view' do
         | 
| 79 73 | 
             
                  it 'exposes a fixed subset of the ActiveCall methods' do
         | 
| 80 | 
            -
                    want = %w(cancelled | 
| 74 | 
            +
                    want = %w(cancelled?, deadline, metadata, shutdown)
         | 
| 81 75 | 
             
                    v = @client_call.single_req_view
         | 
| 82 76 | 
             
                    want.each do |w|
         | 
| 83 77 | 
             
                      expect(v.methods.include?(w))
         | 
| @@ -89,46 +83,42 @@ describe GRPC::ActiveCall do | |
| 89 83 | 
             
              describe '#remote_send' do
         | 
| 90 84 | 
             
                it 'allows a client to send a payload to the server' do
         | 
| 91 85 | 
             
                  call = make_test_call
         | 
| 92 | 
            -
                   | 
| 93 | 
            -
                  @client_call = ActiveCall.new(call, @ | 
| 94 | 
            -
                                                @pass_through, deadline | 
| 95 | 
            -
                                                metadata_tag: md_tag)
         | 
| 86 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 87 | 
            +
                  @client_call = ActiveCall.new(call, @pass_through,
         | 
| 88 | 
            +
                                                @pass_through, deadline)
         | 
| 96 89 | 
             
                  msg = 'message is a string'
         | 
| 97 90 | 
             
                  @client_call.remote_send(msg)
         | 
| 98 91 |  | 
| 99 92 | 
             
                  # check that server rpc new was received
         | 
| 100 | 
            -
                  recvd_rpc = @server.request_call | 
| 93 | 
            +
                  recvd_rpc = @server.request_call
         | 
| 101 94 | 
             
                  expect(recvd_rpc).to_not eq nil
         | 
| 102 95 | 
             
                  recvd_call = recvd_rpc.call
         | 
| 103 96 |  | 
| 104 97 | 
             
                  # Accept the call, and verify that the server reads the response ok.
         | 
| 105 | 
            -
                   | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 108 | 
            -
                  recvd_call.run_batch(@server_queue, @server_tag, deadline, server_ops)
         | 
| 109 | 
            -
                  server_call = ActiveCall.new(recvd_call, @server_queue, @pass_through,
         | 
| 110 | 
            -
                                               @pass_through, deadline)
         | 
| 98 | 
            +
                  server_call = ActiveCall.new(recvd_call, @pass_through,
         | 
| 99 | 
            +
                                               @pass_through, deadline,
         | 
| 100 | 
            +
                                               metadata_received: true)
         | 
| 111 101 | 
             
                  expect(server_call.remote_read).to eq(msg)
         | 
| 112 102 | 
             
                end
         | 
| 113 103 |  | 
| 114 104 | 
             
                it 'marshals the payload using the marshal func' do
         | 
| 115 105 | 
             
                  call = make_test_call
         | 
| 116 | 
            -
                  ActiveCall.client_invoke(call | 
| 106 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 117 107 | 
             
                  marshal = proc { |x| 'marshalled:' + x }
         | 
| 118 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 119 | 
            -
                                               @pass_through, deadline)
         | 
| 108 | 
            +
                  client_call = ActiveCall.new(call, marshal, @pass_through, deadline)
         | 
| 120 109 | 
             
                  msg = 'message is a string'
         | 
| 121 110 | 
             
                  client_call.remote_send(msg)
         | 
| 122 111 |  | 
| 123 112 | 
             
                  # confirm that the message was marshalled
         | 
| 124 | 
            -
                  recvd_rpc =  @server.request_call | 
| 113 | 
            +
                  recvd_rpc =  @server.request_call
         | 
| 125 114 | 
             
                  recvd_call = recvd_rpc.call
         | 
| 126 115 | 
             
                  server_ops = {
         | 
| 127 116 | 
             
                    CallOps::SEND_INITIAL_METADATA => nil
         | 
| 128 117 | 
             
                  }
         | 
| 129 | 
            -
                  recvd_call.run_batch( | 
| 130 | 
            -
                  server_call = ActiveCall.new(recvd_call, @ | 
| 131 | 
            -
                                               @pass_through, deadline | 
| 118 | 
            +
                  recvd_call.run_batch(server_ops)
         | 
| 119 | 
            +
                  server_call = ActiveCall.new(recvd_call, @pass_through,
         | 
| 120 | 
            +
                                               @pass_through, deadline,
         | 
| 121 | 
            +
                                               metadata_received: true)
         | 
| 132 122 | 
             
                  expect(server_call.remote_read).to eq('marshalled:' + msg)
         | 
| 133 123 | 
             
                end
         | 
| 134 124 |  | 
| @@ -136,23 +126,24 @@ describe GRPC::ActiveCall do | |
| 136 126 | 
             
                TEST_WRITE_FLAGS.each do |f|
         | 
| 137 127 | 
             
                  it "successfully makes calls with write_flag set to #{f}" do
         | 
| 138 128 | 
             
                    call = make_test_call
         | 
| 139 | 
            -
                    ActiveCall.client_invoke(call | 
| 129 | 
            +
                    ActiveCall.client_invoke(call)
         | 
| 140 130 | 
             
                    marshal = proc { |x| 'marshalled:' + x }
         | 
| 141 | 
            -
                    client_call = ActiveCall.new(call,  | 
| 131 | 
            +
                    client_call = ActiveCall.new(call, marshal,
         | 
| 142 132 | 
             
                                                 @pass_through, deadline)
         | 
| 143 133 | 
             
                    msg = 'message is a string'
         | 
| 144 134 | 
             
                    client_call.write_flag = f
         | 
| 145 135 | 
             
                    client_call.remote_send(msg)
         | 
| 146 136 |  | 
| 147 137 | 
             
                    # confirm that the message was marshalled
         | 
| 148 | 
            -
                    recvd_rpc =  @server.request_call | 
| 138 | 
            +
                    recvd_rpc =  @server.request_call
         | 
| 149 139 | 
             
                    recvd_call = recvd_rpc.call
         | 
| 150 140 | 
             
                    server_ops = {
         | 
| 151 141 | 
             
                      CallOps::SEND_INITIAL_METADATA => nil
         | 
| 152 142 | 
             
                    }
         | 
| 153 | 
            -
                    recvd_call.run_batch( | 
| 154 | 
            -
                    server_call = ActiveCall.new(recvd_call, @ | 
| 155 | 
            -
                                                 @pass_through, deadline | 
| 143 | 
            +
                    recvd_call.run_batch(server_ops)
         | 
| 144 | 
            +
                    server_call = ActiveCall.new(recvd_call, @pass_through,
         | 
| 145 | 
            +
                                                 @pass_through, deadline,
         | 
| 146 | 
            +
                                                 metadata_received: true)
         | 
| 156 147 | 
             
                    expect(server_call.remote_read).to eq('marshalled:' + msg)
         | 
| 157 148 | 
             
                  end
         | 
| 158 149 | 
             
                end
         | 
| @@ -162,8 +153,8 @@ describe GRPC::ActiveCall do | |
| 162 153 | 
             
                it 'sends metadata to the server when present' do
         | 
| 163 154 | 
             
                  call = make_test_call
         | 
| 164 155 | 
             
                  metadata = { k1: 'v1', k2: 'v2' }
         | 
| 165 | 
            -
                  ActiveCall.client_invoke(call,  | 
| 166 | 
            -
                  recvd_rpc =  @server.request_call | 
| 156 | 
            +
                  ActiveCall.client_invoke(call, metadata)
         | 
| 157 | 
            +
                  recvd_rpc =  @server.request_call
         | 
| 167 158 | 
             
                  recvd_call = recvd_rpc.call
         | 
| 168 159 | 
             
                  expect(recvd_call).to_not be_nil
         | 
| 169 160 | 
             
                  expect(recvd_rpc.metadata).to_not be_nil
         | 
| @@ -175,10 +166,9 @@ describe GRPC::ActiveCall do | |
| 175 166 | 
             
              describe '#remote_read' do
         | 
| 176 167 | 
             
                it 'reads the response sent by a server' do
         | 
| 177 168 | 
             
                  call = make_test_call
         | 
| 178 | 
            -
                   | 
| 179 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 180 | 
            -
                                               @pass_through, deadline | 
| 181 | 
            -
                                               metadata_tag: md_tag)
         | 
| 169 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 170 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 171 | 
            +
                                               @pass_through, deadline)
         | 
| 182 172 | 
             
                  msg = 'message is a string'
         | 
| 183 173 | 
             
                  client_call.remote_send(msg)
         | 
| 184 174 | 
             
                  server_call = expect_server_to_receive(msg)
         | 
| @@ -188,10 +178,9 @@ describe GRPC::ActiveCall do | |
| 188 178 |  | 
| 189 179 | 
             
                it 'saves no metadata when the server adds no metadata' do
         | 
| 190 180 | 
             
                  call = make_test_call
         | 
| 191 | 
            -
                   | 
| 192 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 193 | 
            -
                                               @pass_through, deadline | 
| 194 | 
            -
                                               metadata_tag: md_tag)
         | 
| 181 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 182 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 183 | 
            +
                                               @pass_through, deadline)
         | 
| 195 184 | 
             
                  msg = 'message is a string'
         | 
| 196 185 | 
             
                  client_call.remote_send(msg)
         | 
| 197 186 | 
             
                  server_call = expect_server_to_receive(msg)
         | 
| @@ -203,10 +192,9 @@ describe GRPC::ActiveCall do | |
| 203 192 |  | 
| 204 193 | 
             
                it 'saves metadata add by the server' do
         | 
| 205 194 | 
             
                  call = make_test_call
         | 
| 206 | 
            -
                   | 
| 207 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 208 | 
            -
                                               @pass_through, deadline | 
| 209 | 
            -
                                               metadata_tag: md_tag)
         | 
| 195 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 196 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 197 | 
            +
                                               @pass_through, deadline)
         | 
| 210 198 | 
             
                  msg = 'message is a string'
         | 
| 211 199 | 
             
                  client_call.remote_send(msg)
         | 
| 212 200 | 
             
                  server_call = expect_server_to_receive(msg, k1: 'v1', k2: 'v2')
         | 
| @@ -219,10 +207,9 @@ describe GRPC::ActiveCall do | |
| 219 207 |  | 
| 220 208 | 
             
                it 'get a nil msg before a status when an OK status is sent' do
         | 
| 221 209 | 
             
                  call = make_test_call
         | 
| 222 | 
            -
                   | 
| 223 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 224 | 
            -
                                               @pass_through, deadline | 
| 225 | 
            -
                                               metadata_tag: md_tag)
         | 
| 210 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 211 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 212 | 
            +
                                               @pass_through, deadline)
         | 
| 226 213 | 
             
                  msg = 'message is a string'
         | 
| 227 214 | 
             
                  client_call.remote_send(msg)
         | 
| 228 215 | 
             
                  client_call.writes_done(false)
         | 
| @@ -236,11 +223,10 @@ describe GRPC::ActiveCall do | |
| 236 223 |  | 
| 237 224 | 
             
                it 'unmarshals the response using the unmarshal func' do
         | 
| 238 225 | 
             
                  call = make_test_call
         | 
| 239 | 
            -
                   | 
| 226 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 240 227 | 
             
                  unmarshal = proc { |x| 'unmarshalled:' + x }
         | 
| 241 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 242 | 
            -
                                               unmarshal, deadline | 
| 243 | 
            -
                                               metadata_tag: md_tag)
         | 
| 228 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 229 | 
            +
                                               unmarshal, deadline)
         | 
| 244 230 |  | 
| 245 231 | 
             
                  # confirm the client receives the unmarshalled message
         | 
| 246 232 | 
             
                  msg = 'message is a string'
         | 
| @@ -254,17 +240,16 @@ describe GRPC::ActiveCall do | |
| 254 240 | 
             
              describe '#each_remote_read' do
         | 
| 255 241 | 
             
                it 'creates an Enumerator' do
         | 
| 256 242 | 
             
                  call = make_test_call
         | 
| 257 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 243 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 258 244 | 
             
                                               @pass_through, deadline)
         | 
| 259 245 | 
             
                  expect(client_call.each_remote_read).to be_a(Enumerator)
         | 
| 260 246 | 
             
                end
         | 
| 261 247 |  | 
| 262 248 | 
             
                it 'the returns an enumerator that can read n responses' do
         | 
| 263 249 | 
             
                  call = make_test_call
         | 
| 264 | 
            -
                   | 
| 265 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 266 | 
            -
                                               @pass_through, deadline | 
| 267 | 
            -
                                               metadata_tag: md_tag)
         | 
| 250 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 251 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 252 | 
            +
                                               @pass_through, deadline)
         | 
| 268 253 | 
             
                  msg = 'message is a string'
         | 
| 269 254 | 
             
                  reply = 'server_response'
         | 
| 270 255 | 
             
                  client_call.remote_send(msg)
         | 
| @@ -279,10 +264,9 @@ describe GRPC::ActiveCall do | |
| 279 264 |  | 
| 280 265 | 
             
                it 'the returns an enumerator that stops after an OK Status' do
         | 
| 281 266 | 
             
                  call = make_test_call
         | 
| 282 | 
            -
                   | 
| 283 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 284 | 
            -
                                               @pass_through, deadline | 
| 285 | 
            -
                                               metadata_tag: md_tag)
         | 
| 267 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 268 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 269 | 
            +
                                               @pass_through, deadline)
         | 
| 286 270 | 
             
                  msg = 'message is a string'
         | 
| 287 271 | 
             
                  reply = 'server_response'
         | 
| 288 272 | 
             
                  client_call.remote_send(msg)
         | 
| @@ -302,10 +286,9 @@ describe GRPC::ActiveCall do | |
| 302 286 | 
             
              describe '#writes_done' do
         | 
| 303 287 | 
             
                it 'finishes ok if the server sends a status response' do
         | 
| 304 288 | 
             
                  call = make_test_call
         | 
| 305 | 
            -
                   | 
| 306 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 307 | 
            -
                                               @pass_through, deadline | 
| 308 | 
            -
                                               metadata_tag: md_tag)
         | 
| 289 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 290 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 291 | 
            +
                                               @pass_through, deadline)
         | 
| 309 292 | 
             
                  msg = 'message is a string'
         | 
| 310 293 | 
             
                  client_call.remote_send(msg)
         | 
| 311 294 | 
             
                  expect { client_call.writes_done(false) }.to_not raise_error
         | 
| @@ -318,10 +301,9 @@ describe GRPC::ActiveCall do | |
| 318 301 |  | 
| 319 302 | 
             
                it 'finishes ok if the server sends an early status response' do
         | 
| 320 303 | 
             
                  call = make_test_call
         | 
| 321 | 
            -
                   | 
| 322 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 323 | 
            -
                                               @pass_through, deadline | 
| 324 | 
            -
                                               metadata_tag: md_tag)
         | 
| 304 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 305 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 306 | 
            +
                                               @pass_through, deadline)
         | 
| 325 307 | 
             
                  msg = 'message is a string'
         | 
| 326 308 | 
             
                  client_call.remote_send(msg)
         | 
| 327 309 | 
             
                  server_call = expect_server_to_receive(msg)
         | 
| @@ -334,10 +316,9 @@ describe GRPC::ActiveCall do | |
| 334 316 |  | 
| 335 317 | 
             
                it 'finishes ok if writes_done is true' do
         | 
| 336 318 | 
             
                  call = make_test_call
         | 
| 337 | 
            -
                   | 
| 338 | 
            -
                  client_call = ActiveCall.new(call, @ | 
| 339 | 
            -
                                               @pass_through, deadline | 
| 340 | 
            -
                                               metadata_tag: md_tag)
         | 
| 319 | 
            +
                  ActiveCall.client_invoke(call)
         | 
| 320 | 
            +
                  client_call = ActiveCall.new(call, @pass_through,
         | 
| 321 | 
            +
                                               @pass_through, deadline)
         | 
| 341 322 | 
             
                  msg = 'message is a string'
         | 
| 342 323 | 
             
                  client_call.remote_send(msg)
         | 
| 343 324 | 
             
                  server_call = expect_server_to_receive(msg)
         | 
| @@ -355,17 +336,16 @@ describe GRPC::ActiveCall do | |
| 355 336 | 
             
              end
         | 
| 356 337 |  | 
| 357 338 | 
             
              def expect_server_to_be_invoked(**kw)
         | 
| 358 | 
            -
                recvd_rpc =  @server.request_call | 
| 339 | 
            +
                recvd_rpc =  @server.request_call
         | 
| 359 340 | 
             
                expect(recvd_rpc).to_not eq nil
         | 
| 360 341 | 
             
                recvd_call = recvd_rpc.call
         | 
| 361 | 
            -
                recvd_call.run_batch( | 
| 362 | 
            -
             | 
| 363 | 
            -
             | 
| 364 | 
            -
                               @pass_through, deadline)
         | 
| 342 | 
            +
                recvd_call.run_batch(CallOps::SEND_INITIAL_METADATA => kw)
         | 
| 343 | 
            +
                ActiveCall.new(recvd_call, @pass_through, @pass_through, deadline,
         | 
| 344 | 
            +
                               metadata_received: true, started: true)
         | 
| 365 345 | 
             
              end
         | 
| 366 346 |  | 
| 367 347 | 
             
              def make_test_call
         | 
| 368 | 
            -
                @ch.create_call( | 
| 348 | 
            +
                @ch.create_call(nil, nil, '/method', nil, deadline)
         | 
| 369 349 | 
             
              end
         | 
| 370 350 |  | 
| 371 351 | 
             
              def deadline
         | 
| @@ -29,11 +29,14 @@ | |
| 29 29 |  | 
| 30 30 | 
             
            require 'grpc'
         | 
| 31 31 |  | 
| 32 | 
            +
            Thread.abort_on_exception = true
         | 
| 33 | 
            +
             | 
| 32 34 | 
             
            def wakey_thread(&blk)
         | 
| 33 35 | 
             
              n = GRPC::Notifier.new
         | 
| 34 36 | 
             
              t = Thread.new do
         | 
| 35 37 | 
             
                blk.call(n)
         | 
| 36 38 | 
             
              end
         | 
| 39 | 
            +
              t.abort_on_exception = true
         | 
| 37 40 | 
             
              n.wait
         | 
| 38 41 | 
             
              t
         | 
| 39 42 | 
             
            end
         | 
| @@ -54,15 +57,13 @@ describe 'ClientStub' do | |
| 54 57 | 
             
              before(:each) do
         | 
| 55 58 | 
             
                Thread.abort_on_exception = true
         | 
| 56 59 | 
             
                @server = nil
         | 
| 57 | 
            -
                @server_queue = nil
         | 
| 58 60 | 
             
                @method = 'an_rpc_method'
         | 
| 59 61 | 
             
                @pass = OK
         | 
| 60 62 | 
             
                @fail = INTERNAL
         | 
| 61 | 
            -
                @cq = GRPC::Core::CompletionQueue.new
         | 
| 62 63 | 
             
              end
         | 
| 63 64 |  | 
| 64 65 | 
             
              after(:each) do
         | 
| 65 | 
            -
                @server.close( | 
| 66 | 
            +
                @server.close(from_relative_time(2)) unless @server.nil?
         | 
| 66 67 | 
             
              end
         | 
| 67 68 |  | 
| 68 69 | 
             
              describe '#new' do
         | 
| @@ -70,7 +71,7 @@ describe 'ClientStub' do | |
| 70 71 | 
             
                it 'can be created from a host and args' do
         | 
| 71 72 | 
             
                  opts = { channel_args: { a_channel_arg: 'an_arg' } }
         | 
| 72 73 | 
             
                  blk = proc do
         | 
| 73 | 
            -
                    GRPC::ClientStub.new(fake_host,  | 
| 74 | 
            +
                    GRPC::ClientStub.new(fake_host, :this_channel_is_insecure, **opts)
         | 
| 74 75 | 
             
                  end
         | 
| 75 76 | 
             
                  expect(&blk).not_to raise_error
         | 
| 76 77 | 
             
                end
         | 
| @@ -81,7 +82,7 @@ describe 'ClientStub' do | |
| 81 82 | 
             
                    channel_override: @ch
         | 
| 82 83 | 
             
                  }
         | 
| 83 84 | 
             
                  blk = proc do
         | 
| 84 | 
            -
                    GRPC::ClientStub.new(fake_host,  | 
| 85 | 
            +
                    GRPC::ClientStub.new(fake_host, :this_channel_is_insecure, **opts)
         | 
| 85 86 | 
             
                  end
         | 
| 86 87 | 
             
                  expect(&blk).not_to raise_error
         | 
| 87 88 | 
             
                end
         | 
| @@ -92,7 +93,7 @@ describe 'ClientStub' do | |
| 92 93 | 
             
                      channel_args: { a_channel_arg: 'an_arg' },
         | 
| 93 94 | 
             
                      channel_override: Object.new
         | 
| 94 95 | 
             
                    }
         | 
| 95 | 
            -
                    GRPC::ClientStub.new(fake_host,  | 
| 96 | 
            +
                    GRPC::ClientStub.new(fake_host, :this_channel_is_insecure, **opts)
         | 
| 96 97 | 
             
                  end
         | 
| 97 98 | 
             
                  expect(&blk).to raise_error
         | 
| 98 99 | 
             
                end
         | 
| @@ -100,7 +101,7 @@ describe 'ClientStub' do | |
| 100 101 | 
             
                it 'cannot be created with bad credentials' do
         | 
| 101 102 | 
             
                  blk = proc do
         | 
| 102 103 | 
             
                    opts = { channel_args: { a_channel_arg: 'an_arg' } }
         | 
| 103 | 
            -
                    GRPC::ClientStub.new(fake_host,  | 
| 104 | 
            +
                    GRPC::ClientStub.new(fake_host, Object.new, **opts)
         | 
| 104 105 | 
             
                  end
         | 
| 105 106 | 
             
                  expect(&blk).to raise_error
         | 
| 106 107 | 
             
                end
         | 
| @@ -115,7 +116,7 @@ describe 'ClientStub' do | |
| 115 116 | 
             
                      }
         | 
| 116 117 | 
             
                    }
         | 
| 117 118 | 
             
                    creds = GRPC::Core::ChannelCredentials.new(certs[0], nil, nil)
         | 
| 118 | 
            -
                    GRPC::ClientStub.new(fake_host,  | 
| 119 | 
            +
                    GRPC::ClientStub.new(fake_host, creds,  **opts)
         | 
| 119 120 | 
             
                  end
         | 
| 120 121 | 
             
                  expect(&blk).to_not raise_error
         | 
| 121 122 | 
             
                end
         | 
| @@ -130,7 +131,7 @@ describe 'ClientStub' do | |
| 130 131 | 
             
                  it 'should send a request to/receive a reply from a server' do
         | 
| 131 132 | 
             
                    server_port = create_test_server
         | 
| 132 133 | 
             
                    th = run_request_response(@sent_msg, @resp, @pass)
         | 
| 133 | 
            -
                    stub = GRPC::ClientStub.new("localhost:#{server_port}", | 
| 134 | 
            +
                    stub = GRPC::ClientStub.new("localhost:#{server_port}",
         | 
| 134 135 | 
             
                                                :this_channel_is_insecure)
         | 
| 135 136 | 
             
                    expect(get_response(stub)).to eq(@resp)
         | 
| 136 137 | 
             
                    th.join
         | 
| @@ -141,7 +142,7 @@ describe 'ClientStub' do | |
| 141 142 | 
             
                    host = "localhost:#{server_port}"
         | 
| 142 143 | 
             
                    th = run_request_response(@sent_msg, @resp, @pass,
         | 
| 143 144 | 
             
                                              k1: 'v1', k2: 'v2')
         | 
| 144 | 
            -
                    stub = GRPC::ClientStub.new(host,  | 
| 145 | 
            +
                    stub = GRPC::ClientStub.new(host, :this_channel_is_insecure)
         | 
| 145 146 | 
             
                    expect(get_response(stub)).to eq(@resp)
         | 
| 146 147 | 
             
                    th.join
         | 
| 147 148 | 
             
                  end
         | 
| @@ -151,7 +152,7 @@ describe 'ClientStub' do | |
| 151 152 | 
             
                    alt_host = "localhost:#{server_port}"
         | 
| 152 153 | 
             
                    th = run_request_response(@sent_msg, @resp, @pass)
         | 
| 153 154 | 
             
                    ch = GRPC::Core::Channel.new(alt_host, nil, :this_channel_is_insecure)
         | 
| 154 | 
            -
                    stub = GRPC::ClientStub.new('ignored-host', | 
| 155 | 
            +
                    stub = GRPC::ClientStub.new('ignored-host',
         | 
| 155 156 | 
             
                                                :this_channel_is_insecure,
         | 
| 156 157 | 
             
                                                channel_override: ch)
         | 
| 157 158 | 
             
                    expect(get_response(stub)).to eq(@resp)
         | 
| @@ -162,7 +163,7 @@ describe 'ClientStub' do | |
| 162 163 | 
             
                    server_port = create_test_server
         | 
| 163 164 | 
             
                    host = "localhost:#{server_port}"
         | 
| 164 165 | 
             
                    th = run_request_response(@sent_msg, @resp, @fail)
         | 
| 165 | 
            -
                    stub = GRPC::ClientStub.new(host,  | 
| 166 | 
            +
                    stub = GRPC::ClientStub.new(host, :this_channel_is_insecure)
         | 
| 166 167 | 
             
                    blk = proc { get_response(stub) }
         | 
| 167 168 | 
             
                    expect(&blk).to raise_error(GRPC::BadStatus)
         | 
| 168 169 | 
             
                    th.join
         | 
| @@ -182,7 +183,8 @@ describe 'ClientStub' do | |
| 182 183 | 
             
                  def get_response(stub)
         | 
| 183 184 | 
             
                    op = stub.request_response(@method, @sent_msg, noop, noop,
         | 
| 184 185 | 
             
                                               return_op: true,
         | 
| 185 | 
            -
                                               metadata: { k1: 'v1', k2: 'v2' } | 
| 186 | 
            +
                                               metadata: { k1: 'v1', k2: 'v2' },
         | 
| 187 | 
            +
                                               deadline: from_relative_time(2))
         | 
| 186 188 | 
             
                    expect(op).to be_a(GRPC::ActiveCall::Operation)
         | 
| 187 189 | 
             
                    op.execute
         | 
| 188 190 | 
             
                  end
         | 
| @@ -196,7 +198,7 @@ describe 'ClientStub' do | |
| 196 198 | 
             
                  before(:each) do
         | 
| 197 199 | 
             
                    server_port = create_test_server
         | 
| 198 200 | 
             
                    host = "localhost:#{server_port}"
         | 
| 199 | 
            -
                    @stub = GRPC::ClientStub.new(host,  | 
| 201 | 
            +
                    @stub = GRPC::ClientStub.new(host, :this_channel_is_insecure)
         | 
| 200 202 | 
             
                    @metadata = { k1: 'v1', k2: 'v2' }
         | 
| 201 203 | 
             
                    @sent_msgs = Array.new(3) { |i| 'msg_' + (i + 1).to_s }
         | 
| 202 204 | 
             
                    @resp = 'a_reply'
         | 
| @@ -262,7 +264,7 @@ describe 'ClientStub' do | |
| 262 264 | 
             
                    server_port = create_test_server
         | 
| 263 265 | 
             
                    host = "localhost:#{server_port}"
         | 
| 264 266 | 
             
                    th = run_server_streamer(@sent_msg, @replys, @pass)
         | 
| 265 | 
            -
                    stub = GRPC::ClientStub.new(host,  | 
| 267 | 
            +
                    stub = GRPC::ClientStub.new(host, :this_channel_is_insecure)
         | 
| 266 268 | 
             
                    expect(get_responses(stub).collect { |r| r }).to eq(@replys)
         | 
| 267 269 | 
             
                    th.join
         | 
| 268 270 | 
             
                  end
         | 
| @@ -271,7 +273,7 @@ describe 'ClientStub' do | |
| 271 273 | 
             
                    server_port = create_test_server
         | 
| 272 274 | 
             
                    host = "localhost:#{server_port}"
         | 
| 273 275 | 
             
                    th = run_server_streamer(@sent_msg, @replys, @fail)
         | 
| 274 | 
            -
                    stub = GRPC::ClientStub.new(host,  | 
| 276 | 
            +
                    stub = GRPC::ClientStub.new(host, :this_channel_is_insecure)
         | 
| 275 277 | 
             
                    e = get_responses(stub)
         | 
| 276 278 | 
             
                    expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus)
         | 
| 277 279 | 
             
                    th.join
         | 
| @@ -282,7 +284,7 @@ describe 'ClientStub' do | |
| 282 284 | 
             
                    host = "localhost:#{server_port}"
         | 
| 283 285 | 
             
                    th = run_server_streamer(@sent_msg, @replys, @fail,
         | 
| 284 286 | 
             
                                             k1: 'v1', k2: 'v2')
         | 
| 285 | 
            -
                    stub = GRPC::ClientStub.new(host,  | 
| 287 | 
            +
                    stub = GRPC::ClientStub.new(host, :this_channel_is_insecure)
         | 
| 286 288 | 
             
                    e = get_responses(stub)
         | 
| 287 289 | 
             
                    expect { e.collect { |r| r } }.to raise_error(GRPC::BadStatus)
         | 
| 288 290 | 
             
                    th.join
         | 
| @@ -327,7 +329,7 @@ describe 'ClientStub' do | |
| 327 329 | 
             
                  it 'supports sending all the requests first', bidi: true do
         | 
| 328 330 | 
             
                    th = run_bidi_streamer_handle_inputs_first(@sent_msgs, @replys,
         | 
| 329 331 | 
             
                                                               @pass)
         | 
| 330 | 
            -
                    stub = GRPC::ClientStub.new(@host,  | 
| 332 | 
            +
                    stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
         | 
| 331 333 | 
             
                    e = get_responses(stub)
         | 
| 332 334 | 
             
                    expect(e.collect { |r| r }).to eq(@replys)
         | 
| 333 335 | 
             
                    th.join
         | 
| @@ -335,7 +337,7 @@ describe 'ClientStub' do | |
| 335 337 |  | 
| 336 338 | 
             
                  it 'supports client-initiated ping pong', bidi: true do
         | 
| 337 339 | 
             
                    th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, true)
         | 
| 338 | 
            -
                    stub = GRPC::ClientStub.new(@host,  | 
| 340 | 
            +
                    stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
         | 
| 339 341 | 
             
                    e = get_responses(stub)
         | 
| 340 342 | 
             
                    expect(e.collect { |r| r }).to eq(@sent_msgs)
         | 
| 341 343 | 
             
                    th.join
         | 
| @@ -343,7 +345,7 @@ describe 'ClientStub' do | |
| 343 345 |  | 
| 344 346 | 
             
                  it 'supports a server-initiated ping pong', bidi: true do
         | 
| 345 347 | 
             
                    th = run_bidi_streamer_echo_ping_pong(@sent_msgs, @pass, false)
         | 
| 346 | 
            -
                    stub = GRPC::ClientStub.new(@host,  | 
| 348 | 
            +
                    stub = GRPC::ClientStub.new(@host, :this_channel_is_insecure)
         | 
| 347 349 | 
             
                    e = get_responses(stub)
         | 
| 348 350 | 
             
                    expect(e.collect { |r| r }).to eq(@sent_msgs)
         | 
| 349 351 | 
             
                    th.join
         | 
| @@ -372,26 +374,6 @@ describe 'ClientStub' do | |
| 372 374 |  | 
| 373 375 | 
             
                  it_behaves_like 'bidi streaming'
         | 
| 374 376 | 
             
                end
         | 
| 375 | 
            -
             | 
| 376 | 
            -
                describe 'without enough time to run' do
         | 
| 377 | 
            -
                  before(:each) do
         | 
| 378 | 
            -
                    @sent_msgs = Array.new(3) { |i| 'msg_' + (i + 1).to_s }
         | 
| 379 | 
            -
                    @replys = Array.new(3) { |i| 'reply_' + (i + 1).to_s }
         | 
| 380 | 
            -
                    server_port = create_test_server
         | 
| 381 | 
            -
                    @host = "localhost:#{server_port}"
         | 
| 382 | 
            -
                  end
         | 
| 383 | 
            -
             | 
| 384 | 
            -
                  it 'should fail with DeadlineExceeded', bidi: true do
         | 
| 385 | 
            -
                    @server.start
         | 
| 386 | 
            -
                    stub = GRPC::ClientStub.new(@host, @cq, :this_channel_is_insecure)
         | 
| 387 | 
            -
                    blk = proc do
         | 
| 388 | 
            -
                      e = stub.bidi_streamer(@method, @sent_msgs, noop, noop,
         | 
| 389 | 
            -
                                             deadline: from_relative_time(0.001))
         | 
| 390 | 
            -
                      e.collect { |r| r }
         | 
| 391 | 
            -
                    end
         | 
| 392 | 
            -
                    expect(&blk).to raise_error GRPC::BadStatus, /Deadline Exceeded/
         | 
| 393 | 
            -
                  end
         | 
| 394 | 
            -
                end
         | 
| 395 377 | 
             
              end
         | 
| 396 378 |  | 
| 397 379 | 
             
              def run_server_streamer(expected_input, replys, status, **kw)
         | 
| @@ -460,21 +442,18 @@ describe 'ClientStub' do | |
| 460 442 | 
             
              end
         | 
| 461 443 |  | 
| 462 444 | 
             
              def create_test_server
         | 
| 463 | 
            -
                @ | 
| 464 | 
            -
                @server = GRPC::Core::Server.new(@server_queue, nil)
         | 
| 445 | 
            +
                @server = GRPC::Core::Server.new(nil)
         | 
| 465 446 | 
             
                @server.add_http2_port('0.0.0.0:0', :this_port_is_insecure)
         | 
| 466 447 | 
             
              end
         | 
| 467 448 |  | 
| 468 449 | 
             
              def expect_server_to_be_invoked(notifier)
         | 
| 469 450 | 
             
                @server.start
         | 
| 470 451 | 
             
                notifier.notify(nil)
         | 
| 471 | 
            -
                 | 
| 472 | 
            -
                recvd_rpc = @server.request_call(@server_queue, server_tag,
         | 
| 473 | 
            -
                                                 INFINITE_FUTURE)
         | 
| 452 | 
            +
                recvd_rpc = @server.request_call
         | 
| 474 453 | 
             
                recvd_call = recvd_rpc.call
         | 
| 475 454 | 
             
                recvd_call.metadata = recvd_rpc.metadata
         | 
| 476 | 
            -
                recvd_call.run_batch( | 
| 477 | 
            -
             | 
| 478 | 
            -
             | 
| 455 | 
            +
                recvd_call.run_batch(SEND_INITIAL_METADATA => nil)
         | 
| 456 | 
            +
                GRPC::ActiveCall.new(recvd_call, noop, noop, INFINITE_FUTURE,
         | 
| 457 | 
            +
                                     metadata_received: true)
         | 
| 479 458 | 
             
              end
         | 
| 480 459 | 
             
            end
         |