J Oliver EventStore V2.0 CommonDomain 快照
使用 EventStore 和 CommonDomain 时拍摄聚合快照的最佳实践是什么(是否有更好的地方可以询问,用户组,类似的东西)?
Whats considered best practice to take Snapshots of the aggregates when using EventStore and CommonDomain (Is there a better place to ask, usergroup, something like that) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Stack Overflow 是提问的最佳场所,因为每个人都可以从答案中受益。
快照通常应在“带外”获取,即在处理主线之外。换句话说,当提交一系列事件时,您不想在此时拍摄快照。相反,您需要让另一个线程或进程异步拍摄快照。我建议使用另一个线程而不是完全独立的进程,因为您不必担心确保程序集(域、消息等)与主处理线程的程序集相同。
“如何”拍摄快照的代码由最终用户决定。我很可能会在下周左右提供一些关于拍摄快照的确切步骤的额外指导。
另一项考虑是,您真的需要快照吗?您有多少个事件超过 1000 个的流?如果没有,那么您几乎肯定不需要复杂的快照。
Stack Overflow is the best place for questions because everyone can benefit from the answers.
Snapshots should generally be taken "out of band"--that is out of the mainline of processing. In other words, when a series of events are being committed, you don't want to take a snapshot at that point. Instead, you'll want to have another thread or process take a snapshot asynchronously. I recommend another thread instead of a completely separate process because you don't have to worry about making sure your assemblies (domain, message, etc.) are the same as that for your main processing threads.
The code for "how" to take a snapshot is left up to you, the end user. I will very likely provide some additional guidance in the next week or so on the exact steps for taking a snapshot.
One additional consideration is, do you really need snapshotting? How many streams do you have that go above 1000 events? If none, then you almost certainly don't need the complexity of snapshotting.