feat: reflection grpc service (#1107)

* feat: reflection grpc service

* feat: reflection grpc service
master
小小小下 3 years ago committed by GitHub
parent d1e702e8a3
commit 295ec27e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,6 +23,8 @@ import (
"github.com/tal-tech/go-zero/core/conf" "github.com/tal-tech/go-zero/core/conf"
"github.com/tal-tech/go-zero/zrpc" "github.com/tal-tech/go-zero/zrpc"
"google.golang.org/grpc" "google.golang.org/grpc"
"github.com/tal-tech/go-zero/core/service"
"google.golang.org/grpc/reflection"
) )
var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file") var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file")
@ -37,6 +39,13 @@ func main() {
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) { s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
{{.pkg}}.Register{{.service}}Server(grpcServer, srv) {{.pkg}}.Register{{.service}}Server(grpcServer, srv)
switch c.Mode {
case service.DevMode,service.TestMode:
reflection.Register(grpcServer)
default:
}
}) })
defer s.Stop() defer s.Stop()

Loading…
Cancel
Save