Skip to content

Commit

Permalink
Merge pull request grpc#1080 from tbetbetbe/grpc_ruby_add_back_server…
Browse files Browse the repository at this point in the history
…_finish_calls

Adds back calls to #finish at the end of server calls
  • Loading branch information
murgatroid99 committed Mar 18, 2015
2 parents 6c398b3 + e52995e commit 0e93c92
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/ruby/lib/grpc/generic/rpc_desc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def run_server_method(active_call, mth)
active_call.run_server_bidi(mth)
end
send_status(active_call, OK, 'OK')
active_call.finished
rescue BadStatus => e
# this is raised by handlers that want GRPC to send an application
# error code and detail message.
Expand Down
10 changes: 5 additions & 5 deletions src/ruby/spec/generic/client_stub_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def run_server_streamer(expected_input, replys, status, **kw)
end
expect(c.remote_read).to eq(expected_input)
replys.each { |r| c.remote_send(r) }
c.send_status(status, status == @pass ? 'OK' : 'NOK')
c.send_status(status, status == @pass ? 'OK' : 'NOK', true)
end
end

Expand All @@ -444,7 +444,7 @@ def run_bidi_streamer_handle_inputs_first(expected_inputs, replys,
c = expect_server_to_be_invoked(mtx, cnd)
expected_inputs.each { |i| expect(c.remote_read).to eq(i) }
replys.each { |r| c.remote_send(r) }
c.send_status(status, status == @pass ? 'OK' : 'NOK')
c.send_status(status, status == @pass ? 'OK' : 'NOK', true)
end
end

Expand All @@ -460,7 +460,7 @@ def run_bidi_streamer_echo_ping_pong(expected_inputs, status, client_starts)
expect(c.remote_read).to eq(i)
end
end
c.send_status(status, status == @pass ? 'OK' : 'NOK')
c.send_status(status, status == @pass ? 'OK' : 'NOK', true)
end
end

Expand All @@ -473,7 +473,7 @@ def run_client_streamer(expected_inputs, resp, status, **kw)
expect(c.metadata[k.to_s]).to eq(v)
end
c.remote_send(resp)
c.send_status(status, status == @pass ? 'OK' : 'NOK')
c.send_status(status, status == @pass ? 'OK' : 'NOK', true)
end
end

Expand All @@ -486,7 +486,7 @@ def run_request_response(expected_input, resp, status, **kw)
expect(c.metadata[k.to_s]).to eq(v)
end
c.remote_send(resp)
c.send_status(status, status == @pass ? 'OK' : 'NOK')
c.send_status(status, status == @pass ? 'OK' : 'NOK', true)
end
end

Expand Down
4 changes: 4 additions & 0 deletions src/ruby/spec/generic/rpc_desc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
expect(@call).to receive(:remote_read).once.and_return(req)
expect(@call).to receive(:remote_send).once.with(@ok_response)
expect(@call).to receive(:send_status).once.with(OK, 'OK')
expect(@call).to receive(:finished).once
@request_response.run_server_method(@call, method(:fake_reqresp))
end
end
Expand Down Expand Up @@ -134,6 +135,7 @@
it 'sends a response and closes the stream if there no errors' do
expect(@call).to receive(:remote_send).once.with(@ok_response)
expect(@call).to receive(:send_status).once.with(OK, 'OK')
expect(@call).to receive(:finished).once
@client_streamer.run_server_method(@call, method(:fake_clstream))
end
end
Expand Down Expand Up @@ -178,6 +180,7 @@
expect(@call).to receive(:remote_read).once.and_return(req)
expect(@call).to receive(:remote_send).twice.with(@ok_response)
expect(@call).to receive(:send_status).once.with(OK, 'OK')
expect(@call).to receive(:finished).once
@server_streamer.run_server_method(@call, method(:fake_svstream))
end
end
Expand Down Expand Up @@ -207,6 +210,7 @@
it 'closes the stream if there no errors' do
expect(@call).to receive(:run_server_bidi)
expect(@call).to receive(:send_status).once.with(OK, 'OK')
expect(@call).to receive(:finished).once
@bidi_streamer.run_server_method(@call, method(:fake_bidistream))
end
end
Expand Down

0 comments on commit 0e93c92

Please sign in to comment.