JCC-CSScheduler/common/pkgs/mq/executor/task/task.go

46 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package task
import (
"gitlink.org.cn/cloudream/common/pkgs/types"
"gitlink.org.cn/cloudream/common/utils/reflect2"
"gitlink.org.cn/cloudream/common/utils/serder"
)
// 任务
type TaskInfo interface {
Noop()
}
// 增加了新类型后需要在这里也同步添加
var TaskInfoTypeUnion = serder.UseTypeUnionExternallyTagged(types.Ref(types.NewTypeUnion[TaskInfo]()))
type TaskInfoBase struct{}
func (s *TaskInfoBase) Noop() {}
// 任务上报的状态
type TaskStatus interface {
Noop()
}
// 增加了新类型后需要在这里也同步添加
var TaskStatusTypeUnion = serder.UseTypeUnionExternallyTagged(types.Ref(types.NewTypeUnion[TaskStatus]()))
type TaskStatusBase struct{}
func (s *TaskStatusBase) Noop() {}
// 只能在init函数中调用因为包级变量初始化会比init函数调用先进行
func Register[TTaskInfo TaskInfo, TTaskStatus TaskStatus]() any {
TaskInfoTypeUnion.Add(reflect2.TypeOf[TTaskInfo]())
TaskStatusTypeUnion.Add(reflect2.TypeOf[TTaskStatus]())
return nil
}
type TaskOperateInfo struct {
TaskID string
Command string
}