refactor: add unified all service gateway

This commit is contained in:
2026-08-10 10:03:46 +08:00
parent 5ea45a76fe
commit f994b2de9c
143 changed files with 2853 additions and 2129 deletions

View File

@@ -17,10 +17,15 @@ 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(),
Grpc: grpcServ,
grpcConns: make(map[string]*grpc.ClientConn),
}
@@ -29,7 +34,9 @@ func New(addr string) *Server {
pb.RegisterDataServer(srv.Grpc, NewDataServer())
pb.RegisterSupplyServer(srv.Grpc, NewSupplyServer())
reflection.Register(srv.Grpc)
if standalone {
reflection.Register(srv.Grpc)
}
return srv
}