From 7bf9e6c53ce39071b867cc1208c3f1a9c4a4c140 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Mon, 18 Mar 2024 08:22:51 +0100 Subject: [PATCH] Remove unnecessary goroutines --- main.go | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/main.go b/main.go index c015a9f..01291fa 100644 --- a/main.go +++ b/main.go @@ -8,13 +8,6 @@ import ( "github.com/ekzyis/sn-goapi" ) -func WaitUntilNextHour() { - now := time.Now() - dur := now.Truncate(time.Hour).Add(time.Hour).Sub(now) - log.Println("sleeping for", dur.Round(time.Second)) - time.Sleep(dur) -} - func WaitUntilNextMinute() { now := time.Now() dur := now.Truncate(time.Minute).Add(time.Minute).Sub(now) @@ -29,35 +22,6 @@ func WaitUntilNextRun() { time.Sleep(dur) } -func CheckNotifications() { - var prevHasNewNotes bool - for { - log.Println("Checking notifications ...") - hasNewNotes, err := sn.CheckNotifications() - if err != nil { - SendErrorToDiscord(err) - } else { - if !prevHasNewNotes && hasNewNotes { - // only send embed on "rising edge" - SendNotificationsEmbedToDiscord() - log.Println("Forwarded notifications to monitoring") - } else if hasNewNotes { - log.Println("Notifications already forwarded") - } - } - prevHasNewNotes = hasNewNotes - WaitUntilNextRun() - } -} - -func SessionKeepAlive() { - for { - log.Println("Refresh session using GET /api/auth/session ...") - sn.RefreshSession() - WaitUntilNextHour() - } -} - func SyncStories() { for { stories, err := FetchHackerNewsTopStories() @@ -78,8 +42,6 @@ func SyncStories() { } func main() { - go CheckNotifications() - go SessionKeepAlive() go SyncStories() for { var (