Skip to content

Commit

Permalink
fix(doc): format
Browse files Browse the repository at this point in the history
  • Loading branch information
MageekChiu committed May 13, 2022
1 parent 3b080fd commit 85daf68
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 38 deletions.
20 changes: 10 additions & 10 deletions docs/cn/details/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ parent: 中文文档
2. 构建相关 jar 包
3. 运行

```shell script
```
java -Dappactive.machineRulePath=/Path-to-Appactive/appactive-demo/data/frontend-unit/machine.json \
-Dappactive.dataScopeRuleDirectoryPath=/Path-to-Appactive/appactive-demo/data/frontend-unit \
-Dappactive.forbiddenRulePath=/Path-to-Appactive/appactive-demo/data/frontend-unit/forbiddenRule.json \
Expand All @@ -93,7 +93,7 @@ java -Dappactive.machineRulePath=/Path-to-Appactive/appactive-demo/data/frontend

4. 测试

```shell script
```
curl 127.0.0.1:8886/show?r_id=1 -H "r_id:2" -b "r_id=3"
routerId: 1
curl 127.0.0.1:8886/show -H "r_id:2" -b "r_id=3"
Expand All @@ -111,19 +111,19 @@ routerId: null
1.`appactive-portal` 模块中运行 `sh baseline.sh 2`,推送应用基线
2.`appactive-demo`中 运行 nacos

```shell script
```
cd dependency/nacos && sh run.sh
```

3.`appactive-demo`中 运行 mysql

```shell script
```
cd dependency/mysql && sh run.sh
```

然后 运行

```shell script
```
# 进入容器
docker exec -ti appactive-mysql bash
# 导入数据
Expand All @@ -134,7 +134,7 @@ exit

4. 构建所有 jar 包并运行

```shell script
```
java -Dappactive.machineRulePath=/Path-to-Appactive/appactive-demo/data/storage-unit/machine.json \
-Dappactive.dataScopeRuleDirectoryPath=/Path-to-Appactive/appactive-demo/data/storage-unit \
-Dappactive.forbiddenRulePath=/Path-to-Appactive/appactive-demo/data/storage-unit/forbiddenRule.json \
Expand All @@ -150,7 +150,7 @@ java -Dappactive.machineRulePath=/Path-to-Appactive/appactive-demo/data/storage-

5. 测试

```shell script
```
curl 127.0.0.1:8882/buy?r_id=1
routerId 1 bought 1 of item 12, result: success
curl 127.0.0.1:8882/buy?r_id=4567
Expand All @@ -167,14 +167,14 @@ routerId 4567 bought 1 of item 12, result: machine:unit,traffic:CENTER,not equal
构建 Dubbo 的 demo 过于复杂,建议使用 quick start 中启用的demo,直接进行体验,特别地,单元保护功能测试步骤如下:
1. 首先修改 frontend 的规则,以便于 frontend 访问到错误的单元

```shell script
```
cd data/frontend-center
vim idUnitMapping.json
```

如下

```shell script
```
{
"itemType": "UnitRuleItem",
"items": [
Expand Down Expand Up @@ -204,7 +204,7 @@ vim idUnitMapping.json

2. 发起测试

```shell script
```
curl 127.0.0.1:8885/detail -H "Host:demo.appactive.io" -H "r_id:2499"
# 注意到报错会有这样一段
Expand Down
24 changes: 16 additions & 8 deletions docs/cn/details/demo_nacos.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ parent: 中文文档
### 前提

1.`appactive-demo`中 运行 nacos
```shell script
```
cd dependency/nacos && sh run.sh
# 然后在 nacos 中创建命令通道专属空间,如`appactiveDemoNamespaceId`
```

2.`appactive-demo`中 运行 mysql
```shell script
```
cd dependency/mysql && sh run.sh
```

Expand All @@ -94,7 +94,7 @@ cd dependency/mysql && sh run.sh
2. 构建相关 jar 包
3. 运行

```shell script
```
java -Dappactive.unit=unit \
-Dappactive.app=frontend \
-Dio.appactive.demo.unitlist=center,unit \
Expand All @@ -104,8 +104,10 @@ java -Dappactive.unit=unit \
-Dappactive.namespaceId=appactiveDemoNamespaceId \
-jar frontend-0.3.jar
```

