Using etcd discovery with go-grpc
addsvc.go
func main() {
svc := ace.NewService(
ace.Name("hello"),
ace.EtcdUrls([]string{"localhost:2379"}),
ace.RegisterServiceFn(func(s *server.Server) {
pb.RegisterAddServer(s, &service.AddSvc{})
pb.RegisterHelloWorldServiceServer(s, &service.HelloSvc{})
}),
)
svc.Run()
}
addcli.go
func main() {
ctx := context.Background()
conn, err := ace.Dial(ctx, "hello", []string{"localhost:2379"})
if err != nil {
panic(err)
}
defer conn.Close()
var a, b int64 = 2, 3
addClient := pb.NewAddClient(conn)
sumReply, err := addClient.Sum(ctx, &pb.SumRequest{A: a, B: b})
if err != nil {
fmt.Println("err", err)
return
}
fmt.Printf("%d + %d = %d\n", a, b, sumReply.V)
}
go.etcd.io/etcd/client/[email protected]/naming/resolver/resolver.go:22:11: cannot use target.Endpoint (value of type func() string) as type string in struct literal
replace google.golang.org/grpc => google.golang.org/grpc v1.52.3