Pipeline: remove submodule hack.
This commit is contained in:
parent
b3460b15a2
commit
bf4f655ed2
@ -7,50 +7,19 @@ use hyper_tls::HttpsConnector;
|
|||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use futures::future::*;
|
use futures::future::*;
|
||||||
|
|
||||||
use errors::Error;
|
use errors::*;
|
||||||
use Source;
|
use Source;
|
||||||
// use Feed;
|
// use Feed;
|
||||||
|
|
||||||
// Weird magic from #rust irc channel
|
use std;
|
||||||
// kudos to remexre
|
|
||||||
fn collect_futures<F>(
|
|
||||||
futures: Vec<F>,
|
|
||||||
) -> Box<Future<Item = Vec<Result<F::Item, F::Error>>, Error = Error>>
|
|
||||||
where
|
|
||||||
F: 'static + Future,
|
|
||||||
<F as Future>::Item: 'static,
|
|
||||||
<F as Future>::Error: 'static,
|
|
||||||
{
|
|
||||||
Box::new(loop_fn((futures, vec![]), |(futures, mut done)| {
|
|
||||||
select_all(futures).then(|r| {
|
|
||||||
let (r, rest) = match r {
|
|
||||||
Ok((r, _, rest)) => (Ok(r), rest),
|
|
||||||
Err((r, _, rest)) => (Err(r), rest),
|
|
||||||
};
|
|
||||||
done.push(r);
|
|
||||||
if rest.len() == 0 {
|
|
||||||
Ok(Loop::Break(done))
|
|
||||||
} else {
|
|
||||||
Ok(Loop::Continue((rest, done)))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub use self::dirtyhack::pipeline;
|
/// The pipline to be run for indexing and updating a Podcast feed that originates from
|
||||||
|
/// `Source.uri`.
|
||||||
// Use a submodule ot not polute the collect_futures definition with the errorchain Result<T>.
|
///
|
||||||
mod dirtyhack {
|
/// Messy temp diagram:
|
||||||
use super::*;
|
/// Source -> GET Request -> Update Etags -> Check Status -> Parse xml/Rss ->
|
||||||
use errors::*;
|
/// Convert rss::Channel into Feed -> Index Podcast -> Index Episodes.
|
||||||
|
pub fn pipeline<S: IntoIterator<Item = Source>>(sources: S, ignore_etags: bool) -> Result<()> {
|
||||||
/// The pipline to be run for indexing and updating a Podcast feed that originates from
|
|
||||||
/// `Source.uri`.
|
|
||||||
///
|
|
||||||
/// Messy temp diagram:
|
|
||||||
/// Source -> GET Request -> Update Etags -> Check Status -> Parse xml/Rss ->
|
|
||||||
/// Convert rss::Channel into Feed -> Index Podcast -> Index Episodes.
|
|
||||||
pub fn pipeline<S: IntoIterator<Item = Source>>(sources: S, ignore_etags: bool) -> Result<()> {
|
|
||||||
let mut core = Core::new()?;
|
let mut core = Core::new()?;
|
||||||
let handle = core.handle();
|
let handle = core.handle();
|
||||||
let client = Client::configure()
|
let client = Client::configure()
|
||||||
@ -71,5 +40,30 @@ mod dirtyhack {
|
|||||||
.for_each(|err| error!("Error: {}", err));
|
.for_each(|err| error!("Error: {}", err));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Weird magic from #rust irc channel
|
||||||
|
// kudos to remexre
|
||||||
|
fn collect_futures<F>(
|
||||||
|
futures: Vec<F>,
|
||||||
|
) -> Box<Future<Item = Vec<std::result::Result<F::Item, F::Error>>, Error = Error>>
|
||||||
|
where
|
||||||
|
F: 'static + Future,
|
||||||
|
<F as Future>::Item: 'static,
|
||||||
|
<F as Future>::Error: 'static,
|
||||||
|
{
|
||||||
|
Box::new(loop_fn((futures, vec![]), |(futures, mut done)| {
|
||||||
|
select_all(futures).then(|r| {
|
||||||
|
let (r, rest) = match r {
|
||||||
|
Ok((r, _, rest)) => (Ok(r), rest),
|
||||||
|
Err((r, _, rest)) => (Err(r), rest),
|
||||||
|
};
|
||||||
|
done.push(r);
|
||||||
|
if rest.len() == 0 {
|
||||||
|
Ok(Loop::Break(done))
|
||||||
|
} else {
|
||||||
|
Ok(Loop::Continue((rest, done)))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user