gruik

Fork of GCU-Squad's RSS-to-IRC bridge
git clone https://git.instinctive.eu/gruik.git
Log | Files | Refs | README | LICENSE

commit c5964d0d5f2fbb9e3709930a6e6198c77829c77d
parent 4a325eb5d6cf2775b3e776efa0fdb123728f14ae
Author: Emile 'iMil' Heitor <imil@NetBSD.org>
Date:   Fri, 14 Jul 2023 14:03:48 +0200

fix: add context not to wait for a feed

Diffstat:
Mmain.go | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/main.go b/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "crypto/sha256" "encoding/hex" "encoding/json" @@ -112,8 +113,11 @@ func newsFetch(client *girc.Client, channel string) { for { for _, feedURL := range viper.GetStringSlice("feeds.urls") { log.Printf("fetching %s...\n", feedURL) + // don't wait more than 20 seconds for feed to reply + feedctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) + defer cancel() fp := gofeed.NewParser() - feed, err := fp.ParseURL(feedURL) + feed, err := fp.ParseURLWithContext(feedURL, feedctx) if err != nil { log.Printf("Failed to fetch feed '%s': %s", feedURL, err) continue