Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions src/Database/Adapter/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,10 @@ class Pool extends Adapter

/**
* @param UtopiaPool<covariant Adapter> $pool The pool to use for connections. Must contain instances of Adapter.
* @throws DatabaseException
*/
public function __construct(UtopiaPool $pool)
{
$this->pool = $pool;

$this->pool->use(function (mixed $resource) {
if (!($resource instanceof Adapter)) {
throw new DatabaseException('Pool must contain instances of ' . Adapter::class);
}

// Run setters in case the pooled adapter has its own config
try {
$this->setAuthorization($resource->getAuthorization());
} catch (\Error $e) {
// Authorization not initialized yet, so skip it.
}
$this->setDatabase($resource->getDatabase());
$this->setNamespace($resource->getNamespace());
$this->setSharedTables($resource->getSharedTables());
$this->setTenant($resource->getTenant());

if ($resource->getTimeout() > 0) {
$this->setTimeout($resource->getTimeout());
}
$this->resetDebug();
foreach ($resource->getDebug() as $key => $value) {
$this->setDebug($key, $value);
}
$this->resetMetadata();
foreach ($resource->getMetadata() as $key => $value) {
$this->setMetadata($key, $value);
}
});
}

/**
Expand Down