コード例 #1
0
ファイル: main.go プロジェクト: opinionated/pipeline
// for running the pipe
func buildStory(article string) (pipeline.Story, error) {

	story := pipeline.Story{}
	story.MainArticle = analyzer.Analyzable{FileName: article}
	story.RelatedArticles = make(chan analyzer.Analyzable)

	articles, err := relationDB.GetAll()
	if err != nil {
		return story, err
	}

	go func(relatedArticles []string, story pipeline.Story) {

		for i := range relatedArticles {
			story.RelatedArticles <- analyzer.Analyzable{
				FileName: relatedArticles[i],
			}
		}

		close(story.RelatedArticles)

	}(articles, story)

	return story, nil
}
コード例 #2
0
ファイル: module_test.go プロジェクト: opinionated/pipeline
func storyFromSet(set testSet) pipeline.Story {

	story := pipeline.Story{}
	story.MainArticle = pipeline.NewArticle(set.mainArticle)
	story.RelatedArticles = make(chan pipeline.Article)

	go func() {

		for i := range set.relatedArticles {
			story.RelatedArticles <- pipeline.NewArticle(set.relatedArticles[i])
		}

		close(story.RelatedArticles)

	}()

	return story
}