sentinel在限流规则配置方面提供了可视化页面 sentinel dashboard,源码可从github下载,请自行搜索,此处不提供下载链接。
规则持久化后首先触发GatewayFlowRuleController(源码似乎没有,请参考普通规则改造)的/new.json(或)请求,方法会调用publishRules()将本次编辑规则组装后通过远程调用请求gateway/updateRules更新远程服务内存中限流规则,该接口由远程服务UpdateGatewayRuleCommandHandler提供。
UpdateGatewayRuleCommandHandler接收到请求通过调用handle方法,方法通过
Set<GatewayFlowRule> flowRules = (Set)JSON.parseObject(data, new TypeReference<Set<GatewayFlowRule>>() {
}, new Feature[0]);
GatewayRuleManager.loadRules(flowRules);
将规则持久化到内存。
具体请参考以下流程图。
Sentinel DashBoard程序流程
Gateway网关程序流程