fix some bugs and optimize example

pull/217/head
lepdou 3 years ago committed by Haotian Zhang
parent 71a047290c
commit 9158649ff8

@ -99,8 +99,9 @@ public class QuotaCheckReactiveFilter implements WebFilter, Ordered {
Map<String, String> labels = getRequestLabels(exchange, localNamespace, localService); Map<String, String> labels = getRequestLabels(exchange, localNamespace, localService);
try { try {
String path = exchange.getRequest().getURI().getPath();
QuotaResponse quotaResponse = QuotaCheckUtils.getQuota(limitAPI, QuotaResponse quotaResponse = QuotaCheckUtils.getQuota(limitAPI,
localNamespace, localService, 1, labels, null); localNamespace, localService, 1, labels, path);
if (quotaResponse.getCode() == QuotaResultCode.QuotaResultLimited) { if (quotaResponse.getCode() == QuotaResultCode.QuotaResultLimited) {
ServerHttpResponse response = exchange.getResponse(); ServerHttpResponse response = exchange.getResponse();

@ -95,7 +95,7 @@ public class QuotaCheckServletFilter extends OncePerRequestFilter {
try { try {
QuotaResponse quotaResponse = QuotaCheckUtils.getQuota(limitAPI, QuotaResponse quotaResponse = QuotaCheckUtils.getQuota(limitAPI,
localNamespace, localService, 1, labels, null); localNamespace, localService, 1, labels, request.getRequestURI());
if (quotaResponse.getCode() == QuotaResultCode.QuotaResultLimited) { if (quotaResponse.getCode() == QuotaResultCode.QuotaResultLimited) {
response.setStatus(polarisRateLimitProperties.getRejectHttpCode()); response.setStatus(polarisRateLimitProperties.getRejectHttpCode());

@ -54,6 +54,7 @@ import com.tencent.polaris.router.api.rpc.ProcessRoutersRequest;
import com.tencent.polaris.router.api.rpc.ProcessRoutersResponse; import com.tencent.polaris.router.api.rpc.ProcessRoutersResponse;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/** /**
* *
@ -195,7 +196,9 @@ public class PolarisLoadBalancerCompositeRule extends AbstractLoadBalancerRule {
public AbstractLoadBalancerRule getRule() { public AbstractLoadBalancerRule getRule() {
String loadBalanceStrategy = loadBalancerProperties.getStrategy(); String loadBalanceStrategy = loadBalancerProperties.getStrategy();
if (StringUtils.isEmpty(loadBalanceStrategy)) {
return new ZoneAvoidanceRule();
}
switch (loadBalanceStrategy) { switch (loadBalanceStrategy) {
case STRATEGY_RANDOM: case STRATEGY_RANDOM:
return new RandomRule(); return new RandomRule();

@ -23,16 +23,6 @@
<artifactId>spring-cloud-starter-tencent-polaris-router</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-router</artifactId>
</dependency> </dependency>
<dependency>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
<groupId>com.tencent.cloud</groupId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>

@ -9,8 +9,6 @@ spring:
address: grpc://183.47.111.80:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true
discovery:
service-list-refresh-interval: 1000
logging: logging:
level: level:
org.springframework.cloud.gateway: info org.springframework.cloud.gateway: info

@ -23,16 +23,6 @@
<artifactId>spring-cloud-starter-tencent-polaris-router</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-router</artifactId>
</dependency> </dependency>
<dependency>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
<groupId>com.tencent.cloud</groupId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>

@ -9,8 +9,6 @@ spring:
address: grpc://183.47.111.80:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true
discovery:
service-list-refresh-interval: 1000
logging: logging:
level: level:
org.springframework.cloud.gateway: info org.springframework.cloud.gateway: info

@ -28,20 +28,11 @@
<artifactId>spring-cloud-starter-tencent-polaris-router</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-router</artifactId>
</dependency> </dependency>
<dependency>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
<groupId>com.tencent.cloud</groupId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.cloud</groupId> <groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId> <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -9,8 +9,6 @@ spring:
address: grpc://183.47.111.80:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true
discovery:
service-list-refresh-interval: 1000
logging: logging:
level: level:
org.springframework.cloud.gateway: info org.springframework.cloud.gateway: info

@ -23,16 +23,6 @@
<artifactId>spring-cloud-starter-tencent-polaris-router</artifactId> <artifactId>spring-cloud-starter-tencent-polaris-router</artifactId>
</dependency> </dependency>
<dependency>
<artifactId>spring-cloud-starter-tencent-polaris-circuitbreaker</artifactId>
<groupId>com.tencent.cloud</groupId>
</dependency>
<dependency>
<groupId>com.tencent.cloud</groupId>
<artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>

@ -9,8 +9,6 @@ spring:
address: grpc://183.47.111.80:8091 address: grpc://183.47.111.80:8091
namespace: default namespace: default
enabled: true enabled: true
discovery:
service-list-refresh-interval: 1000
logging: logging:
level: level:
org.springframework.cloud.gateway: info org.springframework.cloud.gateway: info

Loading…
Cancel
Save