Database allocator

This commit is contained in:
2024-10-20 19:04:41 +08:00
parent e5a32bc05a
commit 4adbfe9c19
23 changed files with 536 additions and 29 deletions

View File

@@ -14,19 +14,22 @@ import (
health "google.golang.org/grpc/health/grpc_health_v1"
)
type GrpcServer struct {
type Server struct {
proto.UnimplementedDatabaseControllerServer
proto.UnimplementedStreamControllerServer
health.UnimplementedHealthServer
srv *grpc.Server
}
func NewServer() *GrpcServer {
server := &GrpcServer{
func NewServer() *Server {
server := &Server{
srv: grpc.NewServer(),
}
proto.RegisterServiceDirectoryServer(server.srv, &directory.ServiceRpcServer{})
proto.RegisterCommandControllerServer(server.srv, &directory.CommandRpcServer{})
proto.RegisterDatabaseControllerServer(server.srv, server)
proto.RegisterStreamControllerServer(server.srv, server)
health.RegisterHealthServer(server.srv, server)
@@ -35,7 +38,7 @@ func NewServer() *GrpcServer {
return server
}
func (v *GrpcServer) Listen() error {
func (v *Server) Listen() error {
listener, err := net.Listen("tcp", viper.GetString("grpc_bind"))
if err != nil {
return err