forked from go-chassis/go-chassis
/
main.go
27 lines (25 loc) · 877 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package main
import (
"github.com/ServiceComb/go-chassis"
_ "github.com/ServiceComb/go-chassis/bootstrap"
"github.com/ServiceComb/go-chassis/core"
"github.com/ServiceComb/go-chassis/core/lager"
"github.com/ServiceComb/go-chassis/examples/schemas/helloworld"
"golang.org/x/net/context"
)
//if you use go run main.go instead of binary run, plz export CHASSIS_HOME=/path/to/conf/folder
func main() {
//Init framework
if err := chassis.Init(); err != nil {
lager.Logger.Error("Init failed.", err)
return
}
//declare reply struct
reply := &helloworld.HelloReply{}
//Invoke with microservice name, schema ID and operation ID
if err := core.NewRPCInvoker().Invoke(context.Background(), "RPCServer", "HelloService", "SayHello",
&helloworld.HelloRequest{Name: "Peter"}, reply); err != nil {
lager.Logger.Error("error", err)
}
lager.Logger.Info(reply.Message)
}