ßþ→ªn €® €n ßþœ®, ßþœ® ßœππ
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user