Created
November 10, 2015 14:29
-
-
Save asim/80aae1ee40e98a173bcf to your computer and use it in GitHub Desktop.
GRPC example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
h "github.com/grpc/grpc-common/go/helloworld" | |
"github.com/myodc/go-micro/client" | |
"golang.org/x/net/context" | |
) | |
// run github.com/grpc/grpc-common/go/greeter_server/main.go | |
func main() { | |
req := client.NewRpcRequest("helloworld.Greeter", "helloworld.Greeter/SayHello", &h.HelloRequest{ | |
Name: "John", | |
}, "application/grpc") | |
rsp := &h.HelloReply{} | |
err := client.CallRemote(context.Background(), "localhost:50051", req, rsp) | |
if err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(rsp.Message) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment