For Chinese version, see 动态规则扩展.

Rules

Sentinel’s philosophy is that developers only need to pay attention to the definition of resources. Various rules can be dynamically added and updated as soon as the resource is defined. Sentinel provides two ways to modify the rules:

  • Direct modification via API (loadRules of XxxRuleManager)
  • Integrate with external storage via dynamic DataSource

Rule management through the API is straightforward. You can modify different rules with the following APIs:

  • Flow rule: FlowRuleManager.loadRules(List<FlowRule> rules)
  • Degrade rule: DegradeRuleManager.loadRules(List<DegradeRule> rules)
  • System rule: SystemRuleManager.loadRules(List<SystemRule> rules)
  • Authority rule: AuthorityRuleManager.loadRules(List<AuthorityRule> rules)

Dynamic data source extension

The loadRules() methods described above only accept rules in memory. But more often the rules are stored in files, databases, or configuration centers. The dynamic DataSource interface gives us the ability to integrate with any configuration source. It’s recommended to use dynamic rule data sources in production.

We recommend you push the rules to the unified rule configuration center after setting the rules through the Sentinel dashboard. Your service (the Sentinel client) implements the ReadableDataSource interface to observe changes from the configuration center in real-time. The process is as follows:

push-rules-from-dashboard-to-config-center

Data source integrations

Currently we support: