seninel部署
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Lin.Liang 30158bcac0 Add Spring Cloud Config data source extension (#899) 5 лет назад
..
src Add Spring Cloud Config data source extension (#899) 5 лет назад
README.md Add Spring Cloud Config data source extension (#899) 5 лет назад
pom.xml Add Spring Cloud Config data source extension (#899) 5 лет назад

README.md

Sentinel DataSource SpringCloudConfig

Sentinel DataSource SpringCloudConfig provides integration with SpringCloudConfig so that SpringCloudConfig can be the dynamic rule data source of Sentinel.

To use Sentinel DataSource SpringCloudConfig, you should add the following dependency:

<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-datasource-spring-cloud-config</artifactId>
    <version>x.y.z</version>
</dependency>

Then you can create an SpringCloudConfigDataSource and register to rule managers. For instance:

//flow_rule is the propery key in SpringConfigConfig
SpringCloudConfigDataSource dataSource = new SpringCloudConfigDataSource("flow_rule", new Converter<String, List<FlowRule>>() {
            @Override
            public List<FlowRule> convert(String source) {
                return JSON.parseArray(source, FlowRule.class);
            }
        });
        FlowRuleManager.register2Property(dataSource.getProperty());

If the client want to perceive the remote config changed, it can binding a git webhook callback with the com.alibaba.csp.sentinel.datasource.spring.cloud.config.SentinelRuleLocator.refresh API. Like test demo com.alibaba.csp.sentinel.datasource.spring.cloud.config.test.SpringCouldDataSourceTest.refresh do.

We offer test cases and demo in: [com.alibaba.csp.sentinel.datasource.spring.cloud.config.test]. When you run test cases, please follow the steps:

//first start config server
com.alibaba.csp.sentinel.datasource.spring.cloud.config.server.ConfigServer

//second start config client
com.alibaba.csp.sentinel.datasource.spring.cloud.config.client.ConfigClient

//third run test cases and demo
com.alibaba.csp.sentinel.datasource.spring.cloud.config.test.SentinelRuleLocatorTests
com.alibaba.csp.sentinel.datasource.spring.cloud.config.test.SpringCouldDataSourceTest