func (t Thumbnailer) FeedUpdated(feed content.Feed) error { t.logger.Debugln("Generating thumbnailer processors") processors := t.generateProcessors(feed.NewArticles()) numProcessors := 20 done := make(chan struct{}) errc := make(chan error) defer close(done) var wg sync.WaitGroup wg.Add(numProcessors) for i := 0; i < numProcessors; i++ { go func() { err := t.process(done, processors) if err != nil { errc <- err } wg.Done() }() } go func() { wg.Wait() close(errc) }() for err := range errc { return err } return nil }
func (fm FeedManager) processFeedUpdateMonitors(f content.Feed) { if len(f.NewArticles()) > 0 { for _, m := range fm.feedMonitors { if err := m.FeedUpdated(f); err != nil { fm.logger.Printf("Error invoking monitor '%s' on updated feed '%s': %v\n", reflect.TypeOf(m), f, err) } } } else { fm.logger.Infoln("No new articles for " + f.String()) } }
func (si SearchIndex) UpdateFeed(feed content.Feed) { si.logger.Infof("Updating article search index for feed '%s'\n", feed) newArticleLinks := map[string]bool{} for _, a := range feed.NewArticles() { newArticleLinks[a.Data().Link] = true } var articles []content.Article for _, a := range feed.ParsedArticles() { if newArticleLinks[a.Data().Link] { articles = append(articles, a) } } si.batchIndex(articles) }
func (i Index) FeedUpdated(feed content.Feed) error { i.logger.Infof("Updating article search index for feed '%s'\n", feed) return i.provider.BatchIndex(feed.NewArticles(), data.BatchAdd) }