diff --git a/Cargo.lock b/Cargo.lock index 65a979a..b8eb97d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -625,6 +625,7 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "native-tls 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/hammond-data/Cargo.toml b/hammond-data/Cargo.toml index f1a4ef7..01e42cf 100644 --- a/hammond-data/Cargo.toml +++ b/hammond-data/Cargo.toml @@ -25,6 +25,7 @@ tokio-core = "0.1.12" hyper-tls = "0.1.2" native-tls = "0.1.5" futures-cpupool = "0.1.8" +num_cpus = "1.8.0" [dependencies.diesel] features = ["sqlite", "r2d2"] diff --git a/hammond-data/src/lib.rs b/hammond-data/src/lib.rs index aeeda15..7e2de25 100644 --- a/hammond-data/src/lib.rs +++ b/hammond-data/src/lib.rs @@ -44,6 +44,7 @@ extern crate hyper; extern crate hyper_tls; extern crate itertools; extern crate native_tls; +extern crate num_cpus; extern crate rayon; extern crate reqwest; extern crate rfc822_sanitizer; diff --git a/hammond-data/src/pipeline.rs b/hammond-data/src/pipeline.rs index 575fe97..11098f8 100644 --- a/hammond-data/src/pipeline.rs +++ b/hammond-data/src/pipeline.rs @@ -10,6 +10,7 @@ use hyper::client::HttpConnector; use hyper_tls::HttpsConnector; use tokio_core::reactor::Core; +use num_cpus; use rss; use Source; @@ -78,8 +79,7 @@ pub fn run(sources: Vec, ignore_etags: bool) -> Result<()> { let mut core = Core::new()?; let handle = core.handle(); let client = Client::configure() - // FIXME: numcpus instead of 4 - .connector(HttpsConnector::new(4, &handle)?) + .connector(HttpsConnector::new(num_cpus::get(), &handle)?) .build(&handle); pipeline(sources, ignore_etags, &mut core, pool, client)