1

我想在业余时间学习事件溯源(使用 Greg Youngs Event Store)。我已经设置了一个简单的流,我可以从中读取和写入。

请参阅此链接:https ://eventstore.org/docs/getting-started/?tabs=tabid-1%2Ctabid-dotnet-client%2Ctabid-dotnet-client-connect%2Ctabid-4 。它说:

“如果您对领域模型进行事件溯源,则流等同于聚合函数。”

我不相信我以前曾经遇到过聚合函数这个术语——我知道聚合根和聚合,但不知道聚合函数。假设我有以下事件:

BookingCreatedEvent
BookingUpdatedEvent

如果我要在 SQL Server 中创建一个事件日志,那么它可能看起来像这样(Cargo 列包含序列化对象):

在此处输入图像描述

为此,我在 Event Store 中有哪些事件流?我在这里阅读了一位似乎对事件溯源非常了解的用户的回答,他提出了以下建议:

AggregateType+AggregateId+Version

在此基础上,相信这些事件将被命名如下:

BookingCreatedEvent511 (51 is the aggregate ID and 1 is the version)
BookingUpdatedEvent511 (51 is the aggregate ID and 1 is the version)
BookingUpdatedEvent512 (51 is the aggregate ID and 2 is the version)
BookingCreatedEvent521 (52 is the aggregate ID and 1 is the version)
BookingUpdatedEvent513 (51 is the aggregate ID and 3 is the version)
BookingCreatedEvent531 (53 is the aggregate ID and 1 is the version)
BookingUpdatedEvent514 (51 is the aggregate ID and 4 is the version)
BookingUpdatedEvent515 (51 is the aggregate ID and 5 is the version)
BookingUpdatedEvent516 (51 is the aggregate ID and 6 is the version)
BookingUpdatedEvent517 (51 is the aggregate ID and 7 is the version)

因此有 10 个事件流。这看起来有点令人困惑,即连接聚合 ID 和版本 - 例如,假设我有以下内容:

  BookingUpdatedEvent51745

我怎么知道 51745 的哪一部分是聚合 ID,哪一部分是版本。

我是否正确理解了这一点?

4

1 回答 1

1

如果您对领域模型进行事件溯源,则流等同于聚合函数

我找不到任何有意义的证据。

Dan Leech 在 2014 年提交的该文件部分的原始文本使用了这种拼写

如果您对领域模型进行事件溯源,则流将等同于聚合。

Chris 进行更改的提交在 github 中可用,但它与重大重写混合在一起,因此没有对更改的记录解释。

假设我有一个订单聚合(包含订单项目)并且有 100 万个,那么我将有 100 万个流而不是 1 个

基本上,是的。

更准确地说,每个流在逻辑上与所有其他流是隔离的。Event Store 不会为您提供一次对多个流进行原子更改的工具。

因此,域模型中的每个立即一致的事务都应该写入一个事件流。

于 2018-09-19T13:43:44.467 回答