1 Star 0 Fork 0

mosache / go-zero

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
client.go 761 Bytes
一键复制 编辑 原始数据 按行查看 历史
kevwan 提交于 2020-09-18 11:41 . rename rpcx to zrpc
package main
import (
"context"
"flag"
"fmt"
"time"
"github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/example/rpc/remote/unary"
"github.com/tal-tech/go-zero/zrpc"
)
var configFile = flag.String("f", "config.json", "the config file")
func main() {
flag.Parse()
var c zrpc.RpcClientConf
conf.MustLoad(*configFile, &c)
client := zrpc.MustNewClient(c)
ticker := time.NewTicker(time.Millisecond * 500)
defer ticker.Stop()
for {
select {
case <-ticker.C:
conn := client.Conn()
greet := unary.NewGreeterClient(conn)
resp, err := greet.Greet(context.Background(), &unary.Request{
Name: "kevin",
})
if err != nil {
fmt.Println("X", err.Error())
} else {
fmt.Println("=>", resp.Greet)
}
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mosache/go-zero.git
git@gitee.com:mosache/go-zero.git
mosache
go-zero
go-zero
dfb45c801a6c

搜索帮助