Skip to content

Commit

Permalink
Added stamps to the QueryBus
Browse files Browse the repository at this point in the history
  • Loading branch information
tg666 committed Mar 1, 2024
1 parent 3e76114 commit 094df48
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/ArchitectureBundle/Bridge/Symfony/Messenger/Bus/QueryBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use SixtyEightPublishers\ArchitectureBundle\Bus\QueryBusInterface;
use SixtyEightPublishers\ArchitectureBundle\ReadModel\Query\QueryInterface;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\HandleTrait;
use Symfony\Component\Messenger\MessageBusInterface;

Expand All @@ -18,8 +19,13 @@ public function __construct(MessageBusInterface $messageBus)
$this->messageBus = $messageBus;
}

public function dispatch(QueryInterface $message): mixed
public function dispatch(QueryInterface $message, array $stamps = []): mixed
{
return $this->handle($message);
$envelope = new Envelope(
message: $message,
stamps: $stamps,
);

return $this->handle($envelope);
}
}
2 changes: 1 addition & 1 deletion src/ArchitectureBundle/Bus/CommandBusInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
interface CommandBusInterface
{
/**
* @param StampInterface[] $stamps
* @param array<int, StampInterface> $stamps
*/
public function dispatch(CommandInterface $message, array $stamps = []): void;
}
6 changes: 5 additions & 1 deletion src/ArchitectureBundle/Bus/QueryBusInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
namespace SixtyEightPublishers\ArchitectureBundle\Bus;

use SixtyEightPublishers\ArchitectureBundle\ReadModel\Query\QueryInterface;
use Symfony\Component\Messenger\Stamp\StampInterface;

interface QueryBusInterface
{
public function dispatch(QueryInterface $message): mixed;
/**
* @param array<int, StampInterface> $stamps
*/
public function dispatch(QueryInterface $message, array $stamps = []): mixed;
}

0 comments on commit 094df48

Please sign in to comment.