什么是聚合函数?

What is an Aggregate Function?

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

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

"If you are Event Sourcing a domain model, a stream equates to an aggregate function."

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

BookingCreatedEvent
BookingUpdatedEvent

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

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

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,哪一部分是版本。

我的理解正确吗?

If you are Event Sourcing a domain model, a stream equates to an aggregate function

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

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

If you are Event Sourcing a domain model a stream would equate to an aggregate.

Chris 做出更改的提交是 available in github,但它与主要重写混在一起,因此没有记录对更改的解释。

Say I had an Aggregate of order (containing order items) and there were 1 million of them, then I would have 1 million streams instead of 1

基本上是的。

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

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