Skip to content

Commit ca7f7eb

Browse files
committed
Add doc
1 parent 0779627 commit ca7f7eb

7 files changed

+90
-2
lines changed

Course4/database_transaction.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ START TRANSACTION;
212212
COMMIT;
213213
```
214214

215-
2. 如果不允许超卖的话,则在事务的过程中,注意事务还未结束,检查quantity是否小于0, 小于0则说明超卖了,立即回滚事务,撤销当前的订单
216-
215+
2. 如果不允许超卖的话,则在事务的过程中,注意事务还未结束,检查quantity是否小于0, 小于0则说明超卖了,立即回滚事务,撤销当前的订单
216+
217217
```
218218
select quantity from inventory_test where product_id=1
219219

Course5/2021-09-23-06-17-24.png

142 KB
Loading

Course5/2021-09-23-06-20-00.png

145 KB
Loading

Course5/2021-09-23-06-37-56.png

123 KB
Loading

Course5/2021-09-23-06-42-05.png

209 KB
Loading

Course5/index.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# 1. 在Micro Service体系下如何开发业务
2+
3+
4+
## 2. 事务脚本以及领域模型
5+
6+
## 2.1 事务脚本
7+
8+
Organize the business logic as a collection of procedural transaction scripts, one for each type of request.
9+
10+
![](2021-09-23-06-17-24.png)
11+
12+
## 领域模型
13+
14+
Organize the business logic as an object model consisting of classes that have state and behavior.
15+
16+
![](2021-09-23-06-20-00.png)
17+
18+
19+
## 3. 领域驱动(DDD)
20+
21+
* Entity
22+
* Value Object
23+
* Subdomains
24+
* Factory
25+
* Repository
26+
* Aggregate
27+
* Service
28+
29+
### 3.1 Aggregate是什么含义
30+
31+
Organize a domain model as a collection of aggregates, each of which is a graph of objects that can be treated as a unit.
32+
33+
![](2021-09-23-06-37-56.png)
34+
35+
#### 3.1.1 Aggregate的特征
36+
37+
Ensure that an aggregate is a self-contained unit that can enforce its invariants.
38+
39+
* 避免跨服务的Object reference, 即是多个Aggregate通过外键的值相互关联,而不是对象的引用。
40+
![](2021-09-23-06-42-05.png)
41+
* 一个事务只能更新创建和更新单个Aggregate,Aggregate满足Microservice的事务模型约束。
42+
43+
### 3.2 领域事件
44+
45+
An aggregate publishes a domain event when it’s created or undergoes some other significant change.
46+
47+
## 4. 示例

Course6/index.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
CQRS
2+
====
3+
4+
Command query responsibility segregation
5+
6+
## Command
7+
8+
CUD
9+
10+
## Query
11+
12+
R
13+
14+
1. API composition
15+
2. Dedicated data view
16+
17+
18+
OrderHistoryService
19+
20+
handler -> order.created
21+
-> customer.updated
22+
-> ...
23+
24+
ElasticSearch
25+
26+
27+
### Issues
28+
29+
1. Handle duplicated messages
30+
1.1
31+
PROCESSED_EVENT table
32+
eventId
33+
maxEventId
34+
1.2
35+
幂等性
36+
37+
## API Gateway
38+
39+
1. API composition
40+
2. Edge function(Authentication, Authorization, Rate limit, Monitor)
41+
3. Proxy

0 commit comments

Comments
 (0)