1 Star 0 Fork 0

yonglinux / rpcx-sun-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
client.go 863 Bytes
一键复制 编辑 原始数据 按行查看 历史
root 提交于 2022-02-17 17:49 . update
package main
import (
"context"
"flag"
"log"
"time"
example "github.com/rpcxio/rpcx-examples"
"github.com/smallnest/rpcx/client"
)
var (
redisAddr = flag.String("redisAddr", "localhost:6379", "redis address")
basePath = flag.String("base", "/rpcx_test", "prefix path")
)
func main() {
flag.Parse()
d, _ := client.NewRedisDiscovery(*basePath, "Arith", []string{*redisAddr}, nil)
xclient := client.NewXClient("Arith", client.Failover, client.RoundRobin, d, client.DefaultOption)
defer xclient.Close()
args := &example.Args{
A: 10,
B: 20,
}
for {
reply := &example.Reply{}
err := xclient.Call(context.Background(), "Mul", args, reply)
if err != nil {
log.Printf("failed to call: %v\n", err)
time.Sleep(5 * time.Second)
continue
}
log.Printf("%d * %d = %d", args.A, args.B, reply.C)
time.Sleep(5 * time.Second)
}
}
1
https://gitee.com/yonglinux/rpcx-sun-examples.git
git@gitee.com:yonglinux/rpcx-sun-examples.git
yonglinux
rpcx-sun-examples
rpcx-sun-examples
v1.1.8

搜索帮助