1
.github/workflows/maven.yml
vendored
1
.github/workflows/maven.yml
vendored
@@ -85,6 +85,7 @@ jobs:
|
||||
push: true
|
||||
tags: fizzgate/fizz-gateway-community:${{ steps.releaseVersion.outputs.substring }}
|
||||
- name: Publish to Apache Maven Central
|
||||
run: mvn -X -e deploy
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: samuelmeuli/action-maven-publish@v1
|
||||
with:
|
||||
|
||||
@@ -93,7 +93,7 @@ flow-stat-sched:
|
||||
queue: fizz_resource_access_stat
|
||||
|
||||
gateway:
|
||||
prefix: /proxy
|
||||
prefix: /
|
||||
aggr:
|
||||
# set headers when calling the backend API
|
||||
proxy_set_headers: X-Real-IP,X-Forwarded-Proto,X-Forwarded-For
|
||||
|
||||
@@ -52,7 +52,6 @@ import com.fizzgate.util.Consts;
|
||||
import com.fizzgate.util.NettyDataBufferUtils;
|
||||
import com.fizzgate.util.ThreadContext;
|
||||
import com.fizzgate.util.WebUtils;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
/**
|
||||
|
||||
@@ -360,7 +360,7 @@ public class FlowControlFilter extends FizzWebFilter {
|
||||
if (hasHost) {
|
||||
// String resourceId = ResourceIdUtils.buildResourceId(app, ip, node, service, path);
|
||||
String resourceId = ResourceIdUtils.buildResourceId(null, null, node, null, null);
|
||||
ResourceConfig resourceConfig = new ResourceConfig(resourceId, 0, 0);
|
||||
ResourceConfig resourceConfig = new ResourceConfig(resourceId, -1L, -1L);
|
||||
resourceConfigs.add(resourceConfig);
|
||||
}
|
||||
checkRateLimitConfigAndAddTo(resourceConfigs, b, null, null, ResourceIdUtils.NODE, null, null, null);
|
||||
@@ -407,11 +407,11 @@ public class FlowControlFilter extends FizzWebFilter {
|
||||
} else {
|
||||
String node = ResourceIdUtils.getNode(resource);
|
||||
if (node != null && node.equals(ResourceIdUtils.NODE)) {
|
||||
rc = new ResourceConfig(resource, 0, 0);
|
||||
rc = new ResourceConfig(resource, -1L, -1L);
|
||||
}
|
||||
if (defaultRateLimitConfigId != null) {
|
||||
if (defaultRateLimitConfigId.equals(ResourceIdUtils.SERVICE_DEFAULT)) {
|
||||
rc = new ResourceConfig(resource, 0, 0);
|
||||
rc = new ResourceConfig(resource, -1L, -1L);
|
||||
rateLimitConfig = resourceRateLimitConfigService.getResourceRateLimitConfig(ResourceIdUtils.SERVICE_DEFAULT_RESOURCE);
|
||||
if (rateLimitConfig != null && rateLimitConfig.isEnable()) {
|
||||
rc.setMaxCon(rateLimitConfig.concurrents);
|
||||
@@ -441,7 +441,7 @@ public class FlowControlFilter extends FizzWebFilter {
|
||||
}
|
||||
}*/
|
||||
if (cb != null) {
|
||||
rc = new ResourceConfig(resource, 0, 0);
|
||||
rc = new ResourceConfig(resource, -1L, -1L);
|
||||
resourceConfigs.add(rc);
|
||||
}
|
||||
}
|
||||
@@ -508,7 +508,7 @@ public class FlowControlFilter extends FizzWebFilter {
|
||||
|
||||
private void something4(List<ResourceConfig> resourceConfigs, String app, String ip, String service) {
|
||||
String r = ResourceIdUtils.buildResourceId(app, ip, null, service, null);
|
||||
ResourceConfig rc = new ResourceConfig(r, 0, 0);
|
||||
ResourceConfig rc = new ResourceConfig(r, -1L, -1L);
|
||||
resourceConfigs.add(rc);
|
||||
}
|
||||
|
||||
|
||||
@@ -161,10 +161,10 @@ public class FlowStat {
|
||||
for (ResourceConfig resourceConfig : resourceConfigs) {
|
||||
long maxCon = resourceConfig.getMaxCon();
|
||||
long maxQPS = resourceConfig.getMaxQPS();
|
||||
if (maxCon > 0 || maxQPS > 0) {
|
||||
if (maxCon >= 0 || maxQPS >= 0) {
|
||||
ResourceStat resourceStat = getResourceStat(resourceConfig.getResourceId());
|
||||
// check concurrent request
|
||||
if (maxCon > 0) {
|
||||
if (maxCon >= 0) {
|
||||
long n = resourceStat.getConcurrentRequests().get();
|
||||
if (n >= maxCon) {
|
||||
resourceStat.incrBlockRequestToTimeSlot(curTimeSlotId);
|
||||
@@ -184,7 +184,7 @@ public class FlowStat {
|
||||
}
|
||||
|
||||
// check QPS
|
||||
if (maxQPS > 0) {
|
||||
if (maxQPS >= 0) {
|
||||
long total = resourceStat.getTimeSlot(curTimeSlotId).getCounter();
|
||||
if (total >= maxQPS) {
|
||||
resourceStat.incrBlockRequestToTimeSlot(curTimeSlotId);
|
||||
|
||||
@@ -46,14 +46,14 @@ public class ResourceConfig {
|
||||
// Flow control rule
|
||||
//---------------------------------------------------------------------
|
||||
/**
|
||||
* Maximum concurrent request, zero or negative for no limit
|
||||
* Maximum concurrent request, negative for no limit
|
||||
*/
|
||||
private long maxCon;
|
||||
private long maxCon = -1L;
|
||||
|
||||
/**
|
||||
* Maximum QPS, zero or negative for no limit
|
||||
* Maximum QPS, negative for no limit
|
||||
*/
|
||||
private long maxQPS;
|
||||
private long maxQPS = -1L;
|
||||
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@@ -63,9 +63,9 @@ public class ResourceRateLimitConfig {
|
||||
|
||||
public byte type;
|
||||
|
||||
public long qps;
|
||||
public long qps = -1L;
|
||||
|
||||
public long concurrents;
|
||||
public long concurrents = -1L;
|
||||
|
||||
public String responseType;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.fizzgate.util.ReflectionUtils;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -62,7 +63,7 @@ public class CallbackServiceTests {
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.add("h1", "v1");
|
||||
DataBuffer body = null;
|
||||
String body = null;
|
||||
|
||||
CallbackConfig callbackConfig = new CallbackConfig();
|
||||
callbackConfig.receivers = new ArrayList<>();
|
||||
|
||||
@@ -115,8 +115,8 @@ public class FlowStatTests {
|
||||
|
||||
// Note: use different resource ID to avoid being affected by previous test data
|
||||
FlowRuleCase c5 = new FlowRuleCase();
|
||||
c5.resourceConfigs.add(new ResourceConfig("_global5", 0, 0));
|
||||
c5.resourceConfigs.add(new ResourceConfig("service5", 0, 0));
|
||||
c5.resourceConfigs.add(new ResourceConfig("_global5", -1L, -1L));
|
||||
c5.resourceConfigs.add(new ResourceConfig("service5", -1L, -1L));
|
||||
c5.resourceExpects.add(new ResourceExpect(c5.totalReqs, c5.totalReqs, c5.totalReqs, 0));
|
||||
c5.resourceExpects.add(new ResourceExpect(c5.totalReqs, c5.totalReqs, c5.totalReqs, 0));
|
||||
c5.expectResult = IncrRequestResult.success();
|
||||
@@ -124,8 +124,8 @@ public class FlowStatTests {
|
||||
|
||||
// Note: use different resource ID to avoid being affected by previous test data
|
||||
FlowRuleCase c6 = new FlowRuleCase();
|
||||
c6.resourceConfigs.add(new ResourceConfig("_global6", 20, 0));
|
||||
c6.resourceConfigs.add(new ResourceConfig("service6", 20, 0));
|
||||
c6.resourceConfigs.add(new ResourceConfig("_global6", 20, -1L));
|
||||
c6.resourceConfigs.add(new ResourceConfig("service6", 20, -1L));
|
||||
c6.resourceExpects.add(new ResourceExpect(20, 20, 20, c6.totalReqs - 20));
|
||||
c6.resourceExpects.add(new ResourceExpect(20, 20, 20, 0));
|
||||
c6.expectResult = IncrRequestResult.block("_global6", BlockType.CONCURRENT_REQUEST);
|
||||
@@ -133,8 +133,8 @@ public class FlowStatTests {
|
||||
|
||||
// Note: use different resource ID to avoid being affected by previous test data
|
||||
FlowRuleCase c7 = new FlowRuleCase();
|
||||
c7.resourceConfigs.add(new ResourceConfig("_global7", 0, 0));
|
||||
c7.resourceConfigs.add(new ResourceConfig("service7", 0, 20));
|
||||
c7.resourceConfigs.add(new ResourceConfig("_global7", -1L, -1L));
|
||||
c7.resourceConfigs.add(new ResourceConfig("service7", -1L, 20));
|
||||
c7.resourceExpects.add(new ResourceExpect(20, 20, 20, 0));
|
||||
c7.resourceExpects.add(new ResourceExpect(20, 20, 20, c7.totalReqs - 20));
|
||||
c7.expectResult = IncrRequestResult.block("service7", BlockType.QPS);
|
||||
|
||||
Reference in New Issue
Block a user