Skip to content

Commit

Permalink
Remove pool support in DSN as official client doesn't support such co…
Browse files Browse the repository at this point in the history
…nfiguration
  • Loading branch information
sidz committed Jan 21, 2024
1 parent cd9bb18 commit 60c6502
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 43 deletions.
11 changes: 1 addition & 10 deletions src/ClientConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ public static function fromArray(array $config): self
/**
* Create configuration from Dsn string. Example of valid DSN strings:
* - http://localhost
* - http://foo:bar@localhost:1234?timeout=4&persistant=false
* - pool(http://127.0.0.1 http://127.0.0.2/bar?timeout=4).
* - http://foo:bar@localhost:1234?timeout=4&persistant=false.
*/
public static function fromDsn(string $dsnString): self
{
Expand All @@ -76,14 +75,6 @@ public static function fromDsn(string $dsnString): self
/** @var Url $dsn */
$dsn = $func->first();
$clientConfiguration = self::fromArray(self::parseDsn($dsn));
} elseif ('pool' === $func->getName()) {
$hosts = [];
$clientConfiguration = new static();
/** @var Url $arg */
foreach ($func->getArguments() as $arg) {
$hosts[] = self::parseDsn($arg);
}
$clientConfiguration->set('hosts', $hosts);
} else {
throw new FunctionNotSupportedException($dsnString, $func->getName());
}
Expand Down
33 changes: 0 additions & 33 deletions tests/ClientConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public function testFromSimpleDsn(): void
'port' => 9201,
'path' => null,
'url' => null,
'connections' => [],
'roundRobin' => false,
'retryOnConflict' => 0,
'username' => null,
'password' => null,
Expand All @@ -57,8 +55,6 @@ public function testFromDsnWithParameters(): void
'port' => 9201,
'path' => '/my-path',
'url' => null,
'connections' => [],
'roundRobin' => true,
'retryOnConflict' => 2,
'username' => 'user',
'password' => 'p4ss',
Expand All @@ -69,29 +65,6 @@ public function testFromDsnWithParameters(): void
$this->assertEquals($expected, $configuration->getAll());
}

public function testFromDsnWithPool(): void
{
$configuration = ClientConfiguration::fromDsn('pool(http://[email protected] http://127.0.0.2/bar?timeout=4)?extra=abc&username=tobias');
$expected = [
'host' => null,
'port' => null,
'path' => null,
'url' => null,
'connections' => [
['host' => '127.0.0.1', 'username' => 'nicolas'],
['host' => '127.0.0.2', 'path' => '/bar', 'timeout' => 4],
],
'roundRobin' => false,
'retryOnConflict' => 0,
'username' => 'tobias',
'password' => null,
'extra' => 'abc',
'transport_config' => [],
];

$this->assertEquals($expected, $configuration->getAll());
}

public function testFromEmptyArray(): void
{
$configuration = ClientConfiguration::fromArray([]);
Expand All @@ -101,8 +74,6 @@ public function testFromEmptyArray(): void
'port' => null,
'path' => null,
'url' => null,
'connections' => [], // host, port, path, timeout, transport, compression, timeout, username, password, config -> (curl, headers, url)
'roundRobin' => false,
'retryOnConflict' => 0,
'username' => null,
'password' => null,
Expand All @@ -124,8 +95,6 @@ public function testFromArray(): void
'port' => null,
'path' => null,
'url' => null,
'connections' => [], // host, port, path, timeout, transport, compression, timeout, username, password, config -> (curl, headers, url)
'roundRobin' => false,
'retryOnConflict' => 0,
'username' => 'Jdoe',
'password' => null,
Expand All @@ -152,8 +121,6 @@ public function testGet(): void
'port' => null,
'path' => null,
'url' => null,
'connections' => [],
'roundRobin' => false,
'retryOnConflict' => 0,
'username' => null,
'password' => null,
Expand Down

0 comments on commit 60c6502

Please sign in to comment.