Ai
1 Star 0 Fork 0

yonglinux/rpcx-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
client.go 762 Bytes
一键复制 编辑 原始数据 按行查看 历史
鸟窝 提交于 2018-04-25 21:35 +08:00 . add compress example
package main
import (
"context"
"flag"
"log"
"strings"
"time"
"github.com/smallnest/rpcx/client"
"github.com/smallnest/rpcx/protocol"
)
var (
addr = flag.String("addr", "localhost:8972", "server address")
)
func main() {
flag.Parse()
d := client.NewPeer2PeerDiscovery("tcp@"+*addr, "")
option := client.DefaultOption
option.CompressType = protocol.Gzip
xclient := client.NewXClient("Arith", client.Failtry, client.RandomSelect, d, option)
defer xclient.Close()
args := strings.Repeat("world", 2048)
for {
var reply string
err := xclient.Call(context.Background(), "Say", args, &reply)
if err != nil {
log.Fatalf("failed to call: %v", err)
}
log.Printf("replay = (len: %d) %s", len(reply), reply[:20])
time.Sleep(1e9)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yonglinux/rpcx-examples.git
git@gitee.com:yonglinux/rpcx-examples.git
yonglinux
rpcx-examples
rpcx-examples
v1.1.6

搜索帮助