ßþ→ªn €® €n ßþœ®, ßþœ® ßœππ

This commit is contained in:
2021-05-22 10:06:49 +02:00
parent f093c70879
commit 8f648de929
4 changed files with 38 additions and 39 deletions
+7 -5
View File
@@ -19,12 +19,11 @@ func StartEventHandler() {
// Dispatch an HourChanged event at every hour
go func() {
for {
now := time.Now()
nextHour := now.Add(time.Hour).Truncate(time.Hour)
time.Sleep(nextHour.Sub(now))
drift := time.Now().Add(time.Minute).Truncate(time.Minute).Sub(time.Now())
time.Sleep(drift + time.Millisecond * 5)
config.EventChannel <- models.Event{Name: "HourChanged"}
for range time.NewTicker(time.Minute).C {
config.EventChannel <- models.Event{Name: "TimeChanged"}
}
}()
}
@@ -36,6 +35,9 @@ func handleEvent(event models.Event) {
if !event.HasPayload("hour") {
event.AddPayload("hour", time.Now().In(loc).Format("15"))
}
if !event.HasPayload("minute") {
event.AddPayload("minute", time.Now().In(loc).Format("04"))
}
handlers, err := config.EventHandlerRepository().FetchAll(ctx)
if err != nil {