1 Star 0 Fork 0

yonglinux / rpcx-sun-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
client.go 671 Bytes
一键复制 编辑 原始数据 按行查看 历史
root 提交于 2022-02-17 17:49 . update
package main
import (
"context"
"flag"
"log"
"os"
"github.com/smallnest/rpcx/client"
"github.com/smallnest/rpcx/share"
)
var (
addr = flag.String("addr", "localhost:8972", "server address")
)
func main() {
flag.Parse()
d, _ := client.NewPeer2PeerDiscovery("tcp@"+*addr, "")
xclient := client.NewXClient(share.SendFileServiceName, client.Failtry, client.RandomSelect, d, client.DefaultOption)
defer xclient.Close()
f, err := os.Create("abc.txt")
if err != nil {
panic(err)
}
defer f.Close()
err = xclient.DownloadFile(context.Background(), "abc.txt", f, map[string]string{"foo": "bar"})
if err != nil {
panic(err)
}
log.Println("received")
}
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

搜索帮助