diff --git a/crates/store/src/backend/meili/main.rs b/crates/store/src/backend/meili/main.rs index 1e7fc422..02472ee4 100644 --- a/crates/store/src/backend/meili/main.rs +++ b/crates/store/src/backend/meili/main.rs @@ -31,21 +31,31 @@ impl MeiliSearchStore { .property_or_default::((&prefix, "task.poll-interval"), "500ms") .unwrap_or(Duration::from_millis(500)); let task_poll_retries = config - .property_or_default::((&prefix, "task.poll-retries"), "60") - .unwrap_or(60); + .property_or_default::((&prefix, "task.poll-retries"), "120") + .unwrap_or(120); + let task_fail_on_timeout = config + .property_or_default::((&prefix, "task.fail-on-timeout"), "true") + .unwrap_or(true); let ms = Self { client, url, - task_poll_interval, - task_poll_retries, + task_poll_interval: Duration::from_millis(500), + task_poll_retries: 120, + task_fail_on_timeout: true, }; if let Err(err) = ms.create_indexes().await { config.new_build_error(prefix.as_str(), err.to_string()); } - Some(ms) + Some(Self { + client: ms.client, + url: ms.url, + task_poll_interval, + task_poll_retries, + task_fail_on_timeout, + }) } pub async fn create_indexes(&self) -> trc::Result<()> { @@ -58,19 +68,20 @@ impl MeiliSearchStore { async fn create_index(&self) -> trc::Result<()> { let index_name = T::index().index_name(); - let response = self - .client - .post(format!("{}/indexes", self.url)) - .body( - json!({ - "uid": index_name, - "primaryKey": "id", - }) - .to_string(), - ) - .send() - .await - .map_err(|err| trc::StoreEvent::MeilisearchError.reason(err))?; + let response = assert_success( + self.client + .post(format!("{}/indexes", self.url)) + .body( + json!({ + "uid": index_name, + "primaryKey": "id", + }) + .to_string(), + ) + .send() + .await, + ) + .await?; if !self.wait_for_task(response).await? { // Index already exists @@ -245,9 +256,13 @@ impl MeiliSearchStore { } } - Err(trc::StoreEvent::MeilisearchError - .reason("Timed out waiting for Meilisearch task") - .id(task_uid)) + if self.task_fail_on_timeout { + Err(trc::StoreEvent::MeilisearchError + .reason("Timed out waiting for Meilisearch task") + .id(task_uid)) + } else { + Ok(true) + } } } diff --git a/crates/store/src/backend/meili/mod.rs b/crates/store/src/backend/meili/mod.rs index a62b52e2..06ffc2ff 100644 --- a/crates/store/src/backend/meili/mod.rs +++ b/crates/store/src/backend/meili/mod.rs @@ -16,6 +16,7 @@ pub struct MeiliSearchStore { url: String, task_poll_interval: Duration, task_poll_retries: usize, + task_fail_on_timeout: bool, } #[derive(Debug, Deserialize)]