Max concurrency moved to check (#419)

Concurrency is defined by the channel size consuming
from the request stream in  `check`
This commit is contained in:
Matthias 2021-12-07 11:52:40 +01:00 committed by GitHub
parent ec03c8d0f7
commit c41ba64a69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 16 deletions

View file

@ -17,7 +17,6 @@ async fn main() -> Result<()> {
let links = Collector::new(
None, // base
false, // don't skip missing inputs
10, // max concurrency
)
.collect_links(
inputs, // base url or directory

View file

@ -155,13 +155,9 @@ fn run_main() -> Result<i32> {
async fn run(opts: &LycheeOptions) -> Result<i32> {
let inputs = opts.inputs();
let requests = Collector::new(
opts.config.base.clone(),
opts.config.skip_missing,
opts.config.max_concurrency,
)
.collect_links(inputs)
.await;
let requests = Collector::new(opts.config.base.clone(), opts.config.skip_missing)
.collect_links(inputs)
.await;
let client = client::create(&opts.config)?;

View file

@ -12,21 +12,15 @@ use std::collections::HashSet;
pub struct Collector {
base: Option<Base>,
skip_missing_inputs: bool,
max_concurrency: usize,
}
impl Collector {
/// Create a new collector with an empty cache
#[must_use]
pub const fn new(
base: Option<Base>,
skip_missing_inputs: bool,
max_concurrency: usize,
) -> Self {
pub const fn new(base: Option<Base>, skip_missing_inputs: bool) -> Self {
Collector {
base,
skip_missing_inputs,
max_concurrency,
}
}
@ -145,7 +139,7 @@ mod test {
},
];
let responses = Collector::new(None, false, 8).collect_links(inputs).await;
let responses = Collector::new(None, false).collect_links(inputs).await;
let mut links: Vec<Uri> = responses.map(|r| r.unwrap().uri).collect().await;
let mut expected_links = vec![