Pick up the single-page application as frontend

This commit is contained in:
2024-06-24 23:06:20 +08:00
parent 86b2cd8140
commit 1cf675b23a
65 changed files with 2257 additions and 1410 deletions

View File

@ -17,27 +17,31 @@ type Server struct {
proto.UnimplementedFriendshipsServer
proto.UnimplementedRealmsServer
health.UnimplementedHealthServer
srv *grpc.Server
}
var S *grpc.Server
func NewServer() *Server {
server := &Server{
srv: grpc.NewServer(),
}
func NewGRPC() {
S = grpc.NewServer()
proto.RegisterAuthServer(server.srv, &Server{})
proto.RegisterNotifyServer(server.srv, &Server{})
proto.RegisterFriendshipsServer(server.srv, &Server{})
proto.RegisterRealmsServer(server.srv, &Server{})
health.RegisterHealthServer(server.srv, &Server{})
proto.RegisterAuthServer(S, &Server{})
proto.RegisterNotifyServer(S, &Server{})
proto.RegisterFriendshipsServer(S, &Server{})
proto.RegisterRealmsServer(S, &Server{})
health.RegisterHealthServer(S, &Server{})
reflection.Register(server.srv)
reflection.Register(S)
return server
}
func ListenGRPC() error {
func (v *Server) Listen() error {
listener, err := net.Listen("tcp", viper.GetString("grpc_bind"))
if err != nil {
return err
}
return S.Serve(listener)
return v.srv.Serve(listener)
}