* * @throws \Amp\Postgres\FailureException If connecting fails. * @throws \Error If neither ext-pgsql or pecl-pq is loaded. * * @codeCoverageIgnore */ function connect(string $connectionString, CancellationToken $token = null): Promise { if (\extension_loaded("pq")) { return PqConnection::connect($connectionString, $token); } if (\extension_loaded("pgsql")) { return PgSqlConnection::connect($connectionString, $token); } throw new \Error("amphp/postgres requires either pecl-pq or ext-pgsql"); } /** * @param string $connectionString * @param int $maxConnections * * @return \Amp\Postgres\Pool */ function pool(string $connectionString, int $maxConnections = Pool::DEFAULT_MAX_CONNECTIONS): Pool { return new Pool($connectionString, $maxConnections); }