From 361f66869615ea9de1be1d613e795b76555b032d Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Sat, 17 Nov 2018 16:22:43 +0200 Subject: [PATCH] [dsn] Cluster DSN --- GenericStatsStorageFactory.php | 2 +- InfluxDbStorage.php | 10 +++++----- WampStorage.php | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GenericStatsStorageFactory.php b/GenericStatsStorageFactory.php index f4a257c..3fc94a4 100644 --- a/GenericStatsStorageFactory.php +++ b/GenericStatsStorageFactory.php @@ -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); diff --git a/InfluxDbStorage.php b/InfluxDbStorage.php index e3be8ff..7d25e1c 100644 --- a/InfluxDbStorage.php +++ b/InfluxDbStorage.php @@ -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( @@ -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; }); } } diff --git a/WampStorage.php b/WampStorage.php index 79cf78c..44623d4 100644 --- a/WampStorage.php +++ b/WampStorage.php @@ -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( @@ -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; }); }