lloydmeta/tasques

[Feature] Support skip-if-uncompleted-tasks-exist for Recurring Tasks

Closed this issue · 0 comments

It would be nice to support not scheduling a Recurring Task if there are any outstanding Tasks that belong to it (not DEAD or DONE).

This could be added as an optional (default false) field on RecurringTask.

One simple way to do this for Recurring Tasks that have this option set to true would be to do a search for the existence of outstanding tasks any before scheduling the Task in the Scheduler

if log.Debug().Enabled() {
log.Debug().
Str("id", string(task.ID)).
Str("expression", string(task.ScheduleExpression)).
Msg("Enqueuing Task")
}
tx := i.tracer.BackgroundTx("recurring-task-enqueue")
ctx := tx.Context()
_, err := i.tasksService.Create(ctx, i.taskDefToNewTask(task.ID, &task.TaskDefinition))
if err != nil {
log.Error().
Err(err).
Str("id", string(task.ID)).
Str("expression", string(task.ScheduleExpression)).
Msg("Failed to insert new Task at interval")
}
tx.End()