Skip to content

Instantly share code, notes, and snippets.

@FranGM
Created June 28, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FranGM/b22704e11d39e5f634ba5098131cd6d5 to your computer and use it in GitHub Desktop.
Save FranGM/b22704e11d39e5f634ba5098131cd6d5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Copyright 2015 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Sample app that connects to a Greeter service.
#
# Usage: $ path/to/greeter_client.rb
this_dir = File.expand_path(File.dirname(__FILE__))
lib_dir = File.join(this_dir, 'lib')
$LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
require 'grpc'
require 'helloworld_services_pb'
def main
user = 'aaaaaaaaaaaaa' * 2000
while true do
begin
start_time = Time.now
stub = Helloworld::Greeter::Stub.new('my.host.name:6106', :this_channel_is_insecure, timeout: 0.3)
message = stub.say_hello(Helloworld::HelloRequest.new(name: user)).message
rescue GRPC::DeadlineExceeded
duration = Time.now - start_time
p "Timed out after #{duration} seconds", $!
end
p "Greetings"
sleep(0.1)
end
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment