14 Star 51 Fork 12

Hprose / hprose-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
unix_hello_client.go 790 Bytes
一键复制 编辑 原始数据 按行查看 历史
Hprose 提交于 2016-10-31 21:45 . Update to hprose 2.0
package main
import (
"fmt"
"sync/atomic"
"time"
"github.com/hprose/hprose-golang/rpc"
)
// Stub is ...
type Stub struct {
Hello func(string) (string, error)
AsyncHello func(func(string, error), string) `name:"hello"`
}
func main() {
client := rpc.NewClient("unix:/tmp/my.sock")
var stub *Stub
client.UseService(&stub)
stub.AsyncHello(func(result string, err error) {
fmt.Println(result, err)
}, "async world")
fmt.Println(stub.Hello("world"))
start := time.Now()
var n int32 = 500000
done := make(chan bool)
for i := 0; i < 500000; i++ {
stub.AsyncHello(func(result string, err error) {
if atomic.AddInt32(&n, -1) == 0 {
done <- true
}
}, "async world")
}
<-done
stop := time.Now()
fmt.Println((stop.UnixNano() - start.UnixNano()) / 1000000)
}
Go
1
https://gitee.com/andot/hprose-go.git
git@gitee.com:andot/hprose-go.git
andot
hprose-go
hprose-go
v2.0.4

搜索帮助