28 Star 246 Fork 57

Ahoo-Wang / Wow

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

Wow:基于 DDD & EventSourcing 的现代响应式 CQRS 架构微服务开发框架

Wow : 基于 DDD & EventSourcing 的现代响应式 CQRS 架构微服务开发框架

中文文档

License GitHub release Maven Central Codacy Badge codecov Integration Test Status Awesome Kotlin Badge

领域驱动 | 事件驱动 | 测试驱动 | 声明式设计 | 响应式编程 | 命令查询职责分离 | 事件溯源

简介

Wow 是一个基于领域驱动设计和事件溯源的现代响应式 CQRS 微服务开发框架,历经多年生产环境验证。

旨在帮助开发者构建现代化的、高性能且易于维护的微服务应用程序,充分发挥领域驱动设计和事件溯源等模式优势的同时降低应用的复杂性以及实践成本。

值得一提的是,领域驱动设计和事件溯源并非微服务架构的专属,Wow 框架不仅适用于微服务开发,同样也可用于构建基于领域驱动设计的单体应用程序。

快速开始

使用 Wow 项目模板快速创建基于 Wow 框架的 DDD 项目

特性概览

Wow-Features

架构图

Wow-Architecture

背景

随着业务的发展和复杂性的增加,传统的架构和开发方式逐渐显露出瓶颈。领域驱动设计事件溯源等理念在提高系统设计的灵活性和可维护性方面表现出色,但在实践中常常需要面对复杂性和学习曲线的挑战。

Wow 框架的目标是以简单易用的方式将领域驱动设计和事件溯源等理念融入到微服务应用开发中,降低开发者的学习成本,提高开发效率。 通过提供现代响应式的 CQRS 架构和相关组件,Wow 框架旨在让开发者更专注于业务逻辑的实现,而不必过多关心底层技术细节。

经过多年的实践和不断的演进,Wow 框架在生产环境中得到了验证,积累了丰富的经验。这些经验和反馈不仅丰富了框架的功能和性能,也为持续的改进和优化提供了宝贵的指导。

对于开发者而言,Wow 框架意味着什么?

我曾告诫我的团队:如果我们过于依赖数据驱动设计而忽视领域驱动设计,我们最终将沦为CRUD工程师。

CRUD工程师的竞争力和可替代性可想而知,这或许是为何会有 35 岁效应,企业显然更倾向于招募没有太多生活羁绊、更加廉价的 25CRUD工程师。

业务价值

软件系统的核心价值体现在业务价值上,研发人员不应只关注技术实现上,而是应该更多地关注业务价值的实现。 这其中的好处显而易见,当你开发完一个业务系统之后,你将变成一个业务专家,甚至比跟你合作的领域专家还要专业,因为你需要洞察业务细节。

使用 Wow 框架,意味着你将关注点放在围绕领域模型设计上,与业务专家一起探索业务领域,而不是关注于技术实现上。 你仅需编写领域模型,即可完成服务开发,Wow 框架自动为你准备好 OpenAPI 接口。

在《实现领域驱动设计》一书中,作者 Vaughn Vernon 提到:核心域才值得投入精力进行领域驱动设计, 但如果你使用 Wow 框架,你将发现,因为低廉开发成本、快速的开发效率,即使是次要的支撑子域也值得 DDD

性能与伸缩性

随着业务的发展,你需要开始思考系统的性能和伸缩性问题。 在传统架构中,这牵扯到数据库关系模式、分片规则等复杂问题,同时你还需要处理因数据库分片导致的跨分片事务问题。 这时,你不得不修改你的业务代码,以适应水平拆分后的数据库架构。

然而,如果你选择使用 Wow 框架,你将不再需要过多关注数据库关系模式、分片规则等问题。你的业务代码无需变更,系统能够轻松实现水平伸缩。

你可以在这里了解更多关于 Wow 框架的性能

读写分离与同步延迟

读写分离是一种极为普遍的性能优化架构模式。 然而,同步延迟问题常伴随而来,事务执行成功后写库落库成功,但读库同步延迟,用户刷新页面后无法获取最新数据,从而对用户的体验产生影响。例如:

  • 用户发起下单事务,写库执行成功,但由于某种原因,读库同步延迟,用户刷新页面后发现订单未成功创建。
  • 商家编辑完商品后,同步到 Elasticsearch 索引库,但由于某种原因,同步延迟,导致商家刷新页面后搜索不到该商品。

