This commit is contained in:
mr 2024-07-19 13:27:34 +02:00
parent cdc077c59e
commit 3f9814e649
9 changed files with 22 additions and 0 deletions

View File

@ -30,6 +30,10 @@ type LibData struct {
Err string `bson:"error" json:"error"`
}
func (lb LibData) BindID(id string) {
lb.DataResource.BindID(id)
}
func Init(appName string) {
logs.SetAppName(appName)
logs.SetLogger(logs.CreateLogger("main", ""))

View File

@ -14,6 +14,8 @@ type DataResource struct {
Example string `json:"example" bson:"example" required:"true" validate:"required" description:"base64 encoded data"`
}
func (d *DataResource) BindID(id string) {}
func (dma *DataResource) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {

View File

@ -37,6 +37,8 @@ type DatacenterGpuModel struct {
TensorCores uint `bson:"tensor_cores,omitempty" json:"tensor_cores,omitempty"`
}
func (d *DatacenterResource) BindID(id string) {}
func (dma *DatacenterResource) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {

View File

@ -31,6 +31,8 @@ type ExecutionRequirementsModel struct {
DiskIO string `bson:"disk_io,omitempty" json:"disk_io,omitempty"`
}
func (d *ProcessingResource) BindID(id string) {}
func (dma *ProcessingResource) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {

View File

@ -24,6 +24,8 @@ type StorageResource struct {
BookingPrice uint `bson:"booking_price,omitempty" json:"booking_price,omitempty"`
}
func (d *StorageResource) BindID(id string) {}
func (dma *StorageResource) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {

View File

@ -57,6 +57,8 @@ type WorkflowResource struct {
WorkflowID string `bson:"workflow_id,omitempty" json:"workflow_id,omitempty"`
}
func (d *WorkflowResource) BindID(id string) { d.WorkflowID = id }
func (d *WorkflowResource) GetAccessor() utils.Accessor {
data := &WorkflowResourceMongoAccessor{}
data.SetLogger(utils.WORKFLOW_RESOURCE)

View File

@ -17,6 +17,10 @@ type AbstractObject struct {
Name string `json:"name" required:"true" bson:"name" validate:"required"`
}
func (ao *AbstractObject) GetID() string {
return ao.UUID
}
func (dma *AbstractObject) ObjDeserialize(j map[string]interface{}) *AbstractObject {
b, err := json.Marshal(j)
if err != nil {

View File

@ -2,6 +2,8 @@ package utils
type DBObject interface {
GenerateID()
GetID() string
BindID(id string)
GetName() string
Deserialize(j map[string]interface{}) DBObject
Serialize() map[string]interface{}

View File

@ -13,6 +13,8 @@ type Workflow struct {
w.AbstractWorkflow
}
func (d *Workflow) BindID(id string) {}
func (d *Workflow) GetName() string {
return d.Name
}