Skip to content

Commit ad64d45

Browse files
authored
Merge pull request #18 from utopia-php/revert-connection-health
Revert connection health
2 parents 23ac865 + c77456d commit ad64d45

File tree

4 files changed

+6
-68
lines changed

4 files changed

+6
-68
lines changed

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Pools/Connection.php

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ class Connection
1010

1111
protected ?Pool $pool = null;
1212

13-
protected bool $healthy = true;
14-
1513
/**
1614
* @param mixed $resource
1715
*/
18-
public function __construct(
19-
protected mixed $resource,
20-
) {
16+
public function __construct(protected mixed $resource)
17+
{
2118
}
2219

2320
/**
@@ -97,22 +94,4 @@ public function destroy(): Pool
9794

9895
return $this->pool->destroy($this);
9996
}
100-
101-
/**
102-
* @param bool $healthy
103-
* @return self
104-
*/
105-
public function setHealthy(bool $healthy): self
106-
{
107-
$this->healthy = $healthy;
108-
return $this;
109-
}
110-
111-
/**
112-
* @return bool
113-
*/
114-
public function isHealthy(): bool
115-
{
116-
return $this->healthy;
117-
}
11897
}

src/Pools/Pool.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,21 +305,12 @@ public function count(): int
305305
public function reclaim(Connection $connection = null): self
306306
{
307307
if ($connection !== null) {
308-
if ($connection->isHealthy()) {
309-
$this->push($connection);
310-
} else {
311-
$this->destroy($connection);
312-
}
308+
$this->push($connection);
313309
return $this;
314310
}
315311

316312
foreach ($this->active as $connection) {
317-
if ($connection->isHealthy()) {
318-
$this->push($connection);
319-
continue;
320-
}
321-
322-
$this->destroy($connection);
313+
$this->push($connection);
323314
}
324315

325316
return $this;

tests/Pools/PoolTest.php

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -259,38 +259,6 @@ public function testDestroy(): void
259259
$this->assertEquals('y', $connection2->getResource());
260260
}
261261

262-
public function testUnhealthyConnectionsPurged(): void
263-
{
264-
$object = new Pool('testDestroy', 2, function () {
265-
return 'x';
266-
});
267-
268-
$this->assertEquals(2, $object->count());
269-
270-
$connection1 = $object->pop();
271-
$connection2 = $object->pop();
272-
273-
$connection1Id = $connection1->getId();
274-
$connection2Id = $connection2->getId();
275-
276-
$this->assertEquals(0, $object->count());
277-
278-
$this->assertEquals('x', $connection1->getResource());
279-
$this->assertEquals('x', $connection2->getResource());
280-
281-
$connection1->setHealthy(false);
282-
283-
$object->reclaim();
284-
285-
$this->assertEquals(2, $object->count());
286-
287-
$connection2 = $object->pop();
288-
$connection1 = $object->pop();
289-
290-
$this->assertNotEquals($connection1Id, $connection1->getId());
291-
$this->assertEquals($connection2Id, $connection2->getId());
292-
}
293-
294262
public function testTelemetry(): void
295263
{
296264
$telemetry = new TestTelemetry();

0 commit comments

Comments
 (0)