示例#1
0
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
}
示例#2
0
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())
	}
}
示例#3
0
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)
}
示例#4
0
文件: index.go 项目: urandom/readeef
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)
}