diff --git a/composer.lock b/composer.lock index e5678dd..bf1125a 100644 --- a/composer.lock +++ b/composer.lock @@ -3646,13 +3646,13 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": ">=8.3" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "8.3" }, diff --git a/src/Pools/Connection.php b/src/Pools/Connection.php index f121366..eaeec6f 100644 --- a/src/Pools/Connection.php +++ b/src/Pools/Connection.php @@ -10,14 +10,11 @@ class Connection protected ?Pool $pool = null; - protected bool $healthy = true; - /** * @param mixed $resource */ - public function __construct( - protected mixed $resource, - ) { + public function __construct(protected mixed $resource) + { } /** @@ -97,22 +94,4 @@ public function destroy(): Pool return $this->pool->destroy($this); } - - /** - * @param bool $healthy - * @return self - */ - public function setHealthy(bool $healthy): self - { - $this->healthy = $healthy; - return $this; - } - - /** - * @return bool - */ - public function isHealthy(): bool - { - return $this->healthy; - } } diff --git a/src/Pools/Pool.php b/src/Pools/Pool.php index 8336998..a04f990 100644 --- a/src/Pools/Pool.php +++ b/src/Pools/Pool.php @@ -305,21 +305,12 @@ public function count(): int public function reclaim(Connection $connection = null): self { if ($connection !== null) { - if ($connection->isHealthy()) { - $this->push($connection); - } else { - $this->destroy($connection); - } + $this->push($connection); return $this; } foreach ($this->active as $connection) { - if ($connection->isHealthy()) { - $this->push($connection); - continue; - } - - $this->destroy($connection); + $this->push($connection); } return $this; diff --git a/tests/Pools/PoolTest.php b/tests/Pools/PoolTest.php index c43b842..d840ea4 100644 --- a/tests/Pools/PoolTest.php +++ b/tests/Pools/PoolTest.php @@ -259,38 +259,6 @@ public function testDestroy(): void $this->assertEquals('y', $connection2->getResource()); } - public function testUnhealthyConnectionsPurged(): void - { - $object = new Pool('testDestroy', 2, function () { - return 'x'; - }); - - $this->assertEquals(2, $object->count()); - - $connection1 = $object->pop(); - $connection2 = $object->pop(); - - $connection1Id = $connection1->getId(); - $connection2Id = $connection2->getId(); - - $this->assertEquals(0, $object->count()); - - $this->assertEquals('x', $connection1->getResource()); - $this->assertEquals('x', $connection2->getResource()); - - $connection1->setHealthy(false); - - $object->reclaim(); - - $this->assertEquals(2, $object->count()); - - $connection2 = $object->pop(); - $connection1 = $object->pop(); - - $this->assertNotEquals($connection1Id, $connection1->getId()); - $this->assertEquals($connection2Id, $connection2->getId()); - } - public function testTelemetry(): void { $telemetry = new TestTelemetry();