如何在 EventStore 3.0 中使用 GetStreamsToSnapshot 创建快照
我们遵循 CQRS 架构并使用 Jonathan Oliver 的事件存储版本 3 来处理事件。我们希望创建聚合根的快照以提高性能。
我找到了一个可用于此目的的 API (GetStreamsToSnapshot)。它根据创建快照之前的时间提供所有流。
但我不确定如何使用流来创建快照,因为我不知道聚合类型。
请提供有关如何创建快照的任何信息
We are following CQRS architecture and using Jonathan Oliver's event-store version 3 for events. We want to create snapshot of the aggregate roots to improve performance.
I found an API (GetStreamsToSnapshot) which can be used for this. It gives all streams based upon how long before the snapshots have been created.
But I am not sure how to use the stream to create the snapshot as I do not know the aggregate type.
Please provide any inputs on how to create snapshots
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您所发现的,GetStreamsToSnapshot 为您提供了一个流列表,这些流至少落后于头部修订版 X 个修订版。
从那里开始,就需要加载每个流了。您可以在此处将某种标头信息附加到流中,以确定您正在处理的聚合类型。
很多次我被问到为什么不直接将聚合类型信息存储到 EventStore 中并使其成为 API 的一流部分。答案是它不关心聚合,这是一个 DDD 概念。 EventStore 关心的只是流和事件。
As you have discovered, GetStreamsToSnapshot gives you a list of streams that are at least X revisions behind the head revision.
From there, it's a matter of loading up each stream. This is where you can append some kind of header information to the stream to determine what type of aggregate you're dealing.
Many times I'm asked why I don't just store the aggregate type information directly into the EventStore and make it a first-class part of the API. The answer is that it doesn't care about aggregates which is a DDD concept. All the EventStore cares about is streams and events.