Skip to content

fix:fix zuul delay circuit breaker. #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 2020.0
- hoxton
- greenwich
- release/*
pull_request:
branches:
- 2023.0
Expand All @@ -17,6 +18,7 @@ on:
- 2020.0
- hoxton
- greenwich
- release/*

jobs:
codecov:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/junit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ on:
- 2021.0
- 2020.0
- greenwich
- release/*
pull_request:
branches:
- hoxton
- 2021.0
- 2020.0
- greenwich
- release/*

jobs:
junit:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/license-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 2020.0
- hoxton
- greenwich
- release/*
pull_request:
branches:
- 2023.0
Expand All @@ -17,6 +18,7 @@ on:
- 2020.0
- hoxton
- greenwich
- release/*
jobs:
check-license:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 2020.0
- hoxton
- greenwich
- release/*

jobs:
check-snapshot:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

<properties>
<!-- Project revision -->
<revision>2.0.0.0-Hoxton.SR12</revision>
<revision>2.0.0.1-Hoxton.SR12</revision>

<!-- Spring Framework -->
<spring.framework.version>5.2.25.RELEASE</spring.framework.version>
Expand Down
2 changes: 1 addition & 1 deletion spring-cloud-tencent-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</developers>

<properties>
<revision>2.0.0.0-Hoxton.SR12</revision>
<revision>2.0.0.1-Hoxton.SR12</revision>

<!-- Dependencies -->
<polaris.version>2.0.0.0</polaris.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
package com.tencent.cloud.quickstart.caller.circuitbreaker;

import com.tencent.cloud.common.metadata.MetadataContext;
import reactor.core.publisher.Mono;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory;
import org.springframework.cloud.client.circuitbreaker.ReactiveCircuitBreakerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand Down Expand Up @@ -64,9 +62,6 @@ public class CircuitBreakerController {
@Autowired
private CircuitBreakerFactory circuitBreakerFactory;

@Autowired
private ReactiveCircuitBreakerFactory reactiveCircuitBreakerFactory;

@Autowired
private WebClient.Builder webClientBuilder;

Expand Down Expand Up @@ -166,23 +161,4 @@ public ResponseEntity<String> circuitBreakRestTemplateFallbackFromCode() {
return new ResponseEntity<>(httpClientErrorException.getResponseBodyAsString(), httpClientErrorException.getStatusCode());
}
}

/**
* Get information of callee.
* @return information of callee
*/
@GetMapping("/webclient")
public Mono<String> webclient() {
return webClientBuilder
.build()
.get()
.uri("/quickstart/callee/circuitBreak")
.retrieve()
.bodyToMono(String.class)
.transform(it ->
reactiveCircuitBreakerFactory
.create(MetadataContext.LOCAL_NAMESPACE + "QuickstartCalleeService#/quickstart/callee/circuitBreak#http#GET")
.run(it, throwable -> Mono.just("fallback: trigger the refuse for service callee"))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ zuul:
QuickstartCallerService:
serviceId: QuickstartCallerService
path: /QuickstartCallerService/**
QuickstartCalleeService:
serviceId: QuickstartCalleeService
path: /QuickstartCalleeService/**
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;

import static com.tencent.cloud.common.constant.ContextConstant.Zuul.POLARIS_PRE_ROUTE_TIME;

/**
* Polaris circuit breaker implement in Zuul.
*
Expand Down Expand Up @@ -75,6 +77,7 @@ public void run() {
enhancedPluginContext.setRequest(enhancedRequestContext);
enhancedPluginContext.setOriginRequest(context);
enhancedPluginContext.setLocalServiceInstance(pluginRunner.getLocalServiceInstance());
context.set(POLARIS_PRE_ROUTE_TIME, System.currentTimeMillis());

// Run pre enhanced plugins.
pluginRunner.run(EnhancedPluginType.Client.PRE, enhancedPluginContext);
Expand Down