Skip to content

DCB #763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 17 commits into
base: 3.12.x
Choose a base branch
from
Draft

DCB #763

wants to merge 17 commits into from

Conversation

DavidBadura
Copy link
Member

@DavidBadura DavidBadura commented Jul 28, 2025

Implement Dynamic Consistency Boundary according to https://dcb.events/.

The following examples were partially implemented:

There are still some questions open:

  •  How do we handle the different streams? It should be possible to use different streams for different bounded contexts. Currently, this is not reflected in the API.
  •  The EventTagExtractor must handle value objects. The current implementation requires PHP's Stringable interface, which requires a __toString() method. Since this can lead to problems, we need an alternative.
  •  Filtering event types is not yet implemented.
  • Is archiving still possible? Is it necessary? Can this possibly be implemented with tags? -> for DCB: no
  • The Projection API isn't fully developed yet. Returning QueryComponent instead of tags directly? Apply should be converted to Attributes.

@DavidBadura DavidBadura added this to the 3.12.0 milestone Jul 28, 2025
Copy link

github-actions bot commented Jul 28, 2025

Hello 👋

here is the most recent benchmark result:

SimpleSetupStreamStoreBench
===========================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.003ms (±0.00%)   | 1.021ms (±0.00%)   | -1.83%    | 35.201mb        | 34.991mb   | +0.60%      |
| benchLoad10000Events ()                | 59.445ms (±0.00%)  | 59.626ms (±0.00%)  | -0.30%    | 35.201mb        | 34.991mb   | +0.60%      |
| benchSave1Event ()                     | 1.024ms (±0.00%)   | 1.115ms (±0.00%)   | -8.22%    | 34.674mb        | 34.528mb   | +0.42%      |
| benchSave10000Events ()                | 313.701ms (±0.00%) | 311.240ms (±0.00%) | +0.79%    | 34.674mb        | 34.528mb   | +0.42%      |
| benchSave10000Aggregates ()            | 8.608s (±0.00%)    | 8.711s (±0.00%)    | -1.18%    | 34.674mb        | 34.528mb   | +0.42%      |
| benchSave10000AggregatesTransaction () | 5.086s (±0.00%)    | 5.060s (±0.00%)    | +0.52%    | 34.674mb        | 34.528mb   | +0.42%      |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SubscriptionEngineBatchBench
============================

+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                                   | memory                                     |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>    | Tag: base         | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 78.363ms (±0.00%) | 77.996ms (±0.00%) | +0.47%    | 34.961mb        | 34.813mb   | +0.43%      |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+

SnapshotsBench
==============

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad10000EventsMissingSnapshot () | 53.856ms (±0.00%)  | 52.420ms (±0.00%)  | +2.74%    | 34.565mb        | 34.418mb   | +0.42%      |
| benchLoad10000Events ()                | 881.000μs (±0.00%) | 951.700μs (±0.00%) | -7.43%    | 34.564mb        | 34.418mb   | +0.42%      |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SubscriptionEngineBench
=======================

+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                               | memory                                     |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>  | Tag: base       | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 3.165s (±0.00%) | 3.177s (±0.00%) | -0.37%    | 47.107mb        | 46.961mb   | +0.31%      |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+

SimpleSetupTaggableStoreBench
=============================

