Avatars tests are green!

This commit is contained in:
Eldad Fux
2024-04-14 22:17:07 +02:00
parent 6cade89369
commit 766b2ba13e
10 changed files with 330 additions and 256 deletions
+9 -27
View File
@@ -2,41 +2,20 @@
namespace Appwrite\Utopia\Queue;
use Utopia\Pools\Connection;
class Connections
{
/**
* @var Connection[]
* @var array
*/
protected array $connections = [];
/**
* @param Connection $pool
* @param mixed $connection
* @return self
*/
public function add(Connection $connection): self
public function add(mixed $connection, $pool): self
{
$this->connections[$connection->getID()] = $connection;
return $this;
}
/**
* @param string $id
* @return Connection
*/
public function get(string $id): Connection
{
return $this->connections[$id] ?? throw new \Exception("Connection '{$id}' not found");
}
/**
* @param string $id
* @return self
*/
public function remove(string $id): self
{
unset($this->connections[$id]);
$this->connections[] = ['connection' => $connection, 'pool' => $pool];
return $this;
}
@@ -45,8 +24,11 @@ class Connections
*/
public function reclaim(): self
{
foreach ($this->connections as $connection) {
$connection->reclaim();
foreach ($this->connections as $id => $resource) {
$pool = $resource['pool'];
$connection = $resource['connection'];
$pool->put($connection);
unset($this->connections[$id]);
}
return $this;