Pipeline: Print the error right away instead of waiting till all futures complete.

This commit is contained in:
Jordan Petridis 2018-01-23 18:18:56 +02:00
parent e74a2df27f
commit f9096e5fac
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
3 changed files with 7 additions and 9 deletions

View File

@ -211,7 +211,7 @@ impl NewEpisodeMinimal {
let duration = parser::parse_itunes_duration(item);
Ok(NewEpisodeMinimalBuilder::default()
NewEpisodeMinimalBuilder::default()
.title(title)
.uri(uri)
.duration(duration)
@ -219,7 +219,7 @@ impl NewEpisodeMinimal {
.guid(guid)
.podcast_id(parent_id)
.build()
.unwrap())
.map_err(From::from)
}
pub(crate) fn into_new_episode(self, item: &rss::Item) -> NewEpisode {

View File

@ -172,12 +172,12 @@ impl Source {
Ok(res)
})
.and_then(move |res| response_to_channel(res, pool))
.map(move |chan| {
.and_then(move |chan| {
FeedBuilder::default()
.channel(chan)
.source_id(id)
.build()
.unwrap()
.map_err(From::from)
});
Box::new(feed)

View File

@ -57,13 +57,11 @@ pub fn pipeline<S: IntoIterator<Item = Source>>(sources: S, ignore_etags: bool)
.into_iter()
.map(clone!(pool => move |s| s.into_feed(&client, pool.clone(), ignore_etags)))
.map(|fut| fut.and_then(clone!(pool => move |feed| pool.clone().spawn(feed.index()))))
.map(|fut| fut.map(|_| ()).map_err(|err| error!("Error: {}", err)))
.collect();
let f = core.run(collect_futures(list))?;
f.into_iter()
.filter_map(|x| x.err())
.for_each(|err| error!("Error: {}", err));
// Thats not really concurrent yet I think.
core.run(collect_futures(list))?;
Ok(())
}