|
15 | 15 |
|
16 | 16 | use function array_slice;
|
17 | 17 | use function array_unique;
|
| 18 | +use Bolt\error\MessageException; |
18 | 19 | use Bolt\protocol\V3;
|
19 | 20 | use Bolt\protocol\V4;
|
20 | 21 | use Bolt\protocol\V4_3;
|
|
30 | 31 | use Laudis\Neo4j\Databags\SessionConfiguration;
|
31 | 32 | use Laudis\Neo4j\Enum\AccessMode;
|
32 | 33 | use Laudis\Neo4j\Enum\RoutingRoles;
|
| 34 | +use const PHP_INT_MAX; |
33 | 35 | use Psr\Http\Message\UriInterface;
|
34 | 36 | use function random_int;
|
35 | 37 | use function str_starts_with;
|
@@ -128,7 +130,7 @@ private function routingTable(ConnectionInterface $connection, SessionConfigurat
|
128 | 130 | return $this->useRoutingTable($bolt);
|
129 | 131 | }
|
130 | 132 |
|
131 |
| - return $this->useClusterOverview($bolt); |
| 133 | + return $this->useClusterOverview($bolt, $connection); |
132 | 134 | }
|
133 | 135 |
|
134 | 136 | private function useRouteMessage(V4_3 $bolt, SessionConfiguration $config): RoutingTable
|
@@ -172,9 +174,22 @@ private function useRoutingTable(V4 $bolt): RoutingTable
|
172 | 174 | /**
|
173 | 175 | * @throws Exception
|
174 | 176 | */
|
175 |
| - private function useClusterOverview(V3 $bolt): RoutingTable |
| 177 | + private function useClusterOverview(V3 $bolt, ConnectionInterface $c): RoutingTable |
176 | 178 | {
|
177 |
| - $bolt->run('CALL dbms.cluster.overview()'); |
| 179 | + try { |
| 180 | + $bolt->run('CALL dbms.cluster.overview()'); |
| 181 | + } catch (MessageException $e) { |
| 182 | + return new RoutingTable([ |
| 183 | + [ |
| 184 | + 'addresses' => [(string) $c->getServerAddress()], |
| 185 | + 'role' => 'WRITE', |
| 186 | + ], |
| 187 | + [ |
| 188 | + 'addresses' => [(string) $c->getServerAddress()], |
| 189 | + 'role' => 'READ', |
| 190 | + ], |
| 191 | + ], PHP_INT_MAX); |
| 192 | + } |
178 | 193 | /** @var list<array{0: string, 1: list<string>, 2: string, 4: list, 4:string}> */
|
179 | 194 | $response = $bolt->pullAll();
|
180 | 195 | $response = array_slice($response, 0, count($response) - 1);
|
|
0 commit comments