refactor: add unified all service gateway
This commit is contained in:
@@ -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),
|
||||
}
|
||||
|
||||
@@ -33,7 +38,9 @@ func New(addr string) *Server {
|
||||
pb.RegisterStaffServer(srv.Grpc, NewStaffServer())
|
||||
pb.RegisterStoreServer(srv.Grpc, NewStoreServer())
|
||||
|
||||
reflection.Register(srv.Grpc)
|
||||
if standalone {
|
||||
reflection.Register(srv.Grpc)
|
||||
}
|
||||
|
||||
return srv
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user