Add grpc client and example
This commit is contained in:
23
examples/grpc_client.go
Normal file
23
examples/grpc_client.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
h "github.com/grpc/grpc-common/go/helloworld"
|
||||
"github.com/myodc/go-micro/client"
|
||||
)
|
||||
|
||||
// run github.com/grpc/grpc-common/go/greeter_server/main.go
|
||||
func main() {
|
||||
req := client.NewRpcRequest("helloworld.Greeter", "SayHello", &h.HelloRequest{
|
||||
Name: "John",
|
||||
}, "application/grpc")
|
||||
|
||||
rsp := &h.HelloReply{}
|
||||
err := client.CallRemote("localhost:50051", "helloworld.Greeter/SayHello", req, rsp)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
fmt.Println(rsp.Message)
|
||||
}
|
Reference in New Issue
Block a user