update client

This commit is contained in:
Asim 2016-01-02 23:15:57 +00:00
parent 3df078ce4e
commit b11e5789fe

View File

@ -5,7 +5,7 @@ import (
"os" "os"
"github.com/micro/cli" "github.com/micro/cli"
micro "github.com/micro/go-micro" "github.com/micro/go-micro"
proto "github.com/micro/go-micro/examples/service/proto" proto "github.com/micro/go-micro/examples/service/proto"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -24,7 +24,7 @@ func (g *Greeter) Hello(ctx context.Context, req *proto.HelloRequest, rsp *proto
} }
// Setup and the client // Setup and the client
func client(service micro.Service) { func runClient(service micro.Service) {
// Create new greeter client // Create new greeter client
greeter := proto.NewGreeterClient("greeter", service.Client()) greeter := proto.NewGreeterClient("greeter", service.Client())
@ -32,6 +32,7 @@ func client(service micro.Service) {
rsp, err := greeter.Hello(context.TODO(), &proto.HelloRequest{Name: "John"}) rsp, err := greeter.Hello(context.TODO(), &proto.HelloRequest{Name: "John"})
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return
} }
// Print response // Print response
@ -65,7 +66,7 @@ func main() {
// We could actually do this above // We could actually do this above
micro.Action(func(c *cli.Context) { micro.Action(func(c *cli.Context) {
if c.Bool("client") { if c.Bool("client") {
client(service) runClient(service)
os.Exit(0) os.Exit(0)
} }
}), }),