Further consolidate the libraries
This commit is contained in:
40
service/grpc/examples/greeter/client/main.go
Normal file
40
service/grpc/examples/greeter/client/main.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/micro/cli"
|
||||
"github.com/micro/go-micro"
|
||||
"github.com/micro/go-micro/service/grpc"
|
||||
hello "github.com/micro/go-micro/service/grpc/examples/greeter/server/proto/hello"
|
||||
)
|
||||
|
||||
var (
|
||||
// service to call
|
||||
serviceName string
|
||||
)
|
||||
|
||||
func main() {
|
||||
service := grpc.NewService()
|
||||
|
||||
service.Init(
|
||||
micro.Flags(cli.StringFlag{
|
||||
Name: "service_name",
|
||||
Value: "go.micro.srv.greeter",
|
||||
Destination: &serviceName,
|
||||
}),
|
||||
)
|
||||
|
||||
cl := hello.NewSayService(serviceName, service.Client())
|
||||
|
||||
rsp, err := cl.Hello(context.TODO(), &hello.Request{
|
||||
Name: "John",
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(rsp.Msg)
|
||||
}
|
Reference in New Issue
Block a user