aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar apolcyn <apolcyn@google.com>2018-05-17 21:07:22 -0700
committerGravatar GitHub <noreply@github.com>2018-05-17 21:07:22 -0700
commitbdbf04cde1f429787c41013071dea12c6ab2088e (patch)
tree98435444227195ad3d0beddf6989b7d58b53c58a /src/ruby
parent654ecedd0309740b16b53861ae3c24eecd55c55a (diff)
parentad4312aaa9af13addefdcda24432396b3b083c5e (diff)
Merge pull request #15354 from ganmacs/fix-math_client
Fix math client
Diffstat (limited to 'src/ruby')
-rwxr-xr-xsrc/ruby/bin/math_client.rb26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/ruby/bin/math_client.rb b/src/ruby/bin/math_client.rb
index 15120c0c0d..66717d8bf3 100755
--- a/src/ruby/bin/math_client.rb
+++ b/src/ruby/bin/math_client.rb
@@ -27,15 +27,26 @@ $LOAD_PATH.unshift(this_dir) unless $LOAD_PATH.include?(this_dir)
require 'grpc'
require 'math_services_pb'
require 'optparse'
+require 'logger'
include GRPC::Core::TimeConsts
+module StdoutLogger
+ def logger
+ LOGGER
+ end
+
+ LOGGER = Logger.new(STDOUT)
+end
+
+GRPC.extend(StdoutLogger)
+
def do_div(stub)
GRPC.logger.info('request_response')
GRPC.logger.info('----------------')
req = Math::DivArgs.new(dividend: 7, divisor: 3)
GRPC.logger.info("div(7/3): req=#{req.inspect}")
- resp = stub.div(req, timeout: INFINITE_FUTURE)
+ resp = stub.div(req)
GRPC.logger.info("Answer: #{resp.inspect}")
GRPC.logger.info('----------------')
end
@@ -56,7 +67,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, timeout: INFINITE_FUTURE)
+ resp = stub.fib(req)
resp.each do |r|
GRPC.logger.info("Answer: #{r.inspect}")
end
@@ -71,7 +82,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, timeout: INFINITE_FUTURE)
+ resp = stub.div_many(reqs)
resp.each do |r|
GRPC.logger.info("Answer: #{r.inspect}")
end
@@ -107,19 +118,16 @@ def main
# The Math::Math:: module occurs because the service has the same name as its
# package. That practice should be avoided by defining real services.
-
- p options
if options['secure']
stub_opts = {
:creds => test_creds,
- GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr'
+ GRPC::Core::Channel::SSL_TARGET => 'foo.test.google.fr',
+ timeout: INFINITE_FUTURE,
}
- p stub_opts
- p options['host']
stub = Math::Math::Stub.new(options['host'], **stub_opts)
GRPC.logger.info("... connecting securely on #{options['host']}")
else
- stub = Math::Math::Stub.new(options['host'])
+ stub = Math::Math::Stub.new(options['host'], :this_channel_is_insecure, timeout: INFINITE_FUTURE)
GRPC.logger.info("... connecting insecurely on #{options['host']}")
end