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

modify name of ruleType and update example

This commit is contained in:
fangjian0423 2019-05-06 16:45:40 +08:00
parent ef415f87ad
commit 530a36fc06
5 changed files with 87 additions and 86 deletions

View File

@ -25,12 +25,12 @@ spring:
sentinel:
datasource.ds2.file:
file: "classpath: gateway.json"
ruleType: gateway
ruleType: gw-flow
datasource.ds1.file:
file: "classpath: api.json"
ruleType: api
ruleType: gw-api-group
transport:
dashboard: localhost:9999
dashboard: localhost:8080
filter:
enabled: true

View File

@ -7,12 +7,12 @@ spring:
sentinel:
datasource.ds2.file:
file: "classpath: gateway.json"
ruleType: gateway
ruleType: gw-flow
datasource.ds1.file:
file: "classpath: api.json"
ruleType: api
ruleType: gw-api-group
transport:
dashboard: localhost:9999
dashboard: localhost:8080
filter:
enabled: false

View File

@ -46,11 +46,11 @@ public enum RuleType {
/**
* gateway flow
*/
GATEWAY("gateway-flow", GatewayFlowRule.class),
GW_FLOW("gw-flow", GatewayFlowRule.class),
/**
* api
*/
API("api", ApiDefinition.class);
GW_API_GROUP("gw-api-group", ApiDefinition.class);
/**
* alias for {@link AbstractRule}

View File

@ -84,10 +84,10 @@ public class AbstractDataSourceProperties {
case AUTHORITY:
AuthorityRuleManager.register2Property(dataSource.getProperty());
break;
case GATEWAY:
case GW_FLOW:
GatewayRuleManager.register2Property(dataSource.getProperty());
break;
case API:
case GW_API_GROUP:
GatewayApiDefinitionManager.register2Property(dataSource.getProperty());
break;
default:

View File

@ -24,6 +24,21 @@ import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.alibaba.sentinel.SentinelProperties;
import org.springframework.cloud.alibaba.sentinel.datasource.converter.JsonConverter;
import org.springframework.cloud.alibaba.sentinel.datasource.converter.XmlConverter;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPathPredicateItem;
import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiPredicateGroupItem;
@ -52,20 +67,6 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.alibaba.sentinel.SentinelProperties;
import org.springframework.cloud.alibaba.sentinel.datasource.converter.JsonConverter;
import org.springframework.cloud.alibaba.sentinel.datasource.converter.XmlConverter;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
/**
* @author xiaojing
@ -260,12 +261,12 @@ public class SentinelAutoConfiguration {
return new JsonConverter(objectMapper, ParamFlowRule.class);
}
@Bean("sentinel-json-gateway-flow-converter")
@Bean("sentinel-json-gw-flow-converter")
public JsonConverter jsonGatewayFlowConverter() {
return new JsonConverter(objectMapper, GatewayFlowRule.class);
}
@Bean("sentinel-json-api-converter")
@Bean("sentinel-json-gw-api-group-converter")
public JsonConverter jsonApiConverter() {
return new JsonConverter(objectMapper, ApiDefinition.class);
}
@ -317,12 +318,12 @@ public class SentinelAutoConfiguration {
return new XmlConverter(xmlMapper, ParamFlowRule.class);
}
@Bean("sentinel-xml-gateway-flow-converter")
@Bean("sentinel-xml-gw-flow-converter")
public XmlConverter xmlGatewayFlowConverter() {
return new XmlConverter(xmlMapper, GatewayFlowRule.class);
}
@Bean("sentinel-xml-api-converter")
@Bean("sentinel-xml-gw-api-group-converter")
public XmlConverter xmlApiConverter() {
return new XmlConverter(xmlMapper, ApiDefinition.class);
}