Skip to content
Snippets Groups Projects
Commit 879a8f3b authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

Merge pull request #6079 from murgatroid99/ruby_status_code_conformity

Make ruby library conform to status code spec
parents 1b7c0a2c 895c1113
No related branches found
No related tags found
No related merge requests found
...@@ -403,7 +403,7 @@ module GRPC ...@@ -403,7 +403,7 @@ module GRPC
loop_handle_server_calls loop_handle_server_calls
end end
# Sends UNAVAILABLE if there are too many unprocessed jobs # Sends RESOURCE_EXHAUSTED if there are too many unprocessed jobs
def available?(an_rpc) def available?(an_rpc)
jobs_count, max = @pool.jobs_waiting, @max_waiting_requests jobs_count, max = @pool.jobs_waiting, @max_waiting_requests
GRPC.logger.info("waiting: #{jobs_count}, max: #{max}") GRPC.logger.info("waiting: #{jobs_count}, max: #{max}")
...@@ -411,7 +411,7 @@ module GRPC ...@@ -411,7 +411,7 @@ module GRPC
GRPC.logger.warn("NOT AVAILABLE: too many jobs_waiting: #{an_rpc}") GRPC.logger.warn("NOT AVAILABLE: too many jobs_waiting: #{an_rpc}")
noop = proc { |x| x } noop = proc { |x| x }
c = ActiveCall.new(an_rpc.call, @cq, noop, noop, an_rpc.deadline) c = ActiveCall.new(an_rpc.call, @cq, noop, noop, an_rpc.deadline)
c.send_status(StatusCodes::UNAVAILABLE, '') c.send_status(StatusCodes::RESOURCE_EXHAUSTED, '')
nil nil
end end
......
...@@ -426,7 +426,7 @@ describe GRPC::RpcServer do ...@@ -426,7 +426,7 @@ describe GRPC::RpcServer do
threads.each(&:join) threads.each(&:join)
end end
it 'should return UNAVAILABLE on too many jobs', server: true do it 'should return RESOURCE_EXHAUSTED on too many jobs', server: true do
opts = { opts = {
a_channel_arg: 'an_arg', a_channel_arg: 'an_arg',
server_override: @server, server_override: @server,
...@@ -449,7 +449,8 @@ describe GRPC::RpcServer do ...@@ -449,7 +449,8 @@ describe GRPC::RpcServer do
begin begin
stub.an_rpc(req) stub.an_rpc(req)
rescue GRPC::BadStatus => e rescue GRPC::BadStatus => e
one_failed_as_unavailable = e.code == StatusCodes::UNAVAILABLE one_failed_as_unavailable =
e.code == StatusCodes::RESOURCE_EXHAUSTED
end end
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment