pkg/{timex,wait}: Unify code

This commit is contained in:
Tom Wiesing 2022-10-16 19:33:25 +02:00
parent 59fff07b59
commit 8701fab93b
No known key found for this signature in database
10 changed files with 77 additions and 74 deletions

View file

@ -12,11 +12,14 @@ import (
)
func (home *Home) updateRedirect(ctx context.Context, io stream.IOStream) {
timex.SetInterval(ctx, home.RefreshInterval, func(t time.Time) {
io.Printf("[%s]: reloading overrides\n", t.Format(time.Stamp))
redirect, _ := home.loadRedirect()
home.redirect.Set(&redirect)
})
go func() {
for t := range timex.TickContext(ctx, home.RefreshInterval) {
io.Printf("[%s]: reloading overrides\n", t.Format(time.Stamp))
redirect, _ := home.loadRedirect()
home.redirect.Set(&redirect)
}
}()
}
func (home *Home) loadRedirect() (redirect Redirect, err error) {