Skip to content

Commit

Permalink
Gross hack, just loop over the job response until it works.
Browse files Browse the repository at this point in the history
  • Loading branch information
Firaenix committed Sep 10, 2021
1 parent 1ed926c commit 6a499f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/api/job_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use super::JobErrors;
pub async fn get_job_results(job_id: &str, auth_token: &str) -> Result<GetJobAPIResponse, JobErrors> {
let job_response: GetJobAPIResponse;
loop {

log::error!("ko {}", job_id);

let response = Client::new()
.get(&format!("https://api.bitping.com/job/{}", job_id))
.bearer_auth(auth_token)
Expand All @@ -19,10 +18,14 @@ pub async fn get_job_results(job_id: &str, auth_token: &str) -> Result<GetJobAPI
let err_msg = match response.text().await {
Ok(v) => v,
Err(_) => {
return Err(e.into())
continue;
// return Err(e.into())
}
};
return Err(JobErrors::CustomHttpError(e, err_msg))

log::debug!("{} {}", e, err_msg);
continue;
// return Err(JobErrors::CustomHttpError(e, err_msg))
}

let parsed_job_response: GetJobAPIResponse = response.json().await?;
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ async fn main() -> Result<(), BpingErrors> {
}
};

tokio::time::sleep(Duration::from_millis(1000)).await;

let job_id = resp.id;
let api_res = match api::get_job_results(&job_id, &inner_token).await {
Ok(v) => v,
Expand Down

0 comments on commit 6a499f2

Please sign in to comment.