mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Merge 983dd8560d
into a88146d59e
This commit is contained in:
commit
b9ab763f26
19 changed files with 218 additions and 225 deletions
|
@ -407,13 +407,20 @@ impl<State> Server<State> {
|
|||
}
|
||||
|
||||
pub async fn wait_task(&self, update_id: u64) -> Value {
|
||||
Server::<Shared>::_wait_task(async |url| self.service.get(url).await, update_id).await
|
||||
}
|
||||
|
||||
pub(super) async fn _wait_task<F>(request_fn: F, update_id: u64) -> Value
|
||||
where
|
||||
F: AsyncFnOnce(String) -> (Value, StatusCode) + Copy,
|
||||
{
|
||||
// try several times to get status, or panic to not wait forever
|
||||
let url = format!("/tasks/{}", update_id);
|
||||
let max_attempts = 400; // 200 seconds total, 0.5s per attempt
|
||||
let url = format!("/tasks/{update_id}");
|
||||
let max_attempts = 400; // 200 seconds in total, 0.5secs per attempt
|
||||
|
||||
for i in 0..max_attempts {
|
||||
let (response, status_code) = self.service.get(&url).await;
|
||||
assert_eq!(200, status_code, "response: {}", response);
|
||||
let (response, status_code) = request_fn(url.clone()).await;
|
||||
assert_eq!(200, status_code, "response: {response}");
|
||||
|
||||
if response["status"] == "succeeded" || response["status"] == "failed" {
|
||||
return response;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue