From 35fcfb8c81517cffa1dfe39c9fb945b1edff1e17 Mon Sep 17 00:00:00 2001 From: mdecimus Date: Sun, 14 Apr 2024 19:44:28 +0200 Subject: [PATCH] Fix: Fails to start when Elasticsearch is down/starting up (closes #334) --- crates/store/src/backend/elastic/mod.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/crates/store/src/backend/elastic/mod.rs b/crates/store/src/backend/elastic/mod.rs index 86dcdc46..382d0fe1 100644 --- a/crates/store/src/backend/elastic/mod.rs +++ b/crates/store/src/backend/elastic/mod.rs @@ -103,17 +103,19 @@ impl ElasticSearchStore { } }; - es.create_index( - config - .property_or_default((&prefix, "index.shards"), "3") - .unwrap_or(3), - config - .property_or_default((&prefix, "index.replicas"), "0") - .unwrap_or(0), - ) - .await - .map_err(|err| config.new_build_error(prefix.as_str(), err.to_string())) - .ok()?; + if let Err(err) = es + .create_index( + config + .property_or_default((&prefix, "index.shards"), "3") + .unwrap_or(3), + config + .property_or_default((&prefix, "index.replicas"), "0") + .unwrap_or(0), + ) + .await + { + config.new_build_error(prefix.as_str(), err.to_string()); + } Some(es) }