oc-lib/models/resources/processing/processing.go
2024-07-26 08:27:09 +02:00

48 lines
1.3 KiB
Go

package processing
import (
"encoding/json"
resources "cloud.o-forge.io/core/oc-lib/models/resources"
"cloud.o-forge.io/core/oc-lib/models/utils"
)
type ProcessingResource struct {
resources.AbstractResource
CPUs uint `bson:"cp_us,omitempty" json:"cp_us,omitempty"`
GPUs uint `bson:"gp_us,omitempty" json:"gp_us,omitempty"`
RAM uint `bson:"ram,omitempty" json:"ram,omitempty"`
Parallel bool `bson:"parallel,omitempty" json:"parallel,omitempty"`
ScalingModel uint `bson:"scaling_model,omitempty" json:"scaling_model,omitempty"`
DiskIO string `bson:"disk_io,omitempty" json:"disk_io,omitempty"`
// Price uint `bson:"price,omitempty" json:"price,omitempty"`
// License string `bson:"license,omitempty" json:"license,omitempty"`
}
func (dma *ProcessingResource) Deserialize(j map[string]interface{}) utils.DBObject {
b, err := json.Marshal(j)
if err != nil {
return nil
}
json.Unmarshal(b, dma)
return dma
}
func (dma *ProcessingResource) Serialize() map[string]interface{} {
var m map[string]interface{}
b, err := json.Marshal(dma)
if err != nil {
return nil
}
json.Unmarshal(b, &m)
return m
}
func (d *ProcessingResource) GetAccessor() utils.Accessor {
data := &ProcessingMongoAccessor{}
data.SetLogger(utils.PROCESSING_RESOURCE)
return data
}