Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1cfd8b5

Browse files
committed
forward a Clock instance to the created InMemoryTransport
1 parent 0a9cba3 commit 1cfd8b5

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/messenger.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@
135135
->tag('messenger.transport_factory')
136136

137137
->set('messenger.transport.in_memory.factory', InMemoryTransportFactory::class)
138+
->args([
139+
service('clock')->nullOnInvalid(),
140+
])
138141
->tag('messenger.transport_factory')
139142
->tag('kernel.reset', ['method' => 'reset'])
140143

src/Symfony/Component/Messenger/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.1
55
---
66

7+
* `InMemoryTransportFactory` creates the `InMemoryTransport` with a clock (if configured in the factory)
78
* Add option `redis_sentinel` as an alias for `sentinel_master`
89
* Add `--all` option to the `messenger:consume` command
910
* Add parameter `$jitter` to `MultiplierRetryStrategy` in order to randomize delay and prevent the thundering herd effect

src/Symfony/Component/Messenger/Transport/InMemory/InMemoryTransportFactory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Messenger\Transport\InMemory;
1313

14+
use Psr\Clock\ClockInterface;
1415
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
1516
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
1617
use Symfony\Component\Messenger\Transport\TransportInterface;
@@ -28,11 +29,16 @@ class InMemoryTransportFactory implements TransportFactoryInterface, ResetInterf
2829
*/
2930
private array $createdTransports = [];
3031

32+
public function __construct(
33+
private readonly ?ClockInterface $clock = null,
34+
) {
35+
}
36+
3137
public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
3238
{
3339
['serialize' => $serialize] = $this->parseDsn($dsn);
3440

35-
return $this->createdTransports[] = new InMemoryTransport($serialize ? $serializer : null);
41+
return $this->createdTransports[] = new InMemoryTransport($serialize ? $serializer : null, $this->clock);
3642
}
3743

3844
public function supports(string $dsn, array $options): bool

0 commit comments

Comments
 (0)