Skip to content

Commit

Permalink
Merge pull request #539 from patchlevel/move-message-into-own-namespcae
Browse files Browse the repository at this point in the history
move message into own namespace
  • Loading branch information
DavidBadura authored Mar 13, 2024
2 parents 1636023 + 1576af0 commit 05c96b0
Show file tree
Hide file tree
Showing 105 changed files with 150 additions and 149 deletions.
17 changes: 12 additions & 5 deletions deptrac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ deptrac:
collectors:
- type: directory
value: src/EventBus/.*
- name: Message
collectors:
- type: directory
value: src/Message/.*
- name: MetadataAggregate
collectors:
- type: directory
Expand Down Expand Up @@ -96,7 +100,7 @@ deptrac:
Attribute:
Clock:
Console:
- EventBus
- Message
- MetadataAggregate
- MetadataEvent
- Pipeline
Expand All @@ -106,12 +110,13 @@ deptrac:
- Subscription
Debug:
- Attribute
- EventBus
- Message
- Repository
- Subscription
EventBus:
- Aggregate
- Attribute
- Message
Message:
- MetadataMessage
- Serializer
Metadata:
Expand All @@ -132,18 +137,20 @@ deptrac:
Pipeline:
- Aggregate
- EventBus
- Message
- Store
- Subscription
Subscription:
- Attribute
- Clock
- Message
- MetadataSubscriber
- EventBus
- Schema
- Store
Repository:
- Aggregate
- Clock
- Message
- MetadataAggregate
- MetadataEvent
- EventBus
Expand All @@ -159,7 +166,7 @@ deptrac:
Store:
- Aggregate
- Attribute
- Message
- Metadata
- EventBus
- Schema
- Serializer
14 changes: 5 additions & 9 deletions docs/pages/event_bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Each event is packed into a message and dispatched using the event bus.

```php
use Patchlevel\EventSourcing\Clock\SystemClock;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

$clock = SystemClock();
$clock = new SystemClock();
$message = Message::create(new NameChanged('foo'))
->withAggregateName('profile')
->withAggregateId('bca7576c-536f-4428-b694-7b1f00c714b7')
Expand All @@ -46,7 +46,7 @@ As already mentioned, you can enrich the `Message` with your own meta informatio
message object and is also stored in the database.

```php
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

$message = Message::create(new NameChanged('foo'))
// ...
Expand All @@ -61,17 +61,13 @@ You can also access your custom headers. For this case there is also a method to
used internally.

```php
use Patchlevel\EventSourcing\EventBus\Message;

$message->header('application-id'); // app
$message->customHeaders(); // ['application-id' => 'app']
```

If you want *all* the headers you can also retrieve them.

```php
use Patchlevel\EventSourcing\EventBus\Message;

$message->headers();
// results in:
[
Expand Down Expand Up @@ -177,7 +173,7 @@ This listener is then called for all saved events / messages.
```php
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Listener;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

