项目中有 ruby 和 golang,导致两者直接的代码需要相互调用。我们大部分的代码使用的 http 的 rest,但是感觉不太自然。 参加 GOPHER 大会后,看到很多人使用 GRPC。看了文档后感觉有点复杂,我们项目简单,人员少。暂时没有必要用,我们暂时选择了相对简单的 hprose。
Gemfile 中
gem "hprose"
gem "uuidtools"
调用
require 'hprose'
client = HproseClient.new('http://127.0.0.1:8080/rpc')
client.hello('World') { |result|
  puts result
}.join
import "github.com/hprose/hprose-golang/rpc"
func init(){ 
    service := rpc.NewHTTPService() 
    service.AddFunction("hello", hello) 
    beego.Handler("/rpc", service) 
} 
func hello(name string) string { 
    return "Hello " + name + "!" 
}
以上主要想记录一下现在的想法,😄