12345678910111213141516171819202122232425 |
- package main
- import (
- "../service"
- "context"
- client2 "github.com/smallnest/rpcx/client"
- "log"
- )
- const ADDRESS string = "tcp@localhost:10001"
- func main() {
- d := client2.NewPeer2PeerDiscovery(ADDRESS, "")
- c := client2.NewXClient("Format", client2.Failtry, client2.RandomSelect, d, client2.DefaultOption)
- defer func(c client2.XClient) {
- _ = c.Close()
- }(c)
- replay := &service.Replay{}
- err := c.Call(context.Background(), "DoFormat", &service.Args{Text: "Hello world!"}, replay)
- if err != nil {
- log.Fatalf("failed to call: %v", err)
- }
- log.Println(replay.Text)
- }
|