From ad075baa90fe972dc064266c0045526d4491868c Mon Sep 17 00:00:00 2001 From: Dave Gallant Date: Tue, 7 Feb 2023 22:13:08 -0500 Subject: [PATCH] Add random sleep when refreshing Topics --- backend/app.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/app.go b/backend/app.go index 0190fa1..f7da06f 100644 --- a/backend/app.go +++ b/backend/app.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "math/rand" "net/http" "os" "strings" @@ -92,7 +93,8 @@ func (a *App) refreshTopics() { log.Debug().Msg("Refreshing topics") a.CurrentTopics = latestTopics a.LastRefresh = time.Now() - time.Sleep(60 * time.Second) + rand.Seed(time.Now().UnixNano()) + time.Sleep(time.Duration(rand.Intn(90 - 60 + 1) + 60) * time.Second) } }