1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

sentinel commercialization feature

This commit is contained in:
fangjian0423
2018-12-19 22:54:25 +08:00
parent c300ffbbc6
commit 8af824dc2f
7 changed files with 89 additions and 7 deletions

View File

@@ -31,4 +31,6 @@ public interface SentinelDataSourceConstants {
String NACOS_DATASOURCE_ENDPOINT = PROPERTY_PREFIX + ".nacos.config.endpoint";
String PROJECT_NAME = PROPERTY_PREFIX + ".nacos.config.project-name";
}

View File

@@ -28,6 +28,25 @@ public class DataSourcePropertiesConfiguration {
private ApolloDataSourceProperties apollo;
public DataSourcePropertiesConfiguration() {
}
public DataSourcePropertiesConfiguration(FileDataSourceProperties file) {
this.file = file;
}
public DataSourcePropertiesConfiguration(NacosDataSourceProperties nacos) {
this.nacos = nacos;
}
public DataSourcePropertiesConfiguration(ZookeeperDataSourceProperties zk) {
this.zk = zk;
}
public DataSourcePropertiesConfiguration(ApolloDataSourceProperties apollo) {
this.apollo = apollo;
}
public FileDataSourceProperties getFile() {
return file;
}

View File

@@ -101,4 +101,31 @@ public class NacosDataSourceProperties extends AbstractDataSourceProperties {
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
public static NacosDataSourceProperties buildFlowByEDAS() {
return buildByEDAS("flow");
}
public static NacosDataSourceProperties buildDegradeByEDAS() {
return buildByEDAS("degrade");
}
public static NacosDataSourceProperties buildByEDAS(String type) {
NacosDataSourceProperties result = new NacosDataSourceProperties();
result.setFactoryBeanName(
NacosDataSourceWithAuthorizationFactoryBean.class.getName());
result.setEndpoint(System.getProperties()
.getProperty(SentinelDataSourceConstants.NACOS_DATASOURCE_ENDPOINT));
result.setNamespace(System.getProperties()
.getProperty(SentinelDataSourceConstants.NACOS_DATASOURCE_NAMESPACE));
result.setAccessKey(System.getProperties()
.getProperty(SentinelDataSourceConstants.NACOS_DATASOURCE_AK));
result.setSecretKey(System.getProperties()
.getProperty(SentinelDataSourceConstants.NACOS_DATASOURCE_SK));
result.setDataType("json");
result.setDataId(System.getProperties()
.getProperty(SentinelDataSourceConstants.PROJECT_NAME) + "-" + type);
result.setGroupId("nacos-sentinel");
return result;
}
}