通常,大家采用最简便的方法,等待1秒后刷新页面。 虽然这种方式能解决大多数数据同步延迟的问题,但效率不够高。 因为大多数情况下,同步在100毫秒内就已完成,剩余的900毫秒成了浪费。 然而,有时1秒无法完成同步,这就导致用户获取的数据变得无效

使用 Wow 框架,你可以通过等待 PROJECTED 信号完成,然后再将结果返回给用户,以更为优雅和高效的方式处理数据同步延迟的问题。

工程质量

单元测试是确保代码质量且符合预期业务需求的重要手段,但在传统架构中,单元测试往往是一项相当困难的任务,因为你需要考虑数据库连接、事务管理、数据清理等问题。

使用 Wow 框架,你将会发现基于 Given->When->Expect 模式的测试套件,使得单元测试变得异常简单。 你只需关注领域模型是否符合预期,而无需为数据库连接等问题烦恼。

在实际应用中,我们将领域模型的单元测试覆盖率下限阈值设置为 85%,也是可以轻松实现的。

在没有刻意要求的情况下,开发人员甚至自觉地将覆盖率提升至 95%

因此,每次提交代码都变得轻松自在,因为你确信你的代码经过了充分的测试,并且真正意义上从单元测试中获得了收益。

在研发同级别的项目中,我们的测试团队在系统 API 测试中发现,基于 Wow 框架的项目,其 BUG 数仅为传统架构项目的 1/3

你可以在这里了解更多关于 Wow 单元测试套件

对于企业而言,Wow 框架意味着什么?

商业智能

商业智能是企业决策的关键支持,而数据则是商业智能的分析原料。业务数据越为丰富有价值,商业智能的分析结果越准确,决策也就更加可靠。

与传统架构有着显著差异,Wow 提供了实时聚合根状态事件(StateEvent)和聚合命令(Command)作为数据分析的数据源,同时极大降低了实时 ETLExtract, Transform, Load)的难度。

在传统架构中,实现实时 ETL 通常需要经过繁琐的流程,包括 DB->CDC->Process->DB,而在 Wow 框架中,仅需一段简单的 SQL 脚本即可完成这一过程。

另外,在传统架构中,使用 CDCMySql Binlog)数据仅记录数据的变化,缺乏明确的业务语义。进行业务分析时,需要基于数据状态的变化推断出业务语义,这往往需要进行大量的数据处理。 相较之下,Wow 框架直接提供了聚合根状态事件和聚合命令作为数据分析的数据源,极大降低了数据处理的难度。

Wow 提供的实时同步机制将数据实时同步至数据仓库(ClickHouse),为实时数据分析提供了极大的便利。这种方法为商业智能提供了强有力的支持,构建了一个实时数据分析系统,使决策制定能够基于及时而准确的信息。

你可以在这里了解更多关于 Wow 商业智能

操作审计

操作审计是企业中保障安全性和合规性的重要组成部分,同时也是对系统操作进行监控和追踪的关键手段。Wow 框架在这方面为企业带来了显著的优势。

通过记录聚合命令(Command)作为操作审计的数据源,Wow 框架能够详细追踪系统中的各种操作。 这些记录不仅包含了操作本身的内容,还涵盖了操作触发的副作用(领域事件),为审计提供了更为全面和准确的数据基础。

相较于传统审计方法,Wow 框架的操作审计的数据源具备更加明确的业务语义,以及操作后产生的明确领域事件。

此外,Wow 框架提供的实时数据同步机制也为操作审计带来了便利,确保了审计数据的及时性和一致性。

了解更多关于 Wow 操作审计

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [2022] [ahoo wang <ahoowang@qq.com>] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

领域模型即服务 - 基于 DDD & EventSourcing 的现代响应式 CQRS 架构微服务开发框架 展开 收起
取消

发行版 (60)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Kotlin
1
https://gitee.com/AhooWang/Wow.git
git@gitee.com:AhooWang/Wow.git
AhooWang
Wow
Wow
main

搜索帮助