changed how we store upcoming executions from slice to map

This commit is contained in:
pb
2025-05-20 20:06:48 +02:00
parent bcc024caef
commit defdcf4264
3 changed files with 12 additions and 23 deletions

View File

@@ -22,11 +22,11 @@ func (em *ExecutionManager) RetrieveNextExecutions() {
Executions.Mu.Lock()
if len(Executions.Execs) > 0 {
executions := Executions.Execs
for i := len(executions) - 1; i >= 0; i-- {
if executions[i].ExecDate.Before(time.Now().UTC()) {
logger.Info().Msg("Will execute " + executions[i].UUID + " soon")
go em.executeExecution(executions[i])
Executions.Execs = append(executions[:i], executions[i+1:]...)
for execId, exec := range executions {
if exec.ExecDate.Before(time.Now().UTC()) {
logger.Info().Msg("Will execute " + execId + " soon")
go em.executeExecution(&exec)
delete(executions,execId)
}
}
}