简体   繁体   English

域驱动设计-CQRS + ES的使用

[英]Domain Driven Design - CQRS + ES usage

I have a question to people, who implemented CQRS + Event Sourcing architecture in their own projects. 我对在自己的项目中实施CQRS +事件源架构的人们有疑问。

I would like to know, if in long term is it better to use CQRS open source library for your project or to implement it by yourself? 我想知道,从长远来看,为您的项目使用CQRS开源库还是自己实施是更好的选择?

If by yourself, should it be implemented as library for company or it should go hand by hand with project that use it? 如果是您自己,应该将它作为公司的库来实现,还是应该与使用它的项目并驾齐驱?

What are cons and pros for each of the way? 每种方式的利弊是什么?

In both case you should design the right interface to decouple your Domain from the infrastructure itself. 在这两种情况下,您都应该设计正确的界面,以使您的域与基础架构本身脱钩。 At this point the two solutions (home made vs. open source) are a matter of taste. 此时,两种解决方案(自制与开放源代码)只是一个问题。

An home-made solution gives you a better insight on the whole infrastructure. 自制的解决方案使您可以更好地了解整个基础架构。 This is a CONs if you are late on time or you need to be ready as soon as possible. 如果您迟到或需要尽快做好准备,这是一个缺点。

An open-source solution gives you community support while you can still looks into code and learn. 开源解决方案为您提供社区支持,同时您仍然可以研究代码并学习。 If the project dies is a problem but you have source code and do what you want (even resurrect it) or if you are really decoupled by your Domain you can replace infrastructure easily. 如果项目死了是一个问题,但是您有源代码并且可以做您想要做的事情(甚至可以复活它),或者如果您真的与您的域分离,则可以轻松地替换基础结构。

My suggestion goes towards NEventStore. 我的建议是去NEventStore。

I would say try implement a basic home-made solution while using the open-source package as a guideline. 我想说的是,在使用开源软件包作为指南的同时,尝试实现基本的自制解决方案。 Then once completed use the open-source package (NServiceStore). 然后,一旦完成,请使用开源软件包(NServiceStore)。

May seem unnecessary, but I found when I implemented CQRS that it helps to understand the inner-workings of CQRS. 似乎没有必要,但是我发现在实施CQRS时它有助于理解CQRS的内部工作原理。 Was able to grasp CQRS pattern better and make a more informed decision on my business rules than if I went straight to using the packages. 与我直接使用软件包相比,能够更好地掌握CQRS模式并在业务规则上做出更明智的决定。

Also, like marianoc mentioned, it shouldn't be difficult to swap out infrastructural implementations if the need arises in the future. 而且,就像marianoc提到的那样,如果将来需要的话,换掉基础设施的实现应该不难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM