micro/examples/grpc_client.go

25 lines
529 B
Go
Raw Normal View History

2015-05-16 02:33:43 +03:00
package main
import (
"fmt"
h "github.com/grpc/grpc-common/go/helloworld"
"github.com/myodc/go-micro/client"
2015-05-23 13:53:40 +03:00
"golang.org/x/net/context"
2015-05-16 02:33:43 +03:00
)
// run github.com/grpc/grpc-common/go/greeter_server/main.go
func main() {
2015-05-23 13:53:40 +03:00
req := client.NewRpcRequest("helloworld.Greeter", "helloworld.Greeter/SayHello", &h.HelloRequest{
2015-05-16 02:33:43 +03:00
Name: "John",
}, "application/grpc")
rsp := &h.HelloReply{}
2015-05-23 13:53:40 +03:00
err := client.CallRemote(context.Background(), "localhost:50051", req, rsp)
2015-05-16 02:33:43 +03:00
if err != nil {
fmt.Println(err)
}
fmt.Println(rsp.Message)
}