From 29091948e975b071e8b452fa5b188d5751a8531b Mon Sep 17 00:00:00 2001 From: theonefx Date: Sat, 20 Feb 2021 17:49:28 +0800 Subject: [PATCH] remove zuul example --- spring-cloud-alibaba-examples/pom.xml | 1 - .../sentinel-zuul-example/pom.xml | 78 ------------------- .../cloud/examples/RulesController.java | 53 ------------- .../examples/SentinelZuulApplication.java | 34 -------- .../cloud/examples/ZuulConfiguration.java | 68 ---------------- .../src/main/resources/api.json | 32 -------- .../src/main/resources/application.yaml | 40 ---------- .../src/main/resources/gateway.json | 26 ------- 8 files changed, 332 deletions(-) delete mode 100644 spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/pom.xml delete mode 100644 spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/RulesController.java delete mode 100644 spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/SentinelZuulApplication.java delete mode 100644 spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/ZuulConfiguration.java delete mode 100644 spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/api.json delete mode 100644 spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/application.yaml delete mode 100644 spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/gateway.json diff --git a/spring-cloud-alibaba-examples/pom.xml b/spring-cloud-alibaba-examples/pom.xml index 157fc502c..f590ce1e2 100644 --- a/spring-cloud-alibaba-examples/pom.xml +++ b/spring-cloud-alibaba-examples/pom.xml @@ -25,7 +25,6 @@ sentinel-example/sentinel-feign-example/sentinel-feign-provider-example sentinel-example/sentinel-webflux-example sentinel-example/sentinel-spring-cloud-gateway-example - sentinel-example/sentinel-zuul-example nacos-example/nacos-discovery-example nacos-example/nacos-config-example nacos-example/nacos-gateway-example diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/pom.xml b/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/pom.xml deleted file mode 100644 index 82e39e36d..000000000 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - com.alibaba.cloud - spring-cloud-alibaba-examples - ${revision} - ../../pom.xml - - 4.0.0 - - - sentinel-zuul-example - Spring Cloud Starter Alibaba Sentinel x Zuul Example - Example demonstrating how to use sentinel with zuul - jar - - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-sentinel - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-actuator - - - - com.alibaba.cloud - spring-cloud-alibaba-sentinel-gateway - - - - - - - - - - - - - - - - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-deploy-plugin - ${maven-deploy-plugin.version} - - true - - - - - - diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/RulesController.java b/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/RulesController.java deleted file mode 100644 index 5475bcddc..000000000 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/RulesController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2013-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.alibaba.cloud.examples; - -import java.util.List; -import java.util.Set; - -import com.alibaba.csp.sentinel.adapter.gateway.common.api.ApiDefinition; -import com.alibaba.csp.sentinel.adapter.gateway.common.api.GatewayApiDefinitionManager; -import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayFlowRule; -import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager; -import com.alibaba.csp.sentinel.slots.block.flow.FlowRule; -import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Jim - */ -@RestController -public class RulesController { - - @GetMapping("/api") - public Set apiRules() { - return GatewayApiDefinitionManager.getApiDefinitions(); - } - - @GetMapping("/gateway") - public Set apiGateway() { - return GatewayRuleManager.getRules(); - } - - @GetMapping("/flow") - public List apiFlow() { - return FlowRuleManager.getRules(); - } - -} diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/SentinelZuulApplication.java b/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/SentinelZuulApplication.java deleted file mode 100644 index 476cbb05d..000000000 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/SentinelZuulApplication.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2013-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.alibaba.cloud.examples; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.netflix.zuul.EnableZuulProxy; - -/** - * @author Jim - */ -@SpringBootApplication -@EnableZuulProxy -public class SentinelZuulApplication { - - public static void main(String[] args) { - SpringApplication.run(SentinelZuulApplication.class, args); - } - -} diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/ZuulConfiguration.java b/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/ZuulConfiguration.java deleted file mode 100644 index 9dccb6b2e..000000000 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/java/com/alibaba/cloud/examples/ZuulConfiguration.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2013-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.alibaba.cloud.examples; - -import javax.servlet.http.HttpServletRequest; - -import com.alibaba.csp.sentinel.adapter.gateway.zuul.callback.RequestOriginParser; -import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.BlockResponse; -import com.alibaba.csp.sentinel.adapter.gateway.zuul.fallback.ZuulBlockFallbackProvider; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * @author Jim - */ -@Configuration -public class ZuulConfiguration { - - @Bean - public ZuulBlockFallbackProvider zuulBlockFallbackProvider1() { - return new ZuulBlockFallbackProvider() { - @Override - public String getRoute() { - return "*"; - } - - @Override - public BlockResponse fallbackResponse(String route, Throwable cause) { - if ("my-service3".equals(route)) { - return new BlockResponse(433, "Sentinel Block3", route); - } - else if ("my-service4".equals(route)) { - return new BlockResponse(444, "my-service4", route); - } - else { - return new BlockResponse(499, "Sentinel Block 499", route); - } - } - }; - } - - @Bean - public RequestOriginParser requestOriginParser() { - return new RequestOriginParser() { - - @Override - public String parseOrigin(HttpServletRequest request) { - return "123"; - } - }; - } - -} diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/api.json b/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/api.json deleted file mode 100644 index 6de3c4fbc..000000000 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/api.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "apiName": "some_customized_api", - "predicateItems": [ - { - "pattern": "/product/baz" - }, - { - "pattern": "/product/foo/**", - "matchStrategy": 1 - }, - { - "items": [ - { - "pattern": "/spring-cloud/**" - }, - { - "pattern": "/spring-cloud-alibaba/**" - } - ] - } - ] - }, - { - "apiName": "another_customized_api", - "predicateItems": [ - { - "pattern": "/ahas" - } - ] - } -] diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/application.yaml b/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/application.yaml deleted file mode 100644 index 0e9d9abf7..000000000 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/application.yaml +++ /dev/null @@ -1,40 +0,0 @@ -server: - port: 18086 -spring: - application: - name: sentinel-zuul - cloud: - sentinel: - datasource.ds2.file: - file: "classpath: gateway.json" - ruleType: gw-flow - datasource.ds1.file: - file: "classpath: api.json" - ruleType: gw-api-group - transport: - dashboard: localhost:8080 - filter: - enabled: false - -management.endpoints.web.exposure.include: "*" - - -zuul.routes.my-service.path: "/product/foo/**" -zuul.routes.my-service.service-id: "my-service" - -zuul.routes.my-service2.path: "/my-service2/**" -zuul.routes.my-service2.service-id: "my-service2" - -zuul.routes.my-service3.path: "/my-service3/**" -zuul.routes.my-service3.service-id: "my-service3" - -zuul.routes.my-service4.path: "/my-service4/**" -zuul.routes.my-service4.service-id: "my-service4" - - -spring.cloud.sentinel.zuul.order.pre: 2000 -spring.cloud.sentinel.zuul.order.post: 500 -spring.cloud.sentinel.zuul.order.error: -100 - - -spring.cloud.sentinel.zuul.enabled: true \ No newline at end of file diff --git a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/gateway.json b/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/gateway.json deleted file mode 100644 index b3effe88a..000000000 --- a/spring-cloud-alibaba-examples/sentinel-example/sentinel-zuul-example/src/main/resources/gateway.json +++ /dev/null @@ -1,26 +0,0 @@ -[ - { - "resource": "some_customized_api", - "count": 0 - }, - { - "resource": "my-service2", - "count": 0 - }, - { - "resource": "my-service3", - "count": 0, - "paramItem": { - "parseStrategy": 2, - "fieldName": "Spring-Cloud-Alibaba" - } - }, - { - "resource": "my-service4", - "count": 0, - "paramItem": { - "parseStrategy": 3, - "fieldName": "name" - } - } -]