aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/bin
diff options
context:
space:
mode:
authorGravatar Tim Emiola <temiola@google.com>2015-08-28 16:57:28 -0700
committerGravatar Tim Emiola <temiola@google.com>2015-08-28 17:11:11 -0700
commit81d950a5a91d863547761bcf5647ae8ebfc72722 (patch)
tree635cc4abca574b9606fd9d6cc1a0e3aef02220b8 /src/ruby/bin
parent036bf58b281e4ff65ccc62ea68002a50ddb626cc (diff)
Updates server shutdown handling
- ensures that servers cancels calls after the shutdown timeout - uses an infinite timeout when request server calls This two changes fix the issue where the server segfaults on shutdown.
Diffstat (limited to 'src/ruby/bin')
-rwxr-xr-xsrc/ruby/bin/math_client.rb6
-rwxr-xr-xsrc/ruby/bin/math_server.rb16
2 files changed, 19 insertions, 3 deletions
diff --git a/src/ruby/bin/math_client.rb b/src/ruby/bin/math_client.rb
index 6319cda309..0ebd26f780 100755
--- a/src/ruby/bin/math_client.rb
+++ b/src/ruby/bin/math_client.rb
@@ -50,7 +50,7 @@ def do_div(stub)
GRPC.logger.info('----------------')
req = Math::DivArgs.new(dividend: 7, divisor: 3)
GRPC.logger.info("div(7/3): req=#{req.inspect}")
- resp = stub.div(req, INFINITE_FUTURE)
+ resp = stub.div(req, timeout: INFINITE_FUTURE)
GRPC.logger.info("Answer: #{resp.inspect}")
GRPC.logger.info('----------------')
end
@@ -71,7 +71,7 @@ def do_fib(stub)
GRPC.logger.info('----------------')
req = Math::FibArgs.new(limit: 11)
GRPC.logger.info("fib(11): req=#{req.inspect}")
- resp = stub.fib(req, INFINITE_FUTURE)
+ resp = stub.fib(req, timeout: INFINITE_FUTURE)
resp.each do |r|
GRPC.logger.info("Answer: #{r.inspect}")
end
@@ -86,7 +86,7 @@ def do_div_many(stub)
reqs << Math::DivArgs.new(dividend: 5, divisor: 2)
reqs << Math::DivArgs.new(dividend: 7, divisor: 2)
GRPC.logger.info("div(7/3), div(5/2), div(7/2): reqs=#{reqs.inspect}")
- resp = stub.div_many(reqs, 10)
+ resp = stub.div_many(reqs, timeout: INFINITE_FUTURE)
resp.each do |r|
GRPC.logger.info("Answer: #{r.inspect}")
end
diff --git a/src/ruby/bin/math_server.rb b/src/ruby/bin/math_server.rb
index b41ccf6ce1..9a921b13d6 100755
--- a/src/ruby/bin/math_server.rb
+++ b/src/ruby/bin/math_server.rb
@@ -41,9 +41,25 @@ $LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir)
require 'forwardable'
require 'grpc'
+require 'logger'
require 'math_services'
require 'optparse'
+# RubyLogger defines a logger for gRPC based on the standard ruby logger.
+module RubyLogger
+ def logger
+ LOGGER
+ end
+
+ LOGGER = Logger.new(STDOUT)
+end
+
+# GRPC is the general RPC module
+module GRPC
+ # Inject the noop #logger if no module-level logger method has been injected.
+ extend RubyLogger
+end
+
# Holds state for a fibonacci series
class Fibber
def initialize(limit)