fix: task priority not taking effect

This commit is contained in:
garethgeorge
2023-12-01 22:55:26 -08:00
parent f3dc7ffd07
commit af7462cefb
3 changed files with 9 additions and 8 deletions

View File

@@ -20,10 +20,10 @@ var ErrRepoInitializationFailed = errors.New("repo initialization failed")
var ErrPlanNotFound = errors.New("plan not found")
const (
TaskPriorityDefault = iota
TaskPriorityInteractive // higher priority than default scheduled operations e.g. the user clicked to run an operation.
taskPriorityForget
TaskPriorityDefault = iota
TaskPriorityInteractive // higher priority than default scheduled operations e.g. the user clicked to run an operation
taskPriorityIndexSnapshots // higher priority than interactive operations e.g. a system operation like a forget or index (typically scheduled by another task that wants work done immediately after it's completion).
taskPriorityForget
)
// Orchestrator is responsible for managing repos and backups.
@@ -163,8 +163,9 @@ func (o *Orchestrator) ScheduleTask(t Task, priority int) {
}
zap.L().Info("scheduling task", zap.String("task", t.Name()), zap.String("runAt", nextRun.Format(time.RFC3339)))
o.taskQueue.Push(scheduledTask{
task: t,
runAt: *nextRun,
task: t,
runAt: *nextRun,
priority: priority,
})
}