Skip to content

Dynamic Rule Configuration

Eric Zhao edited this page Nov 9, 2018 · 9 revisions

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 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 source in production.

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

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

Clone this wiki locally