♻️ Moved account-based post to publisher-based post

This commit is contained in:
2024-10-31 22:41:32 +08:00
parent d889d22d11
commit 001c9a8140
39 changed files with 559 additions and 924 deletions

View File

@ -1,7 +1,7 @@
package grpc
import (
"git.solsynth.dev/hydrogen/dealer/pkg/proto"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"github.com/spf13/viper"
"google.golang.org/grpc"
health "google.golang.org/grpc/health/grpc_health_v1"
@ -10,25 +10,29 @@ import (
)
type Server struct {
proto.UnimplementedServiceDirectoryServer
proto.UnimplementedDirectoryServiceServer
srv *grpc.Server
}
var S *grpc.Server
func NewGrpc() *Server {
server := &Server{
srv: grpc.NewServer(),
}
func NewGRPC() {
S = grpc.NewServer()
health.RegisterHealthServer(server.srv, server)
proto.RegisterDirectoryServiceServer(server.srv, server)
health.RegisterHealthServer(S, &Server{})
proto.RegisterServiceDirectoryServer(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)
}

View File

@ -23,7 +23,7 @@ func (v *Server) BroadcastDeletion(ctx context.Context, request *proto.DeletionR
database.C.Delete(model, "account_id = ?", numericId)
}
}
database.C.Delete(&models.Account{}, "id = ?", numericId)
database.C.Delete(&models.Publisher{}, "id = ?", numericId)
}
return &proto.DeletionResponse{}, nil