Skip to content

Commit f4c1517

Browse files
qkdreyerfabpot
authored andcommitted
Handle CSV DSN in ZookeeperStore
1 parent fc1053f commit f4c1517

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Store/ZookeeperStore.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ public static function createConnection(string $dsn): \Zookeeper
4545
}
4646

4747
$host = $params['host'] ?? '';
48-
if (isset($params['port'])) {
49-
$host .= ':'.$params['port'];
48+
$hosts = explode(',', $host);
49+
50+
foreach ($hosts as $index => $host) {
51+
if (isset($params['port'])) {
52+
$hosts[$index] = $host.':'.$params['port'];
53+
}
5054
}
5155

52-
return new \Zookeeper($host);
56+
return new \Zookeeper(implode($hosts, ','));
5357
}
5458

5559
/**

Tests/Store/StoreFactoryTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function validConnections()
6262
if (class_exists(\Zookeeper::class)) {
6363
yield [$this->createMock(\Zookeeper::class), ZookeeperStore::class];
6464
yield ['zookeeper://localhost:2181', ZookeeperStore::class];
65+
yield ['zookeeper://localhost01,localhost02:2181', ZookeeperStore::class];
6566
}
6667
if (\extension_loaded('sysvsem')) {
6768
yield ['semaphore', SemaphoreStore::class];

0 commit comments

Comments
 (0)