+----------------------------------------+--------------------+-----------+-----------------+-------------+
|                                        | time (kde mode)                | memory                        |
+----------------------------------------+--------------------+-----------+-----------------+-------------+
| subject                                | Tag: <current>     | time-diff | Tag: <current>  | memory-diff |
+----------------------------------------+--------------------+-----------+-----------------+-------------+
| benchLoad1Event ()                     | 902.800μs (±0.00%) | +0.00%    | 35.821mb        | +0.00%      |
| benchLoad10000Events ()                | 59.992ms (±0.00%)  | +0.00%    | 35.822mb        | +0.00%      |
| benchSave1Event ()                     | 1.010ms (±0.00%)   | +0.00%    | 35.821mb        | +0.00%      |
| benchSave10000Events ()                | 325.104ms (±0.00%) | +0.00%    | 35.822mb        | +0.00%      |
| benchSave10000Aggregates ()            | 8.534s (±0.00%)    | +0.00%    | 35.822mb        | +0.00%      |
| benchSave10000AggregatesTransaction () | 5.123s (±0.00%)    | +0.00%    | 35.822mb        | +0.00%      |
| benchAppend1Event ()                   | 1.160ms (±0.00%)   | +0.00%    | 35.822mb        | +0.00%      |
| benchAppend100Events ()                | 7.114ms (±0.00%)   | +0.00%    | 35.822mb        | +0.00%      |
+----------------------------------------+--------------------+-----------+-----------------+-------------+

SimpleSetupBench
================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 833.200μs (±0.00%) | 999.900μs (±0.00%) | -16.67%   | 34.560mb        | 34.344mb   | +0.63%      |
| benchLoad10000Events ()                | 52.416ms (±0.00%)  | 53.858ms (±0.00%)  | -2.68%    | 34.560mb        | 34.344mb   | +0.63%      |
| benchSave1Event ()                     | 1.116ms (±0.00%)   | 1.155ms (±0.00%)   | -3.38%    | 34.560mb        | 34.344mb   | +0.63%      |
| benchSave10000Events ()                | 220.628ms (±0.00%) | 224.357ms (±0.00%) | -1.66%    | 34.560mb        | 34.344mb   | +0.63%      |
| benchSave10000Aggregates ()            | 8.250s (±0.00%)    | 8.258s (±0.00%)    | -0.10%    | 34.560mb        | 34.344mb   | +0.63%      |
| benchSave10000AggregatesTransaction () | 4.890s (±0.00%)    | 4.917s (±0.00%)    | -0.55%    | 34.560mb        | 34.344mb   | +0.63%      |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

SplitStreamBench
================

+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                         | time (kde mode)                                     | memory                                     |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                 | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad10000Events () | 4.804ms (±0.00%)   | 4.859ms (±0.00%)   | -1.14%    | 37.867mb        | 37.721mb   | +0.39%      |
| benchSave10000Events () | 343.284ms (±0.00%) | 354.974ms (±0.00%) | -3.29%    | 37.868mb        | 37.723mb   | +0.39%      |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

PersonalDataBench
=================

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 854.300μs (±0.00%) | 905.800μs (±0.00%) | -5.69%    | 35.693mb        | 35.548mb   | +0.41%      |
| benchLoad10000Events ()                | 98.525ms (±0.00%)  | 97.939ms (±0.00%)  | +0.60%    | 35.693mb        | 35.548mb   | +0.41%      |
| benchSave1Event ()                     | 1.449ms (±0.00%)   | 1.493ms (±0.00%)   | -2.95%    | 35.693mb        | 35.548mb   | +0.41%      |
| benchSave10000Events ()                | 254.888ms (±0.00%) | 260.064ms (±0.00%) | -1.99%    | 35.695mb        | 35.549mb   | +0.41%      |
| benchSave10000Aggregates ()            | 12.456s (±0.00%)   | 12.465s (±0.00%)   | -0.08%    | 35.693mb        | 35.548mb   | +0.41%      |
| benchSave10000AggregatesTransaction () | 8.991s (±0.00%)    | 9.091s (±0.00%)    | -1.10%    | 36.196mb        | 36.050mb   | +0.40%      |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

This comment gets update everytime a new commit comes in!

use function class_exists;

/** @experimental */
trait EventRouter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be misleading from the naming pov, as this is not really a router implementation in a classical way. Here we have mixed in apply logic (maybe this can be called routing) and query building / filtering. That being said: I come not with a better name 🤣

Maybe we should add a require-implements for the Projection interface here.
Ref: https://phpstan.org/writing-php-code/phpdocs-basics#enforcing-implementing-an-interface-for-traits

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added require-implements, I still have to think about the name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants