Skip to content

Commit

Permalink
[TASK] Show Elasticsearch host on connection failure
Browse files Browse the repository at this point in the history
This makes it slightly easier to debug configuration issues.
  • Loading branch information
mbrodala committed Oct 6, 2020
1 parent fb939a6 commit 6d3c6aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions Classes/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ public static function getClient()
{
if (self::$client == null) {
self::$client = ClientBuilder::create()
->setHosts(
ExtconfService::getInstance()
->getHostsSettings()
)->build();
->setHosts(ExtconfService::getInstance()->getHostsSettings())
->build();
}
return self::$client;
}
Expand All @@ -46,6 +44,7 @@ public static function getClient()
public static function isHealthy()
{
$ping = self::getClient()->ping();

return $ping;
}
}
4 changes: 3 additions & 1 deletion Classes/Service/IndexingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ protected function applyEnvironment(array $environment): array
protected function assertConnectionHealthy(): void
{
if (!Connection::isHealthy()) {
throw new \RuntimeException('Elasticsearch is offline', 1599662577);
$hosts = ExtconfService::getInstance()->getHostsSettings();

throw new \RuntimeException(sprintf('Elasticsearch at "%s" is offline', implode(', ', $hosts)), 1599662577);
}
}

Expand Down

0 comments on commit 6d3c6aa

Please sign in to comment.