Skip to content

Commit

Permalink
rename DefaultCommandBus into SyncCommandBus
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Jan 12, 2025
1 parent 6887364 commit 6f804ea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@
<code><![CDATA[callable]]></code>
</MixedMethodCall>
</file>
<file src="tests/Unit/CommandBus/DefaultCommandBusTest.php">
<InvalidPropertyFetch>
<code><![CDATA[$handler->command]]></code>
</InvalidPropertyFetch>
</file>
<file src="tests/Unit/CommandBus/Handler/CreateAggregateHandlerTest.php">
<InvalidArgument>
<code><![CDATA[$class::class]]></code>
Expand All @@ -276,6 +271,11 @@
<code><![CDATA[callable]]></code>
</MixedMethodCall>
</file>
<file src="tests/Unit/CommandBus/SyncCommandBusTest.php">
<InvalidPropertyFetch>
<code><![CDATA[$handler->command]]></code>
</InvalidPropertyFetch>
</file>
<file src="tests/Unit/EventBus/DefaultEventBusTest.php">
<MoreSpecificImplementedParamType>
<code><![CDATA[$message]]></code>
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/command_bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,22 @@ final class Profile extends BasicAggregateRoot

## Setup

We provide a `DefaultCommandBus` that you can use to dispatch commands.
We provide a `SyncCommandBus` that you can use to dispatch commands.
You need to pass a `HandlerProvider` to the constructor.

```php
use Patchlevel\EventSourcing\CommandBus\DefaultCommandBus;
use Patchlevel\EventSourcing\CommandBus\HandlerProvider;
use Patchlevel\EventSourcing\CommandBus\SyncCommandBus;

/** @var HandlerProvider $handlerProvider */
$commandBus = new DefaultCommandBus($handlerProvider);
$commandBus = new SyncCommandBus($handlerProvider);

$commandBus->dispatch(new CreateProfile($profileId, 'name'));
$commandBus->dispatch(new ChangeProfileName($profileId, 'new name'));
```
!!! note

The `DefaultCommandBus` is a synchronous command bus.
The `SyncCommandBus` is a synchronous command bus.
But it ensures that a command has been completely handled before the next handler is executed.

## Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use function iterator_to_array;
use function sprintf;

final class DefaultCommandBus implements CommandBus
final class SyncCommandBus implements CommandBus
{
private readonly HandlerProvider $handlerProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use DateTimeImmutable;
use Doctrine\DBAL\Connection;
use Patchlevel\EventSourcing\Clock\SystemClock;
use Patchlevel\EventSourcing\CommandBus\DefaultCommandBus;
use Patchlevel\EventSourcing\CommandBus\ServiceLocator;
use Patchlevel\EventSourcing\CommandBus\SyncCommandBus;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Message\Pipe;
use Patchlevel\EventSourcing\Message\Reducer;
Expand Down Expand Up @@ -282,7 +282,7 @@ public function testCommandBus(): void
$engine,
);

$commandBus = DefaultCommandBus::createForAggregateHandlers(
$commandBus = SyncCommandBus::createForAggregateHandlers(
$aggregateRootRegistry,
$manager,
new ServiceLocator([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace Patchlevel\EventSourcing\Tests\Unit\CommandBus;

use Patchlevel\EventSourcing\CommandBus\DefaultCommandBus;
use Patchlevel\EventSourcing\CommandBus\HandlerDescriptor;
use Patchlevel\EventSourcing\CommandBus\HandlerNotFound;
use Patchlevel\EventSourcing\CommandBus\HandlerProvider;
use Patchlevel\EventSourcing\CommandBus\MultipleHandlersFound;
use Patchlevel\EventSourcing\CommandBus\SyncCommandBus;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

/** @covers \Patchlevel\EventSourcing\CommandBus\DefaultCommandBus */
final class DefaultCommandBusTest extends TestCase
/** @covers \Patchlevel\EventSourcing\CommandBus\SyncCommandBus */
final class SyncCommandBusTest extends TestCase
{
use ProphecyTrait;

Expand All @@ -25,7 +25,7 @@ public function testHandlerNotFound(): void
$handlerProvider = $this->prophesize(HandlerProvider::class);
$handlerProvider->handlerForCommand($command::class)->willReturn([]);

$commandBus = new DefaultCommandBus($handlerProvider->reveal());
$commandBus = new SyncCommandBus($handlerProvider->reveal());

$this->expectException(HandlerNotFound::class);

Expand All @@ -43,7 +43,7 @@ public function testMultipleHandlersFound(): void
new HandlerDescriptor(static fn () => null),
]);

$commandBus = new DefaultCommandBus($handlerProvider->reveal());
$commandBus = new SyncCommandBus($handlerProvider->reveal());

$this->expectException(MultipleHandlersFound::class);

Expand All @@ -69,7 +69,7 @@ public function __invoke(object $command): void
new HandlerDescriptor($handler),
]);

$commandBus = new DefaultCommandBus($handlerProvider->reveal());
$commandBus = new SyncCommandBus($handlerProvider->reveal());

$commandBus->dispatch($command);

Expand Down

0 comments on commit 6f804ea

Please sign in to comment.