diff --git a/src/TypesenseClient/Connection.php b/src/TypesenseClient/Connection.php index e88fdf5..4c02fff 100644 --- a/src/TypesenseClient/Connection.php +++ b/src/TypesenseClient/Connection.php @@ -41,7 +41,7 @@ public function __construct(string $baseUrl, string $apikey) $this->logger = new NullLogger(); } - public function getClient(): Client + public function getClient(int $numRetries = self::TYPESENSE_CLIENT_RETRY_COUNT): Client { $parsedUrl = parse_url($this->baseUrl); if ($parsedUrl === false) { @@ -61,7 +61,7 @@ public function getClient(): Client $symfonyClient = new TraceableHttpClient(HttpClient::create()); $symfonyClient->setLogger($this->logger); $symfonyClient = new RetryableHttpClient( - $symfonyClient, null, self::TYPESENSE_CLIENT_RETRY_COUNT, + $symfonyClient, null, $numRetries, $this->logger); return new Client( diff --git a/src/TypesenseClient/SearchIndex.php b/src/TypesenseClient/SearchIndex.php index 92c9dad..ebc905d 100644 --- a/src/TypesenseClient/SearchIndex.php +++ b/src/TypesenseClient/SearchIndex.php @@ -167,7 +167,8 @@ public function setLogger(LoggerInterface $logger): void public function checkConnection(): void { - $client = $this->connection->getClient(); + // Limit retries, so we fail more quickly + $client = $this->connection->getClient(3); $client->getHealth()->retrieve(); $client->getMultiSearch()->perform(['searches' => [['q' => 'healthcheck']]]); }