aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/feed/parse.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/internal/feed/parse.go b/internal/feed/parse.go
index 22d16f2..35a7596 100644
--- a/internal/feed/parse.go
+++ b/internal/feed/parse.go
@@ -32,22 +32,36 @@ func parseFeed(feed *Feed) error {
return nil
}
-func handleFeed(feed *Feed, wg *sync.WaitGroup) {
- defer wg.Done()
+func handleFeed(feed *Feed, group *sync.WaitGroup, success chan<- bool) {
+ defer group.Done()
log.Printf("Fetching %s from %s", feed.Name, feed.Url)
- if err := parseFeed(feed); err != nil {
+ err := parseFeed(feed)
+ if err != nil {
log.Error(err)
}
+ success <- err == nil
}
-func Parse(feeds Feeds) {
+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)
+ go handleFeed(feed, &wg, success)
}
wg.Wait()
+ close(success)
+
+ ctr := 0
+ for s := range success {
+ if s {
+ ctr++
+ }
+ }
+
+ return ctr
}
pan>Rename package 'parse' to 'feed'René 'Necoro' Neumann2-3/+3 2020-04-19SELECT is not necessary for most operations -- skip itRené 'Necoro' Neumann2-12/+1 2020-04-19Store path as array -- the delimiter is not always '.'René 'Necoro' Neumann3-36/+44 2020-04-19Split client part to client.goRené 'Necoro' Neumann2-125/+137 2020-04-19IMAP: Create foldersRené 'Necoro' Neumann1-4/+38 2020-04-19Improved IMAPRené 'Necoro' Neumann1-3/+88 2020-04-19Started IMAP connectionRené 'Necoro' Neumann4-0/+152 2020-04-19Use our own logger for debug for convenience sakeRené 'Necoro' Neumann1-2/+3 2020-04-19Fix debug logging m(René 'Necoro' Neumann1-2/+2 2020-04-19Rename util.go to log.go. Add verbose modeRené 'Necoro' Neumann4-24/+54 2020-04-19Clean go.modRené 'Necoro' Neumann2-3/+0 2020-04-19Do not print the parsedCfg anymoreRené 'Necoro' Neumann1-1/+1 2020-04-19Increase go-version to 1.14René 'Necoro' Neumann1-2/+2 2020-04-19CI: go vetRené 'Necoro' Neumann1-0/+3 2020-04-19Fetching and parsing the feedsRené 'Necoro' Neumann5-4/+113 2020-04-19Ignore all config*.ymlRené 'Necoro' Neumann1-1/+1