Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
sleep(15)
stub = Helloworld::Greeter::Stub.new(ENV["GRPC_TARGET"] || 'localhost:50051', :this_channel_is_insecure)
message = stub.say_hello(Helloworld::HelloRequest.new(name: "username"), {metadata: {"foo":"bar"}}).message
puts "Greeting: #{message}"
sleep(15)
message = stub.say_hello(Helloworld::HelloRequest.new(name: "username"), {metadata: {"foo":"bar"}}).message
puts "Greeting: #{message}"
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.