Skip to content

Commit

Permalink
forward a Clock instance to the created InMemoryTransport
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Apr 13, 2024
1 parent 1fca6b8 commit 9e7087c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
7.1
---

* `InMemoryTransportFactory` creates the `InMemoryTransport` with a clock (if configured in the factory)
* Add option `redis_sentinel` as an alias for `sentinel_master`
* Add `--all` option to the `messenger:consume` command
* Add parameter `$jitter` to `MultiplierRetryStrategy` in order to randomize delay and prevent the thundering herd effect
Expand Down
8 changes: 7 additions & 1 deletion Transport/InMemory/InMemoryTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Messenger\Transport\InMemory;

use Psr\Clock\ClockInterface;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
use Symfony\Component\Messenger\Transport\TransportInterface;
Expand All @@ -28,11 +29,16 @@ class InMemoryTransportFactory implements TransportFactoryInterface, ResetInterf
*/
private array $createdTransports = [];

public function __construct(
private readonly ?ClockInterface $clock = null,
) {
}

public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface
{
['serialize' => $serialize] = $this->parseDsn($dsn);

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

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

0 comments on commit 9e7087c

Please sign in to comment.