diff --git a/fizz-bootstrap/pom.xml b/fizz-bootstrap/pom.xml
index e7746d6..113dac1 100644
--- a/fizz-bootstrap/pom.xml
+++ b/fizz-bootstrap/pom.xml
@@ -12,7 +12,7 @@
com.fizzgate
fizz-bootstrap
- 2.2.0-beta2
+ 2.2.0-beta3
1.8
diff --git a/fizz-common/pom.xml b/fizz-common/pom.xml
index 8cd96fc..c55038a 100644
--- a/fizz-common/pom.xml
+++ b/fizz-common/pom.xml
@@ -5,7 +5,7 @@
fizz-gateway-community
com.fizzgate
- 2.2.0-beta2
+ 2.2.0-beta3
../pom.xml
4.0.0
diff --git a/fizz-core/pom.xml b/fizz-core/pom.xml
index a2bc0a0..936b83d 100644
--- a/fizz-core/pom.xml
+++ b/fizz-core/pom.xml
@@ -5,7 +5,7 @@
fizz-gateway-community
com.fizzgate
- 2.2.0-beta2
+ 2.2.0-beta3
../pom.xml
4.0.0
diff --git a/fizz-core/src/main/java/we/config/FlowStatSchedConfig.java b/fizz-core/src/main/java/we/config/FlowStatSchedConfig.java
index 2ab16df..ec820bc 100644
--- a/fizz-core/src/main/java/we/config/FlowStatSchedConfig.java
+++ b/fizz-core/src/main/java/we/config/FlowStatSchedConfig.java
@@ -137,14 +137,31 @@ public class FlowStatSchedConfig extends SchedConfig {
String app = null, pi = null, node = ResourceRateLimitConfig.NODE, service = null, path = null;
int type = ResourceRateLimitConfig.Type.NODE, id = 0;
ResourceRateLimitConfig c = resourceRateLimitConfigService.getResourceRateLimitConfig(resource);
- if (c == null) {
- service = ResourceRateLimitConfig.getService(resource);
- if (service != null) {
- type = ResourceRateLimitConfig.Type.SERVICE_DEFAULT;
+
+ if (c == null) { // _global, service, app, ip, ip+service
+ node = ResourceRateLimitConfig.getNode(resource);
+ if (node != null && node.equals(ResourceRateLimitConfig.NODE)) {
} else {
+ service = ResourceRateLimitConfig.getService(resource);
app = ResourceRateLimitConfig.getApp(resource);
- if (app != null) {
- type = ResourceRateLimitConfig.Type.APP_DEFAULT;
+ pi = ResourceRateLimitConfig.getIp(resource);
+ if (service == null) {
+ if (app == null) {
+ type = ResourceRateLimitConfig.Type.IP;
+ } else {
+ ResourceRateLimitConfig appConfig = resourceRateLimitConfigService.getResourceRateLimitConfig(ResourceRateLimitConfig.APP_DEFAULT_RESOURCE);
+ if (appConfig != null && appConfig.isEnable()) {
+ type = ResourceRateLimitConfig.Type.APP_DEFAULT;
+ } else {
+ type = ResourceRateLimitConfig.Type.APP;
+ }
+ }
+ } else {
+ if (pi == null) {
+ type = ResourceRateLimitConfig.Type.SERVICE_DEFAULT;
+ } else {
+ type = ResourceRateLimitConfig.Type.IP;
+ }
}
}
} else {
diff --git a/fizz-core/src/main/java/we/filter/FlowControlFilter.java b/fizz-core/src/main/java/we/filter/FlowControlFilter.java
index c2091c0..6cecf7a 100644
--- a/fizz-core/src/main/java/we/filter/FlowControlFilter.java
+++ b/fizz-core/src/main/java/we/filter/FlowControlFilter.java
@@ -203,6 +203,7 @@ public class FlowControlFilter extends FizzWebFilter {
ResourceConfig rc = null;
ResourceRateLimitConfig rateLimitConfig = resourceRateLimitConfigService.getResourceRateLimitConfig(resource);
if (rateLimitConfig != null && rateLimitConfig.isEnable()) {
+ something4appAndIp(resourceConfigs, rateLimitConfig);
rc = new ResourceConfig(resource, rateLimitConfig.concurrents, rateLimitConfig.qps);
resourceConfigs.add(rc);
} else {
@@ -231,4 +232,53 @@ public class FlowControlFilter extends FizzWebFilter {
}
}
}
+
+ private void something4appAndIp(List resourceConfigs, ResourceRateLimitConfig rateLimitConfig) {
+ int sz = resourceConfigs.size();
+ String prev = null, prevPrev = null;
+ if (sz > 1) {
+ prev = resourceConfigs.get(sz - 1).getResourceId();
+ prevPrev = resourceConfigs.get(sz - 2).getResourceId();
+
+ if (rateLimitConfig.type == ResourceRateLimitConfig.Type.APP) {
+ String app = ResourceRateLimitConfig.getApp(prev);
+ if (app == null) {
+ something4(resourceConfigs, rateLimitConfig.app, null, null);
+ } else {
+ String service = ResourceRateLimitConfig.getService(prev);
+ if (service == null) {
+ } else {
+ app = ResourceRateLimitConfig.getApp(prevPrev);
+ if (app == null) {
+ something4(resourceConfigs, rateLimitConfig.app, null, null);
+ }
+ }
+ }
+
+ } else if (rateLimitConfig.type == ResourceRateLimitConfig.Type.IP) {
+
+ String ip = ResourceRateLimitConfig.getIp(prev);
+ if (ip == null) {
+ something4(resourceConfigs, null, rateLimitConfig.ip, null);
+ something4(resourceConfigs, null, rateLimitConfig.ip, rateLimitConfig.service);
+ } else {
+ String service = ResourceRateLimitConfig.getService(prev);
+ if (service == null) {
+ something4(resourceConfigs, null, rateLimitConfig.ip, rateLimitConfig.service);
+ } else {
+ ip = ResourceRateLimitConfig.getIp(prevPrev);
+ if (ip == null) {
+ something4(resourceConfigs, null, rateLimitConfig.ip, null);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void something4(List resourceConfigs, String app, String ip, String service) {
+ String r = ResourceRateLimitConfig.buildResourceId(app, ip, null, service, null);
+ ResourceConfig rc = new ResourceConfig(r, 0, 0);
+ resourceConfigs.add(rc);
+ }
}
diff --git a/fizz-plugin/pom.xml b/fizz-plugin/pom.xml
index 865da1d..4749c02 100644
--- a/fizz-plugin/pom.xml
+++ b/fizz-plugin/pom.xml
@@ -5,7 +5,7 @@
fizz-gateway-community
com.fizzgate
- 2.2.0-beta2
+ 2.2.0-beta3
../pom.xml
4.0.0
diff --git a/fizz-spring-boot-starter/pom.xml b/fizz-spring-boot-starter/pom.xml
index f2091be..de1eea1 100644
--- a/fizz-spring-boot-starter/pom.xml
+++ b/fizz-spring-boot-starter/pom.xml
@@ -5,7 +5,7 @@
fizz-gateway-community
com.fizzgate
- 2.2.0-beta2
+ 2.2.0-beta3
../pom.xml
4.0.0
diff --git a/pom.xml b/pom.xml
index 95ceae9..5270cb8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,7 +31,7 @@
fizz-gateway-community
${project.artifactId}
fizz gateway community
- 2.2.0-beta2
+ 2.2.0-beta3
pom
fizz-common