aboutsummaryrefslogtreecommitdiff
path: root/internal/feed/parse.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-25 11:27:34 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-25 11:27:34 +0200
commitd21881150c09986571a563eaf30bc1687787e63f (patch)
treea5da8a3fdb91a3dcf806b704e20b16616a934801 /internal/feed/parse.go
parentc08aff21cd67cc27926a4cb1ca72ffe67e015ebf (diff)
downloadfeed2imap-go-d21881150c09986571a563eaf30bc1687787e63f.tar.gz
feed2imap-go-d21881150c09986571a563eaf30bc1687787e63f.tar.bz2
feed2imap-go-d21881150c09986571a563eaf30bc1687787e63f.zip
Improved caching
Diffstat (limited to 'internal/feed/parse.go')
-rw-r--r--internal/feed/parse.go24
1 files changed, 8 insertions, 16 deletions
diff --git a/internal/feed/parse.go b/internal/feed/parse.go
index 35a7596..6deebb2 100644
--- a/internal/feed/parse.go
+++ b/internal/feed/parse.go
@@ -32,7 +32,7 @@ func parseFeed(feed *Feed) error {
return nil
}
-func handleFeed(feed *Feed, group *sync.WaitGroup, success chan<- bool) {
+func handleFeed(feed *Feed, group *sync.WaitGroup) {
defer group.Done()
log.Printf("Fetching %s from %s", feed.Name, feed.Url)
@@ -40,25 +40,17 @@ func handleFeed(feed *Feed, group *sync.WaitGroup, success chan<- bool) {
if err != nil {
log.Error(err)
}
- success <- err == nil
}
-func Parse(feeds Feeds) int {
- var wg sync.WaitGroup
- wg.Add(len(feeds))
-
- success := make(chan bool, len(feeds))
-
- for _, feed := range feeds {
- go handleFeed(feed, &wg, success)
- }
-
- wg.Wait()
- close(success)
+func (feeds Feeds) Parse() int {
+ feeds.ForeachGo(handleFeed)
ctr := 0
- for s := range success {
- if s {
+ for _, feed := range feeds.feeds {
+ success := feed.Success()
+ feed.cached.Checked(!success)
+
+ if success {
ctr++
}
}