T - 规则数据类型public abstract class AbstractEzSentinelRuleConfigurer<T> extends java.lang.Object implements EzSentinelRuleConfigurer<T>
说明文档见: https://github.com/shepherdviolet/slate/blob/master/docs/ezsentinel/guide.md
Sentinel官方最佳实践的方案中, 应该是改造Dashboard, 由Dashboard向一个数据源推送规则, 而客户端则连接数据源获取更新. 而EzSentinel是一个简易的变通方案, 不改造Dashboard, 也不配置客户端数据源. 通过一个大JSON来维护规则(人工), 然后手动 将这个JSON配置到Apollo配置中心, 借助Apollo准实时将配置用setter方法注入的特性, 在setter方法中显式地调用Sentinel的 API来实现规则配置. 而Dashboard仅用于观察(不做配置).
通过EzSentinel配置规则后, 可以在Dashboard的流控规则中看到_ez_开头的资源, 这个是用来观察某个应用规则是否生效/何时生效/ 失败原因的.
| 限定符和类型 | 类和说明 |
|---|---|
static class |
AbstractEzSentinelRuleConfigurer.DegradeRuleBuilder |
static class |
AbstractEzSentinelRuleConfigurer.FlowRuleBuilder |
static class |
AbstractEzSentinelRuleConfigurer.RuleGroup |
static class |
AbstractEzSentinelRuleConfigurer.Rules |
static class |
AbstractEzSentinelRuleConfigurer.SystemRuleBuilder |
| 构造器和说明 |
|---|
AbstractEzSentinelRuleConfigurer() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected static com.alibaba.csp.sentinel.slots.block.flow.FlowRule |
commentRule(java.lang.String comment) |
protected abstract AbstractEzSentinelRuleConfigurer.Rules |
convertRuleData(T ruleData) |
protected void |
handleException(java.lang.String errorCode,
java.lang.Exception e,
T ruleData) |
protected static int |
nullable(java.lang.Integer value,
int fallback) |
void |
update(T ruleData)
在Apollo配置变化时, setter方法中调用该方法更新规则, 参考
EnableEzSentinel |
protected void |
updateRules(AbstractEzSentinelRuleConfigurer.Rules rules) |
public void update(T ruleData)
EnableEzSentinelupdate 在接口中 EzSentinelRuleConfigurer<T>ruleData - 规则数据protected abstract AbstractEzSentinelRuleConfigurer.Rules convertRuleData(T ruleData)
protected void updateRules(AbstractEzSentinelRuleConfigurer.Rules rules)
protected void handleException(java.lang.String errorCode,
java.lang.Exception e,
T ruleData)
protected static int nullable(java.lang.Integer value,
int fallback)
protected static com.alibaba.csp.sentinel.slots.block.flow.FlowRule commentRule(java.lang.String comment)