Skip to content

Commit

Permalink
[dsn] Cluster DSN
Browse files Browse the repository at this point in the history
  • Loading branch information
makasim committed Nov 17, 2018
1 parent 43dfb36 commit 361f668
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion GenericStatsStorageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function create($config): StatsStorage
throw new \InvalidArgumentException('The config must have dsn key set.');
}

$dsn = new Dsn($config['dsn']);
$dsn = Dsn::parseFirst($config['dsn']);

if ($storageClass = $this->findStorageClass($dsn, Resources::getKnownStorages())) {
return new $storageClass(1 === count($config) ? $config['dsn'] : $config);
Expand Down
10 changes: 5 additions & 5 deletions InfluxDbStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private function getDb(): Database

private function parseDsn(string $dsn): array
{
$dsn = new Dsn($dsn);
$dsn = Dsn::parseFirst($dsn);

if (false === in_array($dsn->getSchemeProtocol(), ['influxdb'], true)) {
throw new \LogicException(sprintf(
Expand All @@ -196,10 +196,10 @@ private function parseDsn(string $dsn): array
'port' => $dsn->getPort(),
'user' => $dsn->getUser(),
'password' => $dsn->getPassword(),
'db' => $dsn->getQueryParameter('db'),
'measurementSentMessages' => $dsn->getQueryParameter('measurementSentMessages'),
'measurementConsumedMessages' => $dsn->getQueryParameter('measurementConsumedMessages'),
'measurementConsumers' => $dsn->getQueryParameter('measurementConsumers'),
'db' => $dsn->getString('db'),
'measurementSentMessages' => $dsn->getString('measurementSentMessages'),
'measurementConsumedMessages' => $dsn->getString('measurementConsumedMessages'),
'measurementConsumers' => $dsn->getString('measurementConsumers'),
]), function ($value) { return null !== $value; });
}
}
8 changes: 4 additions & 4 deletions WampStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private function createClient(): Client

private function parseDsn(string $dsn): array
{
$dsn = new Dsn($dsn);
$dsn = Dsn::parseFirst($dsn);

if (false === in_array($dsn->getSchemeProtocol(), ['wamp', 'ws'], true)) {
throw new \LogicException(sprintf(
Expand All @@ -204,10 +204,10 @@ private function parseDsn(string $dsn): array
return array_filter(array_replace($dsn->getQuery(), [
'host' => $dsn->getHost(),
'port' => $dsn->getPort(),
'topic' => $dsn->getQueryParameter('topic'),
'max_retries' => $dsn->getInt('max_retries'),
'topic' => $dsn->getString('topic'),
'max_retries' => $dsn->getDecimal('max_retries'),
'initial_retry_delay' => $dsn->getFloat('initial_retry_delay'),
'max_retry_delay' => $dsn->getInt('max_retry_delay'),
'max_retry_delay' => $dsn->getDecimal('max_retry_delay'),
'retry_delay_growth' => $dsn->getFloat('retry_delay_growth'),
]), function ($value) { return null !== $value; });
}
Expand Down

0 comments on commit 361f668

Please sign in to comment.