feat:use polaris-all for shading third-party dependencies. (#1526)
parent
b383bdd28e
commit
c692707a8d
@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.extend.consul;
|
||||
|
||||
import com.tencent.cloud.common.util.inet.PolarisInetUtilsAutoConfiguration;
|
||||
import com.tencent.cloud.polaris.DiscoveryPropertiesAutoConfiguration;
|
||||
import com.tencent.cloud.polaris.context.config.PolarisContextAutoConfiguration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for {@link ConsulHeartbeatProperties}.
|
||||
*
|
||||
* @author Haotian Zhang
|
||||
*/
|
||||
public class ConsulHeartbeatPropertiesTest {
|
||||
|
||||
@Test
|
||||
public void testGettersAndSetters() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PolarisContextAutoConfiguration.class,
|
||||
PolarisInetUtilsAutoConfiguration.class, DiscoveryPropertiesAutoConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.consul.enabled=true")
|
||||
.withPropertyValues("spring.cloud.consul.discovery.heartbeat.ttlValue=60")
|
||||
.withPropertyValues("spring.cloud.consul.discovery.heartbeat.ttl-unit=m")
|
||||
.withPropertyValues("spring.cloud.consul.discovery.heartbeat.interval-ratio=0.5");
|
||||
applicationContextRunner.run(context -> {
|
||||
assertThat(context).hasSingleBean(ConsulHeartbeatProperties.class);
|
||||
ConsulHeartbeatProperties heartbeatProperties = context.getBean(ConsulHeartbeatProperties.class);
|
||||
assertThat(heartbeatProperties.isEnabled()).isTrue();
|
||||
assertThat(heartbeatProperties.getTtlValue()).isEqualTo(60);
|
||||
assertThat(heartbeatProperties.getTtlUnit()).isEqualTo("m");
|
||||
assertThat(heartbeatProperties.getIntervalRatio()).isEqualTo(0.5);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTtlValueWrong() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PolarisInetUtilsAutoConfiguration.class, DiscoveryPropertiesAutoConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.consul.enabled=true")
|
||||
.withPropertyValues("spring.cloud.consul.discovery.heartbeat.ttlValue=0");
|
||||
applicationContextRunner.run(context -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure())
|
||||
.hasRootCauseExactlyInstanceOf(IllegalArgumentException.class)
|
||||
.hasRootCauseMessage("ttlValue must be at least 1");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTtlUnitWrong() {
|
||||
ApplicationContextRunner applicationContextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PolarisInetUtilsAutoConfiguration.class, DiscoveryPropertiesAutoConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.consul.enabled=true")
|
||||
.withPropertyValues("spring.cloud.consul.discovery.heartbeat.ttl-unit=");
|
||||
applicationContextRunner.run(context -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure())
|
||||
.hasRootCauseExactlyInstanceOf(IllegalArgumentException.class)
|
||||
.hasRootCauseMessage("ttlUnit cannot be null or empty");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIntervalRatioWrong() {
|
||||
ApplicationContextRunner applicationContextRunner1 = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PolarisInetUtilsAutoConfiguration.class, DiscoveryPropertiesAutoConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.consul.enabled=true")
|
||||
.withPropertyValues("spring.cloud.consul.discovery.heartbeat.interval-ratio=0");
|
||||
applicationContextRunner1.run(context -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure())
|
||||
.hasRootCauseExactlyInstanceOf(IllegalArgumentException.class)
|
||||
.hasRootCauseMessage("intervalRatio must be between 0.1 and 0.9");
|
||||
});
|
||||
|
||||
ApplicationContextRunner applicationContextRunner2 = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(PolarisInetUtilsAutoConfiguration.class, DiscoveryPropertiesAutoConfiguration.class))
|
||||
.withPropertyValues("spring.cloud.consul.enabled=true")
|
||||
.withPropertyValues("spring.cloud.consul.discovery.heartbeat.interval-ratio=1");
|
||||
applicationContextRunner2.run(context -> {
|
||||
assertThat(context).hasFailed();
|
||||
assertThat(context.getStartupFailure())
|
||||
.hasRootCauseExactlyInstanceOf(IllegalArgumentException.class)
|
||||
.hasRootCauseMessage("intervalRatio must be between 0.1 and 0.9");
|
||||
});
|
||||
}
|
||||
}
|
@ -1,179 +0,0 @@
|
||||
## A Multi-Feature Environment Example
|
||||
|
||||
English | [简体中文](./README-zh.md)
|
||||
|
||||
## I. Deployment Structure
|
||||
|
||||
<img src="./imgs/structs.png" alt="multi-feature environment structure"/>
|
||||
|
||||
As shown in the figure above, there are three environments.
|
||||
|
||||
1. `baseline` environment, including `FrontService`, `MiddleService`, `BackendService`
|
||||
2. `feature1` environment, including `MiddleService`, `BackendService`
|
||||
3. `feature2` environment, including `FrontService`, `BackendService`
|
||||
|
||||
And at the entrance, deploy the `gateway` service.
|
||||
|
||||
Three request links.
|
||||
|
||||
1. `baseline` environment link, `Gateway` -> `FrontService`(baseline) -> `MiddleService`(baseline) -> `BackendService`(
|
||||
baseline)
|
||||
2. `feature1` environment link, `Gateway` -> `FrontService`(baseline) -> `MiddleService`(feature1) -> `BackendService`(
|
||||
feature1)
|
||||
3. `feature2` environment link, `Gateway` -> `FrontService`(feature2) -> `MiddleService`(baseline) -> `BackendService`(
|
||||
feature2)
|
||||
|
||||
## II. Running
|
||||
|
||||
Without any code changes, just start all the applications under `base`, `feature1`, `feature2`, `featureenv-gateway`
|
||||
directly.
|
||||
|
||||
By default, the applications point to the official Polaris experience environment, and you can directly view the service
|
||||
registration data at the experience site after a successful launch.
|
||||
|
||||
- Console address: http://119.91.66.223:80/
|
||||
- Account: polaris
|
||||
- Password: polaris
|
||||
|
||||
## III. Testing
|
||||
|
||||
### Mode 1: Client Request With `featureenv` Label
|
||||
|
||||
#### `baseline` environment link
|
||||
|
||||
````
|
||||
curl http://127.0.0.1:9999/featureenv-front-example/router/rest
|
||||
````
|
||||
|
||||
Response results (base indicates baseline environment)
|
||||
|
||||
````
|
||||
featureenv-front-example[base] -> featureenv-middle-example[base] -> featureenv-backend-example[base]
|
||||
````
|
||||
|
||||
#### `feature1` environment link
|
||||
|
||||
Specify the feature environment via the `X-Polaris-Metadata-Transitive-featureenv` request header.
|
||||
|
||||
````
|
||||
curl -H'X-Polaris-Metadata-Transitive-featureenv:feature1' http://127.0.0.1:9999/featureenv-front-example/router/rest
|
||||
````
|
||||
|
||||
Response results
|
||||
|
||||
````
|
||||
featureenv-front-example[base] -> featureenv-middle-example[feature1] -> featureenv-backend-example[feature1]
|
||||
````
|
||||
|
||||
#### `feature2` environment link
|
||||
|
||||
Specify the feature environment via the `X-Polaris-Metadata-Transitive-featureenv` request header.
|
||||
|
||||
````
|
||||
curl -H'X-Polaris-Metadata-Transitive-featureenv:feature2' http://127.0.0.1:9999/featureenv-front-example/router/rest
|
||||
````
|
||||
|
||||
Response results
|
||||
|
||||
````
|
||||
featureenv-front-example[feature2] -> featureenv-middle-example[base] -> featureenv-backend-example[feature2]
|
||||
````
|
||||
|
||||
### Mode 2: Gateway traffic staining
|
||||
|
||||
Simulate a real-world scenario, assuming that the client request has a uid request parameter and expects:
|
||||
|
||||
1. `uid=1000` requests hit the `feature1` environment
|
||||
2. `uid=2000` requests hit the `feature2` environment
|
||||
3. requests with other uid hit the `baseline` environment
|
||||
|
||||
**Configure coloring rules**
|
||||
|
||||
Polaris Configuration Address: http://119.91.66.223:80/#/filegroup-detail?group=featureenv-gateway&namespace=default
|
||||
|
||||
Modify the `rule/staining.json` configuration file and fill in the following rule:
|
||||
|
||||
````json
|
||||
{
|
||||
"rules": [
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"key": "${http.query.uid}",
|
||||
"values": [
|
||||
"1000"
|
||||
],
|
||||
"operation": "EQUALS"
|
||||
}
|
||||
],
|
||||
"labels": [
|
||||
{
|
||||
"key": "featureenv",
|
||||
"value": "feature1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"key": "${http.query.uid}",
|
||||
"values": [
|
||||
"2000"
|
||||
],
|
||||
"operation": "EQUALS"
|
||||
}
|
||||
],
|
||||
"labels": [
|
||||
{
|
||||
"key": "featureenv",
|
||||
"value": "feature2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
````
|
||||
|
||||
Just fill out and publish the configuration.
|
||||
|
||||
#### `baseline` Environment Link
|
||||
|
||||
````
|
||||
curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=3000
|
||||
````
|
||||
|
||||
Response results (base indicates baseline environment)
|
||||
|
||||
````
|
||||
featureenv-front-example[base] -> featureenv-middle-example[base] -> featureenv-backend-example[base]
|
||||
````
|
||||
|
||||
#### `feature1` Environment Link
|
||||
|
||||
Specify the feature environment via the `X-Polaris-Metadata-Transitive-featureenv` request header.
|
||||
|
||||
````
|
||||
curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=1000
|
||||
````
|
||||
|
||||
Response results
|
||||
|
||||
````
|
||||
featureenv-front-example[base] -> featureenv-middle-example[feature1] -> featureenv-backend-example[feature1]
|
||||
````
|
||||
|
||||
#### `feature2` Environment Link
|
||||
|
||||
Specify the feature environment via the `X-Polaris-Metadata-Transitive-featureenv` request header.
|
||||
|
||||
````
|
||||
curl http://127.0.0.1:9999/featureenv-front-example/router/rest?uid=2000
|
||||
````
|
||||
|
||||
Response results
|
||||
|
||||
````
|
||||
featureenv-front-example[feature2] -> featureenv-middle-example[base] -> featureenv-backend-example[feature2]
|
||||
````
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>base</artifactId>
|
||||
<groupId>com.tencent.cloud</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>base-backend</artifactId>
|
||||
|
||||
|
||||
</project>
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.basebackend;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/router")
|
||||
public class BackendController {
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* Get information of callee.
|
||||
* @return information of callee
|
||||
*/
|
||||
@GetMapping("/rest")
|
||||
public String rest() {
|
||||
return appName + "[base]";
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.basebackend;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class BaseBackendApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BaseBackendApplication.class, args);
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
server:
|
||||
session-timeout: 1800
|
||||
port: 10002
|
||||
spring:
|
||||
application:
|
||||
name: featureenv-backend-example
|
||||
cloud:
|
||||
polaris:
|
||||
address: grpc://119.91.66.223:8091
|
||||
namespace: default
|
||||
enabled: true
|
||||
logging:
|
||||
level:
|
||||
org.springframework.cloud.gateway: info
|
||||
com.tencent.cloud.polaris: debug
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>base</artifactId>
|
||||
<groupId>com.tencent.cloud</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>base-front</artifactId>
|
||||
|
||||
|
||||
</project>
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.basefront;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class BaseFrontApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BaseFrontApplication.class, args);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.basefront;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/router")
|
||||
public class FrontController {
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
@Autowired
|
||||
private MiddleService middleService;
|
||||
|
||||
/**
|
||||
* Get information of callee.
|
||||
* @return information of callee
|
||||
*/
|
||||
@GetMapping("/rest")
|
||||
public String rest() {
|
||||
String curName = appName + "[base]";
|
||||
String resp = middleService.rest();
|
||||
|
||||
return curName + " -> " + resp;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.basefront;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@FeignClient("featureenv-middle-example")
|
||||
public interface MiddleService {
|
||||
|
||||
@GetMapping("/router/rest")
|
||||
String rest();
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
server:
|
||||
session-timeout: 1800
|
||||
port: 10000
|
||||
spring:
|
||||
application:
|
||||
name: featureenv-front-example
|
||||
cloud:
|
||||
polaris:
|
||||
address: grpc://119.91.66.223:8091
|
||||
namespace: default
|
||||
enabled: true
|
||||
logging:
|
||||
level:
|
||||
org.springframework.cloud.gateway: info
|
||||
com.tencent.cloud.polaris: debug
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>base</artifactId>
|
||||
<groupId>com.tencent.cloud</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>base-middle</artifactId>
|
||||
|
||||
|
||||
|
||||
</project>
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.basemiddle;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@FeignClient("featureenv-backend-example")
|
||||
public interface BackendService {
|
||||
|
||||
@GetMapping("/router/rest")
|
||||
String rest();
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.basemiddle;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class BaseMiddleApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BaseMiddleApplication.class, args);
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.basemiddle;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/router")
|
||||
public class MiddleController {
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
@Autowired
|
||||
private BackendService backendService;
|
||||
|
||||
/**
|
||||
* Get information of callee.
|
||||
* @return information of callee
|
||||
*/
|
||||
@GetMapping("/rest")
|
||||
public String rest() {
|
||||
String curName = appName + "[base]";
|
||||
String resp = backendService.rest();
|
||||
|
||||
return curName + " -> " + resp;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
server:
|
||||
session-timeout: 1800
|
||||
port: 10001
|
||||
spring:
|
||||
application:
|
||||
name: featureenv-middle-example
|
||||
cloud:
|
||||
polaris:
|
||||
address: grpc://119.91.66.223:8091
|
||||
namespace: default
|
||||
enabled: true
|
||||
logging:
|
||||
level:
|
||||
org.springframework.cloud.gateway: info
|
||||
com.tencent.cloud.polaris: debug
|
@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>polaris-router-featureenv-example</artifactId>
|
||||
<groupId>com.tencent.cloud</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>base</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>base-front</module>
|
||||
<module>base-middle</module>
|
||||
<module>base-backend</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>feature1</artifactId>
|
||||
<groupId>com.tencent.cloud</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>feature1-backend</artifactId>
|
||||
|
||||
|
||||
</project>
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.feature1backend;
|
||||
|
||||
import com.tencent.cloud.common.metadata.StaticMetadataManager;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/router")
|
||||
public class BackendController {
|
||||
|
||||
@Autowired
|
||||
private StaticMetadataManager staticMetadataManager;
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* Get information of callee.
|
||||
* @return information of callee
|
||||
*/
|
||||
@GetMapping("/rest")
|
||||
public String rest() {
|
||||
String featureEnv = staticMetadataManager.getMergedStaticMetadata().get("featureenv");
|
||||
return appName + "[" + featureEnv + "]";
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.feature1backend;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class Feature1BackendApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Feature1BackendApplication.class, args);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
server:
|
||||
session-timeout: 1800
|
||||
port: 11002
|
||||
spring:
|
||||
application:
|
||||
name: featureenv-backend-example
|
||||
cloud:
|
||||
polaris:
|
||||
address: grpc://119.91.66.223:8091
|
||||
namespace: default
|
||||
enabled: true
|
||||
tencent:
|
||||
metadata:
|
||||
content:
|
||||
featureenv: feature1
|
||||
logging:
|
||||
level:
|
||||
org.springframework.cloud.gateway: info
|
||||
com.tencent.cloud.polaris: debug
|
@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>feature1</artifactId>
|
||||
<groupId>com.tencent.cloud</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>feature1-middle</artifactId>
|
||||
|
||||
|
||||
</project>
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.feature1middle;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@FeignClient("featureenv-backend-example")
|
||||
public interface BackendService {
|
||||
|
||||
@GetMapping("/router/rest")
|
||||
String rest();
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.feature1middle;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableFeignClients
|
||||
public class Feature1MiddleApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Feature1MiddleApplication.class, args);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Tencent is pleased to support the open source community by making spring-cloud-tencent available.
|
||||
*
|
||||
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
|
||||
*
|
||||
* Licensed under the BSD 3-Clause License (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
* 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.tencent.cloud.polaris.router.featureenv.feature1middle;
|
||||
|
||||
import com.tencent.cloud.common.metadata.StaticMetadataManager;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author lepdou 2022-07-20
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/router")
|
||||
public class MiddleController {
|
||||
|
||||
@Value("${spring.application.name}")
|
||||
private String appName;
|
||||
|
||||
@Autowired
|
||||
private BackendService backendService;
|
||||
|
||||
@Autowired
|
||||
private StaticMetadataManager staticMetadataManager;
|
||||
|
||||
/**
|
||||
* Get information of callee.
|
||||
* @return information of callee
|
||||
*/
|
||||
@GetMapping("/rest")
|
||||
public String rest() {
|
||||
String featureEnv = staticMetadataManager.getMergedStaticMetadata().get("featureenv");
|
||||
|
||||
String curName = appName + "[" + featureEnv + "]";
|
||||
String resp = backendService.rest();
|
||||
|
||||
return curName + " -> " + resp;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue