Skip to content

Commit ef5e574

Browse files
committed
refactor(connection): remove redundant connection rebuild logic
- Eliminated the unused `rebuildConnection` method. - Removed the redundant `rebuild` property from the Connection class. - Adjusted `getClient` to build the connection if the client is missing. - Deleted the call to `rebuildConnection` in the Bridge class. Because who needs another rebuild when you can just health-check? 🔧✨
1 parent dc3f344 commit ef5e574

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/Connection.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ class Connection extends BaseConnection
7474

7575
protected mixed $elasticMetaHeader = null;
7676

77-
protected bool $rebuild = false;
78-
7977
protected string $connectionName;
8078

8179
/**
@@ -214,11 +212,6 @@ public function getDriverName(): string
214212
return 'elasticsearch';
215213
}
216214

217-
public function rebuildConnection(): void
218-
{
219-
$this->rebuild = true;
220-
}
221-
222215
public function getClient(): ?Client
223216
{
224217
return $this->client;
@@ -244,9 +237,10 @@ public function __call($method, $parameters)
244237
if (! $this->index) {
245238
$this->index = $this->indexPrefix.'*';
246239
}
247-
if ($this->rebuild) {
240+
241+
// If we are missing a database connection client we need to reconnect.
242+
if (! $this->client) {
248243
$this->client = $this->buildConnection();
249-
$this->rebuild = false;
250244
}
251245
$bridge = new Bridge($this);
252246

src/DSL/Bridge.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,6 @@ private function _throwError(Exception $exception, $params, $queryTag): QueryExc
14341434
$errorMsg = $exception->getMessage();
14351435
$errorCode = $exception->getCode();
14361436
$queryTag = str_replace('_', '', $queryTag);
1437-
$this->connection->rebuildConnection();
14381437
$error = new Results([], [], $params, $queryTag);
14391438
$error->setError($errorMsg, $errorCode);
14401439

0 commit comments

Comments
 (0)