pipeline: Make run function generic again.
also minor formatting changes.
This commit is contained in:
parent
f5f0a5b873
commit
08ebb9e7d6
@ -38,18 +38,23 @@ macro_rules! clone {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type HttpsClient = Client<HttpsConnector<HttpConnector>>;
|
||||||
|
|
||||||
/// The pipline to be run for indexing and updating a Podcast feed that originates from
|
/// The pipline to be run for indexing and updating a Podcast feed that originates from
|
||||||
/// `Source.uri`.
|
/// `Source.uri`.
|
||||||
///
|
///
|
||||||
/// Messy temp diagram:
|
/// Messy temp diagram:
|
||||||
/// Source -> GET Request -> Update Etags -> Check Status -> Parse xml/Rss ->
|
/// Source -> GET Request -> Update Etags -> Check Status -> Parse `xml/Rss` ->
|
||||||
/// Convert `rss::Channel` into Feed -> Index Podcast -> Index Episodes.
|
/// Convert `rss::Channel` into `Feed` -> Index Podcast -> Index Episodes.
|
||||||
pub fn pipeline<S: IntoIterator<Item = Source>>(
|
pub fn pipeline<S>(
|
||||||
sources: S,
|
sources: S,
|
||||||
ignore_etags: bool,
|
ignore_etags: bool,
|
||||||
tokio_core: &mut Core,
|
tokio_core: &mut Core,
|
||||||
client: Client<HttpsConnector<HttpConnector>>,
|
client: HttpsClient,
|
||||||
) -> Result<(), DataError> {
|
) -> Result<(), DataError>
|
||||||
|
where
|
||||||
|
S: IntoIterator<Item = Source>,
|
||||||
|
{
|
||||||
let list: Vec<_> = sources
|
let list: Vec<_> = sources
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(clone!(client => move |s| s.into_feed(client.clone(), ignore_etags)))
|
.map(clone!(client => move |s| s.into_feed(client.clone(), ignore_etags)))
|
||||||
@ -67,11 +72,10 @@ pub fn pipeline<S: IntoIterator<Item = Source>>(
|
|||||||
|
|
||||||
/// Creates a tokio `reactor::Core`, and a `hyper::Client` and
|
/// Creates a tokio `reactor::Core`, and a `hyper::Client` and
|
||||||
/// runs the pipeline.
|
/// runs the pipeline.
|
||||||
pub fn run(sources: Vec<Source>, ignore_etags: bool) -> Result<(), DataError> {
|
pub fn run<S>(sources: S, ignore_etags: bool) -> Result<(), DataError>
|
||||||
if sources.is_empty() {
|
where
|
||||||
return Ok(());
|
S: IntoIterator<Item = Source>,
|
||||||
}
|
{
|
||||||
|
|
||||||
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()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user