4. 测试
```shell script

```
curl 127.0.0.1:8886/show?r_id=1 -H "r_id:2" -b "r_id=3"
routerId: 1
curl 127.0.0.1:8886/show -H "r_id:2" -b "r_id=3"
Expand All @@ -123,17 +125,19 @@ routerId: null
1.`appactive-portal` 模块中运行 `sh baseline.sh 2 NACOS appactiveDemoNamespaceId`,推送应用基线

2. 初始化数据
```shell script

```
# 进入容器
docker exec -ti appactive-mysql bash
# 导入数据
mysql -uroot -pdemo_appactiive_pw product < /root/init.sql
# 退出
exit
```

3. 构建所有 jar 包并运行

```shell script
```
java -Dappactive.channelTypeEnum=NACOS \
-Dappactive.namespaceId=appactiveDemoNamespaceId \
-Dappactive.unit=unit \
Expand All @@ -142,8 +146,10 @@ java -Dappactive.channelTypeEnum=NACOS \
-Dserver.port=8882 \
-jar storage-0.3.jar
```

4. 测试
```shell script

```
curl 127.0.0.1:8882/buy?r_id=1
routerId 1 bought 1 of item 12, result: success
curl 127.0.0.1:8882/buy?r_id=4567
Expand All @@ -160,12 +166,14 @@ routerId 4567 bought 1 of item 12, result: machine:unit,traffic:CENTER,not equal
构建 Dubbo 的 demo 过于复杂,建议使用 quick start 中启用的demo,直接进行体验,特别地,单元保护功能测试步骤如下:

1. 发起测试
```shell script

```
curl 127.0.0.1:8885/detail -H "Host:demo.appactive.io" -H "r_id:2499"
# 注意到报错会有这样一段
[appactive/io.appactive.demo.common.service.dubbo.ProductServiceUnit:1.0.0] [detail] from [172.18.0.9] is rejected by UnitRule Protection, targetUnit [CENTER], currentUnit [unit].)
```

因为我们直接将 路由id为 2499 的 请求路由到了单元,但实际上,这个请求应该路由到中心,所以被单元的provider拒绝请求了。

## 规则说明
Expand Down
24 changes: 12 additions & 12 deletions docs/en/details/demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Note: The registry nacos and database mysql that the application depends on are

There are 2 units:

-center: center unit
-unit: ordinary unit
- center: center unit
- unit: ordinary unit

There are 4 applications in total, according to the distance (call link) of the end user from near and far:

Expand Down Expand Up @@ -70,7 +70,7 @@ note: this demo contains many applications,please adjust your memory settings
2. build all jar needed
3. run java application

```shell script
```
java -Dappactive.machineRulePath=/Path-to-Appactive/appactive-demo/data/frontend-unit/machine.json \
-Dappactive.dataScopeRuleDirectoryPath=/Path-to-Appactive/appactive-demo/data/frontend-unit \
-Dappactive.forbiddenRulePath=/Path-to-Appactive/appactive-demo/data/frontend-unit/forbiddenRule.json \
Expand All @@ -87,7 +87,7 @@ java -Dappactive.machineRulePath=/Path-to-Appactive/appactive-demo/data/frontend

4. test

```shell script
```
curl 127.0.0.1:8886/show?r_id=1 -H "r_id:2" -b "r_id=3"
routerId: 1
curl 127.0.0.1:8886/show -H "r_id:2" -b "r_id=3"
Expand All @@ -104,18 +104,18 @@ routerId: null

1. in `appactive-portal` module, run `sh baseline.sh 2`
2. in `appactive-demo`module, run nacos
```shell script
```
cd dependency/nacos && sh run.sh
```
3. in `appactive-demo` module, run mysql

