mirror of
https://github.com/rust-unofficial/awesome-rust
synced 2024-11-16 06:12:56 +00:00
Don't retry 429's and don't worry about them if we've got a previous success
This commit is contained in:
parent
94d76d64c9
commit
7bc2d0bb56
16
src/main.rs
16
src/main.rs
@ -26,6 +26,9 @@ enum CheckerError {
|
|||||||
location: Option<String>,
|
location: Option<String>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
#[fail(display = "too many requests")]
|
||||||
|
TooManyRequests,
|
||||||
|
|
||||||
#[fail(display = "reqwest error: {}", error)]
|
#[fail(display = "reqwest error: {}", error)]
|
||||||
ReqwestError {
|
ReqwestError {
|
||||||
error: String,
|
error: String,
|
||||||
@ -191,6 +194,12 @@ fn get_url_core(url: String) -> BoxFuture<'static, (String, Result<(), CheckerEr
|
|||||||
return (url, res);
|
return (url, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if status == StatusCode::TOO_MANY_REQUESTS {
|
||||||
|
// We get a lot of these, and we should not retry as they'll just fail again
|
||||||
|
warn!("Error while getting {}: {}", url, status);
|
||||||
|
return (url, Err(CheckerError::TooManyRequests));
|
||||||
|
}
|
||||||
|
|
||||||
warn!("Error while getting {}, retrying: {}", url, status);
|
warn!("Error while getting {}, retrying: {}", url, status);
|
||||||
if status.is_redirection() {
|
if status.is_redirection() {
|
||||||
res = Err(CheckerError::HttpError {status: status.as_u16(), location: ok.headers().get(header::LOCATION).and_then(|h| h.to_str().ok()).map(|x| x.to_string())});
|
res = Err(CheckerError::HttpError {status: status.as_u16(), location: ok.headers().get(header::LOCATION).and_then(|h| h.to_str().ok()).map(|x| x.to_string())});
|
||||||
@ -365,6 +374,13 @@ async fn main() -> Result<(), Error> {
|
|||||||
failed +=1;
|
failed +=1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
CheckerError::TooManyRequests => {
|
||||||
|
// too many tries
|
||||||
|
if link.last_working.is_some() {
|
||||||
|
info!("Ignoring 429 failure on {} as we've seen success before", url);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
if let Some(last_working) = link.last_working {
|
if let Some(last_working) = link.last_working {
|
||||||
|
Loading…
Reference in New Issue
Block a user