Mercurial > gemma
comparison 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 |
comparison
equal
deleted
inserted
replaced
3245:60f25cbe77fb | 3246:64324aaeb1fb |
---|---|
13 | 13 |
14 package scheduler | 14 package scheduler |
15 | 15 |
16 import ( | 16 import ( |
17 "log" | 17 "log" |
18 "sort" | |
19 "strings" | |
18 "sync" | 20 "sync" |
19 | 21 |
20 "github.com/robfig/cron" | 22 "github.com/robfig/cron" |
21 ) | 23 ) |
22 | 24 |
291 s.mu.Lock() | 293 s.mu.Lock() |
292 defer s.mu.Unlock() | 294 defer s.mu.Unlock() |
293 return s.actions[name] | 295 return s.actions[name] |
294 } | 296 } |
295 | 297 |
298 func LogActionNames() { | |
299 names := global.actionNames() | |
300 sort.Strings(names) | |
301 log.Printf("info: actions registered to scheduler: %s\n", | |
302 strings.Join(names, ", ")) | |
303 } | |
304 | |
305 func (s *scheduler) actionNames() []string { | |
306 s.mu.Lock() | |
307 defer s.mu.Unlock() | |
308 names := make([]string, len(s.actions)) | |
309 var i int | |
310 for k := range s.actions { | |
311 names[i] = k | |
312 i++ | |
313 } | |
314 return names | |
315 } | |
316 | |
296 func (s *scheduler) registerAction(name string, action Action) { | 317 func (s *scheduler) registerAction(name string, action Action) { |
297 log.Printf("info: register action '%s' in scheduler.", name) | |
298 s.mu.Lock() | 318 s.mu.Lock() |
299 defer s.mu.Unlock() | 319 defer s.mu.Unlock() |
300 s.actions[name] = action | 320 s.actions[name] = action |
301 } | 321 } |
302 | 322 |