Commit b9698a8f by Nepxion

增加细粒度版本控制

parent aabd5047
......@@ -12,7 +12,7 @@ package com.nepxion.discovery.plugin.configuration.constant;
public class ConfigurationConstant {
public static final String SPRING_APPLICATION_DISCOVERY_REMOTE_CONFIG_ENABLED = "spring.application.discovery.remote.config.enabled";
public static final String PLUGIN_ELEMENT_NAME = "plugin";
public static final String RULE_ELEMENT_NAME = "rule";
public static final String REGISTER_ELEMENT_NAME = "register";
public static final String SERVICE_ELEMENT_NAME = "service";
public static final String FILTER_TYPE_ATTRIBUTE_NAME = "filter-type";
......
......@@ -14,9 +14,10 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.nepxion.discovery.plugin.core.cache.PluginCache;
import com.nepxion.discovery.plugin.core.entity.PluginEntity;
import com.nepxion.discovery.plugin.core.strategy.RegisterStrategy;
import com.nepxion.discovery.plugin.core.strategy.DiscoveryStrategy;
import com.nepxion.discovery.plugin.core.strategy.RegisterStrategy;
@Configuration
public class PluginConfig {
......@@ -26,6 +27,11 @@ public class PluginConfig {
}
@Bean
public PluginCache pluginCache() {
return new PluginCache();
}
@Bean
public ReentrantReadWriteLock reentrantReadWriteLock() {
return new ReentrantReadWriteLock();
}
......
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<rule>
<!-- 服务注册的黑/白名单过滤。白名单表示只允许指定IP地址前缀注册,黑名单表示不允许指定IP地址前缀注册。每个服务只能同时开启要么白名单,要么黑名单 -->
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- service-name,表示服务名 -->
......@@ -14,9 +14,7 @@
<!-- service-name,表示服务名 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<discovery>
<!-- 表示消费端服务a,允许访问提供端服务b的1.0版本-->
<consumer service-name="discovery-springcloud-example-a">
<provider service-name="discovery-springcloud-example-b" version-value="1.0"/>
</consumer>
<!-- 表示消费端服务a的1.0,允许访问提供端服务b的1.0版本 -->
<service consumer-service-name="discovery-springcloud-example-a" provider-service-name="discovery-springcloud-example-b" consumer-version-value="1.0" provider-version-value="1.0"/>
</discovery>
</plugin>
\ No newline at end of file
</rule>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<rule>
<!-- 服务注册的黑/白名单过滤。白名单表示只允许指定IP地址前缀注册,黑名单表示不允许指定IP地址前缀注册。每个服务只能同时开启要么白名单,要么黑名单 -->
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- service-name,表示服务名 -->
......@@ -14,9 +14,7 @@
<!-- service-name,表示服务名 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<discovery>
<!-- 表示消费端服务a,允许访问提供端服务b的1.1版本-->
<consumer service-name="discovery-springcloud-example-a">
<provider service-name="discovery-springcloud-example-b" version-value="1.1"/>
</consumer>
<!-- 表示消费端服务a的1.1,允许访问提供端服务b的1.1版本 -->
<service consumer-service-name="discovery-springcloud-example-a" provider-service-name="discovery-springcloud-example-b" consumer-version-value="1.1" provider-version-value="1.1"/>
</discovery>
</plugin>
\ No newline at end of file
</rule>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<rule>
<!-- 服务注册的黑/白名单过滤。白名单表示只允许指定IP地址前缀注册,黑名单表示不允许指定IP地址前缀注册。每个服务只能同时开启要么白名单,要么黑名单 -->
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- service-name,表示服务名 -->
......@@ -14,9 +14,7 @@
<!-- service-name,表示服务名 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<discovery>
<!-- 表示消费端服务a,不允许访问提供端服务b的任何版本-->
<consumer service-name="discovery-springcloud-example-a">
<provider service-name="discovery-springcloud-example-b" version-value=""/>
</consumer>
<!-- 表示消费端服务a的1.0和1.1版本,允许访问提供端服务b的1.0和1.1版本 -->
<service consumer-service-name="discovery-springcloud-example-a" provider-service-name="discovery-springcloud-example-b" consumer-version-value="1.0;1.1" provider-version-value="1.0;1.1"/>
</discovery>
</plugin>
\ No newline at end of file
</rule>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<rule>
<!-- 服务注册的黑/白名单过滤。白名单表示只允许指定IP地址前缀注册,黑名单表示不允许指定IP地址前缀注册。每个服务只能同时开启要么白名单,要么黑名单 -->
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- service-name,表示服务名 -->
<!-- filter-value,表示黑/白名单的IP地址列表。IP地址一般用前缀来表示,如果多个用“;”分隔 -->
<!-- 表示下面所有服务,不允许10.10和11.11为前缀的IP地址注册(全局过滤) -->
<register filter-type="BLACKLIST" filter-value="10.10;11.11">
<!-- 表示下面服务,不允许172.16和10.10和11.11为前缀的IP地址注册 -->
<service service-name="discovery-springcloud-example-a" filter-value="172.16"/>
</register>
<!-- 服务发现下,服务多版本调用的控制 -->
<!-- service-name,表示服务名 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<discovery>
<!-- 表示消费端服务a的1.0版本,允许访问提供端服务b的1.1版本-->
<service consumer-service-name="discovery-springcloud-example-a" provider-service-name="discovery-springcloud-example-b" consumer-version-value="1.0" provider-version-value="1.1"/>
<!-- 表示消费端服务a的1.1版本,允许访问提供端服务b的1.0版本-->
<service consumer-service-name="discovery-springcloud-example-a" provider-service-name="discovery-springcloud-example-b" consumer-version-value="1.1" provider-version-value="1.0"/>
</discovery>
</rule>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<rule>
<!-- 服务注册的黑/白名单过滤。白名单表示只允许指定IP地址前缀注册,黑名单表示不允许指定IP地址前缀注册。每个服务只能同时开启要么白名单,要么黑名单 -->
<!-- filter-type,可选值BLACKLIST/WHITELIST,表示白名单或者黑名单 -->
<!-- service-name,表示服务名 -->
......@@ -14,9 +14,11 @@
<!-- service-name,表示服务名 -->
<!-- version-value,表示可供访问的版本,如果多个用“;”分隔 -->
<discovery>
<!-- 表示消费端服务a,允许访问提供端服务b的1.0和1.1版本-->
<consumer service-name="discovery-springcloud-example-a">
<provider service-name="discovery-springcloud-example-b" version-value="1.0;1.1"/>
</consumer>
<!-- 下面三种情况视作不会灰度版本做控制: -->
<!-- 1. 版本值不配置(即xxx-version-value属性缺失) -->
<!-- 2. 版本值空字符串(即xxx-version-value="") -->
<!-- 3. 版本对应关系不配置(即<service .../>不存在) -->
<!-- 表示消费端服务a的任何版本,允许访问提供端服务b的任何版本 -->
<service consumer-service-name="discovery-springcloud-example-a" provider-service-name="discovery-springcloud-example-b" consumer-version-value="" provider-version-value=""/>
</discovery>
</plugin>
\ No newline at end of file
</rule>
\ No newline at end of file
......@@ -12,6 +12,7 @@
<modules>
<module>discovery-plugin-core</module>
<module>discovery-plugin-actuator</module>
<module>discovery-plugin-configuration</module>
<module>discovery-plugin-starter</module>
<module>discovery-springcloud-example-a</module>
......@@ -26,6 +27,7 @@
<commons.io.version>2.5</commons.io.version>
<dom4j.version>1.6.1</dom4j.version>
<spring.cloud.version>Dalston.SR4</spring.cloud.version>
<spring.boot.version>1.5.8.RELEASE</spring.boot.version>
<disruptor.version>3.3.7</disruptor.version>
<log4j.version>2.9.1</log4j.version>
<java.version>1.8</java.version>
......@@ -42,6 +44,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>discovery-plugin-actuator</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>discovery-plugin-configuration</artifactId>
<version>${project.version}</version>
</dependency>
......@@ -89,6 +97,14 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment