Commit cd18334f authored by luxq's avatar luxq

Initial commit

parents
Pipeline #744 canceled with stages
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# GitHub Copilot persisted chat sessions
/copilot/chatSessions
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/mogo.iml" filepath="$PROJECT_DIR$/.idea/mogo.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.idea/copilot/chatSessions" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
package db
import (
"context"
"time"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
func ConnectMongoDB(uri string) (*mongo.Client, error) {
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri).SetAuth(options.Credential{
Username: "admin",
Password: "admin",
}))
if err != nil {
return nil, err
}
return client, nil
}
package db
type DbTaskInfo struct {
ID string `bson:"_id,omitempty" json:"id"`
TaskId int32 `json:"task_id"` // 任务类型id
Name string `json:"name"`
Desc string `json:"desc"` // 任务类型描述
Price int64 `json:"price"` // 该任务类型的费用
PublicKey string `json:"public_key"`
Complexity int8 `json:"complexity"`
HardwareRequire string `json:"hardware_require"`
ImageId string `json:"image_id"`
ImageUrl string `json:"image_url"`
ImageName string `json:"image_name"`
SignUrl string `json:"sign_url"`
Username string `json:"username"`
Password string `json:"password"`
Cmd string `json:"cmd"`
Workload int32 `json:"workload"`
ApiPath string `json:"api_path"`
Type int8 `json:"type"` // 类型 1=txt2img 2=txt2txt 3=txt2video
BaseModel string `json:"base_model"`
Model string `json:"model"`
Examples string `json:"examples"`
ApiDocUrl string `json:"api_doc_url"`
ApiDocContent string `json:"api_doc_content"`
Codes string `json:"codes"`
Tags string `json:"tags"`
Kind int8 `json:"kind"` // 任务种类 SystemTask = 0; ComputeTask = 1; CustomTask = 2; StandardTask = 3;
Category int8 `json:"category"`
ResultFileExpires int32 `json:"result_file_expires"`
Version string `json:"version"`
Form string `json:"form"`
AccessStatus int8 `json:"access_status"` // 接入状体啊 1= 公开 2-= 私有
EstimatExeTime int32 `json:"estimat_exe_time"` // 预计执行时长
Unit string `json:"unit"`
PublishStatus int8 `json:"publish_status"` // 发布状态 1= 发布 2= 取消发布
MaxExecTime int32 `json:"max_exec_time"` // 任务执行超时时间
}
package db
import (
"context"
"errors"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"mogo/types"
)
type DbWorkerInfo struct {
ID string `bson:"_id,omitempty" json:"id"`
WorkerId string `bson:"worker_id" json:"worker_id"`
NodeInfo *types.NodeInfo `bson:"node_info" json:"node_info"`
Models *types.ModelInfo `bson:"model_infos" json:"model_infos"`
Hardware *types.HardwareInfo `bson:"hardware" json:"hardware"`
}
func (worker *DbWorkerInfo) Read(client *mongo.Client, ctx context.Context, collection string, id string) error {
coll := client.Database("test").Collection(collection)
oid, err := primitive.ObjectIDFromHex(id)
if err != nil {
return errors.New("Invalid ID")
}
return coll.FindOne(ctx, bson.M{"_id": oid}).Decode(&worker)
}
func (worker *DbWorkerInfo) ReadMultiple(client *mongo.Client, ctx context.Context, collection string) ([]DbWorkerInfo, error) {
coll := client.Database("test").Collection(collection)
cursor, err := coll.Find(ctx, bson.M{"resource": bson.M{"$ne": nil}})
if err != nil {
return nil, err
}
defer cursor.Close(ctx)
var workers []DbWorkerInfo
if err = cursor.All(ctx, &workers); err != nil {
return nil, err
}
return workers, nil
}
func (worker *DbWorkerInfo) Update(client *mongo.Client, ctx context.Context, collection string, id string) error {
coll := client.Database("test").Collection(collection)
_, err := coll.UpdateOne(ctx, bson.M{"_id": id}, bson.M{"$set": worker})
return err
}
func (worker *DbWorkerInfo) UpdateModel(client *mongo.Client, ctx context.Context, collection string, id string, models *types.ModelInfo) error {
coll := client.Database("test").Collection(collection)
update := bson.M{"$set": bson.M{"model_infos": models}}
_, err := coll.UpdateOne(ctx, bson.M{"_id": id}, update)
return err
}
func (worker *DbWorkerInfo) Delete(client *mongo.Client, ctx context.Context, collection string, id string) error {
coll := client.Database("test").Collection(collection)
_, err := coll.DeleteOne(ctx, bson.M{"_id": id})
return err
}
type dbWorker struct {
client *mongo.Client
col *mongo.Collection
}
func NewDBWorker(client *mongo.Client, database string, collection string) *dbWorker {
return &dbWorker{
client: client,
col: client.Database(database).Collection(collection),
}
}
func (d *dbWorker) InsertWorker(ctx context.Context, worker *DbWorkerInfo) (*mongo.InsertOneResult, error) {
return d.col.InsertOne(ctx, worker)
}
func (d *dbWorker) UpdateModel(ctx context.Context, id string, models *types.ModelInfo) error {
update := bson.M{"$set": bson.M{"model_infos": models}}
_, err := d.col.UpdateOne(ctx, bson.M{"_id": id}, update)
return err
}
package db
import (
"context"
"fmt"
"github.com/google/uuid"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"log"
"math/rand"
"mogo/types"
"strconv"
"testing"
"time"
)
var (
idlist []interface{}
)
func getRandId(max int) string {
return strconv.Itoa(rand.Intn(max) + 1)
}
func initdata(client *mongo.Client) []interface{} {
t1 := time.Now()
// insert 1000000 DbWorkerInfo to db
idlist := make([]interface{}, 0, 1000000)
db := NewDBWorker(client, "test", "workers")
// Insert 1,000,000 DbWorkerInfo to db
for i := 0; i < 1000; i++ {
worker := &DbWorkerInfo{
WorkerId: uuid.NewString(),
NodeInfo: &types.NodeInfo{
MinerPubkey: "0x3434332432432231213213213423142132132132132132132132132132132133",
BenefitAddress: "0x8888888333338383833838332432432454545444",
DeviceIp: "192.168.1.200",
},
Models: &types.ModelInfo{
InstalledModels: []*types.InstalledModelInfo{
&types.InstalledModelInfo{
ModelId: getRandId(100),
DiskSize: 100,
},
},
RunningModels: []*types.RunningModelInfo{
&types.RunningModelInfo{
ModelId: getRandId(100),
StartedTime: uint64((time.Now().Add(-time.Hour)).Unix()),
LatestTime: uint64(time.Now().Add(-time.Minute * 10).Unix()),
RunCount: 100,
GpuRamUsed: 80,
},
},
},
Hardware: &types.HardwareInfo{
Devices: []*types.DeviceInfo{
&types.DeviceInfo{
DeviceType: "cpu",
DeviceModel: "xxxxxxxxx",
DeviceParam: "kkkkkkkk",
DevicePower: 0,
},
&types.DeviceInfo{
DeviceType: "gpu",
DeviceModel: "Nvidia 3090",
DeviceParam: "kkkkkkkk",
DevicePower: 100,
},
},
Usages: []*types.DeviceUsage{
&types.DeviceUsage{},
},
},
}
result, err := db.InsertWorker(context.Background(), worker)
if err != nil {
panic(fmt.Sprintf("insert worker failed with err:%s", err))
}
id, ok := result.InsertedID.(primitive.ObjectID)
if !ok {
panic("inserted id is not primitive.ObjectID")
}
idlist = append(idlist, id.Hex())
fmt.Printf("insert worker %s: %v\n", id.Hex(), worker)
}
t2 := time.Now()
fmt.Printf("init data cost %s\n", t2.Sub(t1).String())
return idlist
}
func init() {
client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil {
log.Fatal(err)
}
idlist = initdata(client)
}
func BenchmarkDbWorkerInfo_UpdateResource(b *testing.B) {
client, err := ConnectMongoDB("mongodb://localhost:27017")
if err != nil {
log.Fatal(err)
}
b.ResetTimer()
nresource := &types.ModelInfo{
InstalledModels: []*types.InstalledModelInfo{
&types.InstalledModelInfo{
ModelId: getRandId(100),
DiskSize: 101,
},
&types.InstalledModelInfo{
ModelId: getRandId(100),
DiskSize: 44,
},
},
RunningModels: []*types.RunningModelInfo{
&types.RunningModelInfo{
ModelId: getRandId(100),
StartedTime: uint64((time.Now().Add(-time.Hour)).Unix()),
LatestTime: uint64(time.Now().Add(-time.Minute * 20).Unix()),
RunCount: 101,
GpuRamUsed: 80,
},
},
}
db := NewDBWorker(client, "test", "workers")
for i := 0; i < b.N; i++ {
idx := rand.Intn(len(idlist))
if err := db.UpdateModel(context.Background(), idlist[idx].(string), nresource); err != nil {
panic(fmt.Sprintf("update worker failed with err:%s", err))
//ufailed++
}
}
//fmt.Println("update failed:", ufailed)
}
version: "3.5"
services:
mongo:
image: mongo:latest
container_name: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
ports:
- "0.0.0.0:27017:27017"
networks:
- MONGO
volumes:
- type: volume
source: MONGO_DATA
target: /data/db
- type: volume
source: MONGO_CONFIG
target: /data/configdb
mongo-express:
image: mongo-express:latest
container_name: mongo-express
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: admin
ME_CONFIG_MONGODB_ADMINPASSWORD: admin
ME_CONFIG_MONGODB_SERVER: mongo
ME_CONFIG_MONGODB_PORT: "27017"
ports:
- "0.0.0.0:8081:8081"
networks:
- MONGO
depends_on:
- mongo
networks:
MONGO:
name: MONGO
volumes:
MONGO_DATA:
name: MONGO_DATA
MONGO_CONFIG:
name: MONGO_CONFIG
\ No newline at end of file
module mogo
go 1.20
require (
github.com/docker/docker v26.1.1+incompatible
github.com/google/uuid v1.6.0
go.mongodb.org/mongo-driver v1.15.0
)
require (
github.com/golang/snappy v0.0.1 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/docker/docker v26.1.1+incompatible h1:oI+4kkAgIwwb54b9OC7Xc3hSgu1RlJA/Lln/DF72djQ=
github.com/docker/docker v26.1.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.15.0 h1:rJCKC8eEliewXjZGf0ddURtl7tTVy1TK3bfl0gkUSLc=
go.mongodb.org/mongo-driver v1.15.0/go.mod h1:Vzb0Mk/pa7e6cWw85R4F/endUC3u0U9jGcNU603k65c=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
package main
func main() {
}
package types
type TaskTypeInfo struct {
Id int32 `json:"id"` // 任务类型id
Name string `json:"name"`
Desc string `json:"desc"` // 任务类型描述
Price int64 `json:"price"` // 该任务类型的费用
PublicKey string `json:"public_key"`
Complexity int8 `json:"complexity"`
HardwareRequire string `json:"hardware_require"`
ImageId string `json:"image_id"`
ImageUrl string `json:"image_url"`
ImageName string `json:"image_name"`
SignUrl string `json:"sign_url"`
Username string `json:"username"`
Password string `json:"password"`
Cmd string `json:"cmd"`
Workload int32 `json:"workload"`
ApiPath string `json:"api_path"`
Type int8 `json:"type"` // 类型 1=txt2img 2=txt2txt 3=txt2video
BaseModel string `json:"base_model"`
Model string `json:"model"`
Examples string `json:"examples"`
ApiDocUrl string `json:"api_doc_url"`
ApiDocContent string `json:"api_doc_content"`
Codes string `json:"codes"`
Tags string `json:"tags"`
Kind int8 `json:"kind"` // 任务种类 SystemTask = 0; ComputeTask = 1; CustomTask = 2; StandardTask = 3;
Category int8 `json:"category"`
ResultFileExpires int32 `json:"result_file_expires"`
Version string `json:"version"`
Form string `json:"form"`
AccessStatus int8 `json:"access_status"` // 接入状体啊 1= 公开 2-= 私有
EstimatExeTime int32 `json:"estimat_exe_time"` // 预计执行时长
Unit string `json:"unit"`
PublishStatus int8 `json:"publish_status"` // 发布状态 1= 发布 2= 取消发布
MaxExecTime int32 `json:"max_exec_time"` // 任务执行超时时间
}
package types
type NodeInfo struct {
MinerPubkey string `bson:"miner_pubkey" json:"miner_pubkey"`
BenefitAddress string `bson:"benefit_address" json:"benefit_address"`
DeviceIp string `bson:"device_ip" json:"device_ip"`
}
type InstalledModelInfo struct {
ModelId string `bson:"model_id" json:"model_id"`
DiskSize uint64 `bson:"disk_size" json:"disk_size"`
}
type RunningModelInfo struct {
ModelId string `bson:"model_id" json:"model_id"`
StartedTime uint64 `bson:"started_time" json:"started_time"`
LatestTime uint64 `bson:"latest_time" json:"latest_time"`
RunCount uint64 `bson:"run_count" json:"run_count"`
GpuRamUsed uint64 `bson:"gpu_ram" json:"gpu_ram"`
}
type ModelInfo struct {
InstalledModels []*InstalledModelInfo `bson:"installed_models" json:"installed_models"`
RunningModels []*RunningModelInfo `bson:"running_models" json:"running_models"`
}
type DeviceInfo struct {
DeviceType string `bson:"device_type" json:"device_type"`
DeviceModel string `bson:"device_model" json:"device_model"`
DeviceParam string `bson:"device_param" json:"device_param"`
DevicePower uint64 `bson:"device_power" json:"device_power"`
}
type DeviceUsage struct {
DeviceType string `bson:"device_type" json:"device_type"`
DeviceUsage uint64 `bson:"device_usage" json:"device_usage"`
}
type HardwareInfo struct {
Devices []*DeviceInfo `bson:"devices" json:"devices"`
Usages []*DeviceUsage `bson:"usages" json:"usages"`
}
type WorkerInfo struct {
WorkerId string `bson:"worker_id" json:"worker_id"`
NodeInfo *NodeInfo `bson:"node_info" json:"node_info"`
ModelInofs *ModelInfo `bson:"model_infos" json:"model_infos"`
Hardware *HardwareInfo `bson:"hardware" json:"hardware"`
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment