From 96a8c0f10303afd28f32967c761abfea2e104eb2 Mon Sep 17 00:00:00 2001 From: Jean-Pascal Devierne Date: Tue, 25 Feb 2020 17:34:51 +0100 Subject: [PATCH 1/2] :fire: Remove Elasticsearch centric files, to only keep Elastica ones Signed-off-by: Jean-Pascal Devierne --- src/Elasticsearch/Client.php | 32 ----------------------------- src/Elasticsearch/ClientBuilder.php | 26 ----------------------- src/Factory/ClientFactory.php | 28 ------------------------- src/Resources/config/services.xml | 1 - 4 files changed, 87 deletions(-) delete mode 100644 src/Elasticsearch/Client.php delete mode 100644 src/Elasticsearch/ClientBuilder.php delete mode 100644 src/Factory/ClientFactory.php diff --git a/src/Elasticsearch/Client.php b/src/Elasticsearch/Client.php deleted file mode 100644 index fcf806f..0000000 --- a/src/Elasticsearch/Client.php +++ /dev/null @@ -1,32 +0,0 @@ -dispatcher->dispatch(SearchQuery::NAME, new SearchQuery($params, $timestamp)); - $result = parent::search($params); - $this->dispatcher->dispatch(SearchResult::NAME, new SearchResult($result, $timestamp)); - return $result; - } -} diff --git a/src/Elasticsearch/ClientBuilder.php b/src/Elasticsearch/ClientBuilder.php deleted file mode 100644 index 5a17fc1..0000000 --- a/src/Elasticsearch/ClientBuilder.php +++ /dev/null @@ -1,26 +0,0 @@ -setHosts($hosts); - if (null !== $serializer) { - $builder->setSerializer($serializer); - } - return $builder->build(); - } -} diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml index 4e17586..f253f1a 100644 --- a/src/Resources/config/services.xml +++ b/src/Resources/config/services.xml @@ -6,7 +6,6 @@ - Date: Tue, 25 Feb 2020 17:36:04 +0100 Subject: [PATCH 2/2] :sparkles: Throw an exception if index couldn't be marked as live, as otherwise the problem wasn't explicit Signed-off-by: Jean-Pascal Devierne --- src/Provider/IndexProvider.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Provider/IndexProvider.php b/src/Provider/IndexProvider.php index 6ce1b51..7931590 100644 --- a/src/Provider/IndexProvider.php +++ b/src/Provider/IndexProvider.php @@ -72,6 +72,8 @@ public function rebuildIndex($markAsLive = true, $removeOldIndexes = true): Inde * @param Index $index The index to link to the $this->name alias * @param bool $removeOldIndexes If true, remove the indexes currently linked to $this->name alias after marking $index as live * + * @throws \Exception if the index couldn't be marked as live + * * @return bool index is markedAsLive */ public function markAsLive(Index $index, bool $removeOldIndexes = true): bool @@ -95,7 +97,7 @@ public function markAsLive(Index $index, bool $removeOldIndexes = true): bool } // and delete the failed one $index->delete(); - return false; + throw $e; } if ($removeOldIndexes) { // if everything went well, the new index is set as the alias @@ -109,7 +111,7 @@ public function markAsLive(Index $index, bool $removeOldIndexes = true): bool return true; } - + protected function getIndexByName($name): Index { return new Index($this->eventDispatcher, $this->client, $name);