Skip to content

Instantly share code, notes, and snippets.

@marshallbrekka
Created May 10, 2017 17:24
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 marshallbrekka/382e18317df71801b06e003ac227b79a to your computer and use it in GitHub Desktop.
Save marshallbrekka/382e18317df71801b06e003ac227b79a to your computer and use it in GitHub Desktop.
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