diff pkg/scheduler/scheduler.go @ 3246:64324aaeb1fb

Made logging of waht is registered to the scheduler and the import queue more deterministic.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 13 May 2019 09:41:35 +0200
parents e9ff3e8d3c46
children c9315a6eb2c2
line wrap: on
line diff
--- a/pkg/scheduler/scheduler.go	Mon May 13 09:15:20 2019 +0200
+++ b/pkg/scheduler/scheduler.go	Mon May 13 09:41:35 2019 +0200
@@ -15,6 +15,8 @@
 
 import (
 	"log"
+	"sort"
+	"strings"
 	"sync"
 
 	"github.com/robfig/cron"
@@ -293,8 +295,26 @@
 	return s.actions[name]
 }
 
+func LogActionNames() {
+	names := global.actionNames()
+	sort.Strings(names)
+	log.Printf("info: actions registered to scheduler: %s\n",
+		strings.Join(names, ", "))
+}
+
+func (s *scheduler) actionNames() []string {
+	s.mu.Lock()
+	defer s.mu.Unlock()
+	names := make([]string, len(s.actions))
+	var i int
+	for k := range s.actions {
+		names[i] = k
+		i++
+	}
+	return names
+}
+
 func (s *scheduler) registerAction(name string, action Action) {
-	log.Printf("info: register action '%s' in scheduler.", name)
 	s.mu.Lock()
 	defer s.mu.Unlock()
 	s.actions[name] = action