final class WelcomeSubscriber
{
Expand All @@ -200,7 +196,7 @@ If you want to listen on all events, you can pass `*` or `Subscribe::ALL` instea
```php
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Listener;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

final class WelcomeSubscriber
{
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ use Patchlevel\EventSourcing\Attribute\Projector;
use Patchlevel\EventSourcing\Attribute\Setup;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\Attribute\Teardown;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberUtil;

#[Projector('hotel')]
Expand Down Expand Up @@ -246,7 +246,7 @@ In our example we also want to email the head office as soon as a guest is check
```php
use Patchlevel\EventSourcing\Attribute\Processor;
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

#[Processor('admin_emails')]
final class SendCheckInEmailProcessor
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/message_decorator.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You can also use this feature to add your own metadata to your events. For this
to add data `withHeader` and to read this data later on `header`.

```php
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Repository\MessageDecorator\MessageDecorator;

final class OnSystemRecordedDecorator implements MessageDecorator
Expand Down
8 changes: 4 additions & 4 deletions docs/pages/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ $source = new StoreSource($store);
There is an `InMemorySource` that receives the messages in an array. This source can be used to write pipeline tests.

```php
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Pipeline\Source\InMemorySource;

$source = new InMemorySource([
Expand All @@ -92,7 +92,7 @@ You can also create your own source class. It has to inherit from `Source`.
Here you can, for example, create a migration from another event sourcing system or similar system.

```php
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Pipeline\Source\Source;

$source = new class implements Source {
Expand Down Expand Up @@ -178,7 +178,7 @@ $messages = $target->messages();
You can also define your own target. To do this, you need to implement the `Target` interface.

```php
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

final class OtherStoreTarget implements Target
{
Expand Down Expand Up @@ -366,7 +366,7 @@ Now we have a `ProfileRegistered` and a `ProfileActivated` event,
which should replace the `ProfileCreated` event.

```php
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Pipeline\Middleware\Middleware;

final class SplitProfileCreatedMiddleware implements Middleware
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ The method name itself doesn't matter.
```php
use Patchlevel\EventSourcing\Attribute\Subscribe;
use Patchlevel\EventSourcing\Attribute\Subscriber;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

#[Subscriber('do_stuff', RunMode::Once)]
final class DoStuffSubscriber
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/ShowAggregateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Console\InputHelper;
use Patchlevel\EventSourcing\Console\OutputStyle;
use Patchlevel\EventSourcing\EventBus\Serializer\HeadersSerializer;
use Patchlevel\EventSourcing\Message\Serializer\HeadersSerializer;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AggregateRootRegistry;
use Patchlevel\EventSourcing\Serializer\EventSerializer;
use Patchlevel\EventSourcing\Store\Criteria;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/ShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Console\InputHelper;
use Patchlevel\EventSourcing\Console\OutputStyle;
use Patchlevel\EventSourcing\EventBus\Serializer\HeadersSerializer;
use Patchlevel\EventSourcing\Message\Serializer\HeadersSerializer;
use Patchlevel\EventSourcing\Serializer\EventSerializer;
use Patchlevel\EventSourcing\Store\Store;
use Symfony\Component\Console\Attribute\AsCommand;
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Command/WatchCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Console\InputHelper;
use Patchlevel\EventSourcing\Console\OutputStyle;
use Patchlevel\EventSourcing\EventBus\Serializer\HeadersSerializer;
use Patchlevel\EventSourcing\Message\Serializer\HeadersSerializer;
use Patchlevel\EventSourcing\Serializer\EventSerializer;
use Patchlevel\EventSourcing\Store\Criteria;
use Patchlevel\EventSourcing\Store\Store;
Expand Down
4 changes: 2 additions & 2 deletions src/Console/OutputStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Patchlevel\EventSourcing\Console;

use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\EventBus\Serializer\HeadersSerializer;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Message\Serializer\HeadersSerializer;
use Patchlevel\EventSourcing\Serializer\Encoder\Encoder;
use Patchlevel\EventSourcing\Serializer\EventSerializer;
use Symfony\Component\Console\Style\SymfonyStyle;
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Trace/TraceDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Patchlevel\EventSourcing\Debug\Trace;

use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Repository\MessageDecorator\MessageDecorator;

use function array_map;
Expand Down
2 changes: 1 addition & 1 deletion src/Debug/Trace/TraceableSubscriberAccessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Patchlevel\EventSourcing\Debug\Trace;

use Closure;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Subscription\RunMode;
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberAccessor;

Expand Down
2 changes: 2 additions & 0 deletions src/EventBus/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Patchlevel\EventSourcing\EventBus;

use Patchlevel\EventSourcing\Message\Message;

interface Consumer
{
public function consume(Message $message): void;
Expand Down
1 change: 1 addition & 0 deletions src/EventBus/DefaultConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Patchlevel\EventSourcing\EventBus;

use Patchlevel\EventSourcing\Message\Message;
use Psr\Log\LoggerInterface;

use function sprintf;
Expand Down
1 change: 1 addition & 0 deletions src/EventBus/DefaultEventBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Patchlevel\EventSourcing\EventBus;

use Patchlevel\EventSourcing\Message\Message;
use Psr\Log\LoggerInterface;

use function array_shift;
Expand Down
2 changes: 2 additions & 0 deletions src/EventBus/EventBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Patchlevel\EventSourcing\EventBus;

use Patchlevel\EventSourcing\Message\Message;

interface EventBus
{
public function dispatch(Message ...$messages): void;
Expand Down
11 changes: 0 additions & 11 deletions src/EventBus/EventBusException.php

This file was deleted.

1 change: 1 addition & 0 deletions src/EventBus/Psr14EventBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Patchlevel\EventSourcing\EventBus;

use Patchlevel\EventSourcing\Message\Message;
use Psr\EventDispatcher\EventDispatcherInterface;

final class Psr14EventBus implements EventBus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

declare(strict_types=1);

namespace Patchlevel\EventSourcing\EventBus;
namespace Patchlevel\EventSourcing\Message;

use RuntimeException;

use function sprintf;

final class HeaderNotFound extends EventBusException
final class HeaderNotFound extends RuntimeException
{
public function __construct(
public readonly string $name,
Expand Down
2 changes: 1 addition & 1 deletion src/EventBus/Message.php → src/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Patchlevel\EventSourcing\EventBus;
namespace Patchlevel\EventSourcing\Message;

use function array_key_exists;
use function array_values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Patchlevel\EventSourcing\EventBus\Serializer;
namespace Patchlevel\EventSourcing\Message\Serializer;

use Patchlevel\EventSourcing\Metadata\Message\AttributeMessageHeaderRegistryFactory;
use Patchlevel\EventSourcing\Metadata\Message\MessageHeaderRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Patchlevel\EventSourcing\EventBus\Serializer;
namespace Patchlevel\EventSourcing\Message\Serializer;

use RuntimeException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Patchlevel\EventSourcing\EventBus\Serializer;
namespace Patchlevel\EventSourcing\Message\Serializer;

interface HeadersSerializer
{
Expand Down
2 changes: 1 addition & 1 deletion src/Pipeline/Middleware/ChainMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Patchlevel\EventSourcing\Pipeline\Middleware;

use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

use function array_values;

Expand Down
4 changes: 2 additions & 2 deletions src/Pipeline/Middleware/ExcludeArchivedEventMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace Patchlevel\EventSourcing\Pipeline\Middleware;

use Patchlevel\EventSourcing\EventBus\HeaderNotFound;
use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\HeaderNotFound;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Store\ArchivedHeader;

final class ExcludeArchivedEventMiddleware implements Middleware
Expand Down
2 changes: 1 addition & 1 deletion src/Pipeline/Middleware/ExcludeEventMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Patchlevel\EventSourcing\Pipeline\Middleware;

use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

final class ExcludeEventMiddleware implements Middleware
{
Expand Down
2 changes: 1 addition & 1 deletion src/Pipeline/Middleware/FilterEventMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Patchlevel\EventSourcing\Pipeline\Middleware;

use Patchlevel\EventSourcing\EventBus\Message;
use Patchlevel\EventSourcing\Message\Message;

final class FilterEventMiddleware implements Middleware
{
Expand Down
Loading

0 comments on commit 05c96b0

Please sign in to comment.