This commit is contained in:
2026-09-22 22:15:25 +08:00
parent 4c710bf943
commit 9d5411b62a

View File

@@ -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
}