Skip to content

Commit

Permalink
replace pipeline with subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Mar 13, 2024
1 parent 05c96b0 commit a314cfc
Show file tree
Hide file tree
Showing 43 changed files with 50 additions and 1,017 deletions.
12 changes: 2 additions & 10 deletions deptrac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ deptrac:
value: MetadataMessage
- type: layer
value: MetadataSubscriber
- name: Pipeline
collectors:
- type: directory
value: src/Pipeline/.*
- name: Repository
collectors:
- type: directory
Expand Down Expand Up @@ -117,8 +113,10 @@ deptrac:
- Attribute
- Message
Message:
- Aggregate
- MetadataMessage
- Serializer
- Store
Metadata:
MetadataAggregate:
- Aggregate
Expand All @@ -134,12 +132,6 @@ deptrac:
- Attribute
- Metadata
- Subscription
Pipeline:
- Aggregate
- EventBus
- Message
- Store
- Subscription
Subscription:
- Attribute
- Clock
Expand Down
29 changes: 10 additions & 19 deletions docs/pages/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ whether the migration worked.
In this example the event `PrivacyAdded` is removed and the event `OldVisited` is replaced by `NewVisited`:

```php
use Patchlevel\EventSourcing\Pipeline\Middleware\ExcludeEventMiddleware;
use Patchlevel\EventSourcing\Pipeline\Middleware\RecalculatePlayheadMiddleware;
use Patchlevel\EventSourcing\Pipeline\Middleware\ReplaceEventMiddleware;
use Patchlevel\EventSourcing\Pipeline\Pipeline;
use Patchlevel\EventSourcing\Pipeline\Source\StoreSource;
use Patchlevel\EventSourcing\Pipeline\Target\StoreTarget;
use Patchlevel\EventSourcing\Message\Middleware\ExcludeEventMiddleware;use Patchlevel\EventSourcing\Message\Middleware\RecalculatePlayheadMiddleware;use Patchlevel\EventSourcing\Message\Middleware\ReplaceEventMiddleware;use Patchlevel\EventSourcing\Pipeline\Pipeline;use Patchlevel\EventSourcing\Pipeline\Source\StoreSource;use Patchlevel\EventSourcing\Pipeline\Target\StoreTarget;

$pipeline = new Pipeline(
new StoreSource($oldStore),
Expand Down Expand Up @@ -211,7 +206,7 @@ Middelwares can be used to manipulate, delete or expand messages or events durin
With this middleware you can exclude certain events.

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

$middleware = new ExcludeEventMiddleware([EmailChanged::class]);
```
Expand All @@ -226,7 +221,7 @@ $middleware = new ExcludeEventMiddleware([EmailChanged::class]);
With this middleware you can only allow certain events.

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

$middleware = new IncludeEventMiddleware([ProfileCreated::class]);
```
Expand All @@ -242,8 +237,7 @@ you can also write your own filter.
This middleware expects a callback that returns either true to allow events or false to not allow them.

```php
use Patchlevel\EventSourcing\Aggregate\AggregateChanged;
use Patchlevel\EventSourcing\Pipeline\Middleware\FilterEventMiddleware;
use Patchlevel\EventSourcing\Aggregate\AggregateChanged;use Patchlevel\EventSourcing\Message\Middleware\FilterEventMiddleware;

$middleware = new FilterEventMiddleware(function (AggregateChanged $event) {
if (!$event instanceof ProfileCreated) {
Expand All @@ -263,7 +257,7 @@ $middleware = new FilterEventMiddleware(function (AggregateChanged $event) {
With this middleware you can exclude archived events.

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

$middleware = new ExcludeArchivedEventMiddleware();
```
Expand All @@ -277,7 +271,7 @@ $middleware = new ExcludeArchivedEventMiddleware();
With this middleware you can only allow archived events.

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

$middleware = new OnlyArchivedEventMiddleware();
```
Expand All @@ -293,7 +287,7 @@ The first parameter you have to define is the event class that you want to repla
And as a second parameter a callback, that the old event awaits and a new event returns.

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

$middleware = new ReplaceEventMiddleware(OldVisited::class, static function (OldVisited $oldVisited) {
return new NewVisited($oldVisited->profileId());
Expand Down Expand Up @@ -326,7 +320,7 @@ The playhead must always be in ascending order so that the data is valid.
Some middleware can break this order and the middleware `RecalculatePlayheadMiddleware` can fix this problem.

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

$middleware = new RecalculatePlayheadMiddleware();
```
Expand All @@ -340,9 +334,7 @@ $middleware = new RecalculatePlayheadMiddleware();
If you want to group your middleware, you can use one or more `ChainMiddleware`.

```php
use Patchlevel\EventSourcing\Pipeline\Middleware\ChainMiddleware;
use Patchlevel\EventSourcing\Pipeline\Middleware\ExcludeEventMiddleware;
use Patchlevel\EventSourcing\Pipeline\Middleware\RecalculatePlayheadMiddleware;
use Patchlevel\EventSourcing\Message\Middleware\ChainMiddleware;use Patchlevel\EventSourcing\Message\Middleware\ExcludeEventMiddleware;use Patchlevel\EventSourcing\Message\Middleware\RecalculatePlayheadMiddleware;

$middleware = new ChainMiddleware([
new ExcludeEventMiddleware([EmailChanged::class]),
Expand All @@ -366,8 +358,7 @@ Now we have a `ProfileRegistered` and a `ProfileActivated` event,
which should replace the `ProfileCreated` event.

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

final class SplitProfileCreatedMiddleware implements Middleware
{
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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Message\Message;

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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Message\HeaderNotFound;
use Patchlevel\EventSourcing\Message\Message;
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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Message\Message;

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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Message\Message;

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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Message\Message;

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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Message\Message;

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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Message\HeaderNotFound;
use Patchlevel\EventSourcing\Message\Message;
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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Aggregate\AggregateHeader;
use Patchlevel\EventSourcing\Message\Message;
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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use Patchlevel\EventSourcing\Message\Message;

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\Pipeline\Middleware;
namespace Patchlevel\EventSourcing\Message\Middleware;

use DateTimeImmutable;
use Patchlevel\EventSourcing\Aggregate\AggregateHeader;
Expand Down
44 changes: 0 additions & 44 deletions src/Pipeline/Pipeline.php

This file was deleted.

35 changes: 0 additions & 35 deletions src/Pipeline/Source/InMemorySource.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/Pipeline/Source/Source.php

This file was deleted.

36 changes: 0 additions & 36 deletions src/Pipeline/Source/StoreSource.php

This file was deleted.

30 changes: 0 additions & 30 deletions src/Pipeline/Target/ConsumerTarget.php

This file was deleted.

Loading

0 comments on commit a314cfc

Please sign in to comment.