什么是集合函数? [英] What is an Aggregate Function?
问题描述
我想在业余时间学习事件采购(使用Greg Youngs Event Store)。我已经设置了一个简单的流,可以对其进行读取和写入。
请参见以下链接:
我将在事件存储中拥有哪些事件流?我正在阅读来自一位对此事件非常了解的用户的答复,他建议以下内容:
AggregateType + AggregateId +版本
在此基础上,相信事件的命名如下:
BookingCreatedEvent511(51是聚合ID,版本1)
BookingUpdatedEvent511(51是聚合ID,版本1)
BookingUpdatedEvent512(51是聚合ID,版本2)
BookingCreatedEvent521(52是聚合ID,版本1)
BookingUpdatedEvent513(51是聚合ID,版本3)
BookingCreatedEvent531(53是聚合ID,1是版本)
BookingUpdatedEvent514(51是聚合ID,4是版本)
BookingUpdatedEvent515(51是聚合ID,5是版本) )
BookingUpdatedEvent516(51是集合ID,6是版本)
BookingUpdatedEvent5 17(总ID为51,版本7为版本)
因此有10个事件流。这看起来有些混乱,例如,将聚合ID和版本连接在一起-例如,说我有以下内容:
BookingUpdatedEvent51745
我怎么知道51745的哪个部分是汇总ID,哪个部分是版本。
我正确理解了吗?
如果如果是事件搜索域模型,则流等于聚合函数
我找不到任何有意义的证据。
Dan Leech在2014年提交的文档的该部分的原始文本使用了这种拼写方式
如果您是事件采购域模型,则流将等于聚合。
Chris在其中进行的提交更改为可在github 中找到,但是它与主要的重写混在一起,因此没有有关更改的书面说明。
说我有一个订单的汇总(包含订单项),有100万个,那么我将有100万个流,而不是1个。
基本上是。
更确切地说,每个流在逻辑上都与其他所有流都隔离开;事件存储无法为您提供一次对多个流进行原子更改的功能。
因此,域模型中的每个立即一致的事务都应准确地写入一个事件流。
I am trying to learn Event Sourcing (using Greg Youngs Event Store) in my spare time. I have setup a simple stream and I can read from it and write to it.
Please see this link: https://eventstore.org/docs/getting-started/?tabs=tabid-1%2Ctabid-dotnet-client%2Ctabid-dotnet-client-connect%2Ctabid-4. It says:
"If you are Event Sourcing a domain model, a stream equates to an aggregate function."
I don't believe I have ever come across the term Aggregate Function before - I know aggregate root and aggregate, however not aggregate function. Say I have the events below:
BookingCreatedEvent
BookingUpdatedEvent
If I was to create an event log in SQL server then it could look something like this (the Cargo column contains the serialized object):
What Event streams would I have in Event Store for this? I was reading an answer from a user on here who seems to be very knowledgeable about Event Sourcing and he suggested the following:
AggregateType+AggregateId+Version
On that basis believe the events would be named as follows:
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)
Therefore there are 10 event streams. This looks a little confusing i.e. concatenating the aggregate ID and version - for example, say I had the following:
BookingUpdatedEvent51745
How would I know what part of 51745 is the aggregate ID and what part is the version.
Have I understood this correctly?
If you are Event Sourcing a domain model, a stream equates to an aggregate function
I can't find any evidence that means anything.
The original text of that section of the document, committed by Dan Leech in 2014, used this spelling
If you are Event Sourcing a domain model a stream would equate to an aggregate.
The commit where Chris made the change is available in github, but it's mixed in with a major rewrite, so there's no documented explanation for the change.
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
Basically, yes.
More precisely, each stream is logically isolated from all of the others; Event Store doesn't give you facilities to make atomic changes to more than one stream at a time.
So each immediately consistent transaction in your domain model should be writing to exactly one event stream.
这篇关于什么是集合函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!