@Bean
+public Customizer<SentinelCircuitBreakerFactory> defaultCustomizer() {
+ return factory -> factory.configureDefault(id -> new SentinelConfigBuilder(id)
+ .build());
+}
+From 610d23b2733e552ff0d1330a65deadfd18e97d3e Mon Sep 17 00:00:00 2001
From: buildmaster
To provide a default configuration for all of your circuit breakers create a Customizer bean that is passed a
+SentinelCircuitBreakerFactory.
+The configureDefault method can be used to provide a default configuration.
@Bean
+public Customizer<SentinelCircuitBreakerFactory> defaultCustomizer() {
+ return factory -> factory.configureDefault(id -> new SentinelConfigBuilder(id)
+ .build());
+}
+You can choose to provide default circuit breaking rules via SentinelConfigBuilder#rules(rules).
+You can also choose to load circuit breaking rules later elsewhere using
+DegradeRuleManager.loadRules(rules) API of Sentinel.
Similarly to providing a default configuration, you can create a Customizer bean this is passed a
+SentinelCircuitBreakerFactory.
@Bean
+public Customizer<SentinelCircuitBreakerFactory> slowCustomizer() {
+ String slowId = "slow";
+ List<DegradeRule> rules = Collections.singletonList(
+ new DegradeRule(slowId).setGrade(RuleConstant.DEGRADE_GRADE_RT)
+ .setCount(100)
+ .setTimeWindow(10)
+ );
+ return factory -> factory.configure(builder -> builder.rules(rules), slowId);
+}
+