1. 函数改名
2. 删掉没用文件
This commit is contained in:
@@ -215,7 +215,7 @@ func (m *AnalysisPlanTaskManager) cleanupInvalidTasks(invalidPlanIDs []uint, all
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 批量更新相关执行日志状态为“已取消”
|
// 批量更新相关执行日志状态为“已取消”
|
||||||
if err := m.executionLogRepo.UpdateLogStatusByIDs(logsToCancelIDs, models.ExecutionStatusCancelled); err != nil {
|
if err := m.executionLogRepo.UpdateTaskExecutionLogStatusByIDs(logsToCancelIDs, models.ExecutionStatusCancelled); err != nil {
|
||||||
// 这是一个非关键性错误,只记录日志
|
// 这是一个非关键性错误,只记录日志
|
||||||
m.logger.Warnf("批量更新日志状态为 'Cancelled' 失败: %v", err)
|
m.logger.Warnf("批量更新日志状态为 'Cancelled' 失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package task
|
|
||||||
|
|
||||||
import (
|
|
||||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/logs"
|
|
||||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PlanAnalysisTask 用于在任务执行队列中触发一个plan的执行
|
|
||||||
// 该任务会解析plan生成扁平化的待执行任务表, 并将任务列表插入任务执行队列
|
|
||||||
// 该任务会预写入plan所有待执行任务的执行日志
|
|
||||||
// 每个plan执行完毕时 或 创建plan时 都应该重新创建一个 PlanAnalysisTask 以便触发下次plan执行
|
|
||||||
// 更新plan后应当更新对应 PlanAnalysisTask
|
|
||||||
type PlanAnalysisTask struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlanAnalysisTask) Execute() error {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlanAnalysisTask) ParseParams(logger *logs.Logger, claimedLog *models.TaskExecutionLog) error {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlanAnalysisTask) OnFailure(executeErr error) {
|
|
||||||
//TODO implement me
|
|
||||||
panic("implement me")
|
|
||||||
}
|
|
||||||
@@ -217,7 +217,7 @@ func (app *Application) initializePendingTasks(
|
|||||||
|
|
||||||
// 批量更新 TaskExecutionLog 状态为取消
|
// 批量更新 TaskExecutionLog 状态为取消
|
||||||
if len(taskLogIDsToCancel) > 0 {
|
if len(taskLogIDsToCancel) > 0 {
|
||||||
if err := executionLogRepo.UpdateLogStatusByIDs(taskLogIDsToCancel, models.ExecutionStatusCancelled); err != nil {
|
if err := executionLogRepo.UpdateTaskExecutionLogStatusByIDs(taskLogIDsToCancel, models.ExecutionStatusCancelled); err != nil {
|
||||||
logger.Errorf("批量更新任务执行日志状态为取消失败: %v", err)
|
logger.Errorf("批量更新任务执行日志状态为取消失败: %v", err)
|
||||||
// 这是一个非阻塞性错误,继续执行
|
// 这是一个非阻塞性错误,继续执行
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import (
|
|||||||
// ExecutionLogRepository 定义了与执行日志交互的接口。
|
// ExecutionLogRepository 定义了与执行日志交互的接口。
|
||||||
// 这为服务层提供了一个清晰的契约,并允许在测试中轻松地进行模拟。
|
// 这为服务层提供了一个清晰的契约,并允许在测试中轻松地进行模拟。
|
||||||
type ExecutionLogRepository interface {
|
type ExecutionLogRepository interface {
|
||||||
UpdateLogStatusByIDs(logIDs []uint, status models.ExecutionStatus) error
|
UpdateTaskExecutionLogStatusByIDs(logIDs []uint, status models.ExecutionStatus) error
|
||||||
UpdateLogStatus(logID uint, status models.ExecutionStatus) error
|
UpdateTaskExecutionLogStatus(logID uint, status models.ExecutionStatus) error
|
||||||
CreateTaskExecutionLog(log *models.TaskExecutionLog) error
|
CreateTaskExecutionLog(log *models.TaskExecutionLog) error
|
||||||
CreatePlanExecutionLog(log *models.PlanExecutionLog) error
|
CreatePlanExecutionLog(log *models.PlanExecutionLog) error
|
||||||
UpdatePlanExecutionLog(log *models.PlanExecutionLog) error
|
UpdatePlanExecutionLog(log *models.PlanExecutionLog) error
|
||||||
@@ -43,7 +43,7 @@ func NewGormExecutionLogRepository(db *gorm.DB) ExecutionLogRepository {
|
|||||||
return &gormExecutionLogRepository{db: db}
|
return &gormExecutionLogRepository{db: db}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *gormExecutionLogRepository) UpdateLogStatusByIDs(logIDs []uint, status models.ExecutionStatus) error {
|
func (r *gormExecutionLogRepository) UpdateTaskExecutionLogStatusByIDs(logIDs []uint, status models.ExecutionStatus) error {
|
||||||
if len(logIDs) == 0 {
|
if len(logIDs) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ func (r *gormExecutionLogRepository) UpdateLogStatusByIDs(logIDs []uint, status
|
|||||||
Update("status", status).Error
|
Update("status", status).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *gormExecutionLogRepository) UpdateLogStatus(logID uint, status models.ExecutionStatus) error {
|
func (r *gormExecutionLogRepository) UpdateTaskExecutionLogStatus(logID uint, status models.ExecutionStatus) error {
|
||||||
return r.db.Model(&models.TaskExecutionLog{}).Where("id = ?", logID).Update("status", status).Error
|
return r.db.Model(&models.TaskExecutionLog{}).Where("id = ?", logID).Update("status", status).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ func (r *gormExecutionLogRepository) UpdatePlanExecutionLogsStatusByIDs(logIDs [
|
|||||||
// FindIncompletePlanExecutionLogs 查找所有未完成的计划执行日志
|
// FindIncompletePlanExecutionLogs 查找所有未完成的计划执行日志
|
||||||
func (r *gormExecutionLogRepository) FindIncompletePlanExecutionLogs() ([]models.PlanExecutionLog, error) {
|
func (r *gormExecutionLogRepository) FindIncompletePlanExecutionLogs() ([]models.PlanExecutionLog, error) {
|
||||||
var logs []models.PlanExecutionLog
|
var logs []models.PlanExecutionLog
|
||||||
err := r.db.Where("status = ?", models.ExecutionStatusStarted).Find(&logs).Error
|
err := r.db.Where("status = ? OR status = ?", models.ExecutionStatusStarted, models.ExecutionStatusWaiting).Find(&logs).Error
|
||||||
return logs, err
|
return logs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -694,7 +694,7 @@ func (r *gormPlanRepository) StopPlanTransactionally(planID uint) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3.1 批量更新任务执行日志状态为“已取消”
|
// 3.1 批量更新任务执行日志状态为“已取消”
|
||||||
if err := executionLogRepoTx.UpdateLogStatusByIDs(taskLogIDs, models.ExecutionStatusCancelled); err != nil {
|
if err := executionLogRepoTx.UpdateTaskExecutionLogStatusByIDs(taskLogIDs, models.ExecutionStatusCancelled); err != nil {
|
||||||
return fmt.Errorf("批量更新任务执行日志状态为 '已取消' 失败: %w", err)
|
return fmt.Errorf("批量更新任务执行日志状态为 '已取消' 失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user