Nexus/pkg/nex/cruda/allocator.go

21 lines
527 B
Go
Raw Normal View History

2024-10-20 11:04:41 +00:00
package cruda
import (
"context"
"git.solsynth.dev/hypernet/nexus/pkg/proto"
"google.golang.org/grpc/metadata"
)
func (v *CudaConn) AllocDatabase(name string) (string, error) {
conn := v.Conn.GetNexusGrpcConn()
ctx := context.Background()
ctx = metadata.AppendToOutgoingContext(ctx, "client_id", v.Conn.Info.Id)
out, err := proto.NewDatabaseControllerClient(conn).AllocDatabase(ctx, &proto.AllocDatabaseRequest{
Name: name,
})
if err != nil || !out.GetIsSuccess() {
return "", err
}
return out.GetDsn(), nil
}