创建与注销服务器

This commit is contained in:
2023-06-27 20:16:21 +08:00
parent 9ec1490cf2
commit 9bcd9540ef
2 changed files with 120 additions and 4 deletions

View File

@@ -13,6 +13,31 @@ type Task struct {
UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}
// 异步任务调度管理
type AsynchronousTaskSchedulingManagement struct {
tasks map[int]Task // 任务队列
servers map[string]Server // 服务器队列
}
// 向任务队列添加任务
func (m *AsynchronousTaskSchedulingManagement) AddTask(task Task) {
// 1. 任务加入队列, 任务状态为 waiting, 每次从最后一个任务开始执行, 并向上全取同模型的任务, 任务状态更新为 waiting(排队), 并更新此模型的排队状态到所有关注此模型的用户(管理员每个连接都关注所有模型)
// 2. 任务从队列中取出, 任务队列长度超过12则增加机器, 模型类型持续占用机器则增加机器
// 加入任务队列
m.tasks[task.ID] = task
// 检查任务队列长度, 持续增长超过12则增加机器
if len(m.tasks) > 12 {
var server Server
m.servers[server.ID] = server
}
// 向目标机器发送模型
// 向目标机器切换模型
// 向目标机器发送任务
}
//// 推理任務
//func startInferenceTask(task *Task) {
//