Put a semaphore for connection limit as a temporary hack
This commit is contained in:
parent
9ccec9878a
commit
04fadd3d89
3 changed files with 272 additions and 262 deletions
|
@ -97,6 +97,7 @@ async fn get_all_recipes(api_client: &ApiClient) -> Result<HashMap<String, Rc<re
|
|||
"Cannot fetch recipe {} with id {}",
|
||||
rm.name, rm.id
|
||||
));
|
||||
|
||||
response.json::<recipe::Recipe>().await.map(|r| Rc::new(r))
|
||||
});
|
||||
|
||||
|
@ -134,7 +135,7 @@ where
|
|||
&helpers::ical_escape_text(&ev.recipe.name)
|
||||
);
|
||||
|
||||
log::info!(
|
||||
let info_message = format!(
|
||||
"Saving event at {} for '{}'",
|
||||
&ev.ends_at.date(),
|
||||
&ev.recipe.name
|
||||
|
@ -157,13 +158,20 @@ where
|
|||
1,
|
||||
);
|
||||
|
||||
api_client
|
||||
// TODO: wrap this
|
||||
let _ = api_client.rest_semaphore.acquire().await.unwrap();
|
||||
log::info!("{}", info_message);
|
||||
let response = api_client
|
||||
.rest()
|
||||
.put(url)
|
||||
.header("Content-Type", "text/calendar; charset=utf-8")
|
||||
.body(cal_as_string)
|
||||
.send()
|
||||
.await
|
||||
.await;
|
||||
|
||||
// TODO: magic numbers are bad...
|
||||
std::thread::sleep(std::time::Duration::from_millis(300));
|
||||
response
|
||||
});
|
||||
|
||||
let responses = try_join_all(update_requests).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue