initialize the asynchronous task system's initial structure
This commit is contained in:
parent
898beaeec4
commit
a94abdb479
|
|
@ -0,0 +1,55 @@
|
|||
package task
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type TaskStatus string
|
||||
|
||||
const (
|
||||
StatusPending TaskStatus = "PENDING"
|
||||
StatusRunning TaskStatus = "RUNNING"
|
||||
StatusCompleted TaskStatus = "COMPLETED"
|
||||
StatusFailed TaskStatus = "FAILED"
|
||||
)
|
||||
|
||||
// TaskType 定义异步任务的具体业务类型
|
||||
type TaskType string
|
||||
|
||||
const (
|
||||
TypeTopologyAnalysis TaskType = "TOPOLOGY_ANALYSIS"
|
||||
TypeEventAnalysis TaskType = "EVENT_ANALYSIS"
|
||||
TypeBatchImport TaskType = "BATCH_IMPORT"
|
||||
)
|
||||
|
||||
type Task struct {
|
||||
ID string `bson:"_id" json:"id"`
|
||||
Type TaskType `bson:"type" json:"type"`
|
||||
Status TaskStatus `bson:"status" json:"status"`
|
||||
Priority int `bson:"priority" json:"priority"`
|
||||
|
||||
Params map[string]interface{} `bson:"params" json:"params"`
|
||||
Result map[string]interface{} `bson:"result,omitempty" json:"result"`
|
||||
ErrorMsg string `bson:"error_msg,omitempty" json:"error_msg"`
|
||||
|
||||
CreatedAt time.Time `bson:"created_at" json:"created_at"`
|
||||
StartedAt time.Time `bson:"started_at,omitempty" json:"started_at"`
|
||||
CompletedAt time.Time `bson:"completed_at,omitempty" json:"completed_at"`
|
||||
}
|
||||
|
||||
type TopologyParams struct {
|
||||
CheckIsland bool `json:"check_island"`
|
||||
CheckShort bool `json:"check_short"`
|
||||
BaseModelIDs []string `json:"base_model_ids"`
|
||||
}
|
||||
|
||||
type EventAnalysisParams struct {
|
||||
MotorID string `json:"motor_id"`
|
||||
TriggerID string `json:"trigger_id"`
|
||||
DurationMS int `json:"duration_ms"`
|
||||
}
|
||||
|
||||
type BatchImportParams struct {
|
||||
FileName string `json:"file_name"`
|
||||
FilePath string `json:"file_path"`
|
||||
}
|
||||
Loading…
Reference in New Issue