client: Retry failing send()s
This commit is contained in:
parent
02110d9826
commit
cf7f54adb5
1 changed files with 8 additions and 6 deletions
|
@ -4,13 +4,15 @@ use spaceapi::Status;
|
||||||
fn get_spaceapi(url: String) -> Status {
|
fn get_spaceapi(url: String) -> Status {
|
||||||
let user_agent = "spaceapi2prometheus";
|
let user_agent = "spaceapi2prometheus";
|
||||||
let status: Status;
|
let status: Status;
|
||||||
|
let client = reqwest::blocking::Client::builder()
|
||||||
|
.user_agent(user_agent)
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.get(url);
|
||||||
loop {
|
loop {
|
||||||
let client = reqwest::blocking::Client::builder()
|
let res = client.try_clone().unwrap().send();
|
||||||
.user_agent(user_agent)
|
if let Ok(r) = res {
|
||||||
.build();
|
status = serde_json::from_str(&r.text().unwrap()).unwrap();
|
||||||
if let Ok(c) = client {
|
|
||||||
let res = c.get(url).send().unwrap().text().unwrap();
|
|
||||||
status = serde_json::from_str(&res).unwrap();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
eprintln!("Failed to connect to endpoint, trying again!");
|
eprintln!("Failed to connect to endpoint, trying again!");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue