2016-12-30 06:21:17 +01:00
|
|
|
<?php
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
namespace Amp\Postgres;
|
|
|
|
|
2016-11-15 18:06:21 +01:00
|
|
|
use Interop\Async\Promise;
|
2016-09-14 16:27:39 +02:00
|
|
|
|
|
|
|
class AggregatePool extends AbstractPool {
|
|
|
|
/**
|
|
|
|
* @param \Amp\Postgres\Connection $connection
|
|
|
|
*/
|
|
|
|
public function addConnection(Connection $connection) {
|
|
|
|
parent::addConnection($connection);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2016-11-15 18:06:21 +01:00
|
|
|
protected function createConnection(): Promise {
|
2016-09-14 16:27:39 +02:00
|
|
|
throw new PoolError("Creating connections is not available in an aggregate pool");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getMaxConnections(): int {
|
|
|
|
$count = $this->getConnectionCount();
|
|
|
|
|
|
|
|
if (!$count) {
|
|
|
|
throw new PoolError("No connections in aggregate pool");
|
|
|
|
}
|
|
|
|
|
|
|
|
return $count;
|
|
|
|
}
|
|
|
|
}
|