diff --git a/tpl/server.go b/tpl/server.go index 988ed7c..3cdb859 100644 --- a/tpl/server.go +++ b/tpl/server.go @@ -20,7 +20,12 @@ type Server struct { grpcConns map[string]*grpc.ClientConn // 连接池 } -func New(addr string) *Server { +func New(grpcServ *grpc.Server) *Server { + standalone := grpcServ == nil + if standalone { + grpcServ = grpc.NewServer() + } + srv := &Server{ Ctx: context.Background(), Grpc: grpc.NewServer(), @@ -31,6 +36,10 @@ func New(addr string) *Server { {register} reflection.Register(srv.Grpc) + + if standalone { + reflection.Register(srv.Grpc) + } return srv }