Nexus/pkg/internal/grpc/database.go

21 lines
550 B
Go
Raw Normal View History

2024-10-20 11:04:41 +00:00
package grpc
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/internal/database"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func (v *Server) AllocDatabase(ctx context.Context, request *proto.AllocDatabaseRequest) (*proto.AllocDatabaseResponse, error) {
dsn, err := database.AllocDatabase(request.GetName())
if err != nil {
return nil, status.Errorf(codes.Internal, err.Error())
}
return &proto.AllocDatabaseResponse{
IsSuccess: true,
Dsn: dsn,
}, nil
}