```shell script
```
cd dependency/mysql && sh run.sh
```

then

```shell script
```
# enter container
docker exec -ti appactive-mysql bash
# import data
Expand All @@ -126,7 +126,7 @@ exit

4. build all the jars and run

```shell script
```
java -Dappactive.machineRulePath=/Path-to-Appactive/appactive-demo/data/storage-unit/machine.json \
-Dappactive.dataScopeRuleDirectoryPath=/Path-to-Appactive/appactive-demo/data/storage-unit \
-Dappactive.forbiddenRulePath=/Path-to-Appactive/appactive-demo/data/storage-unit/forbiddenRule.json \
Expand All @@ -142,7 +142,7 @@ java -Dappactive.machineRulePath=/Path-to-Appactive/appactive-demo/data/storage-

5. test

```shell script
```
curl 127.0.0.1:8882/buy?r_id=1
routerId 1 bought 1 of item 12, result: success
curl 127.0.0.1:8882/buy?r_id=4567
Expand All @@ -159,14 +159,14 @@ Visit [nginx-plugin](/appactive-gateway/nginx-plugin/Readme.md)
the building process of demo of Dubbo is far too complicated,we suggest using demo in "quick start":
1. first of all, modify rules in frontend-center, so that frontend-center would route request to the wrong unit

```shell script
```
cd data/frontend-center
vim idUnitMapping.json
```

the rules are as follows

```shell script
```
{
"itemType": "UnitRuleItem",
"items": [
Expand Down Expand Up @@ -196,7 +196,7 @@ the rules are as follows

2. run test

```shell script
```
curl 127.0.0.1:8885/detail -H "Host:demo.appactive.io" -H "r_id:2499"
# you can see error logs as follows
[appactive/io.appactive.demo.common.service.dubbo.ProductServiceUnit:1.0.0] [detail] from [172.18.0.9] is rejected by UnitRule Protection, targetUnit [CENTER], currentUnit [unit].)
Expand Down
25 changes: 17 additions & 8 deletions docs/en/details/demo_nacos.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ note: this demo contains many applications,please adjust your memory settings
### Premise

1. Run nacos in `appactive-demo`
```shell script

```
cd dependency/nacos && sh run.sh
# and then create a namespace for command channel,like `appactiveDemoNamespaceId`
```

2. Run maysql in `appactive-demo`
```shell script

```
cd dependency/mysql && sh run.sh
```

Expand All @@ -89,7 +91,7 @@ cd dependency/mysql && sh run.sh
2. build all jar needed
3. run java application

```shell script
```
java -Dappactive.unit=unit \
-Dappactive.app=frontend \
-Dio.appactive.demo.unitlist=center,unit \
Expand All @@ -99,8 +101,10 @@ java -Dappactive.unit=unit \
-Dappactive.namespaceId=appactiveDemoNamespaceId \
-jar frontend-0.3.jar
```

4. test
```shell script

```
curl 127.0.0.1:8886/show?r_id=1 -H "r_id:2" -b "r_id=3"
routerId: 1
curl 127.0.0.1:8886/show -H "r_id:2" -b "r_id=3"
Expand All @@ -118,17 +122,19 @@ routerId: null
1. In `appactive-portal` module, run `sh baseline.sh 2 NACOS appactiveDemoNamespaceId`

2. Data initiation
```shell script

```
# enter container
docker exec -ti appactive-mysql bash
# import data
mysql -uroot -pdemo_appactiive_pw product < /root/init.sql
# exit
exit
```

4. build all the jars and run

```shell script
```
java -Dappactive.channelTypeEnum=NACOS \
-Dappactive.namespaceId=appactiveDemoNamespaceId \
-Dappactive.unit=unit \
Expand All @@ -137,8 +143,10 @@ java -Dappactive.channelTypeEnum=NACOS \
-Dserver.port=8882 \
-jar storage-0.3.jar
```

5. test
```shell script

```
curl 127.0.0.1:8882/buy?r_id=1
routerId 1 bought 1 of item 12, result: success
curl 127.0.0.1:8882/buy?r_id=4567
Expand All @@ -154,7 +162,8 @@ Visit [nginx-plugin](/appactive-gateway/nginx-plugin/Readme.md)

the building process of demo of Dubbo is far too complicated,we suggest using demo in "quick start":
1. run test
```shell script

```
curl 127.0.0.1:8885/detail -H "Host:demo.appactive.io" -H "r_id:2499"
# you can see error logs as follows
[appactive/io.appactive.demo.common.service.dubbo.ProductServiceUnit:1.0.0] [detail] from [172.18.0.9] is rejected by unit protection, targetUnit [CENTER], currentUnit [unit].)
Expand Down

0 comments on commit 85daf68

Please sign in to comment.