事件溯源和字典对象

发布于 2024-10-04 16:32:22 字数 521 浏览 0 评论 0原文

事件源如何与多种类型的字典对象(如国家/地区、地区、时区等)以及特定域模型中的字典类型相结合预算可用性定义。有些字典对象应该可以在管理 UI 中编辑,但有些则不能。

例如,我们决定不需要国家/地区的管理 UI。因此我们不需要实现AddCountry/RemoveCountry命令。

我应该生成一组 CountryAdded 事件,即我应该将字典对象保留为事件流吗? 除了事件流之外,我们是否使用过真实来源?


如果我可以不使用字典对象的事件流,您将如何解决这个问题:

显示具有以下特征的国家/地区列表 每个国家/地区的用户数量。

在这种情况下,我需要在读取模型中表示 Country 对象,并使用 UserAdded 事件的侦听器。

谢谢。

How event sourcing can be combined with several types of dictionary objects like Country, Region, Time Zone etc. and dictionary types from particular domain model like Budget or Availability definitions. Some of dictionary objects should be possible to edit in admin UI but some not.

For example we decided, that we do not need admin UI for countries. Thus we do not need to implement AddCountry/RemoveCountry commands.

Should i generate set of CountryAdded events i.e. should i persist dictionary objects as stream of events? Do we ever use source of truth other then event stream?


In case i can go without event stream for dictionary objects, how you'll solve this problem:

Display list of countries with the
number of users in each country.

In this case i need representation of Country objects in the read model with listener for UserAdded event.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疯狂的代价 2024-10-11 16:32:22

如果使用事件源作为持久化机制,那么:

  • 事件流是唯一的事实来源(从事件流生成的对象快照可以用来提高性能,但它们只是技术)。
  • 使用事件源时,不需要显式生成事件 - 只需发布处理命令时生成的实际事件。
  • 如果您有一个永远不会改变的预定义国家/地区列表,您可以通过其国家/地区代码进行硬编码和引用。然而,这意味着视图模型和 UI 知道这一点,并且国家/地区不会改变。

顺便说一句,我建议将此类问题发布到 DDD/CQRS 群组。它是 CQRS/DDD/ES 问题上最活跃的社区。

If you use event sourcing as the persistence mechanism, then:

  • event stream is the only source of truth (object snapshots generated from event stream could be used to improve the performance, but they are just the technique).
  • When you use event sourcing, you don't need to generate event explicitly - just publish actual events generated while processing the command.
  • if you have a predefined list of countries, that are never going to change, you can just hard-code and reference them by their country codes. However this implies that view model and UI know about that and countries are not going to change.

BTW I recommend posting questions like these to DDD/CQRS group. It's the most active community on the questions of CQRS/DDD/ES.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文