You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.5 KiB
37 lines
1.5 KiB
5 years ago
|
# ClusterForwardProvider 接口 demo
|
||
|
|
||
|
demo 插件中提供了三个接口:
|
||
|
|
||
|
1. /req/demo/create
|
||
|
2. /req/demo/search
|
||
|
3. /req/demo/view
|
||
|
|
||
|
search 接口需要携带 create 接口返回的id;
|
||
|
携带了 id 参数的search 请求总是会被转发到生成该 id 的节点,即处理前一个 create 请求的节点上。
|
||
|
|
||
|
浏览器中访问 http://host:port/webroot/decision/url/req/demo/create 得到返回值,其中有 id:
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"id": "4da3ca4a-9bb9-5116-dbaf-3d005fc4cab9",
|
||
|
"isCluster": true,
|
||
|
"clusterId": "M+n28J6oNcJMRUJhC+UczHLb2t1xQWXk2jqx2HHpGu3smaPzPw6DDQ==",
|
||
|
"taskName": "4da3ca4a-9bb9-5116-dbaf-3d005fc4cab9M+n28J6oNcJMRUJhC+UczHLb2t1xQWXk2jqx2HHpGu3smaPzPw6DDQ=="
|
||
|
}
|
||
|
```
|
||
|
|
||
|
该请求被集群转发策略,例如随机转发或者智能转发,转发到了节点 M+n28J6oNcJMRUJhC+UczHLb2t1xQWXk2jqx2HHpGu3smaPzPw6DDQ== 上;
|
||
|
后续浏览器访问 http://host:port/webroot/decision/url/req/demo/search?id=4da3ca4a-9bb9-5116-dbaf-3d005fc4cab9
|
||
|
的请求也会被转发到节点 M+n28J6oNcJMRUJhC+UczHLb2t1xQWXk2jqx2HHpGu3smaPzPw6DDQ==,返回值如下:
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"id": "4da3ca4a-9bb9-5116-dbaf-3d005fc4cab9",
|
||
|
"isCluster": true,
|
||
|
"clusterId": "M+n28J6oNcJMRUJhC+UczHLb2t1xQWXk2jqx2HHpGu3smaPzPw6DDQ==",
|
||
|
"taskName": "4da3ca4a-9bb9-5116-dbaf-3d005fc4cab9M+n28J6oNcJMRUJhC+UczHLb2t1xQWXk2jqx2HHpGu3smaPzPw6DDQ=="
|
||
|
}
|
||
|
```
|
||
|
|
||
|
而浏览器中访问 http://host:port/webroot/decision/url/req/demo/view 的请求会被代理例如 nginx 随机转发到某一节点。
|