1313
1414namespace Laudis \Neo4j \Neo4j ;
1515
16- use function array_unique ;
17-
1816use Bolt \error \ConnectException ;
1917
2018use function count ;
2523use function implode ;
2624
2725use Laudis \Neo4j \Bolt \BoltConnection ;
28- use Laudis \Neo4j \Bolt \Connection ;
2926use Laudis \Neo4j \Bolt \ConnectionPool ;
3027use Laudis \Neo4j \BoltFactory ;
3128use Laudis \Neo4j \Common \Cache ;
@@ -127,7 +124,7 @@ public function acquire(SessionConfiguration $config): Generator
127124 {
128125 $ key = $ this ->createKey ($ this ->data , $ config );
129126
130- /** @var RoutingTable|null */
127+ /** @var RoutingTable|null $table */
131128 $ table = $ this ->cache ->get ($ key );
132129 $ triedAddresses = [];
133130
@@ -164,7 +161,7 @@ public function acquire(SessionConfiguration $config): Generator
164161 throw new RuntimeException (sprintf ('Cannot connect to host: "%s". Hosts tried: "%s" ' , $ this ->data ->getUri ()->getHost (), implode ('", " ' , $ triedAddresses )), previous: $ latestError );
165162 }
166163
167- $ server = $ this ->getNextServer ($ table , $ config ->getAccessMode ()) ?? $ this -> data -> getUri () ;
164+ $ server = $ this ->getNextServer ($ table , $ config ->getAccessMode ());
168165
169166 if ($ server ->getScheme () === '' ) {
170167 $ server = $ server ->withScheme ($ this ->data ->getUri ()->getScheme ());
@@ -181,13 +178,8 @@ public function getLogger(): ?Neo4jLogger
181178 /**
182179 * @throws Exception
183180 */
184- private function getNextServer (RoutingTable $ table , AccessMode $ mode ): ? Uri
181+ private function getNextServer (RoutingTable $ table , AccessMode $ mode ): Uri
185182 {
186- $ servers = array_unique ($ table ->getWithRole ());
187- if (count ($ servers ) === 1 ) {
188- return null ;
189- }
190-
191183 if (AccessMode::WRITE () === $ mode ) {
192184 $ servers = $ table ->getWithRole (RoutingRoles::LEADER ());
193185 } else {
@@ -233,7 +225,7 @@ private function createKey(ConnectionRequestData $data, ?SessionConfiguration $c
233225 [
234226 $ data ->getUserAgent (),
235227 $ uri ->getHost (),
236- $ config ? $ config ->getDatabase () : null ,
228+ $ config? ->getDatabase(),
237229 $ uri ->getPort () ?? '7687 ' ,
238230 ]
239231 )
0 commit comments