go-zero/example/bookstore/rpc/add/add.go

39 lines
827 B
Go
Raw Normal View History

2020-09-03 23:26:04 +08:00
// Code generated by goctl. DO NOT EDIT!
// Source: add.proto
package main
import (
2020-09-16 13:27:16 +08:00
"flag"
"fmt"
2020-09-03 23:26:04 +08:00
"bookstore/rpc/add/internal/config"
"bookstore/rpc/add/internal/server"
"bookstore/rpc/add/internal/svc"
add "bookstore/rpc/add/pb"
"github.com/tal-tech/go-zero/core/conf"
2020-09-16 13:27:16 +08:00
"github.com/tal-tech/go-zero/core/logx"
2020-09-03 23:26:04 +08:00
"github.com/tal-tech/go-zero/rpcx"
"google.golang.org/grpc"
)
var configFile = flag.String("f", "etc/add.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
adderSrv := server.NewAdderServer(ctx)
s, err := rpcx.NewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
add.RegisterAdderServer(grpcServer, adderSrv)
})
2020-09-16 13:27:16 +08:00
logx.Must(err)
2020-09-03 23:26:04 +08:00
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}