Skip to content

Commit a9fbe29

Browse files
committed
injected the semaphore factory where needed
1 parent 5c35d36 commit a9fbe29

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/Bolt/BoltDriver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ public static function create($uri, ?DriverConfiguration $configuration = null,
8080

8181
$configuration ??= DriverConfiguration::default();
8282
$authenticate ??= Authenticate::fromUrl($uri);
83+
$semaphore = $configuration->getSemaphoreInterface()->create($uri, $configuration);
8384

8485
/** @psalm-suppress InvalidArgument */
8586
return new self(
8687
$uri,
87-
ConnectionPool::create($uri, $authenticate, $configuration),
88+
ConnectionPool::create($uri, $authenticate, $configuration, $semaphore),
8889
$formatter ?? OGMFormatter::create(),
8990
);
9091
}

src/Bolt/ConnectionPool.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ public function __construct(SemaphoreInterface $semaphore, BoltFactory $factory,
4646
$this->data = $data;
4747
}
4848

49-
public static function create(UriInterface $uri, AuthenticateInterface $auth, DriverConfiguration $conf): self
49+
public static function create(UriInterface $uri, AuthenticateInterface $auth, DriverConfiguration $conf, SemaphoreInterface $semaphore): self
5050
{
51-
$semaphore = SemaphoreFactory::getInstance()->create($uri, $conf);
52-
5351
return new self(
5452
$semaphore,
5553
BoltFactory::create(),

src/Contracts/DriverInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
namespace Laudis\Neo4j\Contracts;
1515

1616
use Laudis\Neo4j\Databags\SessionConfiguration;
17+
use Laudis\Neo4j\Formatter\CypherList;
18+
use Laudis\Neo4j\Formatter\CypherMap;
1719

1820
/**
1921
* The driver creates sessions for carrying out work.
@@ -22,7 +24,7 @@
2224
*
2325
* @psalm-type ParsedUrl = array{host: string, pass: string|null, path: string, port: int, query: array<string,string>, scheme: string, user: string|null}
2426
*
25-
* @psalm-type BasicDriver = DriverInterface<\Laudis\Neo4j\Formatter\CypherList<\Laudis\Neo4j\Formatter\CypherMap<string, scalar|array|null>>>
27+
* @psalm-type BasicDriver = DriverInterface<CypherList<CypherMap<string, scalar|array|null>>>
2628
*/
2729
interface DriverInterface
2830
{

src/Neo4j/Neo4jConnectionPool.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ public function __construct(SemaphoreInterface $semaphore, BoltFactory $factory,
8383
$this->resolver = $resolver;
8484
}
8585

86-
public static function create(UriInterface $uri, AuthenticateInterface $auth, DriverConfiguration $conf, AddressResolverInterface $resolver): self
86+
public static function create(UriInterface $uri, AuthenticateInterface $auth, DriverConfiguration $conf, AddressResolverInterface $resolver, SemaphoreInterface $semaphore): self
8787
{
88-
$semaphore = SemaphoreFactory::getInstance()->create($uri, $conf);
89-
9088
return new self(
9189
$semaphore,
9290
BoltFactory::create(),

src/Neo4j/Neo4jDriver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ public static function create($uri, ?DriverConfiguration $configuration = null,
8484
$configuration ??= DriverConfiguration::default();
8585
$authenticate ??= Authenticate::fromUrl($uri);
8686
$resolver ??= new DNSAddressResolver();
87+
$semaphore = $configuration->getSemaphoreInterface()->create($uri, $configuration);
8788

8889
/** @psalm-suppress InvalidArgument */
8990
return new self(
9091
$uri,
91-
Neo4jConnectionPool::create($uri, $authenticate, $configuration, $resolver),
92+
Neo4jConnectionPool::create($uri, $authenticate, $configuration, $resolver, $semaphore),
9293
$formatter ?? OGMFormatter::create(),
9394
);
9495
}

0 commit comments

Comments
 (0)