1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-01-23 17:53:05 +02:00
go-micro/examples/proxy/ruby/rpc_server.rb
2020-12-26 15:17:20 +00:00

31 lines
570 B
Ruby

require './proxy'
require 'rjr/nodes/web'
$service = {
"name" => "go.micro.srv.greeter",
"nodes" => [{
"id" => "go.micro.srv.greeter-" + SecureRandom.uuid,
"address" => "localhost",
"port" => 4000
}]
}
trap 'INT' do
deregister($service)
exit
end
# create server
server = RJR::Nodes::Web.new :node_id => 'server', :host => 'localhost', :port => 4000
# serve method Say.Hello
server.dispatcher.handle("Say.Hello") { |args|
"Hello #{args['name']}!"
}
# register service
register($service)
# start the server and block
server.listen
server.join