Skip to content

Commit fbc89ad

Browse files
committed
Merge branch 'main' into feat/remove-formatter
2 parents 2816868 + 6c578a0 commit fbc89ad

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

docker-compose.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ services:
6464
- "11474:7474"
6565
environment:
6666
<<: *common-env
67-
NEO4j_server_bolt_advertised_address: localhost:11687
68-
NEO4j_server_http_advertised_address: localhost:11474
67+
NEO4J_server_bolt_advertised__address: neo4j:7687
68+
NEO4J_server_http_advertised__address: neo4j:7474
6969

7070
server1:
7171
<<: *common-cluster
@@ -76,8 +76,8 @@ services:
7676
- "7474:7474"
7777
environment:
7878
<<: *common-core-env
79-
NEO4j_server_bolt_advertised_address: localhost:7687
80-
NEO4j_server_http_advertised_address: localhost:7474
79+
NEO4J_server_bolt_advertised__address: server1:7687
80+
NEO4J_server_http_advertised__address: server1:7474
8181

8282
server2:
8383
<<: *common-cluster
@@ -88,8 +88,8 @@ services:
8888
- "8474:7474"
8989
environment:
9090
<<: *common-core-env
91-
NEO4j_server_bolt_advertised_address: localhost:8687
92-
NEO4j_server_http_advertised_address: localhost:8474
91+
NEO4J_server_bolt_advertised__address: server2:7687
92+
NEO4J_server_http_advertised__address: server2:7474
9393

9494
server3:
9595
<<: *common-cluster
@@ -100,8 +100,8 @@ services:
100100
- "9687:7687"
101101
environment:
102102
<<: *common-core-env
103-
NEO4j_server_bolt_advertised_address: localhost:9687
104-
NEO4j_server_http_advertised_address: localhost:9474
103+
NEO4J_server_bolt_advertised__address: server3:7687
104+
NEO4J_server_http_advertised__address: server3:7474
105105

106106
server4:
107107
<<: *common-cluster
@@ -113,5 +113,5 @@ services:
113113
environment:
114114
<<: *common-cluster-env
115115
NEO4J_initial_server_mode__constraint: 'SECONDARY'
116-
NEO4j_server_bolt_advertised_address: localhost:10687
117-
NEO4j_server_http_advertised_address: localhost:10474
116+
NEO4J_server_bolt_advertised__address: server4:7687
117+
NEO4J_server_http_advertised__address: server4:7474

src/DriverFactory.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,26 @@ private static function createNeo4jDriver(string|UriInterface $uri, ?DriverConfi
7373

7474
return Neo4jDriver::create($uri, $configuration, $authenticate);
7575
}
76+
77+
/**
78+
* @template U
79+
*
80+
* @param FormatterInterface<U> $formatter
81+
*
82+
* @return (
83+
* func_num_args() is 4
84+
* ? DriverInterface<U>
85+
* : DriverInterface<OGMResults>
86+
* )
87+
*
88+
* @pure
89+
*/
90+
private static function createHttpDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, ?FormatterInterface $formatter = null): DriverInterface
91+
{
92+
if ($formatter !== null) {
93+
return HttpDriver::create($uri, $configuration, $authenticate, $formatter);
94+
}
95+
96+
return HttpDriver::create($uri, $configuration, $authenticate);
97+
}
7698
}

src/Formatter/SummarizedResultFormatter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747

4848
use function microtime;
4949

50+
use Psr\Http\Message\RequestInterface;
51+
use Psr\Http\Message\ResponseInterface;
52+
use stdClass;
53+
use UnexpectedValueException;
54+
5055
/**
5156
* Decorates the result of the provided format with an extensive summary.
5257
*

src/Neo4j/Neo4jConnectionPool.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
namespace Laudis\Neo4j\Neo4j;
1515

16-
use function array_unique;
17-
1816
use Bolt\error\ConnectException;
1917

2018
use function count;
@@ -25,7 +23,6 @@
2523
use function implode;
2624

2725
use Laudis\Neo4j\Bolt\BoltConnection;
28-
use Laudis\Neo4j\Bolt\Connection;
2926
use Laudis\Neo4j\Bolt\ConnectionPool;
3027
use Laudis\Neo4j\BoltFactory;
3128
use 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

Comments
 (0)