mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
Polish alibaba/spring-cloud-alibaba#1363 : Sync spring-cloud-alibaba-sentinel-datasource module
This commit is contained in:
parent
1d9c1975b2
commit
d11f2a0608
@ -17,6 +17,7 @@
|
|||||||
package com.alibaba.cloud.sentinel.datasource.config;
|
package com.alibaba.cloud.sentinel.datasource.config;
|
||||||
|
|
||||||
import com.alibaba.cloud.sentinel.datasource.factorybean.ConsulDataSourceFactoryBean;
|
import com.alibaba.cloud.sentinel.datasource.factorybean.ConsulDataSourceFactoryBean;
|
||||||
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +28,7 @@ import org.springframework.util.StringUtils;
|
|||||||
*/
|
*/
|
||||||
public class ConsulDataSourceProperties extends AbstractDataSourceProperties {
|
public class ConsulDataSourceProperties extends AbstractDataSourceProperties {
|
||||||
|
|
||||||
public ConsulDataSourceProperties(){
|
public ConsulDataSourceProperties() {
|
||||||
super(ConsulDataSourceFactoryBean.class.getName());
|
super(ConsulDataSourceFactoryBean.class.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ public class ConsulDataSourceProperties extends AbstractDataSourceProperties {
|
|||||||
/**
|
/**
|
||||||
* consul server port.
|
* consul server port.
|
||||||
*/
|
*/
|
||||||
private int port=8500;
|
private int port = 8500;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* data key in Redis.
|
* data key in Redis.
|
||||||
@ -53,11 +54,10 @@ public class ConsulDataSourceProperties extends AbstractDataSourceProperties {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preCheck(String dataSourceName) {
|
public void preCheck(String dataSourceName) {
|
||||||
if(StringUtils.isEmpty(host)){
|
if (StringUtils.isEmpty(host)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException("ConsulDataSource server-host is empty");
|
||||||
"ConsulDataSource server-host is empty");
|
|
||||||
}
|
}
|
||||||
if(StringUtils.isEmpty(ruleKey)){
|
if (StringUtils.isEmpty(ruleKey)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"ConsulDataSource ruleKey can not be empty");
|
"ConsulDataSource ruleKey can not be empty");
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ package com.alibaba.cloud.sentinel.datasource.factorybean;
|
|||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||||
import com.alibaba.csp.sentinel.datasource.consul.ConsulDataSource;
|
import com.alibaba.csp.sentinel.datasource.consul.ConsulDataSource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,12 +41,7 @@ public class ConsulDataSourceFactoryBean implements FactoryBean<ConsulDataSource
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConsulDataSource getObject() throws Exception {
|
public ConsulDataSource getObject() throws Exception {
|
||||||
return new ConsulDataSource(
|
return new ConsulDataSource(host, port, ruleKey, waitTimeoutInSecond, converter);
|
||||||
host,
|
|
||||||
port,
|
|
||||||
ruleKey,
|
|
||||||
waitTimeoutInSecond,
|
|
||||||
converter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user