function ZookeeperStore::createConnection
1 call to ZookeeperStore::createConnection()
- StoreFactory::createStore in vendor/
symfony/ lock/ Store/ StoreFactory.php
File
-
vendor/
symfony/ lock/ Store/ ZookeeperStore.php, line 35
Class
- ZookeeperStore
- ZookeeperStore is a PersistingStoreInterface implementation using Zookeeper as store engine.
Namespace
Symfony\Component\Lock\StoreCode
public static function createConnection(string $dsn) : \Zookeeper {
if (!str_starts_with($dsn, 'zookeeper:')) {
throw new InvalidArgumentException('Unsupported DSN for Zookeeper.');
}
if (false === ($params = parse_url($dsn))) {
throw new InvalidArgumentException('Invalid Zookeeper DSN.');
}
$host = $params['host'] ?? '';
$hosts = explode(',', $host);
foreach ($hosts as $index => $host) {
if (isset($params['port'])) {
$hosts[$index] = $host . ':' . $params['port'];
}
}
return new \Zookeeper(implode(',', $hosts));
}