Skip to content
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

Lookup #659

Draft
wants to merge 2 commits into
base: 3.7.x
Choose a base branch
from
Draft

Lookup #659

wants to merge 2 commits into from

Conversation

DavidBadura
Copy link
Member

@DavidBadura DavidBadura commented Dec 17, 2024

This allows you to look at the current event stream in your subscription.
To look up information that is only relevant now. It also ensures that you cannot see into the future.

#[Subscribe(AuctionClosed::class)]
public function onAuctionClosed(AuctionClosed $event, Lookup $lookup): void
{
    $messages = $lookup->lookAgain(
      Sold::class,
      AuctionPublished::class
    );
    
    $state = (new Reducer())
        ->initState(['description' => null, 'price' => null])
        ->match([
            Sold::class => static function (Message $message): array {
                return ['price' => $message->event()->price];
            },
            AuctionPublished::class => static function (Message $message): array {
                return ['description' => $message->event()->description];
            },
        ])
        ->reduce($messages);
        
    $this->connection->insert('expired_auctions', $state);
}

The API of the Lookup class is not finished yet. I am thinking about how to build the API for it to filter by aggregateId, etc.

Copy link

github-actions bot commented Dec 17, 2024

Hello 👋

here is the most recent benchmark result:

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

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 956.000μs (±0.00%) | 992.400μs (±0.00%) | -3.67%    | 34.266mb        | 34.274mb   | -0.02%      |
| benchLoad10000Events ()                | 51.868ms (±0.00%)  | 51.431ms (±0.00%)  | +0.85%    | 33.765mb        | 34.274mb   | -1.48%      |
| benchSave1Event ()                     | 1.028ms (±0.00%)   | 1.020ms (±0.00%)   | +0.76%    | 33.765mb        | 33.765mb   | 0.00%       |
| benchSave10000Events ()                | 229.225ms (±0.00%) | 237.374ms (±0.00%) | -3.43%    | 33.765mb        | 33.765mb   | 0.00%       |
| benchSave10000Aggregates ()            | 8.494s (±0.00%)    | 8.692s (±0.00%)    | -2.27%    | 33.765mb        | 33.765mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 4.937s (±0.00%)    | 4.932s (±0.00%)    | +0.12%    | 33.765mb        | 33.765mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

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

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad10000EventsMissingSnapshot () | 54.218ms (±0.00%)  | 50.444ms (±0.00%)  | +7.48%    | 33.836mb        | 33.836mb   | 0.00%       |
| benchLoad10000Events ()                | 989.600μs (±0.00%) | 957.100μs (±0.00%) | +3.40%    | 33.836mb        | 33.836mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

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

+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                                   | memory                                     |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>    | Tag: base         | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 76.964ms (±0.00%) | 74.696ms (±0.00%) | +3.04%    | 34.234mb        | 34.234mb   | 0.00%       |
+---------------------------+-------------------+-------------------+-----------+-----------------+------------+-------------+

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

+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
|                           | time (kde mode)                               | memory                                     |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| subject                   | Tag: <current>  | Tag: base       | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+
| benchHandle10000Events () | 3.212s (±0.00%) | 3.202s (±0.00%) | +0.30%    | 46.382mb        | 46.382mb   | 0.00%       |
+---------------------------+-----------------+-----------------+-----------+-----------------+------------+-------------+

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

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 954.900μs (±0.00%) | 908.300μs (±0.00%) | +5.13%    | 34.895mb        | 34.895mb   | 0.00%       |
| benchLoad10000Events ()                | 89.953ms (±0.00%)  | 87.884ms (±0.00%)  | +2.35%    | 34.895mb        | 34.895mb   | 0.00%       |
| benchSave1Event ()                     | 1.999ms (±0.00%)   | 1.653ms (±0.00%)   | +20.97%   | 34.895mb        | 34.895mb   | 0.00%       |
| benchSave10000Events ()                | 265.815ms (±0.00%) | 258.106ms (±0.00%) | +2.99%    | 34.897mb        | 34.897mb   | 0.00%       |
| benchSave10000Aggregates ()            | 12.862s (±0.00%)   | 12.730s (±0.00%)   | +1.04%    | 34.895mb        | 34.895mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 9.145s (±0.00%)    | 9.087s (±0.00%)    | +0.64%    | 35.396mb        | 35.396mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

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

+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                                        | time (kde mode)                                     | memory                                     |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                                | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad1Event ()                     | 1.006ms (±0.00%)   | 1.008ms (±0.00%)   | -0.22%    | 34.862mb        | 34.862mb   | 0.00%       |
| benchLoad10000Events ()                | 58.224ms (±0.00%)  | 57.646ms (±0.00%)  | +1.00%    | 34.862mb        | 34.862mb   | 0.00%       |
| benchSave1Event ()                     | 1.045ms (±0.00%)   | 1.046ms (±0.00%)   | -0.08%    | 34.862mb        | 34.862mb   | 0.00%       |
| benchSave10000Events ()                | 298.893ms (±0.00%) | 305.566ms (±0.00%) | -2.18%    | 34.862mb        | 34.862mb   | 0.00%       |
| benchSave10000Aggregates ()            | 8.465s (±0.00%)    | 9.103s (±0.00%)    | -7.01%    | 34.862mb        | 34.862mb   | 0.00%       |
| benchSave10000AggregatesTransaction () | 5.159s (±0.00%)    | 5.149s (±0.00%)    | +0.19%    | 34.862mb        | 34.862mb   | 0.00%       |
+----------------------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

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

+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
|                         | time (kde mode)                                     | memory                                     |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| subject                 | Tag: <current>     | Tag: base          | time-diff | Tag: <current>  | Tag: base  | memory-diff |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+
| benchLoad10000Events () | 4.445ms (±0.00%)   | 4.553ms (±0.00%)   | -2.37%    | 37.072mb        | 37.072mb   | 0.00%       |
| benchSave10000Events () | 346.069ms (±0.00%) | 346.364ms (±0.00%) | -0.09%    | 37.145mb        | 37.144mb   | +0.00%      |
+-------------------------+--------------------+--------------------+-----------+-----------------+------------+-------------+

This comment gets update everytime a new commit comes in!

@DavidBadura DavidBadura changed the base branch from 3.6.x to 3.7.x December 20, 2024 12:05
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.

1 participant